[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-06 Thread annita.zhang via Phabricator via cfe-commits
annita.zhang added a comment.

> 
> 
>>> Third, I have not see a justification for why complexity for instruction 
>>> prefix padding is necessary.  All the effected CPUs support multi-byte 
>>> nops, so we're talking about a *single micro op* difference between the nop 
>>> form and prefix form.  Can anyone point to a performance delta due to this? 
>>>  If not, I'd suggest we should start with the nop form, and then build the 
>>> prefix form in a generic manner for all alignment varieties.
>> 
>> +1.
> 
> +1. Starting from just NOP padding sounds a simple and good first step. We 
> can explore segment override prefixes in the future.

I think it's a good suggestion to start with NOP padding as the first step. In 
our previous experiment, we saw that the prefix padding was slight better than 
NOP padding, but not much. We will retest the NOP padding and go back to you.


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

https://reviews.llvm.org/D70157



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


[clang-tools-extra] 99768b2 - [clangd] (take 2) Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-06T09:47:03+01:00
New Revision: 99768b243cd7afd312745da58b20ea067f39f89e

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

LOG: [clangd] (take 2) Try harder to find a plausible `clang` as argv0, 
particularly on Mac.

Summary:
This was originally committed in 88bccded8fa169481fa367debf5ec615640635a1,
and reverted in 93f77617abba512d2861e2fc50ce385883f587b6.

This version is now much more testable: the "detect toolchain properties" part
is still not tested but also not active in tests.
All the command manipulation based on the detected properties is
directly tested, and also not active in other tests.

Fixes https://github.com/clangd/clangd/issues/211
Fixes https://github.com/clangd/clangd/issues/178

Reviewers: kbobyrev, ilya-biryukov

Subscribers: mgorny, ormris, cfe-commits, usaxena95, kadircet, arphaman, 
jkorous, MaskRay

Tags: #clang

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

Added: 
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index c1aea3bd119d..c0ad99dd6b69 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -41,6 +41,7 @@ add_clang_library(clangDaemon
   ClangdServer.cpp
   CodeComplete.cpp
   CodeCompletionStrings.cpp
+  CompileCommands.cpp
   Compiler.cpp
   Context.cpp
   Diagnostics.cpp

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 57ed97f7a782..8ee320b5fc71 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -485,8 +485,11 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
 llvm::makeArrayRef(ClangdServerOpts.QueryDriverGlobs),
 std::move(BaseCDB));
   }
+  auto Mangler = CommandMangler::detect();
+  if (ClangdServerOpts.ResourceDir)
+Mangler.ResourceDir = *ClangdServerOpts.ResourceDir;
   CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags,
-  ClangdServerOpts.ResourceDir);
+  tooling::ArgumentsAdjuster(Mangler));
   {
 // Switch caller's context with LSPServer's background context. Since we
 // rather want to propagate information from LSPServer's context into the

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
new file mode 100644
index ..b1eca02813b3
--- /dev/null
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -0,0 +1,187 @@
+//===--- CompileCommands.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CompileCommands.h"
+#include "Logger.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Query apple's `xcrun` launcher, which is the source of truth for "how 
should"
+// clang be invoked on this system.
+llvm::Optional queryXcrun(llvm::ArrayRef Argv) {
+  auto Xcrun = llvm::sys::findProgramByName("xcrun");
+  if (!Xcrun) {
+log("Couldn't find xcrun. Hopefully you have a non-apple toolchain...");
+return llvm::None;
+  }
+  llvm::SmallString<64> OutFile;
+  llvm::sys::fs::createTemporaryFile("clangd-xcrun", "", OutFile);
+  llvm::FileRemover OutRemover(OutFile);
+  llvm::Optional Redirects[3] = {
+  /*stdin=*/{""}, /*stdout=*/{OutFile}, /*stderr=*/{""}};
+  vlog("Invoking {0} to find clang installation", *Xcrun);
+  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv,
+  /*Env=*/llvm::None, Redirects,
+  /*SecondsToWait=*/10);
+ 

[PATCH] D71029: [clangd] (take 2) Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-06 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99768b243cd7: [clangd] (take 2) Try harder to find a 
plausible `clang` as argv0, particularly… (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71029

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -42,19 +42,16 @@
   DirectoryBasedGlobalCompilationDatabase DB(None);
   auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
   EXPECT_EQ(Cmd.Directory, testPath("foo"));
-  EXPECT_THAT(Cmd.CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo/bar.cc")));
+  EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", testPath("foo/bar.cc")));
   EXPECT_EQ(Cmd.Output, "");
 
   // .h files have unknown language, so they are parsed liberally as obj-c++.
   Cmd = DB.getFallbackCommand(testPath("foo/bar.h"));
-  EXPECT_THAT(Cmd.CommandLine,
-  ElementsAre(EndsWith("clang"), "-xobjective-c++-header",
-  testPath("foo/bar.h")));
+  EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", "-xobjective-c++-header",
+   testPath("foo/bar.h")));
   Cmd = DB.getFallbackCommand(testPath("foo/bar"));
-  EXPECT_THAT(Cmd.CommandLine,
-  ElementsAre(EndsWith("clang"), "-xobjective-c++-header",
-  testPath("foo/bar")));
+  EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", "-xobjective-c++-header",
+   testPath("foo/bar")));
 }
 
 static tooling::CompileCommand cmd(llvm::StringRef File, llvm::StringRef Arg) {
@@ -87,7 +84,7 @@
 };
 
 TEST_F(OverlayCDBTest, GetCompileCommand) {
-  OverlayCDB CDB(Base.get(), {}, std::string(""));
+  OverlayCDB CDB(Base.get());
   EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
   AllOf(Contains(testPath("foo.cc")), Contains("-DA=1")));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
@@ -105,12 +102,11 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
-  "-fsyntax-only", StartsWith("-resource-dir")));
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
-  OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));
+  OverlayCDB CDB(nullptr, {"-DA=6"});
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
@@ -118,8 +114,7 @@
   Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
-  "-fsyntax-only"));
+  ElementsAre("clang", testPath("foo.cc"), "-DA=6"));
 }
 
 TEST_F(OverlayCDBTest, Watch) {
@@ -140,32 +135,32 @@
 }
 
 TEST_F(OverlayCDBTest, Adjustments) {
-  OverlayCDB CDB(Base.get(), {}, std::string(""));
+  OverlayCDB CDB(Base.get(), {"-DFallback"},
+ [](const std::vector &Cmd, llvm::StringRef File) {
+   auto Ret = Cmd;
+   Ret.push_back(
+   ("-DAdjust_" + llvm::sys::path::filename(File)).str());
+   return Ret;
+ });
+  // Command from underlying gets adjusted.
   auto Cmd = CDB.getCompileCommand(testPath("foo.cc")).getValue();
-  // Delete the file name.
-  Cmd.CommandLine.pop_back();
-
-  // Check dependency file commands are dropped.
-  Cmd.CommandLine.push_back("-MF");
-  Cmd.CommandLine.push_back("random-dependency");
-
-  // Check plugin-related commands are dropped.
-  Cmd.CommandLine.push_back("-Xclang");
-  Cmd.CommandLine.push_back("-load");
-  Cmd.CommandLine.push_back("-Xclang");
-  Cmd.CommandLine.push_back("random-plugin");
-
-  Cmd.CommandLine.push_back("-DA=5");
-  Cmd.CommandLine.push_back(Cmd.Fi

[clang-tools-extra] fac4e3c - [clang-tidy] Fix PR26274

2019-12-06 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2019-12-06T10:10:15+01:00
New Revision: fac4e3c5f8a018599cbd9363a735b1c13e8f8a05

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

LOG: [clang-tidy] Fix PR26274

Summary:
This commit fixes http://llvm.org/PR26274 in a simpler and more correct way than
4736d63f752f8d13f4c6a9afd558565c32119718 did. See
https://reviews.llvm.org/D69855#1767089 for details.

Reviewers: gribozavr, aaron.ballman, gribozavr2

Reviewed By: aaron.ballman, gribozavr2

Subscribers: gribozavr2, merge_guards_bot, xazax.hun, cfe-commits

Tags: #clang

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments-c++17.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp

Removed: 

clang-tools-extra/test/clang-tidy/checkers/google-readability-nested-namespace-comments.cpp



diff  --git 
a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index eb3d7c505b83..4a7c4566230e 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -7,9 +7,11 @@
 
//===--===//
 
 #include "NamespaceCommentCheck.h"
+#include "../utils/LexerUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringExtras.h"
 
@@ -46,30 +48,48 @@ static bool locationsInSameFile(const SourceManager 
&Sources,
  Sources.getFileID(Loc1) == Sources.getFileID(Loc2);
 }
 
-static std::string getNamespaceComment(const NamespaceDecl *ND,
-   bool InsertLineBreak) {
-  std::string Fix = "// namespace";
-  if (!ND->isAnonymousNamespace())
-Fix.append(" ").append(ND->getNameAsString());
-  if (InsertLineBreak)
-Fix.append("\n");
-  return Fix;
-}
-
-static std::string getNamespaceComment(const std::string &NameSpaceName,
-   bool InsertLineBreak) {
-  std::string Fix = "// namespace ";
-  Fix.append(NameSpaceName);
-  if (InsertLineBreak)
-Fix.append("\n");
-  return Fix;
+static llvm::Optional
+getNamespaceNameAsWritten(SourceLocation &Loc, const SourceManager &Sources,
+  const LangOptions &LangOpts) {
+  // Loc should be at the begin of the namespace decl (usually, `namespace`
+  // token). We skip the first token right away, but in case of `inline
+  // namespace` or `namespace a::inline b` we can see both `inline` and
+  // `namespace` keywords, which we just ignore. Nested parens/squares before
+  // the opening brace can result from attributes.
+  std::string Result;
+  int Nesting = 0;
+  while (llvm::Optional T = utils::lexer::findNextTokenSkippingComments(
+ Loc, Sources, LangOpts)) {
+Loc = T->getLocation();
+if (T->is(tok::l_brace))
+  break;
+
+if (T->isOneOf(tok::l_square, tok::l_paren)) {
+  ++Nesting;
+} else if (T->isOneOf(tok::r_square, tok::r_paren)) {
+  --Nesting;
+} else if (Nesting == 0) {
+  if (T->is(tok::raw_identifier)) {
+StringRef ID = T->getRawIdentifier();
+if (ID != "namespace" && ID != "inline")
+  Result.append(ID);
+  } else if (T->is(tok::coloncolon)) {
+Result.append("::");
+  } else { // Any other kind of token is unexpected here.
+return llvm::None;
+  }
+}
+  }
+  return Result;
 }
 
 void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *ND = Result.Nodes.getNodeAs("namespace");
   const SourceManager &Sources = *Result.SourceManager;
 
-  if (!locationsInSameFile(Sources, ND->getBeginLoc(), ND->getRBraceLoc()))
+  // Ignore namespaces inside macros and namespaces split across files.
+  if (ND->getBeginLoc().isMacroID() ||
+  !locationsInSameFile(Sources, ND->getBeginLoc(), ND->getRBraceLoc()))
 return;
 
   // Don't require closing comments for namespaces spanning less than certain
@@ -80,44 +100,32 @@ void NamespaceCommentCheck::check(const 
MatchFinder::MatchResult &Result) {
 return;
 
   // Find next token after the namespace closing brace.
-  SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
+  SourceLocation AfterRBrace = Lexer::getLocForEndOfToken(
+  ND->getRBraceLoc(), /*Offset=*/0, Sources, getLangOpts());
   SourceLocation Loc = AfterRBrace;
-  Token Tok;
-  SourceLocation LBracke

[PATCH] D70974: [clang-tidy] Fix PR26274

2019-12-06 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfac4e3c5f8a0: [clang-tidy] Fix PR26274 (authored by alexfh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70974

Files:
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments-c++17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
  
clang-tools-extra/test/clang-tidy/checkers/google-readability-nested-namespace-comments.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
@@ -1,14 +1,14 @@
 // RUN: %check_clang_tidy %s google-readability-namespace-comments %t
 
 namespace n1 {
-namespace n2 {
+namespace /* a comment */ n2 /* another comment */ {
 
 
 void f(); // So that the namespace isn't empty.
 
 
 // CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n2' not terminated with a closing comment [google-readability-namespace-comments]
-// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n2' starts here
+// CHECK-MESSAGES: :[[@LINE-7]]:27: note: namespace 'n2' starts here
 // CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1' not terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1' starts here
 }}
@@ -25,11 +25,72 @@
 // 5
 // 6
 // 7
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'MACRO' not terminated with
+// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'MACRO' starts here
+}
+// CHECK-FIXES: }  // namespace MACRO
+
+namespace macro_expansion {
+void ff(); // So that the namespace isn't empty.
+// 1
+// 2
+// 3
+// 4
+// 5
+// 6
+// 7
 // CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts here
 }
 // CHECK-FIXES: }  // namespace macro_expansion
 
+namespace [[deprecated("foo")]] namespace_with_attr {
+inline namespace inline_namespace {
+void g();
+// 1
+// 2
+// 3
+// 4
+// 5
+// 6
+// 7
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'inline_namespace' not terminated with
+// CHECK-MESSAGES: :[[@LINE-10]]:18: note: namespace 'inline_namespace' starts here
+}
+// CHECK-FIXES: }  // namespace inline_namespace
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'namespace_with_attr' not terminated with
+// CHECK-MESSAGES: :[[@LINE-15]]:33: note: namespace 'namespace_with_attr' starts here
+}
+// CHECK-FIXES: }  // namespace namespace_with_attr
+
+namespace [[deprecated]] {
+void h();
+// 1
+// 2
+// 3
+// 4
+// 5
+// 6
+// 7
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: anonymous namespace not terminated with
+// CHECK-MESSAGES: :[[@LINE-10]]:26: note: anonymous namespace starts here
+}
+// CHECK-FIXES: }  // namespace{{$}}
+
+namespace [[]] {
+void hh();
+// 1
+// 2
+// 3
+// 4
+// 5
+// 6
+// 7
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: anonymous namespace not terminated with
+// CHECK-MESSAGES: :[[@LINE-10]]:16: note: anonymous namespace starts here
+}
+// CHECK-FIXES: }  // namespace{{$}}
+
 namespace short1 {
 namespace short2 {
 // Namespaces covering 10 lines or fewer are exempt from this rule.
Index: clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments-c++17.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments-c++17.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments-c++17.cpp
@@ -1,17 +1,17 @@
 // RUN: %check_clang_tidy %s google-readability-namespace-comments %t
 
 namespace n1::n2 {
-namespace n3 {
+namespace /*comment1*/n3/*comment2*/::/*comment3*/inline/*comment4*/n4/*comment5*/ {
 
 // So that namespace is not empty.
 void f();
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n3' not terminated with
-// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n3::n4' not terminated with
+// CHECK-MESSAGES: :[[@LINE-7]]:23: note: namespace 'n3::n4' starts here
 // CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1::n2' not terminated with a closing comment [google-readability-namespace-comments]
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here
 }}
-// CHECK-FIXES: }  // namespace n3
+// CHECK-FIXES: }  // namespace n3::n4
 // CHECK-FIXES: }  // namespace n1::n2
 
Index: clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/NamespaceC

[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-06 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D70157#1772227 , @annita.zhang 
wrote:

> > 
> > 
> >>> Third, I have not see a justification for why complexity for instruction 
> >>> prefix padding is necessary.  All the effected CPUs support multi-byte 
> >>> nops, so we're talking about a *single micro op* difference between the 
> >>> nop form and prefix form.  Can anyone point to a performance delta due to 
> >>> this?  If not, I'd suggest we should start with the nop form, and then 
> >>> build the prefix form in a generic manner for all alignment varieties.
> >> 
> >> +1.
> > 
> > +1. Starting from just NOP padding sounds a simple and good first step. We 
> > can explore segment override prefixes in the future.
>
> I think it's a good suggestion to start with NOP padding as the first step. 
> In our previous experiment, we saw that the prefix padding was slight better 
> than NOP padding, but not much. We will retest the NOP padding and go back to 
> you.


For whatever it may be worth: Agnor Fog's empirical research on x86 pipelines 
and his review of manufacturer optimization guidelines also concludes that 
prefixes are often preferable to NOPs on modern x86 processors. (See: 
https://www.agner.org/optimize/microarchitecture.pdf) This arguably isn't 
surprising given that the decoder needs to be good at finding instruction 
boundaries but the decoder isn't responsible for interpreting instructions, 
therefore NOPs of any size dilute decode bandwidth.


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

https://reviews.llvm.org/D70157



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


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-12-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The fix looks OK (other alternative is to remove the CHECK with CXXRecordDecl, 
or make a single line with regular expressions).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60499



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


[PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers

2019-12-06 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

In D69778#1771799 , @rsmith wrote:

> It's a bit weird for this to be controlled by a `-fmodules` flag, but it's 
> only a `-cc1` flag, so I'm OK with that; we can rename it if/when we expose 
> it from the driver.


It's a bit weird, but I didn't want to add -fpch-codegen and then duplicate the 
checks everywhere. And the -building-pch-with-obj part requires a non-trivial 
build setup anyway. But I can create another patch that maps it all to some 
common flag, if wanted.

In D69778#1772125 , @dblaikie wrote:

> I was/am still wondering whether there's a way to coalesce these codepaths 
> between PCH and the existing modular code generation support?


In what way could this be united more? The way I understand it, the code paths 
are pretty much the same, they just need to account for being invoked in 
different contexts. This patch is tiny compared to what it was originally 
before I made it reuse all the codegen code.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69778



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


[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> Our build system does not handle randomly named files created during the 
> build well.

Can you share more details about why this is a problem? At least the build 
systems I work with would not even see the temporary files, as they're written 
to /tmp or similar, and instead only see either the finished object file on 
success, or no file on failure -- which as thakis points out is an important 
property.


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

https://reviews.llvm.org/D70615



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


[clang-tools-extra] d8821ad - [clangd] Fix gcc warning about extra "; " [NFC]

2019-12-06 Thread Mikael Holmen via cfe-commits

Author: Mikael Holmen
Date: 2019-12-06T11:22:48+01:00
New Revision: d8821adacbb02fe9f9707079087d35cb02ef4a6c

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

LOG: [clangd] Fix gcc warning about extra ";" [NFC]

gcc complained with

/data/repo/master/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:326:30:
 warning: extra ';' [-Wpedantic]
 REGISTER_TWEAK(DefineOutline);
  ^

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index f6bed9727cf1..925eb7e4ffde 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -323,7 +323,7 @@ class DefineOutline : public Tweak {
   const FunctionDecl *Source = nullptr;
 };
 
-REGISTER_TWEAK(DefineOutline);
+REGISTER_TWEAK(DefineOutline)
 
 } // namespace
 } // namespace clangd



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


[PATCH] D70073: [ConstExprPreter] Implemented function calls and if statements

2019-12-06 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70073



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


[PATCH] D70723: [clangd] Store index::SymbolKind in HoverInfo

2019-12-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 232519.
kadircet marked an inline comment as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70723

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -32,7 +32,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -49,7 +49,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "ns1::ns2::";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -68,7 +68,7 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -86,7 +86,7 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -102,7 +102,7 @@
  HI.NamespaceScope = "ns1::(anonymous)::";
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -114,7 +114,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
}},
@@ -126,7 +126,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "vector";
- HI.Kind = SymbolKind::Class;
+ HI.Kind = index::SymbolKind::Class;
  HI.Definition = "template  class vector {}";
  HI.TemplateParameters = {
  {std::string("typename"), std::string("T"), llvm::None},
@@ -145,7 +145,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "Foo";
- HI.Kind = SymbolKind::Class;
+ HI.Kind = index::SymbolKind::Class;
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
@@ -175,7 +175,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
@@ -204,7 +204,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Definition = "Foo foo(int, bool T = false)";
  HI.ReturnType = "Foo";
  HI.Type = "Foo (int, bool)";
@@ -225,7 +225,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "c";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "auto *c = &b";
  HI.Type = "class (lambda) **";
  HI.ReturnType = "bool";
@@ -246,7 +246,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Parameter;
  HI.Definition = "decltype(lamb) &bar";
  HI.Type = "decltype(lamb) &";
  HI.ReturnType = "bool";
@@ -267,7 +267,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Parameter;
  HI.Definition = "decltype(lamb) bar";
  HI.Type = "class (lambda)";
  HI.ReturnType = "bool";
@@ -290,7 +290,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "lamb";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;

[PATCH] D71029: [clangd] (take 2) Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Breaks Win: http://45.33.8.238/win/3549/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71029



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


[PATCH] D70723: [clangd] Store index::SymbolKind in HoverInfo

2019-12-06 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60506 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70723



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


[clang-tools-extra] 6b11760 - [clangd] Try to fix CompileCommandsTests on windows. NFC

2019-12-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-06T12:28:01+01:00
New Revision: 6b11760128751455a73d9f00a5f935d1f49fbd0f

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

LOG: [clangd] Try to fix CompileCommandsTests on windows. NFC

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.h 
b/clang-tools-extra/clangd/CompileCommands.h
index b0c34b883644..02b1a76c5bff 100644
--- a/clang-tools-extra/clangd/CompileCommands.h
+++ b/clang-tools-extra/clangd/CompileCommands.h
@@ -5,6 +5,8 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILECOMMANDS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILECOMMANDS_H
 
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -46,3 +48,5 @@ struct CommandMangler {
 
 } // namespace clangd
 } // namespace clang
+
+#endif

diff  --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index e16a8ac94df0..fc98b56de2d6 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "CompileCommands.h"
+#include "TestFS.h"
 
 #include "llvm/ADT/StringExtras.h"
 
@@ -30,32 +31,34 @@ using ::testing::Not;
 // Other tests just verify presence/absence of certain args.
 TEST(CommandMangler, Everything) {
   auto Mangler = CommandMangler::forTests();
-  Mangler.ClangPath = "/fake/bin/clang";
-  Mangler.ResourceDir = "/fake/resources";
-  Mangler.Sysroot = "/fake/sysroot";
+  Mangler.ClangPath = testPath("fake/clang");
+  Mangler.ResourceDir = testPath("fake/resources");
+  Mangler.Sysroot = testPath("fake/sysroot");
   std::vector Cmd = {"clang++", "-Xclang", "-load", "-Xclang",
   "plugin",  "-MF", "dep",   "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_THAT(Cmd, ElementsAre("/fake/bin/clang++", "foo.cc", "-fsyntax-only",
-   "-resource-dir=/fake/resources", "-isysroot",
-   "/fake/sysroot"));
+  EXPECT_THAT(Cmd, ElementsAre(testPath("fake/clang++"), "foo.cc",
+   "-fsyntax-only",
+   "-resource-dir=" + testPath("fake/resources"),
+   "-isysroot", testPath("fake/sysroot")));
 }
 
 TEST(CommandMangler, ResourceDir) {
   auto Mangler = CommandMangler::forTests();
-  Mangler.ResourceDir = "/fake/resources";
+  Mangler.ResourceDir = testPath("fake/resources");
   std::vector Cmd = {"clang++", "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_THAT(Cmd, Contains("-resource-dir=/fake/resources"));
+  EXPECT_THAT(Cmd, Contains("-resource-dir=" + testPath("fake/resources")));
 }
 
 TEST(CommandMangler, Sysroot) {
   auto Mangler = CommandMangler::forTests();
-  Mangler.Sysroot = "/fake/sysroot";
+  Mangler.Sysroot = testPath("fake/sysroot");
 
   std::vector Cmd = {"clang++", "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_THAT(llvm::join(Cmd, " "), HasSubstr("-isysroot /fake/sysroot"));
+  EXPECT_THAT(llvm::join(Cmd, " "),
+  HasSubstr("-isysroot " + testPath("fake/sysroot")));
 }
 
 TEST(CommandMangler, StripPlugins) {
@@ -78,19 +81,19 @@ TEST(CommandMangler, StripOutput) {
 
 TEST(CommandMangler, ClangPath) {
   auto Mangler = CommandMangler::forTests();
-  Mangler.ClangPath = "/fake/clang";
+  Mangler.ClangPath = testPath("fake/clang");
 
   std::vector Cmd = {"clang++", "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_EQ("/fake/clang++", Cmd.front());
+  EXPECT_EQ(testPath("fake/clang++"), Cmd.front());
 
   Cmd = {"unknown-binary", "foo.cc"};
   Mangler.adjust(Cmd);
   EXPECT_EQ("unknown-binary", Cmd.front());
 
-  Cmd = {"/path/clang++", "foo.cc"};
+  Cmd = {testPath("path/clang++"), "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_EQ("/path/clang++", Cmd.front());
+  EXPECT_EQ(testPath("path/clang++"), Cmd.front());
 }
 
 } // namespace



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


[PATCH] D71090: [clangd] Navigation from definition of template specialization to primary templateFixes https://github.com/clangd/clangd/issues/212.

2019-12-06 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.

Nice!




Comment at: clang-tools-extra/clangd/XRefs.cpp:194
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation MaybeMacroLocation = SM.getMacroArgExpandedLocation(
+  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, AST.getSourceManager(), 
AST.getLangOpts()));

Not thrilled about reusing this after previous patches disentangled it - it 
works well for macros but if (for example) you have a templated `operator<<` I 
think the feature you're adding probably won't work.

That said, I don't see a simple alternative, and it's unlikely to be a big 
deal, so I think this is OK.



Comment at: clang-tools-extra/clangd/XRefs.cpp:240
+// it's more useful to navigate to the template declaration.
+if (Preferred->getLocation() == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {

Be aware that this is going to break "go to definition" toggling between def 
and decl. I think that's fine.



Comment at: clang-tools-extra/clangd/XRefs.cpp:240
+// it's more useful to navigate to the template declaration.
+if (Preferred->getLocation() == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {

sammccall wrote:
> Be aware that this is going to break "go to definition" toggling between def 
> and decl. I think that's fine.
(I think you probably want the macro-arg-expanded location here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71090



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


[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.

This is a tool that helps us to evaluate the rename results, we may not
submit this tool to the code repository, but it has value, helps us find
out bugs in AST/Refs/Rename code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71110

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/RenameMain.cpp
  clang-tools-extra/clangd/eval-rename/eval-rename.py
  clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt

Index: clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
@@ -0,0 +1,4 @@
+clang-tools-extra/clangd/XRefs.h clang::clangd::findReferences clangd
+clang-tools-extra/clangd/index/Index.h clang::clangd::SymbolIndex clangd
+clang-tools-extra/clangd/ClangdServer.h clang::clangd::ClangdServer clangd
+clang-tools-extra/clangd/index/Ref.h clang::clangd::RefKind clangd
\ No newline at end of file
Index: clang-tools-extra/clangd/eval-rename/eval-rename.py
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/eval-rename.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+"""
+A script to perform cross-file rename and evalute the results.
+
+Usage:
+
+$ cd /llvm-project
+$ ninja -C build clangd-indexer
+$ ./build/bin/clangd-indexer -format=binary -executor=all-TUs . > llvm-index.idx
+$ ninja -C build clangd-rename
+$ clang-tools-extra/clangd/eval-rename/eval-rename.py --index=llvm-index.idx --file=clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+RENAME_EXECUTOR='build/bin/clangd-rename'
+
+def Run(cmd):
+  s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  print '>', ' '.join(cmd)
+  [stdout, stderr] = s.communicate()
+  return (s.returncode, stdout, stderr)
+
+if __name__ == '__main__':
+  if not os.getcwd().endswith('llvm-project'):
+sys.exit('The tool must be run from llvm-project/ root.')
+
+  ap = argparse.ArgumentParser()
+  ap.add_argument(
+  '-f',
+  '--file',
+  required=True,
+  help='A file containing rename symbols to be evaluted.'
+  )
+  ap.add_argument(
+  '-idx',
+  '--index',
+  required=True,
+  help='A path to the index file'
+  )
+  args = ap.parse_args()
+
+  with open(args.file) as f:
+out = f.read()
+  test_cases = [line.strip().split() for line in out.split('\n') if line.strip()]
+
+  log_output_dir = tempfile.mkdtemp(prefix='eval-rename_')
+  success_cnt = 0
+  for file_name, rename_symbol, verify_target in test_cases:
+Run(['git', 'reset', '--hard'])
+execute_rename_cmd = [
+  RENAME_EXECUTOR,
+   '--index-path=%s' % args.index,
+   '--rename-symbol=%s' % rename_symbol,
+   '-fix',
+   file_name,
+]
+rename_results = Run(execute_rename_cmd)
+if rename_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_RenameFailed'), 'w')
+  log_file.write(rename_results[1]) # stdout
+  log_file.write(rename_results[2]) # stderr
+  log_file.close()
+  continue
+
+build_results = Run(['ninja', '-C', 'build', verify_target])
+if build_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_BuildFailed'), 'w')
+  log_file.write(build_results[1]) # stdout
+  log_file.write(build_results[2]) # stderr
+  log_file.close()
+  continue
+
+success_cnt += 1
+  Run(['git', 'reset', '--hard'])
+  print 'Evaluated rename on %d symbols, %d symbol succeeded, go %s for failure logs' % (
+len(test_cases), success_cnt, log_output_dir)
\ No newline at end of file
Index: clang-tools-extra/clangd/eval-rename/RenameMain.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/RenameMain.cpp
@@ -0,0 +1,198 @@
+//===--- RenameMain.cpp --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Compiler.h"
+#include "FS.h"
+#include "FSProvider.h"
+#include "FindTarget.h"
+#include "GlobalCompilationDatabase.h"
+#include "Logger.h"
+#include "ParsedAST.h"
+#include "SourceCode.h"
+#include "index/MemIndex.h"
+#include "index/Serialization.h"
+#include "refactor/Rename.h"
+#include "clang/AST/Decl.h"

[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-06 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60496 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110



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


[PATCH] D70849: [AST] Traverse the class type loc inside the member pointer type loc.

2019-12-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:1169
 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
-  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
+  if (auto *TSI = TL.getClassTInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));

saugustine wrote:
> ilya-biryukov wrote:
> > Can this actually happen in practice?
> > Did we try doing **only** `TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()))` and 
> > seeing whether this fails?
> > 
> > The code in `MemberPointerTypeLoc` suggests this can happen, but would be 
> > interesting to find examples when it happens.
> This can happen when traversing a TypeNodeLoc, and the assertion will fail. 
> I'm reverting this change for now.
> This can happen when traversing a TypeNodeLoc, and the assertion will fail. 
> I'm reverting this change for now.

Thanks for reverting it, could you share more details?  would be nice if you 
could point us an example that triggers the assertion, I believe it was found 
when you did the llvm buildcop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70849



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


[clang-tools-extra] c5adbac - [clangd] Switch Hover.All to structured tests

2019-12-06 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-12-06T13:40:22+01:00
New Revision: c5adbac9b85a53112a9fc9b72e64d2615e3e4df9

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

LOG: [clangd] Switch Hover.All to structured tests

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.h 
b/clang-tools-extra/clangd/Hover.h
index f332f5d9eeea..f42e7f3a7b54 100644
--- a/clang-tools-extra/clangd/Hover.h
+++ b/clang-tools-extra/clangd/Hover.h
@@ -12,6 +12,7 @@
 #include "FormattedString.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
+#include "clang/Index/IndexSymbol.h"
 
 namespace clang {
 namespace clangd {
@@ -53,7 +54,7 @@ struct HoverInfo {
   /// Name of the symbol, does not contain any "::".
   std::string Name;
   llvm::Optional SymRange;
-  index::SymbolKind Kind;
+  index::SymbolKind Kind = index::SymbolKind::Unknown;
   std::string Documentation;
   /// Source code containing the definition of the symbol.
   std::string Definition;

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index bd6a33d8d67e..5862b1d03bf4 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -11,9 +11,14 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -532,252 +537,333 @@ void foo())cpp";
   }
 }
 
-TEST(Hover, All) {
-  struct OneTest {
-StringRef Input;
-StringRef ExpectedHover;
-  };
-
-  OneTest Tests[] = {
-  {
-  R"cpp(// No hover
-^int main() {
+TEST(Hover, NoHover) {
+  llvm::StringRef Tests[] = {
+  "^int main() {}",
+  "void foo() {^}",
+  R"cpp(// structured binding. Not supported yet
+struct Bar {};
+void foo() {
+  Bar a[2];
+  ^auto [x,y] = a;
+}
+  )cpp",
+  R"cpp(// Template auto parameter. Nothing (Not useful).
+template<^auto T>
+void func() {
+}
+void foo() {
+   func<1>();
 }
   )cpp",
-  "",
-  },
+  };
+
+  for (const auto &Test : Tests) {
+SCOPED_TRACE(Test);
+
+Annotations T(Test);
+TestTU TU = TestTU::withCode(T.code());
+TU.ExtraArgs.push_back("-std=c++17");
+auto AST = TU.build();
+ASSERT_TRUE(AST.getDiagnostics().empty());
+
+auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+ASSERT_FALSE(H);
+  }
+}
+
+TEST(Hover, All) {
+  struct {
+const char *const Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {
   {
   R"cpp(// Local variable
 int main() {
   int bonjour;
-  ^bonjour = 2;
+  ^[[bonjour]] = 2;
   int test1 = bonjour;
 }
   )cpp",
-  "text[Declared in]code[main]\n"
-  "codeblock(cpp) [\n"
-  "int bonjour\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "bonjour";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.LocalScope = "main::";
+HI.Type = "int";
+HI.Definition = "int bonjour";
+  }},
   {
   R"cpp(// Local variable in method
 struct s {
   void method() {
 int bonjour;
-^bonjour = 2;
+^[[bonjour]] = 2;
   }
 };
   )cpp",
-  "text[Declared in]code[s::method]\n"
-  "codeblock(cpp) [\n"
-  "int bonjour\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "bonjour";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.LocalScope = "s::method::";
+HI.Type = "int";
+HI.Definition = "int bonjour";
+  }},
   {
   R"cpp(// Struct
 namespace ns1 {
   struct MyClass {};
 } // namespace ns1
 int main() {
-  ns1::My^Class* Params;
+  ns1::[[My^Class]]* Params;
 }
   )cpp",
-  "text[Declared in]code[ns1]\n"
-  "codeblock(cpp) [\n"
-  "struct MyClass {

[clang-tools-extra] 24439a7 - [clangd] Store index::SymbolKind in HoverInfo

2019-12-06 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-12-06T13:40:22+01:00
New Revision: 24439a761c5e21fda8f9410a5e80ff07b4ba03a2

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

LOG: [clangd] Store index::SymbolKind in HoverInfo

Summary:
LSP's SymbolKind has some shortcomings when it comes to C++ types,
index::SymbolKind has more detailed info like Destructor, Parameter, MACRO etc.

We are planning to make use of that information in our new Hover response, and
it would be nice to display the Symbol type in full detail, rather than some
approximation.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 6a7d994ce7e3..5bc15629b05b 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -20,6 +20,8 @@
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/PrettyPrinter.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace clangd {
@@ -298,7 +300,7 @@ HoverInfo getHoverContents(const Decl *D, const SymbolIndex 
*Index) {
 HI.Name = printName(Ctx, *ND);
   }
 
-  HI.Kind = indexSymbolKindToSymbolKind(index::getSymbolInfo(D).Kind);
+  HI.Kind = index::getSymbolInfo(D).Kind;
 
   // Fill in template params.
   if (const TemplateDecl *TD = D->getDescribedTemplate()) {
@@ -347,7 +349,7 @@ HoverInfo getHoverContents(QualType T, const Decl *D, 
ASTContext &ASTCtx,
   OS.flush();
 
   if (D) {
-HI.Kind = indexSymbolKindToSymbolKind(index::getSymbolInfo(D).Kind);
+HI.Kind = index::getSymbolInfo(D).Kind;
 enhanceFromIndex(HI, D, Index);
   }
   return HI;
@@ -358,8 +360,7 @@ HoverInfo getHoverContents(const DefinedMacro &Macro, 
ParsedAST &AST) {
   HoverInfo HI;
   SourceManager &SM = AST.getSourceManager();
   HI.Name = Macro.Name;
-  HI.Kind = indexSymbolKindToSymbolKind(
-  index::getSymbolInfoForMacro(*Macro.Info).Kind);
+  HI.Kind = index::SymbolKind::Macro;
   // FIXME: Populate documentation
   // FIXME: Pupulate parameters
 

diff  --git a/clang-tools-extra/clangd/Hover.h 
b/clang-tools-extra/clangd/Hover.h
index 704e5c4b14e5..f332f5d9eeea 100644
--- a/clang-tools-extra/clangd/Hover.h
+++ b/clang-tools-extra/clangd/Hover.h
@@ -28,7 +28,7 @@ struct HoverInfo {
   /// - template  class Foo {};
   struct Param {
 /// The pretty-printed parameter type, e.g. "int", or "typename" (in
-/// TemplateParameters)
+/// TemplateParameters), might be None for macro parameters.
 llvm::Optional Type;
 /// None for unnamed parameters.
 llvm::Optional Name;
@@ -53,9 +53,7 @@ struct HoverInfo {
   /// Name of the symbol, does not contain any "::".
   std::string Name;
   llvm::Optional SymRange;
-  /// Scope containing the symbol. e.g, "global namespace", "function x::Y"
-  /// - None for deduced types, e.g "auto", "decltype" keywords.
-  SymbolKind Kind;
+  index::SymbolKind Kind;
   std::string Documentation;
   /// Source code containing the definition of the symbol.
   std::string Definition;

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 530dfe600ecf..bd6a33d8d67e 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -32,7 +32,7 @@ TEST(Hover, Structured) {
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -49,7 +49,7 @@ TEST(Hover, Structured) {
[](HoverInfo &HI) {
  HI.NamespaceScope = "ns1::ns2::";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -68,7 +68,7 @@ TEST(Hover, Structured) {
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -86,7 +86,7 @@ TEST(Hover, Structured) {
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::foo

[PATCH] D70911: [clangd] Switch Hover.All to structured tests

2019-12-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5adbac9b85a: [clangd] Switch Hover.All to structured tests 
(authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D70911?vs=231735&id=232537#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70911

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -11,9 +11,14 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -532,252 +537,333 @@
   }
 }
 
-TEST(Hover, All) {
-  struct OneTest {
-StringRef Input;
-StringRef ExpectedHover;
-  };
-
-  OneTest Tests[] = {
-  {
-  R"cpp(// No hover
-^int main() {
+TEST(Hover, NoHover) {
+  llvm::StringRef Tests[] = {
+  "^int main() {}",
+  "void foo() {^}",
+  R"cpp(// structured binding. Not supported yet
+struct Bar {};
+void foo() {
+  Bar a[2];
+  ^auto [x,y] = a;
+}
+  )cpp",
+  R"cpp(// Template auto parameter. Nothing (Not useful).
+template<^auto T>
+void func() {
+}
+void foo() {
+   func<1>();
 }
   )cpp",
-  "",
-  },
+  };
+
+  for (const auto &Test : Tests) {
+SCOPED_TRACE(Test);
+
+Annotations T(Test);
+TestTU TU = TestTU::withCode(T.code());
+TU.ExtraArgs.push_back("-std=c++17");
+auto AST = TU.build();
+ASSERT_TRUE(AST.getDiagnostics().empty());
+
+auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+ASSERT_FALSE(H);
+  }
+}
+
+TEST(Hover, All) {
+  struct {
+const char *const Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {
   {
   R"cpp(// Local variable
 int main() {
   int bonjour;
-  ^bonjour = 2;
+  ^[[bonjour]] = 2;
   int test1 = bonjour;
 }
   )cpp",
-  "text[Declared in]code[main]\n"
-  "codeblock(cpp) [\n"
-  "int bonjour\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "bonjour";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.LocalScope = "main::";
+HI.Type = "int";
+HI.Definition = "int bonjour";
+  }},
   {
   R"cpp(// Local variable in method
 struct s {
   void method() {
 int bonjour;
-^bonjour = 2;
+^[[bonjour]] = 2;
   }
 };
   )cpp",
-  "text[Declared in]code[s::method]\n"
-  "codeblock(cpp) [\n"
-  "int bonjour\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "bonjour";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.LocalScope = "s::method::";
+HI.Type = "int";
+HI.Definition = "int bonjour";
+  }},
   {
   R"cpp(// Struct
 namespace ns1 {
   struct MyClass {};
 } // namespace ns1
 int main() {
-  ns1::My^Class* Params;
+  ns1::[[My^Class]]* Params;
 }
   )cpp",
-  "text[Declared in]code[ns1]\n"
-  "codeblock(cpp) [\n"
-  "struct MyClass {}\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "MyClass";
+HI.Kind = index::SymbolKind::Struct;
+HI.NamespaceScope = "ns1::";
+HI.Definition = "struct MyClass {}";
+  }},
   {
   R"cpp(// Class
 namespace ns1 {
   class MyClass {};
 } // namespace ns1
 int main() {
-  ns1::My^Class* Params;
+  ns1::[[My^Class]]* Params;
 }
   )cpp",
-  "text[Declared in]code[ns1]\n"
-  "codeblock(cpp) [\n"
-  "class MyClass {}\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "MyClass";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "ns1::";
+HI.Definition = "class MyClass {}";
+  }},
   {
   R"cpp(// Union
 namespace ns1 {
   union MyUnion { int x; int y; };
 } // namespace n

[PATCH] D70723: [clangd] Store index::SymbolKind in HoverInfo

2019-12-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24439a761c5e: [clangd] Store index::SymbolKind in HoverInfo 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70723

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -32,7 +32,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -49,7 +49,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "ns1::ns2::";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -68,7 +68,7 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -86,7 +86,7 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -102,7 +102,7 @@
  HI.NamespaceScope = "ns1::(anonymous)::";
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -114,7 +114,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
}},
@@ -126,7 +126,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "vector";
- HI.Kind = SymbolKind::Class;
+ HI.Kind = index::SymbolKind::Class;
  HI.Definition = "template  class vector {}";
  HI.TemplateParameters = {
  {std::string("typename"), std::string("T"), llvm::None},
@@ -145,7 +145,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "Foo";
- HI.Kind = SymbolKind::Class;
+ HI.Kind = index::SymbolKind::Class;
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
@@ -175,7 +175,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
@@ -204,7 +204,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Definition = "Foo foo(int, bool T = false)";
  HI.ReturnType = "Foo";
  HI.Type = "Foo (int, bool)";
@@ -225,7 +225,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "c";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "auto *c = &b";
  HI.Type = "class (lambda) **";
  HI.ReturnType = "bool";
@@ -246,7 +246,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Parameter;
  HI.Definition = "decltype(lamb) &bar";
  HI.Type = "decltype(lamb) &";
  HI.ReturnType = "bool";
@@ -267,7 +267,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Parameter;
  HI.Definition = "decltype(lamb) bar";
  HI.Type = "class (lambda)";
  HI.ReturnType = "bool";
@@ -290,7 +290,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "lamb";
- HI.Kind = SymbolKind::Variable;
+   

[clang] a3b2552 - Fix for PR44000. Optimization record for bytecode input missing.

2019-12-06 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2019-12-06T07:48:42-05:00
New Revision: a3b2552575d3c333e928446fac10cc5b0b4092a9

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

LOG: Fix for PR44000. Optimization record for bytecode input missing.
Review is here:  https://reviews.llvm.org/D70691

Added: 
clang/test/CodeGen/opt-record-1.c

Modified: 
clang/lib/CodeGen/CodeGenAction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 87bda4a0fc2c..867a8938e022 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -82,6 +82,24 @@ namespace clang {
 BackendConsumer *BackendCon;
   };
 
+  static void reportOptRecordError(Error E, DiagnosticsEngine &Diags,
+   const CodeGenOptions CodeGenOpts) {
+handleAllErrors(
+std::move(E),
+  [&](const RemarkSetupFileError &E) {
+  Diags.Report(diag::err_cannot_open_file)
+  << CodeGenOpts.OptRecordFile << E.message();
+},
+  [&](const RemarkSetupPatternError &E) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << E.message() << CodeGenOpts.OptRecordPasses;
+},
+  [&](const RemarkSetupFormatError &E) {
+  Diags.Report(diag::err_drv_optimization_remark_format)
+  << CodeGenOpts.OptRecordFormat;
+});
+}
+
   class BackendConsumer : public ASTConsumer {
 using LinkModule = CodeGenAction::LinkModule;
 
@@ -268,29 +286,16 @@ namespace clang {
 CodeGenOpts, this));
 
   Expected> OptRecordFileOrErr =
-  setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
-   CodeGenOpts.OptRecordPasses,
-   CodeGenOpts.OptRecordFormat,
-   CodeGenOpts.DiagnosticsWithHotness,
-   CodeGenOpts.DiagnosticsHotnessThreshold);
+  setupOptimizationRemarks(
+  Ctx, CodeGenOpts.OptRecordFile, CodeGenOpts.OptRecordPasses,
+  CodeGenOpts.OptRecordFormat, CodeGenOpts.DiagnosticsWithHotness,
+  CodeGenOpts.DiagnosticsHotnessThreshold);
 
   if (Error E = OptRecordFileOrErr.takeError()) {
-handleAllErrors(
-std::move(E),
-[&](const RemarkSetupFileError &E) {
-  Diags.Report(diag::err_cannot_open_file)
-  << CodeGenOpts.OptRecordFile << E.message();
-},
-[&](const RemarkSetupPatternError &E) {
-  Diags.Report(diag::err_drv_optimization_remark_pattern)
-  << E.message() << CodeGenOpts.OptRecordPasses;
-},
-[&](const RemarkSetupFormatError &E) {
-  Diags.Report(diag::err_drv_optimization_remark_format)
-  << CodeGenOpts.OptRecordFormat;
-});
+reportOptRecordError(std::move(E), Diags, CodeGenOpts);
 return;
   }
+
   std::unique_ptr OptRecordFile =
   std::move(*OptRecordFileOrErr);
 
@@ -1046,6 +1051,8 @@ void CodeGenAction::ExecuteAction() {
   if (getCurrentFileKind().getLanguage() == Language::LLVM_IR) {
 BackendAction BA = static_cast(Act);
 CompilerInstance &CI = getCompilerInstance();
+auto &CodeGenOpts = CI.getCodeGenOpts();
+auto &Diagnostics = CI.getDiagnostics();
 std::unique_ptr OS =
 GetOutputStream(CI, getCurrentFile(), BA);
 if (BA != Backend_EmitNothing && !OS)
@@ -1064,23 +1071,41 @@ void CodeGenAction::ExecuteAction() {
 
 const TargetOptions &TargetOpts = CI.getTargetOpts();
 if (TheModule->getTargetTriple() != TargetOpts.Triple) {
-  CI.getDiagnostics().Report(SourceLocation(),
- diag::warn_fe_override_module)
+  Diagnostics.Report(SourceLocation(),
+ diag::warn_fe_override_module)
   << TargetOpts.Triple;
   TheModule->setTargetTriple(TargetOpts.Triple);
 }
 
-EmbedBitcode(TheModule.get(), CI.getCodeGenOpts(),
+EmbedBitcode(TheModule.get(), CodeGenOpts,
  MainFile->getMemBufferRef());
 
 LLVMContext &Ctx = TheModule->getContext();
 Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler,
-  &CI.getDiagnostics());
+  &Diagnostics);
+
+Expected> OptRecordFileOrErr =
+setupOptimizationRemarks(
+Ctx, CodeGenOpts.OptRecordFile,
+CodeGenOpts.OptRecordPasses,
+CodeGenOpts.OptRecordFormat,
+CodeGenOpts.DiagnosticsWithHotness,
+CodeGenOpts.DiagnosticsHotnessThreshold);
+
+if (Error E = OptRecordFileOrErr.takeError()) {
+ 

[PATCH] D71111: [Sema] Improve diagnostic about addr spaces for overload candidates

2019-12-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added a subscriber: ebevhan.

As discussed in https://reviews.llvm.org/D69938#inline-629726 this commit 
improves the diagnostic of addr spaces. The approach is currently reusing 
diagnostic streaming of `Qualifiers`.

There are a number of issues however:

1. Address spaces don't always have representation i.e. in C++ it is just a 
number or `Default` address space doesn't correspond to anything at all. For 
the former case with the current approach  we will get 
`'__attribute__((address_space(N)))'` printed into the diagnostic. For the 
latter one it will print `unqualified`.

2. In OpenCL we threat `__private` and `Default` in the same way and therefore 
it doesn't get printed. With this patch therefore `unqualified` will appear 
even if `__private` was specified in the original source. There is a bug open 
to fix that however: https://bugs.llvm.org/show_bug.cgi?id=43295. Perhaps it 
should be fixed as soon as this gets committed.


https://reviews.llvm.org/D7

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/address-space-references.cpp
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl

Index: clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
===
--- clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
+++ clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
@@ -7,8 +7,8 @@
 };
 
 void bar(__local C*);
-// expected-note@-1{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka '__global C *')), parameter type must be '__local C *'}}
-// expected-note@-2{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka 'C *')), parameter type must be '__local C *'}}
+// expected-note@-1{{candidate function not viable: cannot convert address spaces in 1st argument ('decltype(this)' (aka '__global C *')) from '__global' to '__local'}}
+// expected-note@-2{{candidate function not viable: cannot convert address spaces in 1st argument ('decltype(this)' (aka 'C *')) from unqualified to '__local'}}
 
 __global C Glob;
 void foo(){
Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- clang/test/SemaOpenCLCXX/address-space-lambda.cl
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -12,7 +12,7 @@
   // Test lambda with default parameters
 //CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
   [&] {i++;} ();
-  __constant auto err = [&]() {}; //expected-note-re{{candidate function not viable: address space mismatch in 'this' argument ('__constant (lambda at {{.*}})'), parameter type must be 'const __generic (lambda at {{.*}})'}}
+  __constant auto err = [&]() {}; //expected-note-re{{candidate function not viable: cannot convert address spaces in 'this' argument ('__constant (lambda at {{.*}}') from '__constant' to '__generic'}}
   err();  //expected-error-re{{no matching function for call to object of type '__constant (lambda at {{.*}})'}}
   // FIXME: There is very limited addr space functionality
   // we can test when taking lambda type from the object.
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -42,7 +42,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-3{{passing argument to parameter 'arg_glob' here}}
 #else
-// expected-note-re@-5{{candidate function not viable: address space mismatch in 1st argument ('__{{generic|constant}} int *'), parameter type must be '__global int *'}}
+// expected-note-re@-5{{candidate function not viable: cannot convert address spaces in 1st argument ('__{{generic|constant}} int *') from '__{{generic|constant}}' to '__global'}}
 #endif
 #endif
 
@@ -50,7 +50,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-2{{passing argument to parameter 'arg_loc' here}}
 #else
-// expected-note-re@-4{{candidate function not viable: address space mismatch in 1st argument ('__{{global|generic|constant}} int *'), parameter type must be '__local int *'}}
+// expected-note-re@-4{{candidate function not viable: cannot convert address spaces in 1st argument ('__{{global|generic|constant}} int *') from '__{{global|generic|constant}}' to '__local'}}
 #endif
 
 void f_const(__constant int *arg_const) {}
@@ -58,7 +58,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-3{{passing argument to parameter 'arg_const' here}}
 #else
-// expected-note-re@-5{{candidate function not viable: address space mismatch in 1st argument ('__{{global|gen

[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
teemperor added a reviewer: martong.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

When Sema encounters a ObjCMethodDecl definition it declares the implicit 
parameters for the ObjCMethodDecl.
When importing such a method with the ASTImporter we need to do the same for 
the imported method
otherwise we will crash when generating code (where CodeGen expects that this 
was called by Sema).

Note I had to implement Objective-C[++] support in Language.cpp as this is the 
first test for Objective-C and this
would otherwise just hit this 'not implemented' assert when running the unit 
test.


Repository:
  rC Clang

https://reviews.llvm.org/D71112

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/Language.cpp


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,9 +37,11 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
-llvm_unreachable("Not implemented yet!");
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
+llvm_unreachable("-std=objc++");
   }
   return BasicArgs;
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,28 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl("__attribute__((objc_root_class))\n"
+   "@interface Root\n"
+   "@end\n"
+   "@interface C : Root\n"
+   "-(void)method;\n"
+   "@end\n"
+   "@implementation C\n"
+   "-(void)method {}\n"
+   "@end\n",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(ToMethod);
+
+  // Implicit params are declared when Sema encounters the definition but this
+  // never happens when the method is imported. Manually declare the implicit
+  // params now that the MethodDecl knows its class interface.
+  if (D->getSelfDecl())
+ToMethod->createImplicitParams(Importer.getToContext(),
+   ToMethod->getClassInterface());
+
   return ToMethod;
 }
 


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,9 +37,11 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
-llvm_unreachable("Not implemented yet!");
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
+llvm_unreachable("-std=objc++");
   }
   return BasicArgs;
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,28 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl("__attribute__((objc_root_class))\n"
+   "@interface Root\n"
+   "@end\n"
+   "@interface C : Root\n"
+   "-(void)method;\n"
+   "@end\n"
+   "@implementation C\n"
+   "-(void)method {}\n"
+   "@end\n",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRU

[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for addressing this, I just have some minor comments.




Comment at: clang/unittests/AST/ASTImporterTest.cpp:5603
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl("__attribute__((objc_root_class))\n"
+   "@interface Root\n"

You could use a raw string literal for the code, that way we could get rid of 
the '\n's and the trailing " characters.


Repository:
  rC Clang

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

https://reviews.llvm.org/D71112



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


[PATCH] D70439: [Analyzer][Docs][NFC] Add CodeChecker to the command line tools

2019-12-06 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 232540.
martong marked 3 inline comments as done.
martong added a comment.

Put back the menu, add "open source" property.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70439

Files:
  clang/www/analyzer/codechecker.html
  clang/www/analyzer/command-line.html
  clang/www/analyzer/index.html

Index: clang/www/analyzer/index.html
===
--- clang/www/analyzer/index.html
+++ clang/www/analyzer/index.html
@@ -72,9 +72,9 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in
 C, C++, and Objective-C programs.
 
-Currently it can be run either as a standalone
-tool or within Xcode. The standalone tool is
-invoked from the command line, and is intended to be run in tandem with a build
+Currently it can be run either from the command
+  line or if you use macOS then within Xcode. When
+invoked from the command line, it is intended to be run in tandem with a build
 of a codebase.
 
 The analyzer is 100% open source and is part of the http://www.w3.org/TR/html4/strict.dtd";>
+
+
+  Running the analyzer from the command line
+  
+  
+  
+
+
+
+
+
+
+
+Running the analyzer from the command line
+
+ Static Analyzer is by design a GUI tool. Its purpose is to find buggy execution
+paths in the program, and such paths are very hard to comprehend by looking at
+a non-interactive standard output. It is possible, however, to invoke the
+Static Analyzer from the command line in order to obtain analysis results, and
+then later view them interactively in a graphical interface. The following
+tools are used commonly to run the analyzer from the command line. Both tools
+are wrapper scripts to drive the analysis and the underlying invocations of the
+Clang compiler:
+
+  Scan-Build
+is an old and simple command-line tool that emits static analyzer warnings as HTML files while compiling your project. You can view the analysis results in your web browser.
+  
+  
+
+  Useful for individual developers who simply want to view static analysis results at their desk, or in a very simple collaborative environment.
+
+
+  Works on all major platforms (Windows, Linux, macOS) and is available as a package in many Linux distributions.
+
+
+  Does not include support for cross-translation-unit analysis.
+
+  
+  CodeChecker
+ is a web server that runs the Static Analyzer on your projects on demand and maintains a database of issues.
+  
+  
+
+  Perfect for managing large amounts of Static Analyzer warnings in a collaborative environment.
+
+
+  Generally much more feature-rich than scan-build.
+
+Supports incremental analysis: Results can be stored in a database, subsequent analysis runs can be compared to list the newly added defects.
+https://clang.llvm.org/docs/analyzer/user-docs/CrossTranslationUnit.html";>Cross Translation Unit (CTU) analysis is supported fully on Linux via CodeChecker.
+Can run clang-tidy checkers too.
+Open source, but out-of-tree, i.e. not part of the LLVM project.
+  
+
+
+
+
+
+
+
+
+
+
+
+
Index: clang/www/analyzer/codechecker.html
===
--- /dev/null
+++ clang/www/analyzer/codechecker.html
@@ -0,0 +1,74 @@
+http://www.w3.org/TR/html4/strict.dtd";>
+
+
+  CodeChecker: running the analyzer from the command line
+  
+  
+  
+
+
+
+
+
+
+
+CodeChecker: running the analyzer from the command line
+
+Basic Usage
+
+
+Install CodeChecker as described here: https://github.com/Ericsson/codechecker/#Install-guide";> CodeChecker Install Guide.
+
+
+
+Create a compilation database. If you use cmake then pass the -DCMAKE_EXPORT_COMPILE_COMMANDS=1 parameter to cmake. Cmake will create a compile_commands.json file.
+If you have a Makefile based or similar build system then you can log the build commands with the help of CodeChecker:
+
+make clean
+CodeChecker log -b "make" -o compile_commands.json
+
+
+
+
+Analyze your project.
+
+CodeChecker analyze compile_commands.json -o ./reports
+
+
+
+
+View the analysis results.
+Print the detailed results in the command line:
+
+CodeChecker parse --print-steps ./reports
+
+Or view the detailed results in a browser:
+
+CodeChecker parse ./reports -e html -o ./reports_html
+firefox ./reports_html/index.html
+
+
+
+
+Optional: store the analysis results in a DB.
+
+mkdir ./ws
+CodeChecker server -w ./ws -v 8555 &
+CodeChecker store ./reports --name my-project --url http://localhost:8555/Default
+
+
+
+
+Optional: manage (categorize, suppress) the results in your web browser:
+
+firefox http://localhost:8555/Default
+
+
+
+Detailed Usage
+
+
+For extended documentation please refer to the https://github.com/Ericsson/codechecker/blob/master/docs/usage.md";>official site of CodeChecker!
+
+
___
cfe

[PATCH] D70439: [Analyzer][Docs][NFC] Add CodeChecker to the command line tools

2019-12-06 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 6 inline comments as done.
martong added a comment.

In D70439#1772168 , @Charusso wrote:

> I would change the order of CCh and scan-build because we usually list stuff 
> in alphabetical order. Also the chronological order is that, the newest is 
> the first.


I am not sure if the order matters that much  because the page is very terse 
and small, so a reader can have a quick look to see that there are only these 
tools.




Comment at: clang/www/analyzer/codechecker.html:13
+
+
+

NoQ wrote:
> martong wrote:
> > NoQ wrote:
> > > Note related to your patch, but SSI seem to be completely broken these 
> > > days; previously the dropdown menus header kept working on the front page 
> > > but now even that's missing. Patches are very welcome >.<
> > Ok, actually, this line is a result of copy pasting from scan-build.html. I 
> > don't think I'd be competence enough to solve the drop-down menu issue, so, 
> > I just removed this line.
> No-no, i'd rather keep it. Otherwise how do we remember to fix it? :D
Alright, I've put it back.



Comment at: clang/www/analyzer/codechecker.html:48
+CodeChecker parse ./reports -e html -o ./reports_html
+firefox ./reports_html/index.html
+

NoQ wrote:
> Maybe `xdg-open`?
I'd like to keep "firefox" so readers immediately know that we are dealing with 
a web-browser. "xdg-open" might not be that obvious I think.



Comment at: clang/www/analyzer/command-line.html:54
+Can run clang-tidy checkers too.
+Out-of-tree, not part of the LLVM project.
+  

Charusso wrote:
> LLVM peoples seems to care to use open source projects, so I would mention it.
Ok, I added that to this list item.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70439



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


[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 232541.
teemperor added a comment.

- Put code in raw string (Thanks Gabor!)


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

https://reviews.llvm.org/D71112

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/Language.cpp


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,9 +37,11 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
-llvm_unreachable("Not implemented yet!");
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
+llvm_unreachable("-std=objc++");
   }
   return BasicArgs;
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(ToMethod);
+
+  // Implicit params are declared when Sema encounters the definition but this
+  // never happens when the method is imported. Manually declare the implicit
+  // params now that the MethodDecl knows its class interface.
+  if (D->getSelfDecl())
+ToMethod->createImplicitParams(Importer.getToContext(),
+   ToMethod->getClassInterface());
+
   return ToMethod;
 }
 


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,9 +37,11 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
-llvm_unreachable("Not implemented yet!");
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
+llvm_unreachable("-std=objc++");
   }
   return BasicArgs;
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(

[PATCH] D71063: [clangd] New rendering structs

2019-12-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/FormattedString.h:25
 /// plaintext upon requrest.
-class FormattedString {
+class RenderableString {
 public:

Naming: not sure "string" is the right name - it doesn't represent the things 
here that are stringiest.

Block? (maybe in a `markup` namespace?)



Comment at: clang-tools-extra/clangd/FormattedString.h:34
+
+/// Leaf type of the struct representation.
+class Paragraph : public RenderableString {

Comments throughout should probably refer to the semantics (what part of markup 
is this) rather than its role in the tree.



Comment at: clang-tools-extra/clangd/FormattedString.h:67
 
+/// Container for a set of documents. Each document is prepended with a "- " 
and
+/// separated by newlines.

"List" and "Container" commonly mean other things in C++, so I got confused. 
`BulletList`?

The comment "Container for a list of documents" describes its structure in the 
tree rather than its semantics, which most callers (markup composers) will care 
about. Maybe "A bulleted list. Each item is a child Document"?

I think the comment "each document is prepended..." belongs on 
renderAsPlainText() if at all



Comment at: clang-tools-extra/clangd/FormattedString.h:70
+class List : public RenderableString {
+public:
+  std::string renderAsMarkdown() const override;

obvious attribute here is bullet style (bullets vs numbers) - but you probably 
only need one for now



Comment at: clang-tools-extra/clangd/FormattedString.h:82
+/// Top-level container for structured strings.
+class Document : public RenderableString {
+public:

Document doesn't need to inherit from RenderableString AFAICS, it doesn't need 
to be embedded in Documents itself, just Lists.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71063



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


[PATCH] D58634: [PR40778] Generate address space conversion when binding reference to a temporary value in different address space

2019-12-06 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Sema/SemaInit.cpp:4806-4808
+  if ((RefRelationship == Sema::Ref_Related &&
+   (T1CVRQuals | T2CVRQuals) != T1CVRQuals) ||
+  !T1Quals.isAddressSpaceSupersetOf(T2Quals)) {

Sorry for the really late comment on this, but shouldn't this be:
```
  if (RefRelationship == Sema::Ref_Related &&
  ((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
   !T1Quals.isAddressSpaceSupersetOf(T2Quals))) {
```

Currently, this fails on AS qualification regardless of ref-compatibility.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58634



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


[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/unittests/AST/Language.cpp:44
+  case Lang_OpenCL:
+llvm_unreachable("-std=objc++");
   }

I think, we should keep the "Not implemented yet!" message here. Perhaps you 
wanted "-std=objc++" to put next to -x objective-c++ in line 41?


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

https://reviews.llvm.org/D71112



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


[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor marked an inline comment as done.
teemperor added inline comments.



Comment at: clang/unittests/AST/Language.cpp:44
+  case Lang_OpenCL:
+llvm_unreachable("-std=objc++");
   }

martong wrote:
> I think, we should keep the "Not implemented yet!" message here. Perhaps you 
> wanted "-std=objc++" to put next to -x objective-c++ in line 41?
Whoops, yes that should have stayed "Not implemented"...


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

https://reviews.llvm.org/D71112



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


[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 232547.
teemperor added a comment.

- Reverted unintentional change to unreachable error message.


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

https://reviews.llvm.org/D71112

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/Language.cpp


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,8 +37,10 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
 llvm_unreachable("Not implemented yet!");
   }
   return BasicArgs;
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(ToMethod);
+
+  // Implicit params are declared when Sema encounters the definition but this
+  // never happens when the method is imported. Manually declare the implicit
+  // params now that the MethodDecl knows its class interface.
+  if (D->getSelfDecl())
+ToMethod->createImplicitParams(Importer.getToContext(),
+   ToMethod->getClassInterface());
+
   return ToMethod;
 }
 


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,8 +37,10 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
 llvm_unreachable("Not implemented yet!");
   }
   return BasicArgs;
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(ToMethod);
+
+  // Implicit params are declared when Sema enc

[PATCH] D70804: [Frontend] Allow OpenMP offloading to aarch64

2019-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/test/OpenMP/openmp_offload_registration.cpp:3-5
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=aarch64-unknown-linux-gnu,powerpc64-ibm-linux-gnu -emit-llvm 
%s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=i686-pclinux-gnu,powerpc-ibm-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=nvptx-nvidia-cuda,nvptx64-nvidia-cuda -emit-llvm %s -o - | 
FileCheck %s

Do not add tests targets other than aarch64



Comment at: clang/test/OpenMP/target_messages.cpp:4
+
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o 
- %s 2>&1 | FileCheck %s
 // CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'

bryanpkc wrote:
> ABataev wrote:
> > Why do you need the changes in this file?
> The clean-up is not strictly necessary. I came across this file when I was 
> looking for the right file to add the tests, and thought it would be better 
> to group similar tests (and their corresponding CHECK patterns) together.
Do not do this in this patch, these changes are not related to the patch itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70804



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


[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 232553.
hokein added a comment.

add more symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/RenameMain.cpp
  clang-tools-extra/clangd/eval-rename/eval-rename.py
  clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt

Index: clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
@@ -0,0 +1,5 @@
+clang-tools-extra/clangd/XRefs.h clang::clangd::findReferences clangd
+clang-tools-extra/clangd/index/Index.h clang::clangd::SymbolIndex clangd
+clang-tools-extra/clangd/ClangdServer.h clang::clangd::ClangdServer clangd
+clang-tools-extra/clangd/index/Ref.h clang::clangd::RefKind clangd
+clang-tools-extra/clangd/FindTarget.h clang::clangd::DeclRelation::Alias clangd
\ No newline at end of file
Index: clang-tools-extra/clangd/eval-rename/eval-rename.py
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/eval-rename.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+"""
+A script to perform cross-file rename and evalute the results.
+
+Usage:
+
+$ cd /llvm-project
+$ ninja -C build clangd-indexer
+$ ./build/bin/clangd-indexer -format=binary -executor=all-TUs . > llvm-index.idx
+$ ninja -C build clangd-rename
+$ clang-tools-extra/clangd/eval-rename/eval-rename.py --index=llvm-index.idx --file=clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+RENAME_EXECUTOR='build/bin/clangd-rename'
+
+def Run(cmd):
+  s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  print '>', ' '.join(cmd)
+  [stdout, stderr] = s.communicate()
+  return (s.returncode, stdout, stderr)
+
+if __name__ == '__main__':
+  if not os.getcwd().endswith('llvm-project'):
+sys.exit('The tool must be run from llvm-project/ root.')
+
+  ap = argparse.ArgumentParser()
+  ap.add_argument(
+  '-f',
+  '--file',
+  required=True,
+  help='A file containing rename symbols to be evaluted.'
+  )
+  ap.add_argument(
+  '-idx',
+  '--index',
+  required=True,
+  help='A path to the index file'
+  )
+  args = ap.parse_args()
+
+  with open(args.file) as f:
+out = f.read()
+  test_cases = [line.strip().split() for line in out.split('\n') if line.strip()]
+
+  log_output_dir = tempfile.mkdtemp(prefix='eval-rename_')
+  success_cnt = 0
+  for file_name, rename_symbol, verify_target in test_cases:
+Run(['git', 'reset', '--hard'])
+execute_rename_cmd = [
+  RENAME_EXECUTOR,
+   '--index-path=%s' % args.index,
+   '--rename-symbol=%s' % rename_symbol,
+   '-fix',
+   file_name,
+]
+rename_results = Run(execute_rename_cmd)
+if rename_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_RenameFailed'), 'w')
+  log_file.write(rename_results[1]) # stdout
+  log_file.write(rename_results[2]) # stderr
+  log_file.close()
+  continue
+
+build_results = Run(['ninja', '-C', 'build', verify_target])
+if build_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_BuildFailed'), 'w')
+  log_file.write(build_results[1]) # stdout
+  log_file.write(build_results[2]) # stderr
+  log_file.close()
+  continue
+
+success_cnt += 1
+  Run(['git', 'reset', '--hard'])
+  print 'Evaluated rename on %d symbols, %d symbol succeeded, go %s for failure logs' % (
+len(test_cases), success_cnt, log_output_dir)
\ No newline at end of file
Index: clang-tools-extra/clangd/eval-rename/RenameMain.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/RenameMain.cpp
@@ -0,0 +1,198 @@
+//===--- RenameMain.cpp --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Compiler.h"
+#include "FS.h"
+#include "FSProvider.h"
+#include "FindTarget.h"
+#include "GlobalCompilationDatabase.h"
+#include "Logger.h"
+#include "ParsedAST.h"
+#include "SourceCode.h"
+#include "index/MemIndex.h"
+#include "index/Serialization.h"
+#include "refactor/Rename.h"
+#include "clang/AST/Decl.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Re

[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 232554.
hokein added a comment.

Fix empty lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/CMakeLists.txt
  clang-tools-extra/clangd/eval-rename/RenameMain.cpp
  clang-tools-extra/clangd/eval-rename/eval-rename.py
  clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt

Index: clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
@@ -0,0 +1,5 @@
+clang-tools-extra/clangd/XRefs.h clang::clangd::findReferences clangd
+clang-tools-extra/clangd/index/Index.h clang::clangd::SymbolIndex clangd
+clang-tools-extra/clangd/ClangdServer.h clang::clangd::ClangdServer clangd
+clang-tools-extra/clangd/index/Ref.h clang::clangd::RefKind clangd
+clang-tools-extra/clangd/FindTarget.h clang::clangd::DeclRelation::Alias clangd
Index: clang-tools-extra/clangd/eval-rename/eval-rename.py
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/eval-rename.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+"""
+A script to perform cross-file rename and evalute the results.
+
+Usage:
+
+$ cd /llvm-project
+$ ninja -C build clangd-indexer
+$ ./build/bin/clangd-indexer -format=binary -executor=all-TUs . > llvm-index.idx
+$ ninja -C build clangd-rename
+$ clang-tools-extra/clangd/eval-rename/eval-rename.py --index=llvm-index.idx --file=clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+RENAME_EXECUTOR='build/bin/clangd-rename'
+
+def Run(cmd):
+  s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  print '>', ' '.join(cmd)
+  [stdout, stderr] = s.communicate()
+  return (s.returncode, stdout, stderr)
+
+if __name__ == '__main__':
+  if not os.getcwd().endswith('llvm-project'):
+sys.exit('The tool must be run from llvm-project/ root.')
+
+  ap = argparse.ArgumentParser()
+  ap.add_argument(
+  '-f',
+  '--file',
+  required=True,
+  help='A file containing rename symbols to be evaluted.'
+  )
+  ap.add_argument(
+  '-idx',
+  '--index',
+  required=True,
+  help='A path to the index file'
+  )
+  args = ap.parse_args()
+
+  with open(args.file) as f:
+out = f.read()
+  test_cases = [line.strip().split() for line in out.split('\n') if line.strip()]
+
+  log_output_dir = tempfile.mkdtemp(prefix='eval-rename_')
+  success_cnt = 0
+  for file_name, rename_symbol, verify_target in test_cases:
+Run(['git', 'reset', '--hard'])
+execute_rename_cmd = [
+  RENAME_EXECUTOR,
+   '--index-path=%s' % args.index,
+   '--rename-symbol=%s' % rename_symbol,
+   '-fix',
+   file_name,
+]
+rename_results = Run(execute_rename_cmd)
+if rename_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_RenameFailed'), 'w')
+  log_file.write(rename_results[1]) # stdout
+  log_file.write(rename_results[2]) # stderr
+  log_file.close()
+  continue
+
+build_results = Run(['ninja', '-C', 'build', verify_target])
+if build_results[0] != 0:
+  log_file = open(os.path.join(
+log_output_dir, rename_symbol.replace("::", "_") + '_BuildFailed'), 'w')
+  log_file.write(build_results[1]) # stdout
+  log_file.write(build_results[2]) # stderr
+  log_file.close()
+  continue
+
+success_cnt += 1
+  Run(['git', 'reset', '--hard'])
+  print 'Evaluated rename on %d symbols, %d symbol succeeded, go %s for failure logs' % (
+len(test_cases), success_cnt, log_output_dir)
Index: clang-tools-extra/clangd/eval-rename/RenameMain.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/eval-rename/RenameMain.cpp
@@ -0,0 +1,198 @@
+//===--- RenameMain.cpp --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Compiler.h"
+#include "FS.h"
+#include "FSProvider.h"
+#include "FindTarget.h"
+#include "GlobalCompilationDatabase.h"
+#include "Logger.h"
+#include "ParsedAST.h"
+#include "SourceCode.h"
+#include "index/MemIndex.h"
+#include "index/Serialization.h"
+#include "refactor/Rename.h"
+#include "clang/AST/Decl.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/ADT/STLExtras.h"
+
+sta

[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-12-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D70524#1772117 , @dblaikie wrote:

> In D70524#1771709 , @probinson wrote:
>
> > In D70524#1771522 , @shafik wrote:
> >
> > > @probinson I was reading the C++ "auto" return type 
> > >  issue and I can't come 
> > > up with a case where we don't have class descriptions across compilation 
> > > units that are not consistent wrt to auto return type. Do you have a 
> > > specific example?
> >
> >
> > The actual return type is known in a compile_unit where the method is 
> > defined, and not known in other compile_units.  If the non-defining 
> > compile_units omit the return type, that means "void" not "auto".  That is, 
> > one compile unit says it returns "void" and another compile unit says it 
> > returns something else.  That is the inconsistency I meant.
> >
> > If we use unspecified_type instead of omitting the return type, then a 
> > consumer knows that the method returns *something*, but it will have to 
> > look elsewhere to determine what that is.
>
>
> Yeah, my argument was to omit the declarations of auto-returning functions 
> entirely except in cases where their definition is available (either only 
> when the definition is emitted, or whenever the definition's available so the 
> deduced return type can be provided), same as a template instantiation.
>
> So the class would be missing the declaration of the function in cases where 
> the definition isn't available - same as templates and implicit special 
> members.


Understood.  The class descriptions are inconsistent (in that sense) across 
CUs.  This means deduplication in the type-unit sense would be less effective, 
but in the template-member and special-member cases there's really not much to 
be done about it.  This argument says that auto-return methods aren't 
fundamentally different from those.

> (yeah, you could take this to its logical extreme and say we should treat all 
> member functions this way - never produce a whole class definition 
> enumerating all members - Eric and I have bandied that idea about as "classes 
> as namespaces" more or less (the members in a class definition in one CU 
> aren't necessarily the same as those in another, and a consumer would have to 
> consider all of them together like it would have to for namespaces))

Heh.  Implemented that locally years ago as a space-saving measure; 
unreferenced methods are omitted.  Our debugger internally merges the different 
descriptions that it encounters.  In the compiler, the trick is that you don't 
actually know which methods to suppress until IRGen is complete, so I had to 
invent a Suppressed flag on the DISubprogram, that causes DwarfDebug to ignore 
it.

> & honestly it's going to be pretty uncommon that any of this comes up - 
> people aren't likely to separate their auto-returning function declaration 
> from its definition. It'd be awkward to read code like that.

If it's a class method, which is the only case of interest (otherwise the 
unused declaration is suppressed anyway), the auto-return method is in the 
class declaration and all users of the header will have to see it.  Most likely 
it would be a private method and used only in the implementation module, but 
still.


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

https://reviews.llvm.org/D70524



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


[PATCH] D71103: [libomptarget][nfc] Move three more files to common

2019-12-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 232557.
JonChesterfield added a comment.

- update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71103

Files:
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/src/support.cu
  openmp/libomptarget/deviceRTLs/common/src/sync.cu
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/parallel.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/support.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/sync.cu


Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -57,10 +57,10 @@
   src/libcall.cu
   ${devicertl_common_directory}/src/loop.cu
   ${devicertl_common_directory}/src/omptarget.cu
-  src/parallel.cu
+  ${devicertl_common_directory}/src/parallel.cu
   src/reduction.cu
-  src/support.cu
-  src/sync.cu
+  ${devicertl_common_directory}/src/support.cu
+  ${devicertl_common_directory}/src/sync.cu
   ${devicertl_common_directory}/src/task.cu
   )
 
Index: openmp/libomptarget/deviceRTLs/common/src/sync.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/sync.cu
+++ openmp/libomptarget/deviceRTLs/common/src/sync.cu
@@ -1,4 +1,4 @@
-//=== sync.h - NVPTX OpenMP synchronizations - CUDA 
-*-===//
+//=== sync.cu - OpenMP synchronizations -- CUDA 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: openmp/libomptarget/deviceRTLs/common/src/support.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/support.cu
+++ openmp/libomptarget/deviceRTLs/common/src/support.cu
@@ -1,4 +1,4 @@
-//===- support.cu - NVPTX OpenMP support functions --- CUDA 
-*-===//
+//===- support.cu - OpenMP support functions - CUDA 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -1,4 +1,4 @@
-//=== parallel.cu - NVPTX OpenMP parallel implementation - CUDA 
-*-===//
+//=== parallel.cu - GPU OpenMP parallel implementation --- CUDA 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -57,10 +57,10 @@
   src/libcall.cu
   ${devicertl_common_directory}/src/loop.cu
   ${devicertl_common_directory}/src/omptarget.cu
-  src/parallel.cu
+  ${devicertl_common_directory}/src/parallel.cu
   src/reduction.cu
-  src/support.cu
-  src/sync.cu
+  ${devicertl_common_directory}/src/support.cu
+  ${devicertl_common_directory}/src/sync.cu
   ${devicertl_common_directory}/src/task.cu
   )
 
Index: openmp/libomptarget/deviceRTLs/common/src/sync.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/sync.cu
+++ openmp/libomptarget/deviceRTLs/common/src/sync.cu
@@ -1,4 +1,4 @@
-//=== sync.h - NVPTX OpenMP synchronizations - CUDA -*-===//
+//=== sync.cu - OpenMP synchronizations -- CUDA -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: openmp/libomptarget/deviceRTLs/common/src/support.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/support.cu
+++ openmp/libomptarget/deviceRTLs/common/src/support.cu
@@ -1,4 +1,4 @@
-//===- support.cu - NVPTX OpenMP support functions --- CUDA -*-===//
+//===- support.cu - OpenMP support functions - CUDA -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/devic

[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-06 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60496 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110



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


[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-06 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60496 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-12-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D70524#1772690 , @probinson wrote:

> In D70524#1772117 , @dblaikie wrote:
>
> > In D70524#1771709 , @probinson 
> > wrote:
> >
> > > In D70524#1771522 , @shafik 
> > > wrote:
> > >
> > > > @probinson I was reading the C++ "auto" return type 
> > > >  issue and I can't 
> > > > come up with a case where we don't have class descriptions across 
> > > > compilation units that are not consistent wrt to auto return type. Do 
> > > > you have a specific example?
> > >
> > >
> > > The actual return type is known in a compile_unit where the method is 
> > > defined, and not known in other compile_units.  If the non-defining 
> > > compile_units omit the return type, that means "void" not "auto".  That 
> > > is, one compile unit says it returns "void" and another compile unit says 
> > > it returns something else.  That is the inconsistency I meant.
> > >
> > > If we use unspecified_type instead of omitting the return type, then a 
> > > consumer knows that the method returns *something*, but it will have to 
> > > look elsewhere to determine what that is.
> >
> >
> > Yeah, my argument was to omit the declarations of auto-returning functions 
> > entirely except in cases where their definition is available (either only 
> > when the definition is emitted, or whenever the definition's available so 
> > the deduced return type can be provided), same as a template instantiation.
> >
> > So the class would be missing the declaration of the function in cases 
> > where the definition isn't available - same as templates and implicit 
> > special members.
>
>
> Understood.  The class descriptions are inconsistent (in that sense) across 
> CUs.  This means deduplication in the type-unit sense would be less 
> effective, but in the template-member and special-member cases there's really 
> not much to be done about it.  This argument says that auto-return methods 
> aren't fundamentally different from those.


I mean we could do something about them, to a degree - we could compute which 
special members are valid & emit them pre-emptively (though that'd be a bit 
tricky to do reliably, without unnecessarily instantiating any extra code, etc 
- but it's possible) & we could improve DWARF to have some description of 
templates. There still probably wouldn't be enough info to get overload 
resolution right, etc.

>> (yeah, you could take this to its logical extreme and say we should treat 
>> all member functions this way - never produce a whole class definition 
>> enumerating all members - Eric and I have bandied that idea about as 
>> "classes as namespaces" more or less (the members in a class definition in 
>> one CU aren't necessarily the same as those in another, and a consumer would 
>> have to consider all of them together like it would have to for namespaces))
> 
> Heh.  Implemented that locally years ago as a space-saving measure; 
> unreferenced methods are omitted.  Our debugger internally merges the 
> different descriptions that it encounters.  In the compiler, the trick is 
> that you don't actually know which methods to suppress until IRGen is 
> complete, so I had to invent a Suppressed flag on the DISubprogram, that 
> causes DwarfDebug to ignore it.

Oh, I'd just implement it like the template/implicit special member - the 
DISubprograms are built as-needed/only referenced from the llvm::Function, they 
don't appear in the "members" list of the DICompositeType at all, and then 
DwarfDebug attaches any that make it to LLVM's CodeGen/need to be emitted then.

If you comment out this call: 
https://github.com/llvm/llvm-project/blob/master/clang/lib/CodeGen/CGDebugInfo.cpp#L2296
 you can probably get the behavior you want without any other changes? (tested 
that, and it reduced the dwarfdump debug_info dumped output from 3.5k lines to 
1k lines)

Perhaps we should implement this mode under -fno-standalone-debug (or something 
more aggressive) since "standalone" is one of the only places I can think of 
where having the full class definition would be handy - it'd make it clear that 
there is a specific function overload that can be called & the debugger could 
mangle the name and find the symbol in another TU that was built without debug 
info... not sure if any implement that, though. (that wouldn't be quite 
possible with an auto-returning function - you'd need to know the return type 
to figure out the calling ABI/handle the return value)

>> & honestly it's going to be pretty uncommon that any of this comes up - 
>> people aren't likely to separate their auto-returning function declaration 
>> from its definition. It'd be awkward to read code like that.
> 
> If it's a class method, which is the only case of interest (otherwise the 
> unused declaration is suppressed 

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-06 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 232573.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D71001

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+class C {
+  int num;
+public:
+  explicit C(int n) : num(n) {}
+};
+
+void bad_new(int n, int m) {
+  C *p = new C(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  C \*p = new C\(n}} + 10{{\);$}}
+
+  p = new C(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - 10{{\);$}}
+
+  p = new C(n) + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} + m{{\);$}}
+
+  p = new C(n) - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - (m + 10){{\);$}}
+
+  p = new C(n) - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - m{{\) \+ 10;$}}
+  // FIXME: Should be {{^  p = new C\(n}} - m + 10{{\);$}}
+}
+
+void bad_new_array(int n, int m) {
+  char *p = new char[n] + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = new char\[n}} + 10{{\];$}}
+
+  p = new char[n] - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - 10{{\];$}}
+
+  p = new char[n] + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} + m{{\];$}}
+
+  p = new char[n] - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - (m + 10){{\];$}}
+
+  p = new char[n] - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - m{{\] \+ 10;$}}
+  // FIXME: should be {{^  p = new char\[n}} - m + 10{{\];$}}
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void bad_malloc(int n) {
+  char *p = (char *)malloc(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = \(char \*\)malloc\(n}} + 10{{\);$}}
+
+  p = (char *)malloc(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = \(char \*\)malloc\(n}} - 10{{\);$}}
+
+  p = (char *)malloc(n) + n;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is appl

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-06 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp:81-82
+  diag(PtrArith->getBeginLoc(),
+   "pointer arithmetic is applied to the result of %0() instead of its "
+   "argument")
+  << Func->getName() << Hint;

whisperity wrote:
> If I put the `+ b` on `X` as in `malloc(X + b)` instead of `malloc(X) + b`, 
> then it's not //pointer// arithmetic anymore, but (hopefully unsigned) 
> arithmetic. Should the warning message really start with "pointer arithmetic"?
> 
> Maybe you could consider the check saying
> 
> arithmetic operation applied to pointer result of ...() instead of 
> size-like argument
> 
> optionally, I'd clarify it further by putting at the end:
> 
> resulting in ignoring a prefix of the buffer.
> 
> considering you specifically match on the std(-like) allocations. (At least 
> for now.)
"resulting in ignoring a prefix of the buffer" <- this is only true for 
addition. What should we write for subtraction?


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

https://reviews.llvm.org/D71001



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


[PATCH] D71124: [RISCV] support clang driver to select cpu

2019-12-06 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen created this revision.
khchen added a project: clang.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.

This is follow up patch for https://reviews.llvm.org/D68685


Repository:
  rC Clang

https://reviews.llvm.org/D71124

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/riscv-cpus.c


Index: clang/test/Driver/riscv-cpus.c
===
--- /dev/null
+++ clang/test/Driver/riscv-cpus.c
@@ -0,0 +1,8 @@
+// Check target CPUs are correctly passed.
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck 
-check-prefix=ROCKETCHIP32 %s
+// ROCKETCHIP32: "-fuse-init-array" "-target-cpu" "rocket-rv32"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck 
-check-prefix=ROCKETCHIP64 %s
+// ROCKETCHIP64: "-fuse-init-array" "-target-cpu" "rocket-rv64"
+
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -304,6 +304,11 @@
 }
 return TargetCPUName;
   }
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+  return A->getValue();
+return "";
 
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -24,7 +24,7 @@
 // RISC-V Target
 class RISCVTargetInfo : public TargetInfo {
 protected:
-  std::string ABI;
+  std::string ABI, CPU;
   bool HasM;
   bool HasA;
   bool HasF;
@@ -43,6 +43,11 @@
 WIntType = UnsignedInt;
   }
 
+  bool setCPU(const std::string &Name) override {
+CPU = Name;
+return isValidCPUName(Name);
+  }
+
   StringRef getABI() const override { return ABI; }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
@@ -94,6 +99,7 @@
 return false;
   }
 
+  bool isValidCPUName(StringRef Name) const override;
   void setMaxAtomicWidth() override {
 MaxAtomicPromoteWidth = 128;
 
@@ -118,6 +124,7 @@
 return false;
   }
 
+  bool isValidCPUName(StringRef Name) const override;
   void setMaxAtomicWidth() override {
 MaxAtomicPromoteWidth = 128;
 
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -160,3 +160,17 @@
 
   return true;
 }
+
+static constexpr llvm::StringLiteral ValidRV32CPUNames[] = {{"generic-rv32"},
+{"rocket-rv32"}};
+
+bool RISCV32TargetInfo::isValidCPUName(StringRef Name) const {
+  return llvm::find(ValidRV32CPUNames, Name) != std::end(ValidRV32CPUNames);
+}
+
+static constexpr llvm::StringLiteral ValidRV64CPUNames[] = {{"generic-rv64"},
+{"rocket-rv64"}};
+
+bool RISCV64TargetInfo::isValidCPUName(StringRef Name) const {
+  return llvm::find(ValidRV64CPUNames, Name) != std::end(ValidRV64CPUNames);
+}


Index: clang/test/Driver/riscv-cpus.c
===
--- /dev/null
+++ clang/test/Driver/riscv-cpus.c
@@ -0,0 +1,8 @@
+// Check target CPUs are correctly passed.
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck -check-prefix=ROCKETCHIP32 %s
+// ROCKETCHIP32: "-fuse-init-array" "-target-cpu" "rocket-rv32"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck -check-prefix=ROCKETCHIP64 %s
+// ROCKETCHIP64: "-fuse-init-array" "-target-cpu" "rocket-rv64"
+
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -304,6 +304,11 @@
 }
 return TargetCPUName;
   }
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+  return A->getValue();
+return "";
 
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -24,7 +24,7 @@
 // RISC-V Target
 class RISCVTargetInfo : public TargetInfo {
 protected:
-  std::string ABI;
+  std::string ABI, CPU;
   bool HasM;

[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

You should upload patches with context :)




Comment at: clang/lib/CodeGen/CGObjCMac.cpp:4030
   const ObjCContainerDecl *CD) {
-  auto I = DirectMethodDefinitions.find(OMD);
+  auto I = DirectMethodDefinitions.find(OMD->getCanonicalDecl());
   if (I != DirectMethodDefinitions.end())

I'd rather have `auto *` or `Decl *` here.


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

https://reviews.llvm.org/D71091



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


[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2019-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/unittests/Format/FormatTest.cpp:14468
+   "NSNumber *v) {\n" \
+   " u = v;\n" \"   }]", Style);
+}

This line does not compile, I think whilst we are on the subject it would be 
better to move this test into

FormatTestObjC.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926



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


[clang] b8e03ff - [clang-format] update trailing newline treatment in clang-format.py

2019-12-06 Thread via cfe-commits

Author: mydeveloperday
Date: 2019-12-06T17:26:02Z
New Revision: b8e03ff50389d83dabf800203f689e227697c996

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

LOG: [clang-format] update trailing newline treatment in clang-format.py

Summary:
The current clang-format.py does not handle trailing newlines at the end of a 
file correctly.
Trailing empty lines get removed except one.
As far as I understand this is because clang-format gets fed from stdin and 
writes to stdout when called from clang-format.py.
In a "normal" file (with no trailing empty lines) the string that gets passed 
to clang-format does not contain a trailing '\n' after the '\n'.join from 
python.
The clang-format binary does not add a trailing newline to input from stdin, 
but (if there are multiple trailing '\n', all except one get removed).

When reading back this means that we see in python from a "normal" file a 
string with no trailing '\n'. From a file with (potentially multiple) empty 
line(s) at the end, we get a string with one trailing '\n' back in python. In 
the former case all is fine, in the latter case split('\n') makes one empty 
line at the end of the file out of the clang-format output. Desired would be 
instead that the **file** ends with a newline, but not with an empty line.

For the case that a user specifies a range to format (and wants to keep 
trailing empty lines) I did **not** try to fix this by simply removing all 
trailing newlines from the clang-format output. Instead, I add a '\n' to the 
unformatted file content (i.e. newline-terminate what is passed to 
clang-format) and then strip off the last newline from the output (which itself 
is now for sure the newline termination of the clang-format output).

(Should this get approved, I'll need someone to help me land this.)

Reviewers: klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Patch By: pseyfert

Subscribers: cfe-commits, llvm-commits

Tags: #clang-format, #clang

Differential Revision: https://reviews.llvm.org/D70864
update trailing newline treatment in clang-format.py

Added: 


Modified: 
clang/tools/clang-format/clang-format.py

Removed: 




diff  --git a/clang/tools/clang-format/clang-format.py 
b/clang/tools/clang-format/clang-format.py
index 976c222df055..596270cb55d3 100644
--- a/clang/tools/clang-format/clang-format.py
+++ b/clang/tools/clang-format/clang-format.py
@@ -70,7 +70,8 @@ def main():
   # Get the current text.
   encoding = vim.eval("&encoding")
   buf = get_buffer(encoding)
-  text = '\n'.join(buf)
+  # Join the buffer into a single string with a terminating newline
+  text = '\n'.join(buf) + '\n'
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':
@@ -129,7 +130,10 @@ def main():
   else:
 lines = stdout.decode(encoding).split('\n')
 output = json.loads(lines[0])
-lines = lines[1:]
+# Strip off the trailing newline (added above).
+# This maintains trailing empty lines present in the buffer if
+# the -lines specification requests them to remain unchanged.
+lines = lines[1:-1]
 sequence = 
diff lib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':



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


[PATCH] D70864: [clang-format] update trailing newline treatment in clang-format.py

2019-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb8e03ff50389: [clang-format] update trailing newline 
treatment in clang-format.py (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70864

Files:
  clang/tools/clang-format/clang-format.py


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -70,7 +70,8 @@
   # Get the current text.
   encoding = vim.eval("&encoding")
   buf = get_buffer(encoding)
-  text = '\n'.join(buf)
+  # Join the buffer into a single string with a terminating newline
+  text = '\n'.join(buf) + '\n'
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':
@@ -129,7 +130,10 @@
   else:
 lines = stdout.decode(encoding).split('\n')
 output = json.loads(lines[0])
-lines = lines[1:]
+# Strip off the trailing newline (added above).
+# This maintains trailing empty lines present in the buffer if
+# the -lines specification requests them to remain unchanged.
+lines = lines[1:-1]
 sequence = difflib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -70,7 +70,8 @@
   # Get the current text.
   encoding = vim.eval("&encoding")
   buf = get_buffer(encoding)
-  text = '\n'.join(buf)
+  # Join the buffer into a single string with a terminating newline
+  text = '\n'.join(buf) + '\n'
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':
@@ -129,7 +130,10 @@
   else:
 lines = stdout.decode(encoding).split('\n')
 output = json.loads(lines[0])
-lines = lines[1:]
+# Strip off the trailing newline (added above).
+# This maintains trailing empty lines present in the buffer if
+# the -lines specification requests them to remain unchanged.
+lines = lines[1:-1]
 sequence = difflib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 79f8c20 - update string comparison in clang-format.py

2019-12-06 Thread via cfe-commits

Author: mydeveloperday
Date: 2019-12-06T17:36:56Z
New Revision: 79f8c20e2cb634c1b8e42f01b42fc5ab2a512d60

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

LOG: update string comparison in clang-format.py

Summary: Python 3.8 introduces a SyntaxWarning about string comparisons with 
'is'. This commit updates the string comparison in clang-format.py that is done 
with 'is not' to '!='. This should not break compatibility with older python 
versions (tested 3.4.9, 2.7.17, 2.7.5, 3.8.0).

Reviewers: MyDeveloperDay, klimek, llvm-commits, cfe-commits

Reviewed By: MyDeveloperDay, klimek

Patch By: pseyfert

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/tools/clang-format/clang-format.py

Removed: 




diff  --git a/clang/tools/clang-format/clang-format.py 
b/clang/tools/clang-format/clang-format.py
index 596270cb55d3..1a615b170722 100644
--- a/clang/tools/clang-format/clang-format.py
+++ b/clang/tools/clang-format/clang-format.py
@@ -136,7 +136,7 @@ def main():
 lines = lines[1:-1]
 sequence = 
diff lib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
-  if op[0] is not 'equal':
+  if op[0] != 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 if output.get('IncompleteFormat'):
   print('clang-format: incomplete (syntax errors)')



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


[PATCH] D70664: [clang-format] update string comparison in clang-format.py

2019-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79f8c20e2cb6: update string comparison in clang-format.py 
(authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D70664?vs=230873&id=232591#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70664

Files:
  clang/tools/clang-format/clang-format.py


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -136,7 +136,7 @@
 lines = lines[1:-1]
 sequence = difflib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
-  if op[0] is not 'equal':
+  if op[0] != 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 if output.get('IncompleteFormat'):
   print('clang-format: incomplete (syntax errors)')


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -136,7 +136,7 @@
 lines = lines[1:-1]
 sequence = difflib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
-  if op[0] is not 'equal':
+  if op[0] != 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 if output.get('IncompleteFormat'):
   print('clang-format: incomplete (syntax errors)')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 232592.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

revised by Artem's comments.


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

https://reviews.llvm.org/D71080

Files:
  clang/include/clang/Basic/OptionUtils.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/OptionUtils.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3682,35 +3682,8 @@
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 
-template
-static IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id,
-IntTy Default,
-DiagnosticsEngine *Diags) {
-  IntTy Res = Default;
-  if (Arg *A = Args.getLastArg(Id)) {
-if (StringRef(A->getValue()).getAsInteger(10, Res)) {
-  if (Diags)
-Diags->Report(diag::err_drv_invalid_int_value) << A->getAsString(Args)
-   << A->getValue();
-}
-  }
-  return Res;
-}
-
 namespace clang {
 
-// Declared in clang/Frontend/Utils.h.
-int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,
-   DiagnosticsEngine *Diags) {
-  return getLastArgIntValueImpl(Args, Id, Default, Diags);
-}
-
-uint64_t getLastArgUInt64Value(const ArgList &Args, OptSpecifier Id,
-   uint64_t Default,
-   DiagnosticsEngine *Diags) {
-  return getLastArgIntValueImpl(Args, Id, Default, Diags);
-}
-
 IntrusiveRefCntPtr
 createVFSFromCompilerInvocation(const CompilerInvocation &CI,
 DiagnosticsEngine &Diags) {
Index: clang/lib/Basic/OptionUtils.cpp
===
--- /dev/null
+++ clang/lib/Basic/OptionUtils.cpp
@@ -0,0 +1,47 @@
+//===--- OptionUtils.cpp - Utilities for command line arguments ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/OptionUtils.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticDriver.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang;
+using namespace llvm::opt;
+
+namespace {
+template 
+IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id,
+ IntTy Default, DiagnosticsEngine *Diags,
+ unsigned Base) {
+  IntTy Res = Default;
+  if (Arg *A = Args.getLastArg(Id)) {
+if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
+  if (Diags)
+Diags->Report(diag::err_drv_invalid_int_value)
+<< A->getAsString(Args) << A->getValue();
+}
+  }
+  return Res;
+}
+} // namespace
+
+namespace clang {
+
+int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,
+   DiagnosticsEngine *Diags, unsigned Base) {
+  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
+}
+
+uint64_t getLastArgUInt64Value(const ArgList &Args, OptSpecifier Id,
+   uint64_t Default, DiagnosticsEngine *Diags,
+   unsigned Base) {
+  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
+}
+
+} // namespace clang
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -55,6 +55,7 @@
   ObjCRuntime.cpp
   OpenMPKinds.cpp
   OperatorPrecedence.cpp
+  OptionUtils.cpp
   SanitizerBlacklist.cpp
   SanitizerSpecialCaseList.cpp
   Sanitizers.cpp
Index: clang/include/clang/Frontend/Utils.h
===
--- clang/include/clang/Frontend/Utils.h
+++ clang/include/clang/Frontend/Utils.h
@@ -15,6 +15,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/OptionUtils.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -34,12 +35,6 @@
 
 class Triple;
 
-namespace opt {
-
-class ArgList;
-
-} // namespace opt
-
 } // namespace llvm
 
 namespace clang {
@@ -230,29 +225,6 @@
 bool ShouldRecoverOnErrors = false,
 std::vector *CC1Args = nullptr);
 
-/// Return the value of the last argument as an integer, or a default. If Diags
-/// is non-null, emits an error if the argument is given, but non-integral.
-int getLastArgIntValue(const llvm::opt::ArgList &Args,
-   llvm::opt::OptS

[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM, after fixing JF's comments. Please upload patches with full context as JF 
mentioned, as it helps with the review.


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

https://reviews.llvm.org/D71091



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


[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Basic/OptionUtils.cpp:18
+template 
+static IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id,
+IntTy Default, DiagnosticsEngine *Diags) {

tra wrote:
> I'd use anonymous namespace instead of static.
will do



Comment at: clang/lib/Basic/OptionUtils.cpp:22
+  if (Arg *A = Args.getLastArg(Id)) {
+if (StringRef(A->getValue()).getAsInteger(10, Res)) {
+  if (Diags)

tra wrote:
> Does it have to be base-10?
> Now that the functions are part of Basig API intended for wider use, I'd 
> argue for making it more flexible by default. If specific base is needed, 
> then we could add an argument to specify it.
Added



Comment at: clang/lib/Basic/OptionUtils.cpp:33
+
+// Declared in clang/Frontend/Utils.h.
+int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default,

tra wrote:
> This needs updating.
fixed


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

https://reviews.llvm.org/D71080



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-12-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

> Perhaps we should implement this mode under -fno-standalone-debug (or 
> something more aggressive) since "standalone" is one of the only places I can 
> think of where having the full class definition would be handy

You'd also want it for type units, so they deduplicate more reliably?  And 
probably should be DWARF only, not CodeView?  But yeah, I'm down for it.

This tactic would depend on the debuggers knowing they are unlikely to get a 
full class description and shouldn't throw away any class they've "already 
seen."  I remember that was an issue with, uh, one of those other debuggers 
that I never use.  They might take the first one they see, and shrug off any 
others as not contributing anything really important.  That would have to 
change.


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

https://reviews.llvm.org/D70524



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


[clang] 164e0fc - [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2019-12-06T18:50:32+01:00
New Revision: 164e0fc5c7f782b174db5c87b37725ea0e174853

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

LOG: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

Summary:
When Sema encounters a ObjCMethodDecl definition it declares the implicit 
parameters for the ObjCMethodDecl.
When importing such a method with the ASTImporter we need to do the same for 
the imported method
otherwise we will crash when generating code (where CodeGen expects that this 
was called by Sema).

Note I had to implement Objective-C[++] support in Language.cpp as this is the 
first test for Objective-C and this
would otherwise just hit this 'not implemented' assert when running the unit 
test.

Reviewers: martong, a.sidorin, shafik

Reviewed By: martong

Subscribers: rnkovacs, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/AST/Language.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index ff844f98bfb2..7d71a4a143cc 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@ ExpectedDecl 
ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(ToMethod);
+
+  // Implicit params are declared when Sema encounters the definition but this
+  // never happens when the method is imported. Manually declare the implicit
+  // params now that the MethodDecl knows its class interface.
+  if (D->getSelfDecl())
+ToMethod->createImplicitParams(Importer.getToContext(),
+   ToMethod->getClassInterface());
+
   return ToMethod;
 }
 

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ba2feff5fca6..abf29966e92f 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportDefaultConstructibleLambdas) {
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 

diff  --git a/clang/unittests/AST/Language.cpp 
b/clang/unittests/AST/Language.cpp
index 68b78a3179d6..47993cbb99ec 100644
--- a/clang/unittests/AST/Language.cpp
+++ b/clang/unittests/AST/Language.cpp
@@ -37,8 +37,10 @@ ArgVector getBasicRunOptionsForLanguage(Language Lang) {
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
 llvm_unreachable("Not implemented yet!");
   }
   return BasicArgs;



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


[PATCH] D71112: [ASTImporter] Implicitly declare parameters for imported ObjCMethodDecls

2019-12-06 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG164e0fc5c7f7: [ASTImporter] Implicitly declare parameters 
for imported ObjCMethodDecls (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71112

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/Language.cpp


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,8 +37,10 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
 llvm_unreachable("Not implemented yet!");
   }
   return BasicArgs;
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclContext(LexicalDC);
   LexicalDC->addDeclInternal(ToMethod);
+
+  // Implicit params are declared when Sema encounters the definition but this
+  // never happens when the method is imported. Manually declare the implicit
+  // params now that the MethodDecl knows its class interface.
+  if (D->getSelfDecl())
+ToMethod->createImplicitParams(Importer.getToContext(),
+   ToMethod->getClassInterface());
+
   return ToMethod;
 }
 


Index: clang/unittests/AST/Language.cpp
===
--- clang/unittests/AST/Language.cpp
+++ clang/unittests/AST/Language.cpp
@@ -37,8 +37,10 @@
   case Lang_CXX2a:
 BasicArgs = {"-std=c++2a", "-frtti"};
 break;
-  case Lang_OpenCL:
   case Lang_OBJCXX:
+BasicArgs = {"-x", "objective-c++", "-frtti"};
+break;
+  case Lang_OpenCL:
 llvm_unreachable("Not implemented yet!");
   }
   return BasicArgs;
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5599,6 +5599,30 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4010,6 +4010,14 @@
 
   ToMethod->setLexicalDeclConte

[PATCH] D71065: [ARM][MVE] Add intrinsics for immediate shifts.

2019-12-06 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM accepted this revision.
MarkMurrayARM added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71065



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-12-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D70524#1772961 , @probinson wrote:

> > Perhaps we should implement this mode under -fno-standalone-debug (or 
> > something more aggressive) since "standalone" is one of the only places I 
> > can think of where having the full class definition would be handy
>
> You'd also want it for type units, so they deduplicate more reliably?  And 
> probably should be DWARF only, not CodeView?  But yeah, I'm down for it.


It'd basically remove the need for type units entirely (& the DWARF would end 
up looking quite similar to DWARF using type units, just without the type units 
(well, you'd move the member variables from the type DIE In the type unit to 
the "skeleton" type DIE in the CU - but the member function handling looks very 
similar (because the skeleton type DIE ends up needing all the declarations of 
member functions in defined in the CU anyway - so the out of line definitions 
can refer to the member function declarations, their parameters, etc (since you 
can't refer to specific DIEs other than the total type DIE in a type unit.

Yeah, only for DWARF/I have no idea what CodeView can/would do.

> This tactic would depend on the debuggers knowing they are unlikely to get a 
> full class description and shouldn't throw away any class they've "already 
> seen."  I remember that was an issue with, uh, one of those other debuggers 
> that I never use.  They might take the first one they see, and shrug off any 
> others as not contributing anything really important.  That would have to 
> change.

My understanding with GDB is that it tends to treat the types in independent 
CUs as being potentially independent - you can violate the ODR and see that 
reflected in the type descriptions depending on where you print the type from 
(eg: print the type while you're debugging one function in one TU and you get 
that TU's view of the type, then step into a function in another TU and print 
the type and you get that TU's view of the type).

Yeah, it's not high on my list & starting with the DWARF consumers would be the 
right place.


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

https://reviews.llvm.org/D70524



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


[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder updated this revision to Diff 232602.
MadCoder marked 2 inline comments as done.

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

https://reviews.llvm.org/D71091

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/direct-method.m


Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -11,6 +11,7 @@
 
 __attribute__((objc_root_class))
 @interface Root
+- (int)getInt __attribute__((objc_direct));
 @end
 
 @implementation Root
@@ -173,3 +174,9 @@
 // CHECK-LABEL: define hidden void @"\01-[Foo setGetDynamic_setDirect:]"(
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
+
+int useRoot(Root *r) {
+  // CHEC-LABEL: define i32 @useRoot
+  // CHECK: %call = call i32 bitcast {{.*}} @"\01-[Root getInt]"
+  return [r getInt];
+}
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -4836,6 +4836,8 @@
 cast(ClassDecl)->addDecl(ObjCMethod);
   }
 
+  ObjCMethod->createImplicitParams(Context, ObjCMethod->getClassInterface());
+
   if (PrevMethod) {
 // You can never have two method definitions with the same name.
 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -4027,7 +4027,7 @@
 llvm::Function *
 CGObjCCommonMac::GenerateDirectMethod(const ObjCMethodDecl *OMD,
   const ObjCContainerDecl *CD) {
-  auto I = DirectMethodDefinitions.find(OMD);
+  auto I = DirectMethodDefinitions.find(OMD->getCanonicalDecl());
   if (I != DirectMethodDefinitions.end())
 return I->second;
 
@@ -4040,7 +4040,7 @@
   llvm::Function *Method =
   llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
  Name.str(), &CGM.getModule());
-  DirectMethodDefinitions.insert(std::make_pair(OMD, Method));
+  DirectMethodDefinitions.insert(std::make_pair(OMD->getCanonicalDecl(), 
Method));
 
   return Method;
 }


Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -11,6 +11,7 @@
 
 __attribute__((objc_root_class))
 @interface Root
+- (int)getInt __attribute__((objc_direct));
 @end
 
 @implementation Root
@@ -173,3 +174,9 @@
 // CHECK-LABEL: define hidden void @"\01-[Foo setGetDynamic_setDirect:]"(
 // CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]"(
 @end
+
+int useRoot(Root *r) {
+  // CHEC-LABEL: define i32 @useRoot
+  // CHECK: %call = call i32 bitcast {{.*}} @"\01-[Root getInt]"
+  return [r getInt];
+}
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -4836,6 +4836,8 @@
 cast(ClassDecl)->addDecl(ObjCMethod);
   }
 
+  ObjCMethod->createImplicitParams(Context, ObjCMethod->getClassInterface());
+
   if (PrevMethod) {
 // You can never have two method definitions with the same name.
 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -4027,7 +4027,7 @@
 llvm::Function *
 CGObjCCommonMac::GenerateDirectMethod(const ObjCMethodDecl *OMD,
   const ObjCContainerDecl *CD) {
-  auto I = DirectMethodDefinitions.find(OMD);
+  auto I = DirectMethodDefinitions.find(OMD->getCanonicalDecl());
   if (I != DirectMethodDefinitions.end())
 return I->second;
 
@@ -4040,7 +4040,7 @@
   llvm::Function *Method =
   llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
  Name.str(), &CGM.getModule());
-  DirectMethodDefinitions.insert(std::make_pair(OMD, Method));
+  DirectMethodDefinitions.insert(std::make_pair(OMD->getCanonicalDecl(), Method));
 
   return Method;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f2ace9d - Add `QualType::hasAddressSpace`. NFC.

2019-12-06 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2019-12-06T13:08:55-05:00
New Revision: f2ace9d6005b4ffc6f6fc068c1aac897d871df7a

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

LOG: Add `QualType::hasAddressSpace`. NFC.

- Add that as a shorthand of .getQualifiers().hasAddressSpace().
- Simplify related code.

Added: 


Modified: 
clang/include/clang/AST/Type.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 02c9aa403b5a..caf2a3dd79a3 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1046,6 +1046,9 @@ class QualType {
 ID.AddPointer(getAsOpaquePtr());
   }
 
+  /// Check if this type has any address space qualifier.
+  inline bool hasAddressSpace() const;
+
   /// Return the address space of this type.
   inline LangAS getAddressSpace() const;
 
@@ -6276,6 +6279,11 @@ inline void QualType::removeLocalCVRQualifiers(unsigned 
Mask) {
   removeLocalFastQualifiers(Mask);
 }
 
+/// Check if this type has any address space qualifier.
+inline bool QualType::hasAddressSpace() const {
+  return getQualifiers().hasAddressSpace();
+}
+
 /// Return the address space of this type.
 inline LangAS QualType::getAddressSpace() const {
   return getQualifiers().getAddressSpace();

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 660be458a698..0e38d6bfaf93 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6118,7 +6118,7 @@ bool Sema::inferObjCARCLifetime(ValueDecl *decl) {
 }
 
 void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
-  if (Decl->getType().getQualifiers().hasAddressSpace())
+  if (Decl->getType().hasAddressSpace())
 return;
   if (VarDecl *Var = dyn_cast(Decl)) {
 QualType Type = Var->getType();
@@ -6132,7 +6132,7 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
 // type has no address space yet, deduce it now.
 if (auto DT = dyn_cast(Type)) {
   auto OrigTy = DT->getOriginalType();
-  if (!OrigTy.getQualifiers().hasAddressSpace() && OrigTy->isArrayType()) {
+  if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) {
 // Add the address space to the original array type and then propagate
 // that to the element type through `getAsArrayType`.
 OrigTy = Context.getAddrSpaceQualType(OrigTy, ImplAS);
@@ -16094,7 +16094,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, 
QualType T,
   }
 
   // TR 18037 does not allow fields to be declared with address space
-  if (T.getQualifiers().hasAddressSpace() || T->isDependentAddressSpaceType() 
||
+  if (T.hasAddressSpace() || T->isDependentAddressSpaceType() ||
   T->getBaseElementTypeUnsafe()->isDependentAddressSpaceType()) {
 Diag(Loc, diag::err_field_with_address_space);
 Record->setInvalidDecl();

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c53a4b789bed..e2c37f8f5238 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5445,15 +5445,15 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema 
*Sema, ASTContext &Context,
 Expr *Arg = ArgRes.get();
 QualType ArgType = Arg->getType();
 if (!ParamType->isPointerType() ||
-ParamType.getQualifiers().hasAddressSpace() ||
+ParamType.hasAddressSpace() ||
 !ArgType->isPointerType() ||
-!ArgType->getPointeeType().getQualifiers().hasAddressSpace()) {
+!ArgType->getPointeeType().hasAddressSpace()) {
   OverloadParams.push_back(ParamType);
   continue;
 }
 
 QualType PointeeType = ParamType->getPointeeType();
-if (PointeeType.getQualifiers().hasAddressSpace())
+if (PointeeType.hasAddressSpace())
   continue;
 
 NeedsNewDecl = true;

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7421754d95ca..cc9d1a4f6256 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7853,9 +7853,8 @@ ExprResult InitializationSequence::Perform(Sema &S,
 
   // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global 
scope
   QualType ETy = Entity.getType();
-  Qualifiers TyQualifiers = ETy.getQualifiers();
-  bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
- TyQualifiers.getAddressSpace() == LangAS::opencl_global;
+  bool HasGlobalAS = ETy.hasAddressSpace() &&
+ ETy.getAddressSpace() == LangAS::opencl_global;
 
   if (S.getLangOpts().OpenCLVersion >= 200 &&
   ETy->isAtomicType() && !HasGlobalAS &&

diff  --git a/clang/lib/Sema/SemaOverload.c

[PATCH] D71005: [AST] Enable expression of OpenCL language address spaces an attribute

2019-12-06 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

@aaron.ballman, thank you for fixing the problem with documentation generation.

With regards to attributes naming question, let me check if I get it right.

1. You suggest checking with Khronos if they want to adopt 
`[[opencl::private]]` attribute names in OpenCL kernel language standard. 
Right? @Anastasia, can you help with this?
2. If Khronos leaves this decision to implementers, are current names (e.g. 
`[[clang::opencl_private]]`) look okay or we should consider other options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71005



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


[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder added a comment.

just added all the context this time (-W)




Comment at: clang/lib/CodeGen/CGObjCMac.cpp:4030
   const ObjCContainerDecl *CD) {
-  auto I = DirectMethodDefinitions.find(OMD);
+  auto I = DirectMethodDefinitions.find(OMD->getCanonicalDecl());
   if (I != DirectMethodDefinitions.end())

jfb wrote:
> I'd rather have `auto *` or `Decl *` here.
this is a pair this doesn't work


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

https://reviews.llvm.org/D71091



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


[PATCH] D70553: [clang-apply-replacements] Add command line option to overwrite readonly files.

2019-12-06 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

In D70553#1757862 , @aaron.ballman 
wrote:

> Can you add a test case for this functionality?


The reason there's no test case is because it seems like that wouldn't really 
be any different than testing the functionality of `llvm::sys::fs`, which 
should already be handled at the llvm/Support layer.  There's not really any 
interesting logic here.  I can still do one if you think it's important but 
that was my reasoning anyway.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70553



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


[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Liu Liu via Phabricator via cfe-commits
liuliu added a comment.

With this latest fix applied on top of b220662a45c8067a2ae485ae34c1138d93506df9 
, in our 
company's internal code, I still encounter the crash.

  Showing All Messages
  /Users/liuliu/Snapchat/Dev/phantom/3. 
Libraries/Storage/DocObject/Implementations/SCSQLiteDocObjectContext/Tests/Generated/SCTestMainEntityChangeRequest.mm:338:25:
 LLVM IR generation of compound statement ('{}')
  /Users/liuliu/Snapchat/Dev/phantom/0  clang-10 
0x00010b9edf0c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
  1  clang-10 0x00010b9ee4c9 
PrintStackTraceSignalHandler(void*) + 25
  /Users/liuliu/Snapchat/Dev/phantom/2  clang-10 
0x00010b9ec086 llvm::sys::RunSignalHandlers() + 118
  3  clang-10 0x00010b9f1e6c SignalHandler(int) + 252
  4  libsystem_platform.dylib 0x7fff65d8eb5d _sigtramp + 29
  5  libsystem_platform.dylib 0x7ffee7e9b790 _sigtramp + 
18446744071596723280
  /Users/liuliu/Snapchat/Dev/phantom/6  clang-10 
0x00010bfdff14 
clang::CodeGen::CodeGenTypes::arrangeObjCMethodDeclaration(clang::ObjCMethodDecl
 const*) + 52
  /Users/liuliu/Snapchat/Dev/phantom/7  clang-10 
0x00010c1f6bcd (anonymous 
namespace)::CGObjCCommonMac::GenerateDirectMethod(clang::ObjCMethodDecl const*, 
clang::ObjCContainerDecl const*) + 285
  /Users/liuliu/Snapchat/Dev/phantom/8  clang-10 
0x00010c1f63e9 (anonymous 
namespace)::CGObjCCommonMac::EmitMessageSend(clang::CodeGen::CodeGenFunction&, 
clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, 
llvm::Value*, clang::QualType, bool, clang::CodeGen::CallArgList const&, 
clang::ObjCMethodDecl const*, clang::ObjCInterfaceDecl const*, (anonymous 
namespace)::ObjCCommonTypesHelper const&) + 1401
  /Users/liuliu/Snapchat/Dev/phantom/9  clang-10 
0x00010c205b14 (anonymous 
namespace)::CGObjCNonFragileABIMac::GenerateMessageSend(clang::CodeGen::CodeGenFunction&,
 clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, 
llvm::Value*, clang::CodeGen::CallArgList const&, clang::ObjCInterfaceDecl 
const*, clang::ObjCMethodDecl const*) + 644
  /Users/liuliu/Snapchat/Dev/phantom/10 clang-10 
0x00010c1931b1 
clang::CodeGen::CGObjCRuntime::GeneratePossiblySpecializedMessageSend(clang::CodeGen::CodeGenFunction&,
 clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, 
llvm::Value*, clang::CodeGen::CallArgList const&, clang::ObjCInterfaceDecl 
const*, clang::ObjCMethodDecl const*, bool) + 433
  /Users/liuliu/Snapchat/Dev/phantom/11 clang-10 
0x00010c1942d2 
clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(clang::ObjCMessageExpr 
const*, clang::CodeGen::ReturnValueSlot) + 2818
  /Users/liuliu/Snapchat/Dev/phantom/12 clang-10 
0x00010c15cda8 (anonymous 
namespace)::ScalarExprEmitter::VisitObjCMessageExpr(clang::ObjCMessageExpr*) + 
184
  /Users/liuliu/Snapchat/Dev/phantom/13 clang-10 
0x00010c15522b clang::StmtVisitorBase::Visit(clang::Stmt*) + 6523
  /Users/liuliu/Snapchat/Dev/phantom/14 clang-10 
0x00010c14a309 (anonymous 
namespace)::ScalarExprEmitter::Visit(clang::Expr*) + 73
  /Users/liuliu/Snapchat/Dev/phantom/15 clang-10 
0x00010c14a26d clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr 
const*, bool) + 189
  /Users/liuliu/Snapchat/Dev/phantom/16 clang-10 
0x00010c1a209f emitARCRetainCallResult(clang::CodeGen::CodeGenFunction&, 
clang::Expr const*) + 31
  /Users/liuliu/Snapchat/Dev/phantom/17 clang-10 
0x00010c1a1eb4 
clang::CodeGen::CodeGenFunction::EmitARCReclaimReturnedObject(clang::Expr 
const*, bool) + 116
  /Users/liuliu/Snapchat/Dev/phantom/18 clang-10 
0x00010c1650ff (anonymous 
namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 4511
  /Users/liuliu/Snapchat/Dev/phantom/19 clang-10 
0x00010c15a5d8 clang::StmtVisitorBase::VisitImplicitCastExpr(clang::ImplicitCastExpr*) + 40
  /Users/liuliu/Snapchat/Dev/phantom/20 clang-10 
0x00010c154d93 clang::StmtVisitorBase::Visit(clang::Stmt*) + 5347
  /Users/liuliu/Snapchat/Dev/phantom/21 clang-10 
0x00010c14a309 (anonymous 
namespace)::ScalarExprEmitter::Visit(clang::Expr*) + 73
  /Users/liuliu/Snapchat/Dev/phantom/22 clang-10 
0x00010c14a26d clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr 
const*, bool) + 189
  /Users/liuliu/Snapchat/Dev/phantom/23 clang-10 
0x00010c0c1c37 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr 
const*, clang::CodeGen::AggValueSlot, bool) + 167
  /Users/liuliu/Snapchat/Dev/phantom/24 clang-10 
0x00010c0e6543 emitPseudoObjectExpr(clang::CodeGen::CodeGenFunction&, 
clang::PseudoObjectExpr const*, 

[PATCH] D70973: [OPENMP50]Treat context selectors as expressions, not just strings.

2019-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70973



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


[clang] 543ffb4 - [OPENMP]Reorganize OpenMP warning groups.

2019-12-06 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-06T13:31:02-05:00
New Revision: 543ffb4a2d6435004f7e41f2b3d9040aeb3e78ef

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

LOG: [OPENMP]Reorganize OpenMP warning groups.

openmp-mapping group is a subgroup of openmp-target warning group. Also,
added global openmp group to control all other OpenMP warning groups.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/OpenMP/nesting_of_regions.cpp
clang/test/OpenMP/simd_aligned_messages.cpp
clang/test/OpenMP/simd_loop_messages.cpp
clang/test/OpenMP/target_map_messages.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index dec293f45af7..e999ba10a003 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1057,7 +1057,11 @@ def ASM : DiagGroup<"asm", [
 def SourceUsesOpenMP : DiagGroup<"source-uses-openmp">;
 def OpenMPClauses : DiagGroup<"openmp-clauses">;
 def OpenMPLoopForm : DiagGroup<"openmp-loop-form">;
-def OpenMPTarget : DiagGroup<"openmp-target">;
+def OpenMPMapping : DiagGroup<"openmp-mapping">;
+def OpenMPTarget : DiagGroup<"openmp-target", [OpenMPMapping]>;
+def OpenMP : DiagGroup<"openmp", [
+SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget, 
OpenMPMapping
+  ]>;
 
 // Backend warnings.
 def BackendInlineAsm : DiagGroup<"inline-asm">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 61dfd548e120..a2e4cf51232b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9577,7 +9577,7 @@ def err_omp_linear_distribute_var_non_loop_iteration : 
Error<
   "only loop iteration variables are allowed in 'linear' clause in distribute 
directives">;
 def warn_omp_non_trivial_type_mapped : Warning<
   "Non-trivial type %0 is mapped, only trivial types are guaranteed to be 
mapped correctly">,
-  InGroup>;
+  InGroup;
 def err_omp_requires_clause_redeclaration : Error <
   "Only one %0 clause can appear on a requires directive in a single 
translation unit">;
 def note_omp_requires_previous_clause : Note <

diff  --git a/clang/test/OpenMP/nesting_of_regions.cpp 
b/clang/test/OpenMP/nesting_of_regions.cpp
index d80a06a8476b..ac9ed96eb94c 100644
--- a/clang/test/OpenMP/nesting_of_regions.cpp
+++ b/clang/test/OpenMP/nesting_of_regions.cpp
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp45 %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp45,omp45warn %s
 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=50 
-verify=expected,omp50 %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45 -Wno-openmp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45 -Wno-source-uses-openmp %s
 
-// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp45 %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd 
-verify=expected,omp45,omp45warn %s
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=50 
-verify=expected,omp50 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
@@ -234,7 +236,7 @@ void foo() {
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
-#pragma omp simd // omp45-warning {{OpenMP only allows an ordered construct 
with the simd clause nested in a simd construct}}
+#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered 
construct with the simd clause nested in a simd construct}}
 for (int i = 0; i < 10; ++i)
   ;
   }
@@ -763,7 +765,7 @@ void foo() {
   }
 #pragma omp for simd
   for (int i = 0; i < 10; ++i) {
-#pragma omp simd // omp45-warning {{OpenMP only allows an ordered construct 
with the simd clause nested in a simd construct}}
+#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered 
construct with the simd clause nested in a simd construct}}
 for (int i = 0; i < 10; ++i)
   ;
   }
@@ -2726,7 +2728,7 @@ void foo() {
   }
 #pragma omp parallel for simd
   for (int i = 0; i < 10; ++i) {
-#pragma omp simd // omp45-warning {{OpenMP only allows an ordered construct 
with the simd clause nested in a simd construct}}
+#pragma omp simd // omp45warn-warning {{OpenMP only allows an ordered 
construct with the simd clause nested in a simd construct}}
 for (int i = 0; i < 10; ++i)
   ;
   }
@@ -6226,7 +6228,7 @@ void foo() {
 #pragma omp teams
 #pragma omp distribute parallel for simd
   for (int i = 0; i < 10; ++i) {
-#pragma omp simd // omp45-warning {{OpenMP only allows an ordered construct 
with the simd clause nested in a simd cons

[clang] 2cc1194 - clang/AMDGPU: Fix default for frame-pointer attribute

2019-12-06 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2019-12-07T00:09:10+05:30
New Revision: 2cc11941a2e88236e0b4842229454ae6d85142cd

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

LOG: clang/AMDGPU: Fix default for frame-pointer attribute

Enabling optimization should allow frame pointer elimination.

Added: 
clang/test/Driver/frame-pointer-elim.cl

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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5ebf36f13ce9..02a365fa4969 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -538,6 +538,8 @@ static bool useFramePointerForTargetByDefault(const ArgList 
&Args,
   case llvm::Triple::ppc64le:
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
+  case llvm::Triple::amdgcn:
+  case llvm::Triple::r600:
 return !areOptimizationsEnabled(Args);
   default:
 break;

diff  --git a/clang/test/Driver/frame-pointer-elim.cl 
b/clang/test/Driver/frame-pointer-elim.cl
new file mode 100644
index ..c469d10a64be
--- /dev/null
+++ b/clang/test/Driver/frame-pointer-elim.cl
@@ -0,0 +1,8 @@
+// RUN: %clang -target amdgcn-amd-amdhsa -### -S -O3 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKNONE %s
+// RUN: %clang -target amdgcn-amd-amdhsa -### -S -O3 -fno-omit-frame-pointer 
%s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKALL %s
+// RUN: %clang -target amdgcn-amd-amdhsa -### -S %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECKALL %s
+// RUN: %clang -target amdgcn-amd-amdhsa -### -S -O0 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKALL %s
+// RUN: %clang -target amdgcn-amd-amdhsa -### -S -cl-opt-disable %s -o %t.s 
2>&1 | FileCheck -check-prefix=CHECKALL %s
+
+// CHECKNONE: -mframe-pointer=none
+// CHECKALL: -mframe-pointer=all



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


[PATCH] D70424: clang/AMDGPU: Fix default for frame-pointer attribute

2019-12-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

2cc11941a2e88236e0b4842229454ae6d85142cd 



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

https://reviews.llvm.org/D70424



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


[PATCH] D71133: [OpenCL] Add ExtVectorElementExpr constant evaluation (PR42387)

2019-12-06 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added a subscriber: yaxunl.

Add constexpr evaluation for ExtVectorElementExpr nodes by evaluating
the underlying vector expression.

Add basic folding too, for the case that Evaluate does not return an
LValue.


https://reviews.llvm.org/D71133

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenOpenCLCXX/constexpr.cl


Index: clang/test/CodeGenOpenCLCXX/constexpr.cl
===
--- clang/test/CodeGenOpenCLCXX/constexpr.cl
+++ clang/test/CodeGenOpenCLCXX/constexpr.cl
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -O0 
-emit-llvm -o - | FileCheck %s
 
+typedef int int2 __attribute__((ext_vector_type(2)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+
 struct Storage final {
   constexpr const float& operator[](const int index) const noexcept {
 return InternalStorage[index];
@@ -24,3 +27,28 @@
 kernel void foo(global float *x) {
   *x = FloatConstant;
 }
+
+// Test evaluation of constant vectors.
+// CHECK-LABEL: define spir_kernel void @vecEval
+// CHECK: store i32 3
+// CHECK: store <2 x i32> , <2 x i32>
+
+const int oneElt = int4(3).x;
+const int2 twoElts = (int4)(11, 22, 33, 44).yz;
+
+kernel void vecEval(global int *x, global int2 *y) {
+  *x = oneElt;
+  *y = twoElts;
+}
+
+// Test evaluation of vectors initialized through a constexpr function.
+// CHECK-LABEL: define spir_kernel void @vecEval2
+// CHECK: store <2 x i32>
+constexpr int2 addOne(int2 x) {
+  return (int2)(x.x + 1, x.y + 1);
+}
+const int2 fromConstexprFunc = addOne(int2(2));
+
+kernel void vecEval2(global int2 *x) {
+  *x = fromConstexprFunc;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -7049,6 +7049,31 @@
DerivedSuccess(Result, E);
   }
 
+  bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E) {
+APValue Val;
+if (!Evaluate(Val, Info, E->getBase()))
+  return false;
+
+if (Val.isVector()) {
+  SmallVector Indices;
+  E->getEncodedElementAccess(Indices);
+  if (Indices.size() == 1) {
+// Return scalar.
+return DerivedSuccess(Val.getVectorElt(Indices[0]), E);
+  } else {
+// Construct new APValue vector.
+SmallVector Elts;
+for (unsigned I = 0; I < Indices.size(); ++I) {
+  Elts.push_back(Val.getVectorElt(Indices[I]));
+}
+APValue VecResult(Elts.data(), Indices.size());
+return DerivedSuccess(VecResult, E);
+  }
+}
+
+return false;
+  }
+
   bool VisitCastExpr(const CastExpr *E) {
 switch (E->getCastKind()) {
 default:


Index: clang/test/CodeGenOpenCLCXX/constexpr.cl
===
--- clang/test/CodeGenOpenCLCXX/constexpr.cl
+++ clang/test/CodeGenOpenCLCXX/constexpr.cl
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -O0 -emit-llvm -o - | FileCheck %s
 
+typedef int int2 __attribute__((ext_vector_type(2)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+
 struct Storage final {
   constexpr const float& operator[](const int index) const noexcept {
 return InternalStorage[index];
@@ -24,3 +27,28 @@
 kernel void foo(global float *x) {
   *x = FloatConstant;
 }
+
+// Test evaluation of constant vectors.
+// CHECK-LABEL: define spir_kernel void @vecEval
+// CHECK: store i32 3
+// CHECK: store <2 x i32> , <2 x i32>
+
+const int oneElt = int4(3).x;
+const int2 twoElts = (int4)(11, 22, 33, 44).yz;
+
+kernel void vecEval(global int *x, global int2 *y) {
+  *x = oneElt;
+  *y = twoElts;
+}
+
+// Test evaluation of vectors initialized through a constexpr function.
+// CHECK-LABEL: define spir_kernel void @vecEval2
+// CHECK: store <2 x i32>
+constexpr int2 addOne(int2 x) {
+  return (int2)(x.x + 1, x.y + 1);
+}
+const int2 fromConstexprFunc = addOne(int2(2));
+
+kernel void vecEval2(global int2 *x) {
+  *x = fromConstexprFunc;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -7049,6 +7049,31 @@
DerivedSuccess(Result, E);
   }
 
+  bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E) {
+APValue Val;
+if (!Evaluate(Val, Info, E->getBase()))
+  return false;
+
+if (Val.isVector()) {
+  SmallVector Indices;
+  E->getEncodedElementAccess(Indices);
+  if (Indices.size() == 1) {
+// Return scalar.
+return DerivedSuccess(Val.getVectorElt(Indices[0]), E);
+  } else {
+// Construct new APValue vector.
+SmallVector Elts;
+for (unsigned I = 0; I < Indices.size(); ++I) {
+  Elts.push_back(Val.getVectorElt(Indices[I]));
+}
+APValue VecResult(Elts.data(), I

[PATCH] D71134: [OpenMP] Require trivially copyable type for mapping

2019-12-06 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: ABataev, jdoerfert.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

A trivially copyable type provides a trivial copy constructor and a trivial
copy assignment operator. This is enough for the runtime to memcpy the data
to the device. Additionally there must be no virtual functions or virtual
base classes and the destructor is guaranteed to be trivial, ie performs
no action.
The runtime does not require trivial default constructors because on alloc
the memory is undefined. Thus, weaken the warning to be only issued if the
mapped type is not trivially copyable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71134

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_shared_messages.cpp
  clang/test/OpenMP/distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_simd_loop_messages.cpp
  clang/test/OpenMP/distribute_simd_private_messages.cpp
  clang/test/OpenMP/distribute_simd_reduction_messages.cpp
  clang/test/OpenMP/target_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_private_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/target_private_messages.cpp
  clang/test/OpenMP/target_simd_private_messages.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
@@ -416,7 +416,7 @@
   Iter0 begin0, end0;
 #pragma omp target
 #pragma omp teams distribute simd
-  for (GoodIter I = begin; I < end; ++I) // expected-warning 2 {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I = begin; I < end; ++I) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
@@ -425,31 +425,31 @@
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
-  for (GoodIter I = begin; I >= end; --I) // expected-warning 2 {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I = begin; I >= end; --I) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
-  for (GoodIter I(begin); I < end; ++I) // expected-warning 2 {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I(begin); I < end; ++I) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
-  for (GoodIter I(nullptr); I < end; ++I) // expected-warning {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I(nullptr); I < end; ++I) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
-  fo

[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Basic/OptionUtils.h:24
+
+class ArgList;
+

What are the rules on using LLVM headers here? Can we just include 
llvm/Option/ArgList.h instead?



Comment at: clang/include/clang/Basic/OptionUtils.h:46
+   DiagnosticsEngine *Diags = nullptr,
+   unsigned Base = 10);
+

Same question as before -- does it have to be `10`?
`0` would be a more reasonable default for general use. IMO we care about the 
value, but not so much about the form. I.e. is there a reason not to allow 0xf, 
for instance, if that works for the user?




Comment at: clang/lib/Basic/CMakeLists.txt:1
 set(LLVM_LINK_COMPONENTS
   Core

I think now that you're using ArgList, you need to depend on LLVM's LLVMOption 
library.
As is you're likely to run into build issues if shared libraries are enabled.


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

https://reviews.llvm.org/D71080



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


[PATCH] D71134: [OpenMP] Require trivially copyable type for mapping

2019-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:14917
   if (FullCheck && !SemaRef.CurContext->isDependentContext() &&
-  !QTy.isTrivialType(SemaRef.Context))
+  !QTy.isTriviallyCopyableType(SemaRef.Context))
 SemaRef.Diag(SL, diag::warn_omp_non_trivial_type_mapped) << QTy << SR;

Need to add a check for defaulted destructor here, `isTriviallyCopyableType` 
does not include this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71134



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


[PATCH] D70849: [AST] Traverse the class type loc inside the member pointer type loc.

2019-12-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

We also hit this, and I have a repro here, but it depends on the Chromium Blink 
GC plugin:
https://bugs.chromium.org/p/chromium/issues/detail?id=1031274#c4
I think you just need an RAV client that walks over some particular AST node to 
trigger the assert. I assume there is nothing special about the Blink GC plugin 
here.

Thanks again Sterling for the revert, more bots are green this morning as a 
result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70849



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-06 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

Recording something so I don't forget it when we get back to the prefix padding 
version.  The write up on the bundle align mode stuff mentions a concerning 
memory overhead for the feature.  Since the basic implementation techniques are 
similar, we need to make sure we assess the memory overhead of the prefix 
padding implementation.  See 
https://www.chromium.org/nativeclient/pnacl/aligned-bundling-support-in-llvm 
for context.  I don't believe this is likely to be an issue for the nop padding 
variant.


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

https://reviews.llvm.org/D70157



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


[PATCH] D49091: Warn about usage of __has_include/__has_include_next in macro expansions

2019-12-06 Thread Tor Arne Vestbø via Phabricator via cfe-commits
torarnv added a comment.

I'm picking this up on the Qt side and removing our wrapper macro. Does this 
apply to other cases as well? The standard mentions `_­_­has_­cpp_­attribute`, 
but what about `__has_builtin`, `__has_attribute`,  and `__has_include_next`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D49091



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


[clang] dbd1129 - Stop checking whether std::strong_* has ::equivalent members.

2019-12-06 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-12-06T11:35:41-08:00
New Revision: dbd112972416f48f7e5b117e7a14b6e4b4d38146

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

LOG: Stop checking whether std::strong_* has ::equivalent members.

Any attempt to use these would be a bug, so we shouldn't even look for
them.

Added: 


Modified: 
clang/lib/AST/ComparisonCategories.cpp
clang/test/SemaCXX/std-compare-cxx2a.cpp

Removed: 




diff  --git a/clang/lib/AST/ComparisonCategories.cpp 
b/clang/lib/AST/ComparisonCategories.cpp
index ee4c1b0443a3..813b728b 100644
--- a/clang/lib/AST/ComparisonCategories.cpp
+++ b/clang/lib/AST/ComparisonCategories.cpp
@@ -190,19 +190,16 @@ 
ComparisonCategories::getPossibleResultsForType(ComparisonCategoryType Type) {
   using CCT = ComparisonCategoryType;
   using CCR = ComparisonCategoryResult;
   std::vector Values;
-  Values.reserve(6);
-  Values.push_back(CCR::Equivalent);
+  Values.reserve(4);
   bool IsStrong = (Type == CCT::StrongEquality || Type == CCT::StrongOrdering);
   if (IsStrong)
-Values.push_back(CCR::Equal);
+  Values.push_back(IsStrong ? CCR::Equal : CCR::Equivalent);
   if (Type == CCT::StrongOrdering || Type == CCT::WeakOrdering ||
   Type == CCT::PartialOrdering) {
 Values.push_back(CCR::Less);
 Values.push_back(CCR::Greater);
   } else {
-Values.push_back(CCR::Nonequivalent);
-if (IsStrong)
-  Values.push_back(CCR::Nonequal);
+Values.push_back(IsStrong ? CCR::Nonequal : CCR::Nonequivalent);
   }
   if (Type == CCT::PartialOrdering)
 Values.push_back(CCR::Unordered);

diff  --git a/clang/test/SemaCXX/std-compare-cxx2a.cpp 
b/clang/test/SemaCXX/std-compare-cxx2a.cpp
index 6746fb480e62..941c4faeb7ff 100644
--- a/clang/test/SemaCXX/std-compare-cxx2a.cpp
+++ b/clang/test/SemaCXX/std-compare-cxx2a.cpp
@@ -27,7 +27,7 @@ struct partial_ordering {
 } // namespace std
 
 auto missing_member_test() {
-  // expected-error@+1 {{standard library implementation of 
'std::partial_ordering' is not supported; member 'equivalent' is missing}}
+  // expected-error@+1 {{standard library implementation of 
'std::partial_ordering' is not supported; member 'less' is missing}}
   return (1.0 <=> 1.0);
 }
 
@@ -35,13 +35,13 @@ namespace std {
 inline namespace __1 {
 struct strong_ordering {
   long long value;
-  static const strong_ordering equivalent; // expected-note {{declared here}}
+  static const strong_ordering equal; // expected-note {{declared here}}
 };
 } // namespace __1
 } // namespace std
 
 auto test_non_constexpr_var() {
-  // expected-error@+1 {{standard library implementation of 
'std::strong_ordering' is not supported; member 'equivalent' does not have 
expected form}}
+  // expected-error@+1 {{standard library implementation of 
'std::strong_ordering' is not supported; member 'equal' does not have expected 
form}}
   return (1 <=> 0);
 }
 



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


[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman requested changes to this revision.
arphaman added a comment.
This revision now requires changes to proceed.

@MadCoder unfortunately this change causes several test failures when 
`check-clang` runs:

  Clang :: Analysis/analyzeOneFunction.m
  Clang :: Index/c-index-api-loadTU-test.m
  Clang :: SemaObjC/dealloc.m

Please fix them before committing this.


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

https://reviews.llvm.org/D71091



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


[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder added a comment.

In D71091#1773066 , @liuliu wrote:

> With this latest fix applied on top of 
> b220662a45c8067a2ae485ae34c1138d93506df9 
> , in our 
> company's internal code, I still encounter the crash.
>
>   Showing All Messages
>   /Users/liuliu/Snapchat/Dev/phantom/3.   
> Libraries/Storage/DocObject/Implementations/SCSQLiteDocObjectContext/Tests/Generated/SCTestMainEntityChangeRequest.mm:338:25:
>  LLVM IR generation of compound statement ('{}')
>   /Users/liuliu/Snapchat/Dev/phantom/0  clang-10 
> 0x00010b9edf0c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
>   1  clang-10 0x00010b9ee4c9 
> PrintStackTraceSignalHandler(void*) + 25
>   /Users/liuliu/Snapchat/Dev/phantom/2  clang-10 
> 0x00010b9ec086 llvm::sys::RunSignalHandlers() + 118
>   3  clang-10 0x00010b9f1e6c SignalHandler(int) + 252
>   4  libsystem_platform.dylib 0x7fff65d8eb5d _sigtramp + 29
>   5  libsystem_platform.dylib 0x7ffee7e9b790 _sigtramp + 
> 18446744071596723280
>   /Users/liuliu/Snapchat/Dev/phantom/6  clang-10 
> 0x00010bfdff14 
> clang::CodeGen::CodeGenTypes::arrangeObjCMethodDeclaration(clang::ObjCMethodDecl
>  const*) + 52
>   /Users/liuliu/Snapchat/Dev/phantom/7  clang-10 
> 0x00010c1f6bcd (anonymous 
> namespace)::CGObjCCommonMac::GenerateDirectMethod(clang::ObjCMethodDecl 
> const*, clang::ObjCContainerDecl const*) + 285
>   /Users/liuliu/Snapchat/Dev/phantom/8  clang-10 
> 0x00010c1f63e9 (anonymous 
> namespace)::CGObjCCommonMac::EmitMessageSend(clang::CodeGen::CodeGenFunction&,
>  clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, 
> llvm::Value*, clang::QualType, bool, clang::CodeGen::CallArgList const&, 
> clang::ObjCMethodDecl const*, clang::ObjCInterfaceDecl const*, (anonymous 
> namespace)::ObjCCommonTypesHelper const&) + 1401
>   /Users/liuliu/Snapchat/Dev/phantom/9  clang-10 
> 0x00010c205b14 (anonymous 
> namespace)::CGObjCNonFragileABIMac::GenerateMessageSend(clang::CodeGen::CodeGenFunction&,
>  clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, 
> llvm::Value*, clang::CodeGen::CallArgList const&, clang::ObjCInterfaceDecl 
> const*, clang::ObjCMethodDecl const*) + 644
>
>
> It indeed won't crash any more in trivial examples. I need to have some other 
> time to reduce my local example to a reasonable size.


This seems like the problem I just fixed, did you use the latest patch? because 
the problem was that we didn't bother to emit the implicit arguments for just 
prototypes before as it was only used by CodeGen of the implementations. This 
patch is supposed to add it to all declarations now, so I fail to understand 
how it can be missing anywhere ?


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

https://reviews.llvm.org/D71091



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


[PATCH] D70804: [Frontend] Allow OpenMP offloading to aarch64

2019-12-06 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc marked 6 inline comments as done.
bryanpkc added inline comments.



Comment at: clang/test/OpenMP/openmp_offload_registration.cpp:3-5
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=aarch64-unknown-linux-gnu,powerpc64-ibm-linux-gnu -emit-llvm 
%s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=i686-pclinux-gnu,powerpc-ibm-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=nvptx-nvidia-cuda,nvptx64-nvidia-cuda -emit-llvm %s -o - | 
FileCheck %s

ABataev wrote:
> Do not add tests targets other than aarch64
OK, thank you.



Comment at: clang/test/OpenMP/target_messages.cpp:4
+
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o 
- %s 2>&1 | FileCheck %s
 // CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'

ABataev wrote:
> bryanpkc wrote:
> > ABataev wrote:
> > > Why do you need the changes in this file?
> > The clean-up is not strictly necessary. I came across this file when I was 
> > looking for the right file to add the tests, and thought it would be better 
> > to group similar tests (and their corresponding CHECK patterns) together.
> Do not do this in this patch, these changes are not related to the patch 
> itself.
OK, I will remove these changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70804



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


[PATCH] D71139: [Wdocumentation] Use the command marker

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: gribozavr2.
Mordante added a project: clang.

Use the proper marker for `-Wdocumentation-deprecated-sync` instead of 
hard-coded the backslash.

Discovered while looking at https://bugs.llvm.org/show_bug.cgi?id=43753


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71139

Files:
  clang/include/clang/Basic/DiagnosticCommentKinds.td
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation.cpp


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -631,9 +631,9 @@
 /// \deprecated
 void test_deprecated_5(int a);
 
-// expected-warning@+2 {{declaration is marked with '\deprecated' command but 
does not have a deprecation attribute}} expected-note@+3 {{add a deprecation 
attribute to the declaration to silence this warning}}
+// expected-warning@+2 {{declaration is marked with '@deprecated' command but 
does not have a deprecation attribute}} expected-note@+3 {{add a deprecation 
attribute to the declaration to silence this warning}}
 /// Aaa
-/// \deprecated
+/// @deprecated
 void test_deprecated_6(int a) {
 }
 
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -676,9 +676,8 @@
   D->hasAttr())
 return;
 
-  Diag(Command->getLocation(),
-   diag::warn_doc_deprecated_not_sync)
-<< Command->getSourceRange();
+  Diag(Command->getLocation(), diag::warn_doc_deprecated_not_sync)
+  << Command->getSourceRange() << Command->getCommandMarker();
 
   // Try to emit a fixit with a deprecation attribute.
   if (const FunctionDecl *FD = dyn_cast(D)) {
Index: clang/include/clang/Basic/DiagnosticCommentKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -146,8 +146,8 @@
 // \deprecated command
 
 def warn_doc_deprecated_not_sync : Warning<
-  "declaration is marked with '\\deprecated' command but does not have "
-  "a deprecation attribute">,
+  "declaration is marked with '%select{\\|@}0deprecated' command but does "
+  "not have a deprecation attribute">,
   InGroup, DefaultIgnore;
 
 def note_add_deprecation_attr : Note<


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -631,9 +631,9 @@
 /// \deprecated
 void test_deprecated_5(int a);
 
-// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
+// expected-warning@+2 {{declaration is marked with '@deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
 /// Aaa
-/// \deprecated
+/// @deprecated
 void test_deprecated_6(int a) {
 }
 
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -676,9 +676,8 @@
   D->hasAttr())
 return;
 
-  Diag(Command->getLocation(),
-   diag::warn_doc_deprecated_not_sync)
-<< Command->getSourceRange();
+  Diag(Command->getLocation(), diag::warn_doc_deprecated_not_sync)
+  << Command->getSourceRange() << Command->getCommandMarker();
 
   // Try to emit a fixit with a deprecation attribute.
   if (const FunctionDecl *FD = dyn_cast(D)) {
Index: clang/include/clang/Basic/DiagnosticCommentKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -146,8 +146,8 @@
 // \deprecated command
 
 def warn_doc_deprecated_not_sync : Warning<
-  "declaration is marked with '\\deprecated' command but does not have "
-  "a deprecation attribute">,
+  "declaration is marked with '%select{\\|@}0deprecated' command but does "
+  "not have a deprecation attribute">,
   InGroup, DefaultIgnore;
 
 def note_add_deprecation_attr : Note<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71140: [Wdocumentation] Properly place deprecated attribute

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: gribozavr2.
Mordante added a project: clang.

It is now placed before the function:

- allows to replace `__attribute__((deprecated))` with `[[deprecated]]`.
- required for trailing returns.

Fixes bug: https://bugs.llvm.org/show_bug.cgi?id=43753


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71140

Files:
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation-fixits.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
 
 // This file contains lots of corner cases, so ensure that XML we generate is not invalid.
 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
@@ -643,6 +644,44 @@
 template
 void test_deprecated_7(T aaa);
 
+class PR43753 {
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  static void test_deprecated_static();
+
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  static auto test_deprecated_static_trailing_return() -> int;
+
+#if __cplusplus >= 201402L
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  static decltype(auto) test_deprecated_static_decltype_auto() { return 1; }
+#endif
+
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  void test_deprecated_const() const;
+
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  auto test_deprecated_trailing_return() -> int;
+
+#if __cplusplus >= 201402L
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  decltype(auto) test_deprecated_decltype_auto() const { return a; }
+
+private:
+  int a{0};
+#endif
+};
 
 // rdar://12397511
 // expected-note@+2 {{previous command '\headerfile' here}}
Index: clang/test/Sema/warn-documentation-fixits.cpp
===
--- clang/test/Sema/warn-documentation-fixits.cpp
+++ clang/test/Sema/warn-documentation-fixits.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 %s
 
 // expected-warning@+1 {{parameter 'ZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
 /// \param ZZ Blah blah.
@@ -51,6 +52,44 @@
   }
 };
 
+class PR43753 {
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  static void test_deprecated_static();
+
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
+  // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+  /// \deprecated
+  static auto test_deprecated_static_trailing_return() -> int;
+
+#if __cplusplus >= 201402L
+  // expected-warning@+2 {{declaration is marked with '\deprecated' command 

[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: gribozavr2.
Mordante added a project: clang.

This replaces the non-standard `__attribute__((deprecated))` with the standard 
`[[deprecated]]` when compiling in C++14 mode.

Discovered while looking at https://bugs.llvm.org/show_bug.cgi?id=43753

Depends: D71140 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71141

Files:
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation-fixits.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -612,6 +612,12 @@
 /// \deprecated Bbb
 void test_deprecated_1(int a) __attribute__((deprecated));
 
+#if __cplusplus >= 201402L
+/// Aaa
+/// \deprecated Bbb
+[[deprecated]] void test_deprecated_no_warning_std14(int a);
+#endif
+
 // We don't want \deprecated to warn about empty paragraph.  It is fine to use
 // \deprecated by itself without explanations.
 
Index: clang/test/Sema/warn-documentation-fixits.cpp
===
--- clang/test/Sema/warn-documentation-fixits.cpp
+++ clang/test/Sema/warn-documentation-fixits.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 %s
+// RUN  %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -DATTRIBUTE="__attribute__((deprecated))" %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 -DATTRIBUTE="[[deprecated]]" %s
 
 // expected-warning@+1 {{parameter 'ZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
 /// \param ZZ Blah blah.
@@ -96,6 +96,14 @@
 /// \deprecated
 void test_deprecated_9(int a);
 
+#if __cplusplus >= 201402L
+#define ATTRIBUTE_DEPRECATED [[deprecated]]
+
+// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+/// \deprecated
+void test_deprecated_10(int a);
+#endif
+
 // rdar://12381408
 // expected-warning@+2  {{unknown command tag name 'retur'; did you mean 'return'?}}
 /// \brief testing fixit
@@ -119,16 +127,17 @@
 // CHECK: fix-it:"{{.*}}":{10:12-10:15}:"aaa"
 // CHECK: fix-it:"{{.*}}":{14:13-14:23}:"T"
 // CHECK: fix-it:"{{.*}}":{19:13-19:18}:"SomeTy"
-// CHECK: fix-it:"{{.*}}":{26:1-26:1}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{30:1-30:1}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{35:3-35:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{39:3-39:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{47:3-47:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{51:3-51:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{76:3-76:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{81:3-81:3}:"__attribute__((deprecated)) "
-// CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"__attribute__((deprecated)) "
+// CHECK: fix-it:"{{.*}}":{26:1-26:1}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{30:1-30:1}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{35:3-35:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{39:3-39:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{47:3-47:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{51:3-51:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{76:3-76:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{81:3-81:3}:"[[ATTRIBUTE]] "
+// CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"[[ATTRIBUTE]] "
 // CHECK: fix-it:"{{.*}}":{97:1-97:1}:"MY_ATTR_DEPRECATED "
-// CHECK: fix-it:"{{.*}}":{102:6-102:11}:"return"
-// CHECK: fix-it:"{{.*}}":{106:6-106:11}:"foobar"
-// CHECK: fix-it:"{{.*}}":{115:6-115:12}:"endcode"
+// CHECK14: fix-it:"{{.*}}":{104:1-104:1}:"ATTRIBUTE_DEPRECATED "
+// CHECK: fix-it:"{{.*}}":{110:6-110:11}:"return"
+// CHECK: fix-it:"{{.*}}":{114:6-114:11}:"foobar"
+// CHECK: fix-it:"{{.*}}":{123:6-123:12}:"endcode"
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -688,17 +688,33 @@
 FD->doesThisDeclarationHaveABody())
   ret

[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Liu Liu via Phabricator via cfe-commits
liuliu marked an inline comment as done.
liuliu added inline comments.



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4839
 
+  ObjCMethod->createImplicitParams(Context, ObjCMethod->getClassInterface());
+

Yeah, I applied this change. As I said, for my trivial example it does work. 
But for my more thorough example with @property (direct) etc, it doesn't. I can 
dig into more later today or Monday. I just got everything work (with another 
more hackier fix) and would first to evaluate this as a viable path first 
before commit more time to debug this.

We probably can also just have a follow-up fix for that, depends on if 
reviewers thought this is blocking or not. I personally think not.


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

https://reviews.llvm.org/D71091



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


[PATCH] D71134: [OpenMP] Require trivially copyable type for mapping

2019-12-06 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld marked 2 inline comments as done.
Hahnfeld added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:14917
   if (FullCheck && !SemaRef.CurContext->isDependentContext() &&
-  !QTy.isTrivialType(SemaRef.Context))
+  !QTy.isTriviallyCopyableType(SemaRef.Context))
 SemaRef.Diag(SL, diag::warn_omp_non_trivial_type_mapped) << QTy << SR;

ABataev wrote:
> Need to add a check for defaulted destructor here, `isTriviallyCopyableType` 
> does not include this check.
As I said in the summary, this is a prerequisite for being trivially copyable 
and as such checked by `CXXRecordDecl::isTriviallyCopyable()` (line `if 
(!hasTrivialDestructor()) return false;`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71134



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


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

This attribute also exists with this spelling in C2x, FWIW.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71141



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


[PATCH] D71134: [OpenMP] Require trivially copyable type for mapping

2019-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71134



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


[PATCH] D70804: [Frontend] Allow OpenMP offloading to aarch64

2019-12-06 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 232627.
bryanpkc marked 2 inline comments as done.
bryanpkc added a comment.

Removed unrelated changes from this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70804

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/openmp_offload_registration.cpp


Index: clang/test/OpenMP/openmp_offload_registration.cpp
===
--- clang/test/OpenMP/openmp_offload_registration.cpp
+++ clang/test/OpenMP/openmp_offload_registration.cpp
@@ -1,5 +1,6 @@
-// Test for offload registration code for two targets
+// Test offload registration for two targets, and test offload target 
validation.
 // RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=x86_64-pc-linux-gnu,powerpc64le-ibm-linux-gnu -emit-llvm %s -o 
- | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu 
-fopenmp-targets=aarch64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
 // expected-no-diagnostics
 
 void foo() {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3070,7 +3070,8 @@
   llvm::Triple TT(A->getValue(i));
 
   if (TT.getArch() == llvm::Triple::UnknownArch ||
-  !(TT.getArch() == llvm::Triple::ppc ||
+  !(TT.getArch() == llvm::Triple::aarch64 ||
+TT.getArch() == llvm::Triple::ppc ||
 TT.getArch() == llvm::Triple::ppc64 ||
 TT.getArch() == llvm::Triple::ppc64le ||
 TT.getArch() == llvm::Triple::nvptx ||


Index: clang/test/OpenMP/openmp_offload_registration.cpp
===
--- clang/test/OpenMP/openmp_offload_registration.cpp
+++ clang/test/OpenMP/openmp_offload_registration.cpp
@@ -1,5 +1,6 @@
-// Test for offload registration code for two targets
+// Test offload registration for two targets, and test offload target validation.
 // RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux-gnu -fopenmp-targets=aarch64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
 // expected-no-diagnostics
 
 void foo() {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3070,7 +3070,8 @@
   llvm::Triple TT(A->getValue(i));
 
   if (TT.getArch() == llvm::Triple::UnknownArch ||
-  !(TT.getArch() == llvm::Triple::ppc ||
+  !(TT.getArch() == llvm::Triple::aarch64 ||
+TT.getArch() == llvm::Triple::ppc ||
 TT.getArch() == llvm::Triple::ppc64 ||
 TT.getArch() == llvm::Triple::ppc64le ||
 TT.getArch() == llvm::Triple::nvptx ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 779a180 - [OPENMP50]Add if clause in distribute simd directive.

2019-12-06 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-06T14:49:49-05:00
New Revision: 779a180d964bf362f26f4c493db749cbbae550c5

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

LOG: [OPENMP50]Add if clause in distribute simd directive.

According to OpenMP 5.0, if clause can be used in for simd directive. If
condition in the if clause if false, the non-vectorized version of the
loop must be executed.

Added: 
clang/test/OpenMP/distribute_simd_if_messages.cpp

Modified: 
clang/include/clang/Basic/OpenMPKinds.def
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/distribute_simd_ast_print.cpp
clang/test/OpenMP/distribute_simd_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index d2bfae4e60c1..6ab35cafc7ed 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -872,6 +872,7 @@ OPENMP_DISTRIBUTE_SIMD_CLAUSE(safelen)
 OPENMP_DISTRIBUTE_SIMD_CLAUSE(simdlen)
 OPENMP_DISTRIBUTE_SIMD_CLAUSE(reduction)
 OPENMP_DISTRIBUTE_SIMD_CLAUSE(allocate)
+OPENMP_DISTRIBUTE_SIMD_CLAUSE(if)
 
 // Clauses allowed for OpenMP directive 'target parallel for simd'.
 OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(if)

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index d95850fc7963..c075deb01a18 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -790,6 +790,8 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind 
DKind,
 }
 break;
   case OMPD_distribute_simd:
+if (OpenMPVersion < 50 && CKind == OMPC_if)
+  return false;
 switch (CKind) {
 #define OPENMP_DISTRIBUTE_SIMD_CLAUSE(Name)
\
   case OMPC_##Name:
\

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a5190007406d..6f3d6d859357 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3605,8 +3605,6 @@ void CodeGenFunction::EmitOMPDistributeLoop(const 
OMPLoopDirective &S,
   if (RT.isStaticNonchunked(ScheduleKind,
 /* Chunked */ Chunk != nullptr) ||
   StaticChunked) {
-if (isOpenMPSimdDirective(S.getDirectiveKind()))
-  EmitOMPSimdInit(S, /*IsMonotonic=*/true);
 CGOpenMPRuntime::StaticRTInput StaticInit(
 IVSize, IVSigned, /* Ordered = */ false, IL.getAddress(*this),
 LB.getAddress(*this), UB.getAddress(*this), ST.getAddress(*this),
@@ -3656,18 +3654,28 @@ void CodeGenFunction::EmitOMPDistributeLoop(const 
OMPLoopDirective &S,
 //   IV = LB;
 // }
 //
-EmitOMPInnerLoop(S, LoopScope.requiresCleanups(), Cond, IncExpr,
- [&S, LoopExit, &CodeGenLoop](CodeGenFunction &CGF) {
-   CodeGenLoop(CGF, S, LoopExit);
- },
- [&S, StaticChunked](CodeGenFunction &CGF) {
-   if (StaticChunked) {
- 
CGF.EmitIgnoredExpr(S.getCombinedNextLowerBound());
- 
CGF.EmitIgnoredExpr(S.getCombinedNextUpperBound());
- 
CGF.EmitIgnoredExpr(S.getCombinedEnsureUpperBound());
- CGF.EmitIgnoredExpr(S.getCombinedInit());
-   }
- });
+emitCommonSimdLoop(
+*this, S,
+[&S](CodeGenFunction &CGF, PrePostActionTy &) {
+  if (isOpenMPSimdDirective(S.getDirectiveKind()))
+CGF.EmitOMPSimdInit(S, /*IsMonotonic=*/true);
+},
+[&S, &LoopScope, Cond, IncExpr, LoopExit, &CodeGenLoop,
+ StaticChunked](CodeGenFunction &CGF, PrePostActionTy &) {
+  CGF.EmitOMPInnerLoop(
+  S, LoopScope.requiresCleanups(), Cond, IncExpr,
+  [&S, LoopExit, &CodeGenLoop](CodeGenFunction &CGF) {
+CodeGenLoop(CGF, S, LoopExit);
+  },
+  [&S, StaticChunked](CodeGenFunction &CGF) {
+if (StaticChunked) {
+  CGF.EmitIgnoredExpr(S.getCombinedNextLowerBound());
+  CGF.EmitIgnoredExpr(S.getCombinedNextUpperBound());
+  CGF.EmitIgnoredExpr(S.getCombinedEnsureUpperBound());
+  CGF.EmitIgnoredExpr(S.getCombinedInit());
+}
+  });
+});
 EmitBlock(LoopExit.getBlock());
 // Tell the runtime we are done.
 RT.emitForStaticFinish(*this

[PATCH] D71142: [Sema] Validate large bitfields

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: rsmith, majnemer, aaron.ballman.
Mordante added a project: clang.

Note: I'm not entirely happy with the text of the diagnostics and I'm open to 
suggestions.

Fixes PR23505: Large bitfield: Assertion `getActiveBits() <= 64 && "Too many 
bits for uint64_t"' failed


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71142

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/bitfield.c


Index: clang/test/Sema/bitfield.c
===
--- clang/test/Sema/bitfield.c
+++ clang/test/Sema/bitfield.c
@@ -28,6 +28,12 @@
 
   _Bool : 2;   // expected-error {{width of anonymous bit-field (2 bits) 
exceeds width of its type (1 bit)}}
   _Bool h : 5; // expected-error {{width of bit-field 'h' (5 bits) exceeds 
width of its type (1 bit)}}
+
+  // PR23505
+  _Bool : 1 + (unsigned __int128)0x;   // expected-error 
{{width of anonymous bit-field doesn't fit in a 64 bit unsigned integer}}
+  _Bool i : 1 + (unsigned __int128)0x; // expected-error 
{{width of bit-field 'i' doesn't fit in a 64 bit unsigned integer}}
+  int : 1 + (unsigned __int128)0x; // expected-error 
{{width of anonymous bit-field doesn't fit in a 64 bit unsigned integer}}
+  int j : 1 + (unsigned __int128)0x;   // expected-error 
{{width of bit-field 'j' doesn't fit in a 64 bit unsigned integer}}
 };
 
 struct b {unsigned x : 2;} x;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15842,6 +15842,17 @@
 uint64_t TypeWidth = Context.getIntWidth(FieldTy);
 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
 
+// Don't accept too wide bit-fields they will cause assertion failures
+// when used.
+if (BitfieldIsOverwide && Value.ugt(UINT64_MAX)) {
+  if (FieldName)
+return Diag(FieldLoc, diag::warn_bitfield_width_exceeds_maximum_width)
+   << FieldName;
+
+  return Diag(FieldLoc,
+  diag::warn_anon_bitfield_width_exceeds_maximum_width);
+}
+
 // Over-wide bitfields are an error in C or when using the MSVC bitfield
 // ABI.
 bool CStdConstraintViolation =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5183,6 +5183,10 @@
   "number of elements must be either one or match the size of the vector">;
 
 // Used by C++ which allows bit-fields that are wider than the type.
+def warn_bitfield_width_exceeds_maximum_width: Error<
+  "width of bit-field %0 doesn't fit in a 64 bit unsigned integer">;
+def warn_anon_bitfield_width_exceeds_maximum_width : Error<
+  "width of anonymous bit-field doesn't fit in a 64 bit unsigned integer">;
 def warn_bitfield_width_exceeds_type_width: Warning<
   "width of bit-field %0 (%1 bits) exceeds the width of its type; value will "
   "be truncated to %2 bit%s2">, InGroup;


Index: clang/test/Sema/bitfield.c
===
--- clang/test/Sema/bitfield.c
+++ clang/test/Sema/bitfield.c
@@ -28,6 +28,12 @@
 
   _Bool : 2;   // expected-error {{width of anonymous bit-field (2 bits) exceeds width of its type (1 bit)}}
   _Bool h : 5; // expected-error {{width of bit-field 'h' (5 bits) exceeds width of its type (1 bit)}}
+
+  // PR23505
+  _Bool : 1 + (unsigned __int128)0x;   // expected-error {{width of anonymous bit-field doesn't fit in a 64 bit unsigned integer}}
+  _Bool i : 1 + (unsigned __int128)0x; // expected-error {{width of bit-field 'i' doesn't fit in a 64 bit unsigned integer}}
+  int : 1 + (unsigned __int128)0x; // expected-error {{width of anonymous bit-field doesn't fit in a 64 bit unsigned integer}}
+  int j : 1 + (unsigned __int128)0x;   // expected-error {{width of bit-field 'j' doesn't fit in a 64 bit unsigned integer}}
 };
 
 struct b {unsigned x : 2;} x;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15842,6 +15842,17 @@
 uint64_t TypeWidth = Context.getIntWidth(FieldTy);
 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
 
+// Don't accept too wide bit-fields they will cause assertion failures
+// when used.
+if (BitfieldIsOverwide && Value.ugt(UINT64_MAX)) {
+  if (FieldName)
+return Diag(FieldLoc, diag::warn_bitfield_width_exceeds_maximum_width)
+   << FieldName;
+
+  return Diag(FieldLoc,
+  diag::warn_anon_bitfield_width_exceeds_maximum_width);
+}
+
 // Over-wide bitfields are an error in

[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2019-12-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It looks like this patch accidentally suppresses certain warnings when 
_FORTIFY_SOURCE is enabled.  For example, Sema::CheckMemaccessArguments only 
gets called for recognized builtin functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

aaron.ballman wrote:
> This attribute also exists with this spelling in C2x, FWIW.
True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also include 
`CPlusPlus14`. Do you prefer a different name for the Boolean?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71141



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


[PATCH] D71091: Make sure that the implicit arguments for direct methods have been setup

2019-12-06 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder marked an inline comment as done.
MadCoder added inline comments.



Comment at: clang/lib/Sema/SemaDeclObjC.cpp:4839
 
+  ObjCMethod->createImplicitParams(Context, ObjCMethod->getClassInterface());
+

liuliu wrote:
> Yeah, I applied this change. As I said, for my trivial example it does work. 
> But for my more thorough example with @property (direct) etc, it doesn't. I 
> can dig into more later today or Monday. I just got everything work (with 
> another more hackier fix) and would first to evaluate this as a viable path 
> first before commit more time to debug this.
> 
> We probably can also just have a follow-up fix for that, depends on if 
> reviewers thought this is blocking or not. I personally think not.
Huh I could have seen why property methods would have an issue but they seem to 
have gotten their `direct`ness properly anyway (I'll add them to the CG test 
for good measure while I debug the tests I broke).

so I'll need a reduced test case from you I can't seem to find an easy way to 
break it indeed.


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

https://reviews.llvm.org/D71091



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


[clang-tools-extra] a7bdab2 - [clang-tidy] Pass -faligned-allocation on the compiler command line to

2019-12-06 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2019-12-06T12:29:21-08:00
New Revision: a7bdab2e9d59ba0fdf06390f4ddadfd00fe50f2e

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

LOG: [clang-tidy] Pass -faligned-allocation on the compiler command line to
fix compile error

The test was failing when run on OSes older than MacOSX10.14 because
aligned deallocation functions are unavailable on older OSes.

rdar://problem/57706710

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/cert-mem57-cpp-cpp17.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cert-mem57-cpp-cpp17.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/cert-mem57-cpp-cpp17.cpp
index f2c1cb48d9d3..d393b229bda1 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/cert-mem57-cpp-cpp17.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/cert-mem57-cpp-cpp17.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
-// RUN: clang-tidy --extra-arg='-std=c++17' -checks='-*,cert-mem57-cpp' 
--warnings-as-errors='*' %s
-// RUN: clang-tidy --extra-arg='-std=c++2a' -checks='-*,cert-mem57-cpp' 
--warnings-as-errors='*' %s
+// RUN: clang-tidy --extra-arg='-std=c++17' --extra-arg='-faligned-allocation' 
-checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
+// RUN: clang-tidy --extra-arg='-std=c++2a' --extra-arg='-faligned-allocation' 
-checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
 
 struct alignas(128) Vector {
   char Elems[128];



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


[PATCH] D70973: [OPENMP50]Treat context selectors as expressions, not just strings.

2019-12-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1230
-  "unknown '%0' device kind trait in the 'device' context selector set, 
expected"
-  " one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'">;
 

ABataev wrote:
> jdoerfert wrote:
> > I would have expected this error to be still accurate, maybe with the 
> > addition ", or quoted versions thereof".
> Currently, we could emit it only in codegen phase to avoid double converting 
> from expression to string. Will emit it there.
Why can't we emit this error if the user writes `device={kind(gpu)}` 
anymore? Even `device={kind("gpu")}` should be diagnosable early.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:424
+if (ER.isUsable())
+  Values.push_back(ER);
   }

ABataev wrote:
> jdoerfert wrote:
> > When would ER not be usable here? Is there a valid use case or should we 
> > assert it is?
> If the instantiation is failed, the error message is emitted and `ER` is set 
> to `ExprError`, which is not usable.
Thx.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70973



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


[PATCH] D71005: [AST] Enable expression of OpenCL language address spaces an attribute

2019-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71005#1773042 , @bader wrote:

> @aaron.ballman, thank you for fixing the problem with documentation 
> generation.


No problem!

> With regards to attributes naming question, let me check if I get it right.
> 
> 1. You suggest checking with Khronos if they want to adopt 
> `[[opencl::private]]` attribute names in OpenCL kernel language standard. 
> Right? @Anastasia, can you help with this?

That's correct.

> 2. If Khronos leaves this decision to implementers, are current names (e.g. 
> `[[clang::opencl_private]]`) look okay or we should consider other options?

If they want to leave it to implementers, I think the names you have now are 
fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71005



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


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

Mordante wrote:
> aaron.ballman wrote:
> > This attribute also exists with this spelling in C2x, FWIW.
> True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also include 
> `CPlusPlus14`. Do you prefer a different name for the Boolean?
I'm talking about C2x, not C++2a. The name for the variable is fine, but we 
should prefer `[[deprecated]]` in C2x mode to `__attribute__((deprecated))`.

I think the correct predicate is: `getLangOpts().DoubleSquareBracketAttributes` 
-- if the user says they want to use double-square bracket attributes, we 
should probably prefer them to GNU-style attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71141



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


[PATCH] D71049: Remove implicit conversion that promotes half to other larger precision types for fp classification builtins

2019-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for the patch -- can you add some test cases?




Comment at: clang/lib/Sema/SemaChecking.cpp:5835-5836
+"is the only expected cast here");
+Cast->setSubExpr(nullptr);
+TheCall->setArg(NumArgs-1, CastArg);
+  }

I think this should be combined with the code above. Something like:
```
bool IgnoreCast = false;
if (CastArg-> is Float) {
  assert(stuff);
  IgnoreCast = true;
} else if (CastArg-> is Half) {
  assert(stuff);
  IgnoreCast = true;
}

if (IgnoreCast) {
  Cast->setSubExpr(nullptr);
  TheCall->setArg(NumArgs - 1, CastArg);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71049



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


[PATCH] D70973: [OPENMP50]Treat context selectors as expressions, not just strings.

2019-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1230
-  "unknown '%0' device kind trait in the 'device' context selector set, 
expected"
-  " one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'">;
 

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > I would have expected this error to be still accurate, maybe with the 
> > > addition ", or quoted versions thereof".
> > Currently, we could emit it only in codegen phase to avoid double 
> > converting from expression to string. Will emit it there.
> Why can't we emit this error if the user writes `device={kind(gpu)}` 
> anymore? Even `device={kind("gpu")}` should be diagnosable early.
The main problem here is the conversion and expression evaluation. We convert 
the data from the expression to strings at the codegen phase. I don't want to 
do the same thing for the second time in Sema just for diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70973



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


  1   2   >