[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

2019-10-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 226619.
kadircet added a comment.

- Don't rename if parameters have the same name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -1494,6 +1494,44 @@
   EXPECT_EQ(apply(Test), Expected);
 }
 
+TEST_F(DefineInlineTest, TransformParamNames) {
+  EXPECT_EQ(apply(R"cpp(
+void foo(int, bool b);
+
+void ^foo(int f, bool x) {})cpp"), R"cpp(
+void foo(int f, bool x){}
+
+)cpp");
+}
+
+TEST_F(DefineInlineTest, TransformTemplParamNames) {
+  EXPECT_EQ(apply(R"cpp(
+struct Foo {
+  struct Bar {
+template  class, template class Y,
+  int, int Z>
+void foo(X, Y, int W = 5 * Z + 2);
+  };
+};
+
+template  class V, template class W,
+  int X, int Y>
+void Foo::Bar::f^oo(U, W, int Q) {})cpp"),
+R"cpp(
+struct Foo {
+  struct Bar {
+template  class V, template class W,
+  int X, int Y>
+void foo(U, W, int Q = 5 * Y + 2){}
+  };
+};
+
+)cpp");
+}
+
 TEST_F(DefineInlineTest, TransformInlineNamespaces) {
   auto Test = R"cpp(
 namespace a { inline namespace b { namespace { struct Foo{}; } } }
Index: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -226,6 +226,80 @@
   return QualifiedFunc->substr(BodyBegin, BodyEnd - BodyBegin + 1);
 }
 
+/// Returns true if Dest is templated function. Fills in \p ParamToNewName with
+/// a mapping from template decls in \p Dest to theire respective names in \p
+/// Source.
+bool fillTemplateParameterMapping(
+const FunctionDecl *Dest, const FunctionDecl *Source,
+llvm::DenseMap &ParamToNewName) {
+  auto *DestTempl = Dest->getDescribedFunctionTemplate();
+  auto *SourceTempl = Source->getDescribedFunctionTemplate();
+  assert(bool(DestTempl) == bool(SourceTempl));
+  if (!DestTempl)
+return false;
+  const auto *DestTPL = DestTempl->getTemplateParameters();
+  const auto *SourceTPL = SourceTempl->getTemplateParameters();
+  assert(DestTPL->size() == SourceTPL->size());
+
+  for (size_t I = 0, EP = DestTPL->size(); I != EP; ++I)
+ParamToNewName[DestTPL->getParam(I)->getCanonicalDecl()] =
+SourceTPL->getParam(I)->getName();
+  return true;
+}
+
+/// Generates Replacements for changing template and function parameter names in
+/// \p Dest to be the same as in \p Source.
+llvm::Expected
+renameParameters(const FunctionDecl *Dest, const FunctionDecl *Source) {
+  llvm::DenseMap ParamToNewName;
+  bool HasTemplateParams =
+  fillTemplateParameterMapping(Dest, Source, ParamToNewName);
+  tooling::Replacements Replacements;
+
+  // Populate mapping for function params.
+  for (size_t I = 0, E = Dest->param_size(); I != E; ++I) {
+auto *DestParam = Dest->getParamDecl(I);
+auto *SourceParam = Source->getParamDecl(I);
+ParamToNewName[DestParam] = SourceParam->getName();
+  }
+
+  llvm::Error RenamingErrors = llvm::Error::success();
+  const SourceManager &SM = Dest->getASTContext().getSourceManager();
+  findExplicitReferences(
+  // Use function template in case of templated functions to visit template
+  // parameters.
+  HasTemplateParams
+  ? llvm::dyn_cast(Dest->getDescribedFunctionTemplate())
+  : llvm::dyn_cast(Dest),
+  [&](ReferenceLoc Ref) {
+if (Ref.Targets.size() != 1)
+  return;
+const auto *Target =
+llvm::dyn_cast(Ref.Targets.front()->getCanonicalDecl());
+auto It = ParamToNewName.find(Target);
+if (It == ParamToNewName.end())
+  return;
+// No need to rename if parameters already have the same name.
+if (Target->getName() == It->second)
+  return;
+const size_t OldNameLen = Target->getName().size();
+// If decl is unnamed in destination we pad the new name to avoid gluing
+// with previous token, e.g. foo(int^) shouldn't turn into foo(intx).
+auto ReplacementText = (OldNameLen == 0 ? " " : "") + It->second;
+if (auto Err = Replacements.add(tooling::Replacement(
+SM, Ref.NameLoc, OldNameLen, ReplacementText))) {
+  elog("define inline: Couldn't replace parameter name for {0} to {1}: "
+   "{2}",
+   Target->getName(), ReplacementText, Err);
+  RenamingErrors =
+  llvm::joinErrors(std::move(RenamingErr

[PATCH] D69382: [clangd] Do not insert parentheses when completing a using declaration

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 226620.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Update the comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69382

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaCodeComplete.cpp

Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5330,18 +5330,21 @@
 }
 
 void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
-   bool EnteringContext, QualType BaseType,
+   bool EnteringContext,
+   bool IsUsingDeclaration, QualType BaseType,
QualType PreferredType) {
   if (SS.isEmpty() || !CodeCompleter)
 return;
 
+  CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol, PreferredType);
+  CC.setIsUsingDeclaration(IsUsingDeclaration);
+  CC.setCXXScopeSpecifier(SS);
+
   // We want to keep the scope specifier even if it's invalid (e.g. the scope
   // "a::b::" is not corresponding to any context/namespace in the AST), since
   // it can be useful for global code completion which have information about
   // contexts/symbols that are not in the AST.
   if (SS.isInvalid()) {
-CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol, PreferredType);
-CC.setCXXScopeSpecifier(SS);
 // As SS is invalid, we try to collect accessible contexts from the current
 // scope with a dummy lookup so that the completion consumer can try to
 // guess what the specified scope is.
@@ -5371,10 +5374,8 @@
   if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
 return;
 
-  ResultBuilder Results(
-  *this, CodeCompleter->getAllocator(),
-  CodeCompleter->getCodeCompletionTUInfo(),
-  CodeCompletionContext(CodeCompletionContext::CCC_Symbol, PreferredType));
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(), CC);
   if (!PreferredType.isNull())
 Results.setPreferredType(PreferredType);
   Results.EnterNewScope();
@@ -5403,23 +5404,21 @@
CodeCompleter->loadExternal());
   }
 
-  auto CC = Results.getCompletionContext();
-  CC.setCXXScopeSpecifier(SS);
-
-  HandleCodeCompleteResults(this, CodeCompleter, CC, Results.data(),
-Results.size());
+  HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+Results.data(), Results.size());
 }
 
 void Sema::CodeCompleteUsing(Scope *S) {
   if (!CodeCompleter)
 return;
 
+  // This can be both a using alias or using declaration, in the former we
+  // expect a new name and a symbol in the latter case.
+  CodeCompletionContext Context(CodeCompletionContext::CCC_SymbolOrNewName);
+  Context.setIsUsingDeclaration(true);
+
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-CodeCompleter->getCodeCompletionTUInfo(),
-// This can be both a using alias or using
-// declaration, in the former we expect a new name and a
-// symbol in the latter case.
-CodeCompletionContext::CCC_SymbolOrNewName,
+CodeCompleter->getCodeCompletionTUInfo(), Context,
 &ResultBuilder::IsNestedNameSpecifier);
   Results.EnterNewScope();
 
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -143,13 +143,10 @@
 /// \param OnlyNamespace If true, only considers namespaces in lookup.
 ///
 /// \returns true if there was an error parsing a scope specifier
-bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
-ParsedType ObjectType,
-bool EnteringContext,
-bool *MayBePseudoDestructor,
-bool IsTypename,
-IdentifierInfo **LastII,
-bool OnlyNamespace) {
+bool Parser::ParseOptionalCXXScopeSpecifier(
+CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext,
+bool *MayBePseudoDestructor, bool IsTypename, IdentifierInfo **LastII,
+bool OnlyNamespace, bool InUsingDeclaration) {
   a

[PATCH] D69382: [clangd] Do not insert parentheses when completing a using declaration

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:483
   bool EnableFunctionArgSnippets;
+  bool CompleteArgumentList;
 };

kadircet wrote:
> kadircet wrote:
> > maybe rather use `GenerateSnippets`? Since this doesn't generate 
> > completions for the snippets, but rather disables generation of any 
> > snippets at all.
> > 
> > also I think it makes sense to document this one, because of the field just 
> > above it.
> not just function, also template arguments.
Right... That was too specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69382



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


[PATCH] D69382: [clangd] Do not insert parentheses when completing a using declaration

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

Build result: fail - 59587 tests passed, 1 failed and 805 were skipped.

  failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69382



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


[clang-tools-extra] d9971d0 - [clangd] Do not insert parentheses when completing a using declaration

2019-10-28 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-10-28T09:45:10+01:00
New Revision: d9971d0b2e34a6a5ca182089d019c9f079f528af

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

LOG: [clangd] Do not insert parentheses when completing a using declaration

Summary:
Would be nice to also fix this in clang, but that looks like more work
if we want to preserve signatures in informative chunks.

Fixes https://github.com/clangd/clangd/issues/118

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index bc826ba0adcd..db9f9cc0519b 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -253,9 +253,10 @@ struct CodeCompletionBuilder {
 const IncludeInserter &Includes,
 llvm::StringRef FileName,
 CodeCompletionContext::Kind ContextKind,
-const CodeCompleteOptions &Opts)
+const CodeCompleteOptions &Opts, bool GenerateSnippets)
   : ASTCtx(ASTCtx), ExtractDocumentation(Opts.IncludeComments),
-EnableFunctionArgSnippets(Opts.EnableFunctionArgSnippets) {
+EnableFunctionArgSnippets(Opts.EnableFunctionArgSnippets),
+GenerateSnippets(GenerateSnippets) {
 add(C, SemaCCS);
 if (C.SemaResult) {
   assert(ASTCtx);
@@ -419,6 +420,8 @@ struct CodeCompletionBuilder {
   }
 
   std::string summarizeSnippet() const {
+if (!GenerateSnippets)
+  return "";
 auto *Snippet = onlyValue<&BundledEntry::SnippetSuffix>();
 if (!Snippet)
   // All bundles are function calls.
@@ -476,6 +479,8 @@ struct CodeCompletionBuilder {
   llvm::SmallVector Bundled;
   bool ExtractDocumentation;
   bool EnableFunctionArgSnippets;
+  /// When false, no snippets are generated argument lists.
+  bool GenerateSnippets;
 };
 
 // Determine the symbol ID for a Sema code completion result, if possible.
@@ -1204,6 +1209,7 @@ class CodeCompleteFlow {
   // Sema takes ownership of Recorder. Recorder is valid until Sema cleanup.
   CompletionRecorder *Recorder = nullptr;
   CodeCompletionContext::Kind CCContextKind = CodeCompletionContext::CCC_Other;
+  bool IsUsingDeclaration = false;
   // Counters for logging.
   int NSema = 0, NIndex = 0, NSemaAndIndex = 0, NIdent = 0;
   bool Incomplete = false; // Would more be available with a higher limit?
@@ -1254,6 +1260,7 @@ class CodeCompleteFlow {
 auto RecorderOwner = std::make_unique(Opts, [&]() {
   assert(Recorder && "Recorder is not set");
   CCContextKind = Recorder->CCContext.getKind();
+  IsUsingDeclaration = Recorder->CCContext.isUsingDeclaration();
   auto Style = getFormatStyleForFile(
   SemaCCInput.FileName, SemaCCInput.Contents, SemaCCInput.VFS.get());
   // If preprocessor was run, inclusions from preprocessor callback should
@@ -1289,11 +1296,12 @@ class CodeCompleteFlow {
   SPAN_ATTACH(Tracer, "sema_completion_kind",
   getCompletionKindString(CCContextKind));
   log("Code complete: sema context {0}, query scopes [{1}] (AnyScope={2}), 
"
-  "expected type {3}",
+  "expected type {3}{4}",
   getCompletionKindString(CCContextKind),
   llvm::join(QueryScopes.begin(), QueryScopes.end(), ","), AllScopes,
   PreferredType ? Recorder->CCContext.getPreferredType().getAsString()
-: "");
+: "",
+  IsUsingDeclaration ? ", inside using declaration" : "");
 });
 
 Recorder = RecorderOwner.get();
@@ -1328,6 +1336,7 @@ class CodeCompleteFlow {
 HeuristicPrefix = guessCompletionPrefix(Content, Offset);
 populateContextWords(Content);
 CCContextKind = CodeCompletionContext::CCC_Recovery;
+IsUsingDeclaration = false;
 Filter = FuzzyMatcher(HeuristicPrefix.Name);
 auto Pos = offsetToPosition(Content, Offset);
 ReplacedRange.start = ReplacedRange.end = Pos;
@@ -1665,7 +1674,8 @@ class CodeCompleteFlow {
   if (!Builder)
 Builder.emplace(Recorder ? &Recorder->CCSema->getASTContext() : 
nullptr,
 Item, SemaCCS, QueryScopes, *Inserter, FileName,
-   

[PATCH] D69382: [clangd] Do not insert parentheses when completing a using declaration

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9971d0b2e34: [clangd] Do not insert parentheses when 
completing a using declaration (authored by ilya-biryukov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69382

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaCodeComplete.cpp

Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5330,18 +5330,21 @@
 }
 
 void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
-   bool EnteringContext, QualType BaseType,
+   bool EnteringContext,
+   bool IsUsingDeclaration, QualType BaseType,
QualType PreferredType) {
   if (SS.isEmpty() || !CodeCompleter)
 return;
 
+  CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol, PreferredType);
+  CC.setIsUsingDeclaration(IsUsingDeclaration);
+  CC.setCXXScopeSpecifier(SS);
+
   // We want to keep the scope specifier even if it's invalid (e.g. the scope
   // "a::b::" is not corresponding to any context/namespace in the AST), since
   // it can be useful for global code completion which have information about
   // contexts/symbols that are not in the AST.
   if (SS.isInvalid()) {
-CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol, PreferredType);
-CC.setCXXScopeSpecifier(SS);
 // As SS is invalid, we try to collect accessible contexts from the current
 // scope with a dummy lookup so that the completion consumer can try to
 // guess what the specified scope is.
@@ -5371,10 +5374,8 @@
   if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
 return;
 
-  ResultBuilder Results(
-  *this, CodeCompleter->getAllocator(),
-  CodeCompleter->getCodeCompletionTUInfo(),
-  CodeCompletionContext(CodeCompletionContext::CCC_Symbol, PreferredType));
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(), CC);
   if (!PreferredType.isNull())
 Results.setPreferredType(PreferredType);
   Results.EnterNewScope();
@@ -5403,23 +5404,21 @@
CodeCompleter->loadExternal());
   }
 
-  auto CC = Results.getCompletionContext();
-  CC.setCXXScopeSpecifier(SS);
-
-  HandleCodeCompleteResults(this, CodeCompleter, CC, Results.data(),
-Results.size());
+  HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+Results.data(), Results.size());
 }
 
 void Sema::CodeCompleteUsing(Scope *S) {
   if (!CodeCompleter)
 return;
 
+  // This can be both a using alias or using declaration, in the former we
+  // expect a new name and a symbol in the latter case.
+  CodeCompletionContext Context(CodeCompletionContext::CCC_SymbolOrNewName);
+  Context.setIsUsingDeclaration(true);
+
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-CodeCompleter->getCodeCompletionTUInfo(),
-// This can be both a using alias or using
-// declaration, in the former we expect a new name and a
-// symbol in the latter case.
-CodeCompletionContext::CCC_SymbolOrNewName,
+CodeCompleter->getCodeCompletionTUInfo(), Context,
 &ResultBuilder::IsNestedNameSpecifier);
   Results.EnterNewScope();
 
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -143,13 +143,10 @@
 /// \param OnlyNamespace If true, only considers namespaces in lookup.
 ///
 /// \returns true if there was an error parsing a scope specifier
-bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
-ParsedType ObjectType,
-bool EnteringContext,
-bool *MayBePseudoDestructor,
-bool IsTypename,
-IdentifierInfo **LastII,
-bool OnlyNamespace) {
+bool Parser::ParseOptionalCXXScopeSpecifier(
+CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext,
+bool *MayBePseudoDestructor, bool IsTypename, IdentifierInfo **LastII,
+ 

[PATCH] D67787: Add 8548 CPU definition and attributes

2019-10-28 Thread Vitaly Cheptsov via Phabricator via cfe-commits
vit9696 accepted this revision.
vit9696 added a comment.
This revision is now accepted and ready to land.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67787



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


[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

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

Build result: pass - 59695 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937



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


[PATCH] D69431: [clangd] Do not highlight keywords in semantic highlighting

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:233
 
-  bool VisitTypeLoc(TypeLoc TL) {
-if (auto K = kindForType(TL.getTypePtr()))

as we are not visiting this base `TypeLoc` in this patch, will we miss any 
interesting `TypeLoc`s (e.g. FunctionTypeLoc)? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69431



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


[PATCH] D69431: [clangd] Do not highlight keywords in semantic highlighting

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:233
 
-  bool VisitTypeLoc(TypeLoc TL) {
-if (auto K = kindForType(TL.getTypePtr()))

hokein wrote:
> as we are not visiting this base `TypeLoc` in this patch, will we miss any 
> interesting `TypeLoc`s (e.g. FunctionTypeLoc)? 
We didn't do anything interesting with function type locs before this patch as 
well.
This patch aims to produce equivalent results in all cases except the primitive 
types (and spell out those cases explicitly by implementing corresponding 
`Visit*TypeLoc` methods).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69431



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


[PATCH] D69431: [clangd] Do not highlight keywords in semantic highlighting

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:233
 
-  bool VisitTypeLoc(TypeLoc TL) {
-if (auto K = kindForType(TL.getTypePtr()))

ilya-biryukov wrote:
> hokein wrote:
> > as we are not visiting this base `TypeLoc` in this patch, will we miss any 
> > interesting `TypeLoc`s (e.g. FunctionTypeLoc)? 
> We didn't do anything interesting with function type locs before this patch 
> as well.
> This patch aims to produce equivalent results in all cases except the 
> primitive types (and spell out those cases explicitly by implementing 
> corresponding `Visit*TypeLoc` methods).
ah, yes, thanks for the explanation, I was over-concerned. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69431



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


[PATCH] D68877: [AArch64][SVE] Implement masked load intrinsics

2019-10-28 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda720a38b9f2: [AArch64][SVE] Implement masked load 
intrinsics (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D68877?vs=226123&id=226628#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68877

Files:
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-sext.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll

Index: llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll
@@ -0,0 +1,72 @@
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; Masked Loads
+;
+
+define  @masked_zload_nxv2i8(* %src,  %mask) {
+; CHECK-LABEL: masked_zload_nxv2i8:
+; CHECK-NOT: ld1sb
+; CHECK: ld1b { [[IN:z[0-9]+]].d }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv2i8(* %src, i32 1,  %mask,  undef)
+  %ext = zext  %load to 
+  ret  %ext
+}
+
+define  @masked_zload_nxv2i16(* %src,  %mask) {
+; CHECK-LABEL: masked_zload_nxv2i16:
+; CHECK-NOT: ld1sh
+; CHECK: ld1h { [[IN:z[0-9]+]].d }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv2i16(* %src, i32 1,  %mask,  undef)
+  %ext = zext  %load to 
+  ret  %ext
+}
+
+define  @masked_zload_nxv2i32(* %src,  %mask) {
+; CHECK-LABEL: masked_zload_nxv2i32:
+; CHECK-NOT: ld1sw
+; CHECK: ld1w { [[IN:z[0-9]+]].d }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv2i32(* %src, i32 1,  %mask,  undef)
+  %ext = zext  %load to 
+  ret  %ext
+}
+
+define  @masked_zload_nxv4i8(* %src,  %mask) {
+; CHECK-LABEL: masked_zload_nxv4i8:
+; CHECK-NOT: ld1sb
+; CHECK: ld1b { [[IN:z[0-9]+]].s }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv4i8(* %src, i32 1,  %mask,  undef)
+  %ext = zext  %load to 
+  ret  %ext
+}
+
+define  @masked_zload_nxv4i16(* %src,  %mask) {
+; CHECK-LABEL: masked_zload_nxv4i16:
+; CHECK-NOT: ld1sh
+; CHECK: ld1h { [[IN:z[0-9]+]].s }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv4i16(* %src, i32 1,  %mask,  undef)
+  %ext = zext  %load to 
+  ret  %ext
+}
+
+define  @masked_zload_nxv8i8(* %src,  %mask) {
+; CHECK-LABEL: masked_zload_nxv8i8:
+; CHECK-NOT: ld1sb
+; CHECK: ld1b { [[IN:z[0-9]+]].h }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv8i8(* %src, i32 1,  %mask,  undef)
+  %ext = zext  %load to 
+  ret  %ext
+}
+
+declare  @llvm.masked.load.nxv2i8(*, i32, , )
+declare  @llvm.masked.load.nxv2i16(*, i32, , )
+declare  @llvm.masked.load.nxv2i32(*, i32, , )
+declare  @llvm.masked.load.nxv4i8(*, i32, , )
+declare  @llvm.masked.load.nxv4i16(*, i32, , )
+declare  @llvm.masked.load.nxv8i8(*, i32, , )
Index: llvm/test/CodeGen/AArch64/sve-masked-ldst-sext.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-masked-ldst-sext.ll
@@ -0,0 +1,66 @@
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; Masked Loads
+;
+
+define  @masked_sload_nxv2i8( *%a,  %mask) {
+; CHECK-LABEL: masked_sload_nxv2i8:
+; CHECK: ld1sb { [[IN:z[0-9]+]].d }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv2i8( *%a, i32 1,  %mask,  undef)
+  %ext = sext  %load to 
+  ret  %ext
+}
+
+define  @masked_sload_nxv2i16( *%a,  %mask) {
+; CHECK-LABEL: masked_sload_nxv2i16:
+; CHECK: ld1sh { [[IN:z[0-9]+]].d }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv2i16( *%a, i32 1,  %mask,  undef)
+  %ext = sext  %load to 
+  ret  %ext
+}
+
+define  @masked_sload_nxv2i32( *%a,  %mask) {
+; CHECK-LABEL: masked_sload_nxv2i32:
+; CHECK: ld1sw { [[IN:z[0-9]+]].d }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv2i32( *%a, i32 1,  %mask,  undef)
+  %ext = sext  %load to 
+  ret  %ext
+}
+
+define  @masked_sload_nxv4i8( *%a,  %mask) {
+; CHECK-LABEL: masked_sload_nxv4i8:
+; CHECK: ld1sb { [[IN:z[0-9]+]].s }, [[PG:p[0-9]+]]/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv4i8( *%a, i32 1,  %mask,  undef)
+  %ext = sext  %load to 
+  ret  %ext
+}
+
+define  @masked_sload_nxv4i16( *%a,  %mask) {
+; CHEC

Re: r375125 - [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object

2019-10-28 Thread Hans Wennborg via cfe-commits
Since we ran into a couple of errors in Chromium when rolling past
this, would you like to add a note about it in the release notes since
it's possible that others will be affected too?

On Thu, Oct 17, 2019 at 5:24 PM James Y Knight via cfe-commits
 wrote:
>
> Author: jyknight
> Date: Thu Oct 17 08:27:04 2019
> New Revision: 375125
>
> URL: http://llvm.org/viewvc/llvm-project?rev=375125&view=rev
> Log:
> [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object
> pointer types.
>
> For example, in Objective-C mode, the initialization of 'x' in:
> ```
>   @implementation MyType
>   + (void)someClassMethod {
> MyType *x = self;
>   }
>   @end
> ```
> is correctly diagnosed with an incompatible-pointer-types warning, but
> in Objective-C++ mode, it is not diagnosed at all -- even though
> incompatible pointer conversions generally become an error in C++.
>
> This patch fixes that oversight, allowing implicit conversions
> involving Class only to/from unqualified-id, and between qualified and
> unqualified Class, where the protocols are compatible.
>
> Note that this does change some behaviors in Objective-C, as well, as
> shown by the modified tests.
>
> Of particular note is that assignment from from 'Class' to
> 'id' now warns. (Despite appearances, those are not
> compatible types. 'Class' is not expected to have instance
> methods defined by 'MyProtocol', while 'id' is.)
>
> Differential Revision: https://reviews.llvm.org/D67983
>
> Modified:
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/test/SemaObjC/comptypes-1.m
> cfe/trunk/test/SemaObjCXX/class-method-self.mm
> cfe/trunk/test/SemaObjCXX/comptypes-1.mm
> cfe/trunk/test/SemaObjCXX/comptypes-7.mm
> cfe/trunk/test/SemaObjCXX/instancetype.mm
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=375125&r1=375124&r2=375125&view=diff
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct 17 08:27:04 2019
> @@ -8025,14 +8025,15 @@ bool ASTContext::ObjCQualifiedClassTypes
>  bool ASTContext::ObjCQualifiedIdTypesAreCompatible(
>  const ObjCObjectPointerType *lhs, const ObjCObjectPointerType *rhs,
>  bool compare) {
> -  // Allow id and an 'id' or void* type in all cases.
> -  if (lhs->isVoidPointerType() ||
> -  lhs->isObjCIdType() || lhs->isObjCClassType())
> -return true;
> -  else if (rhs->isVoidPointerType() ||
> -   rhs->isObjCIdType() || rhs->isObjCClassType())
> +  // Allow id and an 'id' in all cases.
> +  if (lhs->isObjCIdType() || rhs->isObjCIdType())
>  return true;
>
> +  // Don't allow id to convert to Class or Class in either 
> direction.
> +  if (lhs->isObjCClassType() || lhs->isObjCQualifiedClassType() ||
> +  rhs->isObjCClassType() || rhs->isObjCQualifiedClassType())
> +return false;
> +
>if (lhs->isObjCQualifiedIdType()) {
>  if (rhs->qual_empty()) {
>// If the RHS is a unqualified interface pointer "NSString*",
> @@ -8142,9 +8143,8 @@ bool ASTContext::canAssignObjCInterfaces
>const ObjCObjectType* LHS = LHSOPT->getObjectType();
>const ObjCObjectType* RHS = RHSOPT->getObjectType();
>
> -  // If either type represents the built-in 'id' or 'Class' types, return 
> true.
> -  if (LHS->isObjCUnqualifiedIdOrClass() ||
> -  RHS->isObjCUnqualifiedIdOrClass())
> +  // If either type represents the built-in 'id' type, return true.
> +  if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
>  return true;
>
>// Function object that propagates a successful result or handles
> @@ -8162,14 +8162,22 @@ bool ASTContext::canAssignObjCInterfaces
> 
> LHSOPT->stripObjCKindOfTypeAndQuals(*this));
>};
>
> +  // Casts from or to id are allowed when the other side has compatible
> +  // protocols.
>if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
>  return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false));
>}
>
> +  // Verify protocol compatibility for casts from Class to Class.
>if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
>  return finish(ObjCQualifiedClassTypesAreCompatible(LHSOPT, RHSOPT));
>}
>
> +  // Casts from Class to Class, or vice-versa, are allowed.
> +  if (LHS->isObjCClass() && RHS->isObjCClass()) {
> +return true;
> +  }
> +
>// If we have 2 user-defined types, fall into that path.
>if (LHS->getInterface() && RHS->getInterface()) {
>  return finish(canAssignObjCInterfaces(LHS, RHS));
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=375125&r1=375124&r2=375125&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +

[clang] 5d35b7d - [ARM][AArch64] Implement __arm_rsrf, __arm_rsrf64, __arm_wsrf & __arm_wsrf64

2019-10-28 Thread via cfe-commits

Author: vhscampos
Date: 2019-10-28T10:59:18Z
New Revision: 5d35b7d9e1a34b45c19609f754050e4263bee4ce

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

LOG: [ARM][AArch64] Implement __arm_rsrf, __arm_rsrf64, __arm_wsrf & 
__arm_wsrf64

Summary:
Adding support for ACLE intrinsics.

Patch by Michael Platings.

Reviewers: chill, t.p.northover, efriedma

Reviewed By: chill

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm_acle.c

Removed: 




diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index 0510e6fd809f..942172f9f8ed 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -609,9 +609,13 @@ __jcvt(double __a) {
 #define __arm_rsr(sysreg) __builtin_arm_rsr(sysreg)
 #define __arm_rsr64(sysreg) __builtin_arm_rsr64(sysreg)
 #define __arm_rsrp(sysreg) __builtin_arm_rsrp(sysreg)
+#define __arm_rsrf(sysreg) __builtin_bit_cast(float, __arm_rsr(sysreg))
+#define __arm_rsrf64(sysreg) __builtin_bit_cast(double, __arm_rsr64(sysreg))
 #define __arm_wsr(sysreg, v) __builtin_arm_wsr(sysreg, v)
 #define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v)
 #define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v)
+#define __arm_wsrf(sysreg, v) __arm_wsr(sysreg, __builtin_bit_cast(uint32_t, 
v))
+#define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, 
__builtin_bit_cast(uint64_t, v))
 
 /* Memory Tagging Extensions (MTE) Intrinsics */
 #if __ARM_FEATURE_MEMORY_TAGGING

diff  --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c
index ce2c5fac70b2..7463d0d8e1d5 100644
--- a/clang/test/CodeGen/arm_acle.c
+++ b/clang/test/CodeGen/arm_acle.c
@@ -822,6 +822,55 @@ void test_wsrp(void *v) {
   __arm_wsrp("sysreg", v);
 }
 
+// ARM-LABEL: test_rsrf
+// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
+// AArch32: call i32 @llvm.read_register.i32(metadata ![[M2:[0-9]]])
+// ARM-NOT: uitofp
+// ARM: bitcast
+float test_rsrf() {
+#ifdef __ARM_32BIT_STATE
+  return __arm_rsrf("cp1:2:c3:c4:5");
+#else
+  return __arm_rsrf("1:2:3:4:5");
+#endif
+}
+// ARM-LABEL: test_rsrf64
+// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
+// AArch32: call i64 @llvm.read_register.i64(metadata ![[M3:[0-9]]])
+// ARM-NOT: uitofp
+// ARM: bitcast
+double test_rsrf64() {
+#ifdef __ARM_32BIT_STATE
+  return __arm_rsrf64("cp1:2:c3");
+#else
+  return __arm_rsrf64("1:2:3:4:5");
+#endif
+}
+// ARM-LABEL: test_wsrf
+// ARM-NOT: fptoui
+// ARM: bitcast
+// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 
%{{.*}})
+// AArch32: call void @llvm.write_register.i32(metadata ![[M2:[0-9]]], i32 
%{{.*}})
+void test_wsrf(float v) {
+#ifdef __ARM_32BIT_STATE
+  __arm_wsrf("cp1:2:c3:c4:5", v);
+#else
+  __arm_wsrf("1:2:3:4:5", v);
+#endif
+}
+// ARM-LABEL: test_wsrf64
+// ARM-NOT: fptoui
+// ARM: bitcast
+// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 
%{{.*}})
+// AArch32: call void @llvm.write_register.i64(metadata ![[M3:[0-9]]], i64 
%{{.*}})
+void test_wsrf64(double v) {
+#ifdef __ARM_32BIT_STATE
+  __arm_wsrf64("cp1:2:c3", v);
+#else
+  __arm_wsrf64("1:2:3:4:5", v);
+#endif
+}
+
 // AArch32: ![[M2]] = !{!"cp1:2:c3:c4:5"}
 // AArch32: ![[M3]] = !{!"cp1:2:c3"}
 // AArch32: ![[M4]] = !{!"sysreg"}



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


[PATCH] D69297: [ARM][AArch64] Implement __arm_rsrf, __arm_rsrf64, __arm_wsrf & __arm_wsrf64

2019-10-28 Thread Victor Campos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5d35b7d9e1a3: [ARM][AArch64] Implement __arm_rsrf, 
__arm_rsrf64, __arm_wsrf & __arm_wsrf64 (authored by vhscampos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69297

Files:
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c


Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -822,6 +822,55 @@
   __arm_wsrp("sysreg", v);
 }
 
+// ARM-LABEL: test_rsrf
+// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
+// AArch32: call i32 @llvm.read_register.i32(metadata ![[M2:[0-9]]])
+// ARM-NOT: uitofp
+// ARM: bitcast
+float test_rsrf() {
+#ifdef __ARM_32BIT_STATE
+  return __arm_rsrf("cp1:2:c3:c4:5");
+#else
+  return __arm_rsrf("1:2:3:4:5");
+#endif
+}
+// ARM-LABEL: test_rsrf64
+// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
+// AArch32: call i64 @llvm.read_register.i64(metadata ![[M3:[0-9]]])
+// ARM-NOT: uitofp
+// ARM: bitcast
+double test_rsrf64() {
+#ifdef __ARM_32BIT_STATE
+  return __arm_rsrf64("cp1:2:c3");
+#else
+  return __arm_rsrf64("1:2:3:4:5");
+#endif
+}
+// ARM-LABEL: test_wsrf
+// ARM-NOT: fptoui
+// ARM: bitcast
+// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 
%{{.*}})
+// AArch32: call void @llvm.write_register.i32(metadata ![[M2:[0-9]]], i32 
%{{.*}})
+void test_wsrf(float v) {
+#ifdef __ARM_32BIT_STATE
+  __arm_wsrf("cp1:2:c3:c4:5", v);
+#else
+  __arm_wsrf("1:2:3:4:5", v);
+#endif
+}
+// ARM-LABEL: test_wsrf64
+// ARM-NOT: fptoui
+// ARM: bitcast
+// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 
%{{.*}})
+// AArch32: call void @llvm.write_register.i64(metadata ![[M3:[0-9]]], i64 
%{{.*}})
+void test_wsrf64(double v) {
+#ifdef __ARM_32BIT_STATE
+  __arm_wsrf64("cp1:2:c3", v);
+#else
+  __arm_wsrf64("1:2:3:4:5", v);
+#endif
+}
+
 // AArch32: ![[M2]] = !{!"cp1:2:c3:c4:5"}
 // AArch32: ![[M3]] = !{!"cp1:2:c3"}
 // AArch32: ![[M4]] = !{!"sysreg"}
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -609,9 +609,13 @@
 #define __arm_rsr(sysreg) __builtin_arm_rsr(sysreg)
 #define __arm_rsr64(sysreg) __builtin_arm_rsr64(sysreg)
 #define __arm_rsrp(sysreg) __builtin_arm_rsrp(sysreg)
+#define __arm_rsrf(sysreg) __builtin_bit_cast(float, __arm_rsr(sysreg))
+#define __arm_rsrf64(sysreg) __builtin_bit_cast(double, __arm_rsr64(sysreg))
 #define __arm_wsr(sysreg, v) __builtin_arm_wsr(sysreg, v)
 #define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v)
 #define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v)
+#define __arm_wsrf(sysreg, v) __arm_wsr(sysreg, __builtin_bit_cast(uint32_t, 
v))
+#define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, 
__builtin_bit_cast(uint64_t, v))
 
 /* Memory Tagging Extensions (MTE) Intrinsics */
 #if __ARM_FEATURE_MEMORY_TAGGING


Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -822,6 +822,55 @@
   __arm_wsrp("sysreg", v);
 }
 
+// ARM-LABEL: test_rsrf
+// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
+// AArch32: call i32 @llvm.read_register.i32(metadata ![[M2:[0-9]]])
+// ARM-NOT: uitofp
+// ARM: bitcast
+float test_rsrf() {
+#ifdef __ARM_32BIT_STATE
+  return __arm_rsrf("cp1:2:c3:c4:5");
+#else
+  return __arm_rsrf("1:2:3:4:5");
+#endif
+}
+// ARM-LABEL: test_rsrf64
+// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
+// AArch32: call i64 @llvm.read_register.i64(metadata ![[M3:[0-9]]])
+// ARM-NOT: uitofp
+// ARM: bitcast
+double test_rsrf64() {
+#ifdef __ARM_32BIT_STATE
+  return __arm_rsrf64("cp1:2:c3");
+#else
+  return __arm_rsrf64("1:2:3:4:5");
+#endif
+}
+// ARM-LABEL: test_wsrf
+// ARM-NOT: fptoui
+// ARM: bitcast
+// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %{{.*}})
+// AArch32: call void @llvm.write_register.i32(metadata ![[M2:[0-9]]], i32 %{{.*}})
+void test_wsrf(float v) {
+#ifdef __ARM_32BIT_STATE
+  __arm_wsrf("cp1:2:c3:c4:5", v);
+#else
+  __arm_wsrf("1:2:3:4:5", v);
+#endif
+}
+// ARM-LABEL: test_wsrf64
+// ARM-NOT: fptoui
+// ARM: bitcast
+// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %{{.*}})
+// AArch32: call void @llvm.write_register.i64(metadata ![[M3:[0-9]]], i64 %{{.*}})
+void test_wsrf64(double v) {
+#ifdef __ARM_32BIT_STATE
+  __arm_wsrf64("cp1:2:c3", v);
+#else
+  __arm_wsrf64("1:2:3:4:5", v);
+#endif
+}
+
 // AArch32: ![[M2]] = !{!"cp1:2:c3:c4:5"}
 // AArch32: ![[M3]] = !{!"cp1:2:c3"}
 // AArch32: ![[M4]] = !{!"sysreg"}
Index: clang/lib/Headers/arm_acle.h
==

[PATCH] D69431: [clangd] Do not highlight keywords in semantic highlighting

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69431



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


[clang-tools-extra] c814f4c - [clangd] Do not highlight keywords in semantic highlighting

2019-10-28 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-10-28T12:03:09+01:00
New Revision: c814f4c4592cf0a6049a56b09442369d8e6eb9d7

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

LOG: [clangd] Do not highlight keywords in semantic highlighting

Summary:
Editors are good at highlightings the keywords themselves.
Note that this only affects highlightings of builtin types spelled out
as keywords in the source code. Highlightings of typedefs to builtin
types are unchanged.

Reviewers: hokein

Reviewed By: hokein

Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/test/semantic-highlighting.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 61074852e369..464cbc4fcf85 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -49,7 +49,7 @@ llvm::Optional kindForDecl(const NamedDecl 
*D) {
 return HighlightingKind::Typedef;
   }
   // We highlight class decls, constructor decls and destructor decls as
-  // `Class` type. The destructor decls are handled in `VisitTypeLoc` (we
+  // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
   // will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
   if (auto *RD = llvm::dyn_cast(D)) {
 // We don't want to highlight lambdas like classes.
@@ -214,25 +214,27 @@ class HighlightingTokenCollector
 return true;
   }
 
-  bool WalkUpFromTagTypeLoc(TagTypeLoc L) {
+  bool VisitTagTypeLoc(TagTypeLoc L) {
 if (L.isDefinition())
   return true; // Definition will be highligthed by VisitNamedDecl.
-return RecursiveASTVisitor::WalkUpFromTagTypeLoc(L);
+if (auto K = kindForType(L.getTypePtr()))
+  addToken(L.getBeginLoc(), *K);
+return true;
   }
 
-  bool WalkUpFromElaboratedTypeLoc(ElaboratedTypeLoc L) {
-// Avoid highlighting 'struct' or 'enum' keywords.
+  bool VisitDecltypeTypeLoc(DecltypeTypeLoc L) {
+if (auto K = kindForType(L.getTypePtr()))
+  addToken(L.getBeginLoc(), *K);
 return true;
   }
 
-  bool WalkUpFromDependentNameTypeLoc(DependentNameTypeLoc L) {
+  bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
 addToken(L.getNameLoc(), HighlightingKind::DependentType);
 return true;
   }
 
-  bool VisitTypeLoc(TypeLoc TL) {
-if (auto K = kindForType(TL.getTypePtr()))
-  addToken(TL.getBeginLoc(), *K);
+  bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
+addToken(TL.getBeginLoc(), HighlightingKind::TemplateParameter);
 return true;
   }
 

diff  --git a/clang-tools-extra/clangd/test/semantic-highlighting.test 
b/clang-tools-extra/clangd/test/semantic-highlighting.test
index 38cb186946fa..7d9b381e2842 100644
--- a/clang-tools-extra/clangd/test/semantic-highlighting.test
+++ b/clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -67,7 +67,7 @@
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"line": 0,
-# CHECK-NEXT:"tokens": "AAADABAEAAEAAA=="
+# CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
 # CHECK-NEXT:],
 # CHECK-NEXT:"textDocument": {
@@ -82,11 +82,11 @@
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"line": 0,
-# CHECK-NEXT:"tokens": "AAADABAEAAEAAA=="
+# CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
 # CHECK-NEXT:  {
 # CHECK-NEXT:"line": 1,
-# CHECK-NEXT:"tokens": "AAADABAEAAEAAA=="
+# CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
 # CHECK-NEXT:],
 # CHECK-NEXT:"textDocument": {
@@ -101,7 +101,7 @@
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"line": 1,
-# CHECK-NEXT:"tokens": "AAADABAEAAEAAA=="
+# CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
 # CHECK-NEXT:   ],
 # CHECK-NEXT:"textDocument": {

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index a20fea32d81c..9d33b523f69b 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -153,26 +153,26 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
   R"cpp(
   struct $Class[[AS]] {
-$Primitive[[double]] $Fie

[PATCH] D69431: [clangd] Do not highlight keywords in semantic highlighting

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc814f4c4592c: [clangd] Do not highlight keywords in semantic 
highlighting (authored by ilya-biryukov).

Changed prior to commit:
  https://reviews.llvm.org/D69431?vs=226419&id=226632#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69431

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -442,20 +442,15 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("/* storage.type.primitive.cpp */void "
-"/* entity.name.function.cpp */f() {}",
-apply("void ^f() {}"));
+  EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
 
   EXPECT_EQ(apply("[[void f1(); void f2();]]"),
-"/* storage.type.primitive.cpp */void "
-"/* entity.name.function.cpp */f1(); "
-"/* storage.type.primitive.cpp */void "
-"/* entity.name.function.cpp */f2();");
+"void /* entity.name.function.cpp */f1(); "
+"void /* entity.name.function.cpp */f2();");
 
   EXPECT_EQ(apply("void f1(); void f2() {^}"),
 "void f1(); "
-"/* storage.type.primitive.cpp */void "
-"/* entity.name.function.cpp */f2() {}");
+"void /* entity.name.function.cpp */f2() {}");
 }
 
 TWEAK_TEST(ExpandMacro);
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -153,26 +153,26 @@
   const char *TestCases[] = {
   R"cpp(
   struct $Class[[AS]] {
-$Primitive[[double]] $Field[[SomeMember]];
+double $Field[[SomeMember]];
   };
   struct {
   } $Variable[[S]];
-  $Primitive[[void]] $Function[[foo]]($Primitive[[int]] $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
+  void $Function[[foo]](int $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
 $Primitive[[auto]] $LocalVariable[[VeryLongVariableName]] = 12312;
 $Class[[AS]] $LocalVariable[[AA]];
 $Primitive[[auto]] $LocalVariable[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
-auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]]($Primitive[[int]] $Parameter[[A]]) -> $Primitive[[void]] {};
+auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]](int $Parameter[[A]]) -> void {};
 $LocalVariable[[FN]](12312);
   }
 )cpp",
   R"cpp(
-  $Primitive[[void]] $Function[[foo]]($Primitive[[int]]);
-  $Primitive[[void]] $Function[[Gah]]();
-  $Primitive[[void]] $Function[[foo]]() {
+  void $Function[[foo]](int);
+  void $Function[[Gah]]();
+  void $Function[[foo]]() {
 auto $LocalVariable[[Bou]] = $Function[[Gah]];
   }
   struct $Class[[A]] {
-$Primitive[[void]] $Method[[abc]]();
+void $Method[[abc]]();
   };
 )cpp",
   R"cpp(
@@ -186,17 +186,17 @@
   struct $Class[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
 typename $TemplateParameter[[T]]::$DependentType[[A]]* $Field[[D]];
   };
-  $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Variable[[AA]];
-  typedef $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Class[[AAA]];
+  $Namespace[[abc]]::$Class[[A]] $Variable[[AA]];
+  typedef $Namespace[[abc]]::$Class[[A]] $Class[[AAA]];
   struct $Class[[B]] {
 $Class[[B]]();
 ~$Class[[B]]();
-$Primitive[[void]] operator<<($Class[[B]]);
+void operator<<($Class[[B]]);
 $Class[[AAA]] $Field[[AA]];
   };
   $Class[[B]]::$Class[[B]]() {}
   $Class[[B]]::~$Class[[B]]() {}
-  $Primitive[[void]] $Function[[f]] () {
+  void $Function[[f]] () {
 $Class[[B]] $LocalVariable[[BB]] = $Class[[B]]();
 $LocalVariable[[BB]].~$Class[[B]]();
 $Class[[B]]();
@@ -214,7 +214,7 @@
 $Enum[[E]] $Field[[EEE]];
 $Enum[[EE]] $Field[[]];
   };
-  $Primitive[[int]] $Variable[[I]] = $EnumConstant[[Hi]];
+  int $Variable[[I]] = $EnumConstant[[Hi]];
   $Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumConstant[[B]];
 )cpp",
   R"cpp(
@@ -242,14 +242,14 @@
 )cpp",
   R"cpp(
   struct $Class[[D]] {
-$Pri

[clang-tools-extra] 3cb5764 - [clangd] Flush streams when printing HoverInfo Name and Definition

2019-10-28 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-10-28T12:05:03+01:00
New Revision: 3cb5764f900284666dbb0342c487edb1fde4d7fc

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

LOG: [clangd] Flush streams when printing HoverInfo Name and Definition

Summary: Fixes some windows breakages when compiled via msvc.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 2e75e8c80054..3ee04f031795 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -500,6 +500,7 @@ static std::string printDefinition(const Decl *D) {
   printingPolicyForDecls(D->getASTContext().getPrintingPolicy());
   Policy.IncludeTagDefinition = false;
   D->print(OS, Policy);
+  OS.flush();
   return Definition;
 }
 
@@ -714,6 +715,7 @@ static HoverInfo getHoverContents(QualType T, const Decl 
*D, ASTContext &ASTCtx,
   llvm::raw_string_ostream OS(HI.Name);
   PrintingPolicy Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy());
   T.print(OS, Policy);
+  OS.flush();
 
   if (D) {
 HI.Kind = indexSymbolKindToSymbolKind(index::getSymbolInfo(D).Kind);



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


[clang] f6e11a3 - [ARM][AArch64] Implement __cls, __clsl and __clsll intrinsics from ACLE

2019-10-28 Thread via cfe-commits

Author: vhscampos
Date: 2019-10-28T11:06:58Z
New Revision: f6e11a36c49c065cd71e9c54e4fba917da5bbf2e

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

LOG: [ARM][AArch64] Implement __cls,  __clsl and __clsll intrinsics from ACLE

Summary:
Writing support for three ACLE functions:
  unsigned int __cls(uint32_t x)
  unsigned int __clsl(unsigned long x)
  unsigned int __clsll(uint64_t x)

CLS stands for "Count number of leading sign bits".

In AArch64, these two intrinsics can be translated into the 'cls'
instruction directly. In AArch32, on the other hand, this functionality
is achieved by implementing it in terms of clz (count number of leading
zeros).

Reviewers: compnerd

Reviewed By: compnerd

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
llvm/test/CodeGen/AArch64/cls.ll
llvm/test/CodeGen/ARM/cls.ll

Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/include/clang/Basic/BuiltinsARM.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm_acle.c
clang/test/CodeGen/builtins-arm.c
clang/test/CodeGen/builtins-arm64.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/ARM/ARMISelLowering.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 4df8d5a16762..f07c567053de 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -33,6 +33,8 @@ BUILTIN(__builtin_arm_clrex, "v", "")
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
 BUILTIN(__builtin_arm_rbit64, "WUiWUi", "nc")
+BUILTIN(__builtin_arm_cls, "UiZUi", "nc")
+BUILTIN(__builtin_arm_cls64, "UiWUi", "nc")
 
 // HINT
 BUILTIN(__builtin_arm_nop, "v", "")

diff  --git a/clang/include/clang/Basic/BuiltinsARM.def 
b/clang/include/clang/Basic/BuiltinsARM.def
index 5f8308d29318..81991a57e2bd 100644
--- a/clang/include/clang/Basic/BuiltinsARM.def
+++ b/clang/include/clang/Basic/BuiltinsARM.def
@@ -115,6 +115,8 @@ BUILTIN(__builtin_arm_smusdx, "iii", "nc")
 
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
+BUILTIN(__builtin_arm_cls, "UiZUi", "nc")
+BUILTIN(__builtin_arm_cls64, "UiWUi", "nc")
 
 // Store and load exclusive
 BUILTIN(__builtin_arm_ldrexd, "LLUiv*", "")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9a56116173ec..648837a6d151 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6055,6 +6055,16 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
 CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
   }
 
+  if (BuiltinID == ARM::BI__builtin_arm_cls) {
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::arm_cls), Arg, 
"cls");
+  }
+  if (BuiltinID == ARM::BI__builtin_arm_cls64) {
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::arm_cls64), Arg,
+  "cls");
+  }
+
   if (BuiltinID == ARM::BI__clear_cache) {
 assert(E->getNumArgs() == 2 && "__clear_cache takes 2 arguments");
 const FunctionDecl *FD = E->getDirectCallee();
@@ -7108,6 +7118,17 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
 CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
   }
 
+  if (BuiltinID == AArch64::BI__builtin_arm_cls) {
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_cls), Arg,
+  "cls");
+  }
+  if (BuiltinID == AArch64::BI__builtin_arm_cls64) {
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_cls64), Arg,
+  "cls");
+  }
+
   if (BuiltinID == AArch64::BI__builtin_arm_jcvt) {
 assert((getContext().getTypeSize(E->getType()) == 32) &&
"__jcvt of unusual size!");

diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index 942172f9f8ed..137092fb9d76 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -139,6 +139,26 @@ __clzll(uint64_t __t) {
   return __builtin_clzll(__t);
 }
 
+/* CLS */
+static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+__cls(uint32_t __t) {
+  return __builtin_arm_cls(__t);
+}
+
+static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+__clsl(unsigned long __t) {
+#if __

[PATCH] D69250: [ARM][AArch64] Implement __cls, __clsl and __clsll intrinsics from ACLE

2019-10-28 Thread Victor Campos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6e11a36c49c: [ARM][AArch64] Implement __cls,  __clsl and 
__clsll intrinsics from ACLE (authored by vhscampos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69250

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/include/clang/Basic/BuiltinsARM.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-arm64.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/AArch64/cls.ll
  llvm/test/CodeGen/ARM/cls.ll

Index: llvm/test/CodeGen/ARM/cls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/cls.ll
@@ -0,0 +1,27 @@
+; RUN: llc -mtriple=armv5 %s -o - | FileCheck %s
+
+; CHECK:  eor [[T:r[0-9]+]], [[T]], [[T]], asr #31
+; CHECK-NEXT: mov [[C1:r[0-9]+]], #1
+; CHECK-NEXT: orr [[T]], [[C1]], [[T]], lsl #1
+; CHECK-NEXT: clz [[T]], [[T]]
+define i32 @cls(i32 %t) {
+  %cls.i = call i32 @llvm.arm.cls(i32 %t)
+  ret i32 %cls.i
+}
+
+; CHECK: cmp r1, #0
+; CHECK: mvnne [[ADJUSTEDLO:r[0-9]+]], r0
+; CHECK: clz [[CLZLO:r[0-9]+]], [[ADJUSTEDLO]]
+; CHECK: eor [[A:r[0-9]+]], r1, r1, asr #31
+; CHECK: mov r1, #1
+; CHECK: orr [[A]], r1, [[A]], lsl #1
+; CHECK: clz [[CLSHI:r[0-9]+]], [[A]]
+; CHECK: cmp [[CLSHI]], #31
+; CHECK: addeq r0, [[CLZLO]], #31
+define i32 @cls64(i64 %t) {
+  %cls.i = call i32 @llvm.arm.cls64(i64 %t)
+  ret i32 %cls.i
+}
+
+declare i32 @llvm.arm.cls(i32) nounwind
+declare i32 @llvm.arm.cls64(i64) nounwind
Index: llvm/test/CodeGen/AArch64/cls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/cls.ll
@@ -0,0 +1,20 @@
+; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
+
+; @llvm.aarch64.cls must be directly translated into the 'cls' instruction
+
+; CHECK-LABEL: cls
+; CHECK: cls [[REG:w[0-9]+]], [[REG]]
+define i32 @cls(i32 %t) {
+  %cls.i = call i32 @llvm.aarch64.cls(i32 %t)
+  ret i32 %cls.i
+}
+
+; CHECK-LABEL: cls64
+; CHECK: cls [[REG:x[0-9]+]], [[REG]]
+define i32 @cls64(i64 %t) {
+  %cls.i = call i32 @llvm.aarch64.cls64(i64 %t)
+  ret i32 %cls.i
+}
+
+declare i32 @llvm.aarch64.cls(i32) nounwind
+declare i32 @llvm.aarch64.cls64(i64) nounwind
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -3629,6 +3629,49 @@
 EVT PtrVT = getPointerTy(DAG.getDataLayout());
 return DAG.getNode(ARMISD::THREAD_POINTER, dl, PtrVT);
   }
+  case Intrinsic::arm_cls: {
+const SDValue &Operand = Op.getOperand(1);
+const EVT VTy = Op.getValueType();
+SDValue SRA =
+DAG.getNode(ISD::SRA, dl, VTy, Operand, DAG.getConstant(31, dl, VTy));
+SDValue XOR = DAG.getNode(ISD::XOR, dl, VTy, SRA, Operand);
+SDValue SHL =
+DAG.getNode(ISD::SHL, dl, VTy, XOR, DAG.getConstant(1, dl, VTy));
+SDValue OR =
+DAG.getNode(ISD::OR, dl, VTy, SHL, DAG.getConstant(1, dl, VTy));
+SDValue Result = DAG.getNode(ISD::CTLZ, dl, VTy, OR);
+return Result;
+  }
+  case Intrinsic::arm_cls64: {
+// cls(x) = if cls(hi(x)) != 31 then cls(hi(x))
+//  else 31 + clz(if hi(x) == 0 then lo(x) else not(lo(x)))
+const SDValue &Operand = Op.getOperand(1);
+const EVT VTy = Op.getValueType();
+
+SDValue Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, VTy, Operand,
+ DAG.getConstant(1, dl, VTy));
+SDValue Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, VTy, Operand,
+ DAG.getConstant(0, dl, VTy));
+SDValue Constant0 = DAG.getConstant(0, dl, VTy);
+SDValue Constant1 = DAG.getConstant(1, dl, VTy);
+SDValue Constant31 = DAG.getConstant(31, dl, VTy);
+SDValue SRAHi = DAG.getNode(ISD::SRA, dl, VTy, Hi, Constant31);
+SDValue XORHi = DAG.getNode(ISD::XOR, dl, VTy, SRAHi, Hi);
+SDValue SHLHi = DAG.getNode(ISD::SHL, dl, VTy, XORHi, Constant1);
+SDValue ORHi = DAG.getNode(ISD::OR, dl, VTy, SHLHi, Constant1);
+SDValue CLSHi = DAG.getNode(ISD::CTLZ, dl, VTy, ORHi);
+SDValue CheckLo =
+DAG.getSetCC(dl, MVT::i1, CLSHi, Constant31, ISD::CondCode::SETEQ);
+SDValue HiIsZero =
+DAG.getSetCC(dl, MVT::i1, Hi, Constant0, ISD::CondCode::SETEQ);
+SDValue AdjustedLo =
+DAG.getSelect(dl, VTy, HiIsZero, Lo, DAG.getNOT(dl, Lo, VTy));
+SDValue CLZAdjustedLo = DAG.getNode(ISD::CTLZ, dl, VTy, AdjustedLo);
+SDValue Result =
+DAG.getSelect(dl, VTy, CheckLo,
+  DAG.getNode(ISD::ADD, dl, VTy, CLZAdjustedLo, Constant31), CLSHi);
+return Resul

[PATCH] D69378: [AArch64][SVE] Implement masked store intrinsics

2019-10-28 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 226640.
kmclaughlin added a reviewer: sdesmalen.
kmclaughlin added a comment.

- Split functions in sve-masked-ldst-nonext.ll into separate load & store tests


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

https://reviews.llvm.org/D69378

Files:
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-trunc.ll

Index: llvm/test/CodeGen/AArch64/sve-masked-ldst-trunc.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-masked-ldst-trunc.ll
@@ -0,0 +1,76 @@
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; Masked Stores
+;
+
+define void @masked_trunc_store_nxv2i8( *%a,  *%b,  %mask) {
+; CHECK-LABEL: masked_trunc_store_nxv2i8:
+; CHECK: ld1d { [[IN:z[0-9]]].d }, [[PG:p[0-9]]]/z, [x0]
+; CHECK: st1b { [[IN]].d }, [[PG]], [x1]
+  %load = call  @llvm.masked.load.nxv2i64( *%a, i32 8,  %mask,  undef)
+  %trunc = trunc  %load to 
+  call void @llvm.masked.store.nxv2i8( %trunc,  *%b, i32 8,  %mask)
+  ret void
+}
+
+define void @masked_trunc_store_nxv2i16( *%a,  *%b,  %mask) {
+; CHECK-LABEL: masked_trunc_store_nxv2i16:
+; CHECK: ld1d { [[IN:z[0-9]]].d }, [[PG:p[0-9]]]/z, [x0]
+; CHECK: st1h { [[IN]].d }, [[PG]], [x1]
+  %load = call  @llvm.masked.load.nxv2i64( *%a, i32 8,  %mask,  undef)
+  %trunc = trunc  %load to 
+  call void @llvm.masked.store.nxv2i16( %trunc,  *%b, i32 8,  %mask)
+  ret void
+}
+
+define void @masked_trunc_store_nxv2i32( *%a,  *%b,  %mask) {
+; CHECK-LABEL: masked_trunc_store_nxv2i32:
+; CHECK: ld1d { [[IN:z[0-9]]].d }, [[PG:p[0-9]]]/z, [x0]
+; CHECK: st1w { [[IN]].d }, [[PG]], [x1]
+  %load = call  @llvm.masked.load.nxv2i64( *%a, i32 8,  %mask,  undef)
+  %trunc = trunc  %load to 
+  call void @llvm.masked.store.nxv2i32( %trunc,  *%b, i32 8,  %mask)
+  ret void
+}
+
+define void @masked_trunc_store_nxv4i8( *%a,  *%b,  %mask) {
+; CHECK-LABEL: masked_trunc_store_nxv4i8:
+; CHECK: ld1w { [[IN:z[0-9]]].s }, [[PG:p[0-9]]]/z, [x0]
+; CHECK: st1b { [[IN]].s }, [[PG]], [x1]
+  %load = call  @llvm.masked.load.nxv4i32( *%a, i32 4,  %mask,  undef)
+  %trunc = trunc  %load to 
+  call void @llvm.masked.store.nxv4i8( %trunc,  *%b, i32 4,  %mask)
+  ret void
+}
+
+define void @masked_trunc_store_nxv4i16( *%a,  *%b,  %mask) {
+; CHECK-LABEL: masked_trunc_store_nxv4i16:
+; CHECK: ld1w { [[IN:z[0-9]]].s }, [[PG:p[0-9]]]/z, [x0]
+; CHECK: st1h { [[IN]].s }, [[PG]], [x1]
+  %load = call  @llvm.masked.load.nxv4i32( *%a, i32 4,  %mask,  undef)
+  %trunc = trunc  %load to 
+  call void @llvm.masked.store.nxv4i16( %trunc,  *%b, i32 4,  %mask)
+  ret void
+}
+
+define void @masked_trunc_store_nxv8i8( *%a,  *%b,  %mask) {
+; CHECK-LABEL: masked_trunc_store_nxv8i8:
+; CHECK: ld1h { [[IN:z[0-9]]].h }, [[PG:p[0-9]]]/z, [x0]
+; CHECK: st1b { [[IN]].h }, [[PG]], [x1]
+  %load = call  @llvm.masked.load.nxv8i16( *%a, i32 2,  %mask,  undef)
+  %trunc = trunc  %load to 
+  call void @llvm.masked.store.nxv8i8( %trunc,  *%b, i32 2,  %mask)
+  ret void
+}
+
+declare  @llvm.masked.load.nxv2i64(*, i32, , )
+declare  @llvm.masked.load.nxv4i32(*, i32, , )
+declare  @llvm.masked.load.nxv8i16(*, i32, , )
+
+declare void @llvm.masked.store.nxv2i8(, *, i32, )
+declare void @llvm.masked.store.nxv2i16(, *, i32, )
+declare void @llvm.masked.store.nxv2i32(, *, i32, )
+declare void @llvm.masked.store.nxv4i8(, *, i32, )
+declare void @llvm.masked.store.nxv4i16(, *, i32, )
+declare void @llvm.masked.store.nxv8i8(, *, i32, )
Index: llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
===
--- llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
+++ llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
@@ -74,6 +74,80 @@
   ret  %load
 }
 
+;
+; Masked Stores
+;
+
+define void @masked_store_nxv2i64( *%a,  %val,  %mask) {
+; CHECK-LABEL: masked_store_nxv2i64:
+; CHECK: st1d { [[IN]].d }, [[PG]], [x0]
+  call void @llvm.masked.store.nxv2i64( %val,  *%a, i32 8,  %mask)
+  ret void
+}
+
+define void @masked_store_nxv4i32( *%a,  %val,  %mask) {
+; CHECK-LABEL: masked_store_nxv4i32:
+; CHECK: st1w { [[IN]].s }, [[PG]], [x0]
+  call void @llvm.masked.store.nxv4i32( %val,  *%a, i32 4,  %mask)
+  ret void
+}
+
+define void @masked_store_nxv8i16( *%a,  %val,  %mask) {
+; CHECK-LABEL: masked_store_nxv8i16:
+; CHECK: st1h { [[IN]].h }, [[PG]], [x0]
+  call void @llvm.masked.store.nxv8i16( %val,  *%a, i32 2,  %mask)
+  ret void
+}
+
+define void @masked_store_nxv16i8( *%a,  %val,  %mask) {
+; CHECK-LABEL: masked_store_nxv16i8:
+; CHECK: st1b { [[IN]].b }, [[PG]], [x0]
+  call void @llvm.masked.store.nxv16i8( %val,  *%a, i32 1,  %mask)
+  ret void
+}
+
+define void @masked_store_nxv2f64( *%a,  %val,  %mask) {
+; CHECK-LABEL: masked_store_nxv2f64:
+; CHECK:

[PATCH] D69263: [clangd] Implement cross-file rename.

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:269
+cat(Features),
+desc("Enable cross-file rename feature."),
+init(false),

ilya-biryukov wrote:
> Could you document that the feature is highly experimental and may lead to 
> broken code or incomplete renames for the time being?
> 
> Also, maybe make it hidden for now? 
> At least until we have basic validation of ranges from the index. In the 
> current state we can easily produce edits to unrelated parts of the file...
Done.  yes, we should make it hidden.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:277
+  //   - file on VFS for bar.cc;
+  Annotations MainCode("class  [[Fo^o]] {};");
+  auto MainFilePath = testPath("main.cc");

ilya-biryukov wrote:
> Thinking whether we can encode these transformations in a nicer way?
> If we could convert the contents dirty buffer and replacements to something 
> like:
> ```
> class [[Foo |-> newName]] {};
> ```
> Just a proposal, maybe there's a better syntax here.
> 
> We can easily match strings instead of matching ranges in the tests. This has 
> the advantage of having textual diffs in case something goes wrong - much 
> more pleasant than looking at the offsets in the ranges.
> 
> WDYT?
I agree textual diff would give a more friendly results when there are failures 
in the tests.

I don't have a better way to encode the transformation in the annotation code, 
I think a better way maybe to use a hard-coded new name, and applying the 
actual replacements on the testing code, and verify the the text diffs.

If we want to do this change, I'd prefer to do it in a followup, since it would 
change the existing testcases as well. What do you think?




Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:302
+  testing::UnorderedElementsAre(
+  PairMatcher(Eq(FooPath),
+  EqualFileEdit(FooDirtyBuffer, FooCode.ranges())),

ilya-biryukov wrote:
> Instead of defining custom matchers, could we convert to standard types and 
> use existing gtest matchers?
> Something like `std::vector>` should 
> work just fine.
> 
> Huge advantage we'll get is better output in case of errors.
yeah, converting the `llvm::StringMap` to standard types could work, but we 
have to pay the cost of transformation (that was something I tried to avoid).
 I think there is no strong reason to use llvm::StringMap as the `FileEdits`, 
what do you think if we change the `FileEdits` type to 
`std::vector>`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69263



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


[PATCH] D69263: [clangd] Implement cross-file rename.

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 226641.
hokein marked 3 inline comments as done.
hokein added a comment.

address comments:

- make the command-line flag hidden;
- use the gtesting matcher;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69263

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -38,8 +38,8 @@
 llvm::Expected>
 runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
 
-llvm::Expected>
-runRename(ClangdServer &Server, PathRef File, Position Pos, StringRef NewName);
+llvm::Expected runRename(ClangdServer &Server, PathRef File,
+Position Pos, StringRef NewName);
 
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -96,11 +96,11 @@
   return std::move(*Result);
 }
 
-llvm::Expected> runRename(ClangdServer &Server,
-PathRef File, Position Pos,
-llvm::StringRef NewName) {
-  llvm::Optional>> Result;
-  Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
+llvm::Expected runRename(ClangdServer &Server, PathRef File,
+Position Pos, llvm::StringRef NewName) {
+  llvm::Optional> Result;
+  Server.rename(File, Pos, NewName, /*WantFormat=*/true,
+/*DirtyBuffaer*/ nullptr, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -9,8 +9,10 @@
 #include "Annotations.h"
 #include "TestFS.h"
 #include "TestTU.h"
+#include "index/Ref.h"
 #include "refactor/Rename.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -18,9 +20,68 @@
 namespace clangd {
 namespace {
 
+using testing::Eq;
+using testing::Matches;
+using testing::Pair;
+using testing::UnorderedElementsAre;
+
 MATCHER_P2(RenameRange, Code, Range, "") {
   return replacementToEdit(Code, arg).range == Range;
 }
+MATCHER_P2(EqualFileEdit, Code, Ranges, "") {
+  using ReplacementMatcher = testing::Matcher;
+  std::vector Expected;
+  for (const auto &R : Ranges)
+Expected.push_back(RenameRange(Code, R));
+  auto Matcher =
+  testing::internal::UnorderedElementsAreArrayMatcher(
+  Expected.begin(), Expected.end());
+  return arg.InitialCode == Code && Matches(Matcher)(arg.Replacements);
+}
+
+std::unique_ptr buildRefSlab(const Annotations &Code,
+  llvm::StringRef SymbolName,
+  llvm::StringRef Path) {
+  RefSlab::Builder Builder;
+  TestTU TU;
+  TU.HeaderCode = Code.code();
+  auto Symbols = TU.headerSymbols();
+  const auto &SymbolID = findSymbol(Symbols, SymbolName).ID;
+  for (const auto &Range : Code.ranges()) {
+Ref R;
+R.Kind = RefKind::Reference;
+R.Location.Start.setLine(Range.start.line);
+R.Location.Start.setColumn(Range.start.character);
+R.Location.End.setLine(Range.end.line);
+R.Location.End.setColumn(Range.end.character);
+auto U = URI::create(Path).toString();
+R.Location.FileURI = U.c_str();
+Builder.insert(SymbolID, R);
+  }
+
+  return std::make_unique(std::move(Builder).build());
+}
+
+RenameInputs renameInputs(const Annotations &Code, llvm::StringRef NewName,
+  llvm::StringRef Path,
+  const SymbolIndex *Index = nullptr,
+  bool CrossFile = false) {
+  RenameInputs Inputs;
+  Inputs.Pos = Code.point();
+  Inputs.MainFileCode = Code.code();
+  Inputs.MainFilePath = Path;
+  Inputs.NewName = NewName;
+  Inputs.Index = Index;
+  Inputs.AllowCrossFile = CrossFile;
+  return Inputs;
+}
+
+std::vector> toVector(FileEdits FE) {
+  std::vector> Results;
+  for (auto &It : FE)
+Results.emplace_back(It.first(

Re: Zorg migration to GitHub/monorepo

2019-10-28 Thread Diana Picus via cfe-commits
Hi Galina,

It seems that our libcxx bots are now triggering builds for any changes to llvm:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/2434

Should I file a bug report for this?

Thanks,
Diana

On Sat, 19 Oct 2019 at 11:36, Galina Kistanova via cfe-commits
 wrote:
>
> Hello everyone,
>
> The staging master is ready to accept bots from the list I have sent 
> yesterday. Don't wait too long.
>
> The master has been updated and works with both SVN and Github monorepo now.
>
> The following builders are already listening for changes in monorepo and 
> building monorepo. More are coming.
>
> * clang-sphinx-docs
> * clang-tools-sphinx-docs
> * clang-x86_64-linux-abi-test
> * clang-lld-x86_64-2stage
> * libcxx-libcxxabi-singlethreaded-x86_64-linux-debian
> * libcxx-sphinx-docs
> * libunwind-sphinx-docs
> * lld-sphinx-docs
> * lld-x86_64-darwin13
> * lld-x86_64-ubuntu-fast
> * lldb-sphinx-docs
> * llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
> * llvm-clang-x86_64-win-fast <<-- ?
> * llvm-sphinx-docs
> * clang-x86_64-debian-fast
> * libcxx-libcxxabi-libunwind-x86_64-linux-debian
> * libcxx-libcxxabi-singlethreaded-x86_64-linux-debian
> * libcxx-libcxxabi-x86_64-linux-debian
> * libcxx-libcxxabi-x86_64-linux-debian-noexceptions
>
> A friendly reminder. If your bots are using one of these build factories, you 
> would need either update your build configurations to use one of the 
> currently supported build factories, or port that factory to work with github 
> and monorepo.
>
> * LLVMBuilder (3 bots)
> * PollyBuilder (3 bots)
> * LLDBBuilder (6 bots)
> * SanitizerBuilder (10 bots)
> * CUDATestsuiteBuilder (1 bot) - depends on ClangBuilder.getClangBuildFactory
> * AOSPBuilder (1 bot) - depends on PollyBuilder
> * AnnotatedBuilder (2 bots)
> * OpenMPBuilder (2 bots)
> * FuchsiaBuilder (1 bot)
>
> Thanks
>
> Galina
>
>
> On Fri, Oct 18, 2019 at 12:05 AM Galina Kistanova  
> wrote:
>>
>> Hello build bot owners!
>>
>> The staging master is ready. Please feel free to use it to make sure your 
>> bots would work well with the monorepo and github.
>>
>> The following builders could be configured to build monorepo:
>>
>> * clang-atom-d525-fedora-rel
>> * clang-native-arm-lnt-perf
>> * clang-cmake-armv7-lnt
>> * clang-cmake-armv7-selfhost-neon
>> * clang-cmake-armv7-quick
>> * clang-cmake-armv7-global-isel
>> * clang-cmake-armv7-selfhost
>> * clang-cmake-aarch64-quick
>> * clang-cmake-aarch64-lld
>> * clang-cmake-aarch64-global-isel
>> * clang-ppc64be-linux-lnt
>> * clang-ppc64be-linux-multistage
>> * clang-ppc64le-linux-lnt
>> * clang-ppc64le-linux-multistage
>> * clang-ppc64be-linux
>> * clang-ppc64le-linux
>> * clang-s390x-linux
>> * clang-s390x-linux-multistage
>> * clang-s390x-linux-lnt
>> * clang-hexagon-elf
>> * clang-cmake-x86_64-avx2-linux
>> * clang-cmake-x86_64-avx2-linux-perf
>> * clang-cmake-x86_64-sde-avx512-linux
>> * clang-solaris11-amd64
>> * clang-x64-ninja-win7
>> * clang-solaris11-sparcv9
>> * clang-cmake-armv7-full
>> * clang-cmake-thumbv7-full-sh
>> * clang-cmake-armv8-lld
>> * clang-cmake-aarch64-full
>> * clang-armv7-linux-build-cache
>> * clang-aarch64-linux-build-cache
>> * libcxx-libcxxabi-x86_64-linux-debian
>> * libcxx-libcxxabi-x86_64-linux-debian-noexceptions
>> * libcxx-libcxxabi-libunwind-x86_64-linux-debian
>> * libcxx-libcxxabi-singlethreaded-x86_64-linux-debian
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-32bit
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-asan
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-msan
>> * libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-tsan
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11
>> * libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std
>> * libcxx-libcxxabi-libunwind-armv7-linux
>> * libcxx-libcxxabi-libunwind-armv8-linux
>> * libcxx-libcxxabi-libunwind-armv7-linux-noexceptions
>> * libcxx-libcxxabi-libunwind-armv8-linux-noexceptions
>> * libcxx-libcxxabi-libunwind-aarch64-linux
>> * libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions
>> * ppc64le-lld-multistage-test
>>
>> These builders are already on the staging master. So, please ping me if you 
>> would like to configure any of them to work with monorepo:
>>
>> * clang-freebsd11-amd64
>>
>> These builders have been already tested and could be reconfigured without 
>> staging as soon as public master is ready:
>>
>> * llvm-sphinx-docs
>> * clang-sphinx-docs
>> * clang-tools-sphinx-docs
>> * lld-sphinx-docs
>> * lldb-sphinx-docs
>> * libcxx-sphinx-docs
>> * libunwind-sphinx-docs
>> * clang-x86_64-debian-fast
>> * libcxx-libcxxabi-x86_64-linux-debian
>> * libcxx-libcxxabi-x86_64-linux-debian-noexceptions
>> * libcxx-libcxxabi-libunwind-x86_64-

[PATCH] D69435: [clang-tidy] New checker performance-trivially-destructible-check

2019-10-28 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev added a comment.

Roman, could you please take another look at it?


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

https://reviews.llvm.org/D69435



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


[PATCH] D69391: Add #pragma clang loop ivdep

2019-10-28 Thread Yashas Andaluri via Phabricator via cfe-commits
YashasAndaluri updated this revision to Diff 226644.
YashasAndaluri edited the summary of this revision.
YashasAndaluri changed the edit policy from "Administrators" to "All Users".
YashasAndaluri added a comment.

Removed disable argument for ivdep


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69391

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop-ivdep.cpp
  clang/test/Parser/pragma-loop.cpp
  clang/test/Parser/pragma-unroll-and-jam.cpp

Index: clang/test/Parser/pragma-unroll-and-jam.cpp
===
--- clang/test/Parser/pragma-unroll-and-jam.cpp
+++ clang/test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, ivdep, or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -82,6 +82,7 @@
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
 #pragma clang loop vectorize_predicate(enable)
+#pragma clang loop ivdep(enable)
 #pragma clang loop unroll(full)
   while (i + 1 < Length) {
 List[i] = i;
@@ -135,12 +136,14 @@
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize_predicate
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 /* expected-error {{expected '('}} */ #pragma clang loop distribute
+/* expected-error {{expected '('}} */ #pragma clang loop ivdep
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_predicate(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 /* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop ivdep(enable
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(4
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave_count(4
@@ -151,7 +154,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, ivdep, or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
@@ -205,6 +208,7 @@
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop interleave(badidentifier)
 /* expected-error {{invalid argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute(badidentifier)
+/* expected-error {{invalid argument; expected 'enable'}} */ #pragma clang loop ivdep(badidentifier)
   while (i-7 < Length) {
 List[i] = i;
   }
Index: clang/test/CodeGenCXX/pragma-loop-ivdep.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pragma-loop-ivdep.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+void test0(int *a, int *b, int LEN_1D) {
+  // C

[PATCH] D69435: [clang-tidy] New checker performance-trivially-destructible-check

2019-10-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp:22
+
+bool CheckPotentiallyTriviallyDestructible(const CXXDestructorDecl *Dtor) {
+  if (Dtor->isFirstDecl() || !Dtor->isExplicitlyDefaulted())

AntonBikineev wrote:
> lebedev.ri wrote:
> > I believe static functions are preferred to anon namespaces;
> > most (if not all) of this checking should/could be done in the matcher 
> > itself,
> > i.e. the check() could be called to unconditionally issue diag.
> I couldn't find matchers to check triviallity of special functions or 
> something like isFirstDecl(). Perhaps, would make sense to add some.
You can trivially add your own matchers, see e.g.
https://github.com/llvm/llvm-project/blob/058b628264d276515a0aab66285816fe6cde2aa2/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp#L15-L39



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp:1
+// RUN: %check_clang_tidy %s performance-trivially-destructible %t
+

AntonBikineev wrote:
> lebedev.ri wrote:
> > Do you also want to check that fix-it applies and result passes sema?
> Aren't fix-its already checked by CHECK-FIXES?
> It would be great to check if the result is compilable. Should I run another 
> clang_tidy instance to check that or is there another way to do so?
It `FileCheck`s the `// CHECK-FIXES` lines, but i don't think it actually 
applies them.
https://github.com/llvm/llvm-project/blob/885c559369fe3d6323898c17787bd0454065fc34/clang-tools-extra/test/clang-tidy/checkers/cert-uppercase-literal-suffix-integer.cpp#L2-L4


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

https://reviews.llvm.org/D69435



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


[PATCH] D69263: [clangd] Implement cross-file rename.

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

Build result: pass - 59701 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69263



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69506

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -584,6 +584,11 @@
   return $TemplateParameter[[T]]::$DependentName[[Field]];
 }
   };
+)cpp",
+  // Highlighting the using decl as the underlying using shadow decl.
+  R"cpp(
+  void $Function[[foo]]();
+  using ::$Function[[foo]];
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -48,6 +48,17 @@
 // And fallback to a generic kind if this fails.
 return HighlightingKind::Typedef;
   }
+  if (auto *UD = dyn_cast(D)) {
+if (UD->shadow_size() == 0)
+  return llvm::None; // Should we add a new highlighting kind?
+// Highlight the using decl as one of the underlying shadow decls.
+UsingShadowDecl *Selected = *UD->shadow_begin();
+llvm::for_each(UD->shadows(), [&Selected](UsingShadowDecl *D) {
+  if (D->getLocation() < Selected->getLocation())
+Selected = D;
+});
+return kindForDecl(Selected->getTargetDecl());
+  }
   // We highlight class decls, constructor decls and destructor decls as
   // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
   // will visit a TypeLoc where the underlying Type is a CXXRecordDecl).


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -584,6 +584,11 @@
   return $TemplateParameter[[T]]::$DependentName[[Field]];
 }
   };
+)cpp",
+  // Highlighting the using decl as the underlying using shadow decl.
+  R"cpp(
+  void $Function[[foo]]();
+  using ::$Function[[foo]];
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -48,6 +48,17 @@
 // And fallback to a generic kind if this fails.
 return HighlightingKind::Typedef;
   }
+  if (auto *UD = dyn_cast(D)) {
+if (UD->shadow_size() == 0)
+  return llvm::None; // Should we add a new highlighting kind?
+// Highlight the using decl as one of the underlying shadow decls.
+UsingShadowDecl *Selected = *UD->shadow_begin();
+llvm::for_each(UD->shadows(), [&Selected](UsingShadowDecl *D) {
+  if (D->getLocation() < Selected->getLocation())
+Selected = D;
+});
+return kindForDecl(Selected->getTargetDecl());
+  }
   // We highlight class decls, constructor decls and destructor decls as
   // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
   // will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69266: [clangd] Define out-of-line availability checks

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:1549
+
+  // Not available for out-of-line metohds.
+  EXPECT_UNAVAILABLE(R"cpp(

nit: metohds => methods.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69266



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


[PATCH] D69298: [clangd] Define out-of-line initial apply logic

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:55
+  // Include template parameter list.
+  if (auto *FTD = FD->getDescribedFunctionTemplate())
+return FTD->getBeginLoc();

Could you confirm the code handle template specializations as well? I think 
`getDescribedFunctionTemplate` will return null when FD is a specialization, 
and we still miss the template list.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:73
+  auto &SM = FD->getASTContext().getSourceManager();
+  auto CharRange = toHalfOpenFileRange(SM, FD->getASTContext().getLangOpts(),
+   FD->getSourceRange());

I think we could simplify the code like:

```
const auto* TargetFD = FD->getDescribedFunctionTemplate() ? 
FD->getDescribedFunctionTemplate(): FD;
auto CharRange = toHaleOpenFileRange(.., FD->getSourceRange());
```



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:131
+llvm::StringRef FileName =
+SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
+

should we use `getCanonicalPath` in the `SourceCode.h`?



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:158
+auto InsertionPoint = Region.EligiblePoints.back();
+auto InsertionOffset = positionToOffset(Contents, InsertionPoint);
+if (!InsertionOffset)

nit: maybe put the code for calculating the insertion point to a separate 
function. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69298



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


[PATCH] D69181: [clang-tidy] Adding misc-signal-terminated-thread check

2019-10-28 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 226648.
abelkocsis added a comment.

Small fix in documentation


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69181

Files:
  clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.h
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-bad-signal-to-kill-thread.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-pos44-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-bad-signal-to-kill-thread.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-bad-signal-to-kill-thread.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-bad-signal-to-kill-thread.cpp
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s bugprone-bad-signal-to-kill-thread %t
+
+#define SIGTERM 15
+#define SIGINT 2
+using pthread_t = int;
+using pthread_attr_t = int;
+
+int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
+   void *(*start_routine)(void *), void *arg);
+
+int pthread_kill(pthread_t thread, int sig);
+
+int pthread_cancel(pthread_t thread);
+
+void *test_func_return_a_pointer(void *foo);
+
+int main() {
+  int result;
+  pthread_t thread;
+
+  if ((result = pthread_create(&thread, nullptr, test_func_return_a_pointer, 0)) != 0) {
+  }
+  if ((result = pthread_kill(thread, SIGTERM)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: thread should not be terminated by raising the 'SIGTERM' signal [bugprone-bad-signal-to-kill-thread]
+  }
+
+  //compliant solution
+  if ((result = pthread_cancel(thread)) != 0) {
+  }
+
+  if ((result = pthread_kill(thread, SIGINT)) != 0) {
+  }
+  if ((result = pthread_kill(thread, 0xF)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: thread should not be terminated by raising the 'SIGTERM' signal [bugprone-bad-signal-to-kill-thread]
+  }
+
+  return 0;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -40,6 +40,7 @@
boost-use-to-string
bugprone-argument-comment
bugprone-assert-side-effect
+   bugprone-bad-signal-to-kill-thread
bugprone-bool-pointer-implicit-conversion
bugprone-branch-clone
bugprone-copy-constructor-init
@@ -106,6 +107,7 @@
cert-msc51-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
cert-oop54-cpp (redirects to bugprone-unhandled-self-assignment) 
+   cert-pos44-c (redirects to bugprone-bad-signal-to-kill-thread) 
clang-analyzer-core.CallAndMessage
clang-analyzer-core.DivideZero
clang-analyzer-core.DynamicTypePropagation
Index: clang-tools-extra/docs/clang-tidy/checks/cert-pos44-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-pos44-c.rst
@@ -0,0 +1,9 @@
+.. title:: clang-tidy - cert-pos44-c
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-bad-signal-to-kill-thread.html
+
+cert-pos44-c
+
+
+The cert-pos44-c check is an alias, please see
+`bugprone-bad-signal-to-kill-thread `_ for more information.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-bad-signal-to-kill-thread.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-bad-signal-to-kill-thread.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - bugprone-bad-signal-to-kill-thread
+
+bugprone-bad-signal-to-kill-thread
+==
+
+Finds ``pthread_kill`` function calls when a thread is terminated by 
+raising ``SIGTERM`` signal and the signal kills the entire process, not 
+just the individual thread. Use any signal except ``SIGTERM``.
+
+.. code-block: c++
+
+pthread_kill(thread, SIGTERM);
+
+This check corresponds to the CERT C Coding Standard rule
+`POS44-C. Do not use signals to terminate threads
+`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,6 +67,12 @@
 Improvements to clang-tidy
 --
 
+- New :doc:`bugprone-bad-signal-to-kill-thread
+  ` check.
+
+  Finds ``pthread_kill`` function calls when a thread is terminated by 
+  raising ``SIGTERM`` signal.
+
 - New :doc:`bugprone-dynamic-static-initializers
   ` check.
 
Index: clang-tools-extra

[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:278
+const auto *Target =
+llvm::dyn_cast(Ref.Targets.front()->getCanonicalDecl());
+auto It = ParamToNewName.find(Target);

why not `llvm::cast`? We'd rather fail early (during the cast) than postpone it 
until we dereference `Target` a few lines further



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:285
+  return;
+const size_t OldNameLen = Target->getName().size();
+// If decl is unnamed in destination we pad the new name to avoid 
gluing

Could we measure the token length instead?
There are various bizzare cases when the source text is different and we 
definitely don't want to accidentally crash on those, e.g.
```
int a = N\
A\
ME;
```



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:295
+  RenamingErrors =
+  llvm::joinErrors(std::move(RenamingErrors), std::move(Err));
+}

Wow, TIL I learned something new. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

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

Build result: pass - 59702 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69506



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: hokein.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Otherwise every client dealing with name location should handle
anonymous names in a special manner.

This seems too error-prone, clients can probably handle anonymous
entities they care about differently.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69511

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -852,8 +852,8 @@
};
// delegating initializer
class $10^Foo {
- $11^Foo(int$12^);
- $13^Foo(): $14^Foo(111) {}
+ $11^Foo(int);
+ $12^Foo(): $13^Foo(111) {}
};
  }
)cpp",
@@ -869,11 +869,19 @@
"9: targets = {Base}\n"
"10: targets = {Foo}, decl\n"
"11: targets = {foo()::Foo::Foo}, decl\n"
-   // FIXME: we should exclude the built-in type.
-   "12: targets = {}, decl\n"
-   "13: targets = {foo()::Foo::Foo}, decl\n"
-   "14: targets = {Foo}\n"},
-
+   "12: targets = {foo()::Foo::Foo}, decl\n"
+   "13: targets = {Foo}\n"},
+  // Anonymous entities should not be reported.
+  {
+  R"cpp(
+ void foo() {
+  class {} $0^x;
+  int (*$1^fptr)(int $2^a, int) = nullptr;
+ }
+   )cpp",
+  "0: targets = {x}, decl\n"
+  "1: targets = {fptr}, decl\n"
+  "2: targets = {a}, decl\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -448,8 +448,15 @@
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))
 return;
-  Refs.push_back(ReferenceLoc{
-  getQualifierLoc(*ND), ND->getLocation(), /*IsDecl=*/true, {ND}});
+  // Filter anonymous decls, name location will point outside the name 
token
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())
+return;
+  Refs.push_back(ReferenceLoc{getQualifierLoc(*ND),
+  ND->getLocation(),
+  /*IsDecl=*/true,
+  {ND}});
 }
   };
 


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -852,8 +852,8 @@
};
// delegating initializer
class $10^Foo {
- $11^Foo(int$12^);
- $13^Foo(): $14^Foo(111) {}
+ $11^Foo(int);
+ $12^Foo(): $13^Foo(111) {}
};
  }
)cpp",
@@ -869,11 +869,19 @@
"9: targets = {Base}\n"
"10: targets = {Foo}, decl\n"
"11: targets = {foo()::Foo::Foo}, decl\n"
-   // FIXME: we should exclude the built-in type.
-   "12: targets = {}, decl\n"
-   "13: targets = {foo()::Foo::Foo}, decl\n"
-   "14: targets = {Foo}\n"},
-
+   "12: targets = {foo()::Foo::Foo}, decl\n"
+   "13: targets = {Foo}\n"},
+  // Anonymous entities should not be reported.
+  {
+  R"cpp(
+ void foo() {
+  class {} $0^x;
+  int (*$1^fptr)(int $2^a, int) = nullptr;
+ }
+   )cpp",
+  "0: targets = {x}, decl\n"
+  "1: targets = {fptr}, decl\n"
+  "2: targets = {a}, decl\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -448,8 +448,15 @@
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))
 return;
-  Refs.push_back(ReferenceLoc{
-  getQualifierLoc(*ND), ND->getLocation(), /*IsDecl=*/true, {ND}});
+  // Filter anonymous decls, name location will point outside the name token
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() 

[PATCH] D69122: Add support to find out resource dir and add it as compilation args

2019-10-28 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added a comment.

I discussed with @klimek about this. The conclusion we arrived at was:

Allowing override of `resource-dir` for all tools is not something we should do 
(for reasons that @klimek has outlined above). However, the dependency scanner 
tool can choose to override `resource-dir`, iff we are sure that it would work 
across different versions of clang.

And my reasoning for why `resource-dir`'s behaviour when overridden in 
`clang-scan-deps` will remain the same across different versions of clang is:

1. The tool runs only the preprocessor. The preprocessor spec hasn't changed in 
a backwards incompatible way as far as I know.
2. In addition to (1), the tool doesn't use anything other than header files 
from `resource-dir`, for the purpose of dependency scanning from the 
preprocessor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69122



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Stumbled upon it when trying to move semantic highlight to use 
`findExplicitReferences`.
This will create some trouble for D68937 , but 
I believe it's actually worth it. `NameLoc` was never intended to point outside 
the name token.

We should be better off without anonymous names here in the long run.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69511



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:454
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())
+return;

nit: I think `if (!ND->getDeclName().getAsIdentifierInfo())` is enough, 
getAsIdentifierInfo returns null if the name is not an identifier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69511



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


[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

2019-10-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 226655.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -1489,6 +1489,45 @@
   EXPECT_EQ(apply(Test), Expected);
 }
 
+TEST_F(DefineInlineTest, TransformParamNames) {
+  EXPECT_EQ(apply(R"cpp(
+void foo(int, bool b, int T\
+est);
+
+void ^foo(int f, bool x, int z) {})cpp"), R"cpp(
+void foo(int f, bool x, int z){}
+
+)cpp");
+}
+
+TEST_F(DefineInlineTest, TransformTemplParamNames) {
+  EXPECT_EQ(apply(R"cpp(
+struct Foo {
+  struct Bar {
+template  class, template class Y,
+  int, int Z>
+void foo(X, Y, int W = 5 * Z + 2);
+  };
+};
+
+template  class V, template class W,
+  int X, int Y>
+void Foo::Bar::f^oo(U, W, int Q) {})cpp"),
+R"cpp(
+struct Foo {
+  struct Bar {
+template  class V, template class W,
+  int X, int Y>
+void foo(U, W, int Q = 5 * Y + 2){}
+  };
+};
+
+)cpp");
+}
+
 TEST_F(DefineInlineTest, TransformInlineNamespaces) {
   auto Test = R"cpp(
 namespace a { inline namespace b { namespace { struct Foo{}; } } }
Index: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -226,6 +226,92 @@
   return QualifiedFunc->substr(BodyBegin, BodyEnd - BodyBegin + 1);
 }
 
+/// Returns true if Dest is templated function. Fills in \p ParamToNewName with
+/// a mapping from template decls in \p Dest to theire respective names in \p
+/// Source.
+bool fillTemplateParameterMapping(
+const FunctionDecl *Dest, const FunctionDecl *Source,
+llvm::DenseMap &ParamToNewName) {
+  auto *DestTempl = Dest->getDescribedFunctionTemplate();
+  auto *SourceTempl = Source->getDescribedFunctionTemplate();
+  assert(bool(DestTempl) == bool(SourceTempl));
+  if (!DestTempl)
+return false;
+  const auto *DestTPL = DestTempl->getTemplateParameters();
+  const auto *SourceTPL = SourceTempl->getTemplateParameters();
+  assert(DestTPL->size() == SourceTPL->size());
+
+  for (size_t I = 0, EP = DestTPL->size(); I != EP; ++I)
+ParamToNewName[DestTPL->getParam(I)->getCanonicalDecl()] =
+SourceTPL->getParam(I)->getName();
+  return true;
+}
+
+/// Generates Replacements for changing template and function parameter names in
+/// \p Dest to be the same as in \p Source.
+llvm::Expected
+renameParameters(const FunctionDecl *Dest, const FunctionDecl *Source) {
+  llvm::DenseMap ParamToNewName;
+  bool HasTemplateParams =
+  fillTemplateParameterMapping(Dest, Source, ParamToNewName);
+  tooling::Replacements Replacements;
+
+  // Populate mapping for function params.
+  for (size_t I = 0, E = Dest->param_size(); I != E; ++I) {
+auto *DestParam = Dest->getParamDecl(I);
+auto *SourceParam = Source->getParamDecl(I);
+ParamToNewName[DestParam] = SourceParam->getName();
+  }
+
+  llvm::Error RenamingErrors = llvm::Error::success();
+  const SourceManager &SM = Dest->getASTContext().getSourceManager();
+  const LangOptions &LangOpts = Dest->getASTContext().getLangOpts();
+  findExplicitReferences(
+  // Use function template in case of templated functions to visit template
+  // parameters.
+  HasTemplateParams
+  ? llvm::dyn_cast(Dest->getDescribedFunctionTemplate())
+  : llvm::dyn_cast(Dest),
+  [&](ReferenceLoc Ref) {
+if (Ref.Targets.size() != 1)
+  return;
+const auto *Target =
+llvm::cast(Ref.Targets.front()->getCanonicalDecl());
+auto It = ParamToNewName.find(Target);
+if (It == ParamToNewName.end())
+  return;
+// No need to rename if parameters already have the same name.
+if (Target->getName() == It->second)
+  return;
+// In case of an empty identifier, we can be sure about zero length, but
+// we need to lex to get token length otherwise because of multi-line
+// identifiers, e.g. int T\
+// est
+// We don't want to lex in the case of empty names, since the NameLoc
+// will still likely have some non-identifier token underneath, and it
+// will have some length, e.g. void foo(int, char c); for the first
+// parameter name will point at ','.
+const size_t OldNameLen =
+Target->getName().em

[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks, I'm fine with the current approach, feel free to add unittests.




Comment at: clang-tools-extra/clangd/Protocol.h:1212
   std::string Tokens;
+  /// Is the line in an inactive preprocessor branch?
+  bool IsInactive = false;

could you add some documentation describing this is a clangd extension?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:469
+  auto &AddedLine = DiffedLines.back();
+  for (auto Iter = AddedLine.Tokens.begin();
+   Iter != AddedLine.Tokens.end();) {

it took me a while to understand this code,

If the NewLine is `IsInactive`, it just contains a single token whose range is 
[0, 0), can't we just?

```

if (NewLine.back().Tokens.empty()) continue;

bool InactiveLine = NewLine.back().Tokens.front().Kind == InactiveCode;
assert(InactiveLine && NewLine.back().Tokens.size() == 1 && "IncativeCode must 
have a single token");
DiffedLines.back().IsInactive = true;
```



Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:46
   Macro,
+  InactiveCode,
 

we should document this Kind as it is different than other kinds, it is for 
line-style I believe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:453
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())

i believe this will break D68937, which relies on findExplicitReferences to 
even rename unnamed parameters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69511



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

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

Build result: pass - 59699 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69511



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c430a7c6f6b: [clangd] Do not report anonymous entities in 
findExplicitReferences (authored by ilya-biryukov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69511

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -852,8 +852,8 @@
};
// delegating initializer
class $10^Foo {
- $11^Foo(int$12^);
- $13^Foo(): $14^Foo(111) {}
+ $11^Foo(int);
+ $12^Foo(): $13^Foo(111) {}
};
  }
)cpp",
@@ -869,11 +869,19 @@
"9: targets = {Base}\n"
"10: targets = {Foo}, decl\n"
"11: targets = {foo()::Foo::Foo}, decl\n"
-   // FIXME: we should exclude the built-in type.
-   "12: targets = {}, decl\n"
-   "13: targets = {foo()::Foo::Foo}, decl\n"
-   "14: targets = {Foo}\n"},
-
+   "12: targets = {foo()::Foo::Foo}, decl\n"
+   "13: targets = {Foo}\n"},
+  // Anonymous entities should not be reported.
+  {
+  R"cpp(
+ void foo() {
+  class {} $0^x;
+  int (*$1^fptr)(int $2^a, int) = nullptr;
+ }
+   )cpp",
+  "0: targets = {x}, decl\n"
+  "1: targets = {fptr}, decl\n"
+  "2: targets = {a}, decl\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -448,8 +448,15 @@
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))
 return;
-  Refs.push_back(ReferenceLoc{
-  getQualifierLoc(*ND), ND->getLocation(), /*IsDecl=*/true, {ND}});
+  // Filter anonymous decls, name location will point outside the name 
token
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())
+return;
+  Refs.push_back(ReferenceLoc{getQualifierLoc(*ND),
+  ND->getLocation(),
+  /*IsDecl=*/true,
+  {ND}});
 }
   };
 


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -852,8 +852,8 @@
};
// delegating initializer
class $10^Foo {
- $11^Foo(int$12^);
- $13^Foo(): $14^Foo(111) {}
+ $11^Foo(int);
+ $12^Foo(): $13^Foo(111) {}
};
  }
)cpp",
@@ -869,11 +869,19 @@
"9: targets = {Base}\n"
"10: targets = {Foo}, decl\n"
"11: targets = {foo()::Foo::Foo}, decl\n"
-   // FIXME: we should exclude the built-in type.
-   "12: targets = {}, decl\n"
-   "13: targets = {foo()::Foo::Foo}, decl\n"
-   "14: targets = {Foo}\n"},
-
+   "12: targets = {foo()::Foo::Foo}, decl\n"
+   "13: targets = {Foo}\n"},
+  // Anonymous entities should not be reported.
+  {
+  R"cpp(
+ void foo() {
+  class {} $0^x;
+  int (*$1^fptr)(int $2^a, int) = nullptr;
+ }
+   )cpp",
+  "0: targets = {x}, decl\n"
+  "1: targets = {fptr}, decl\n"
+  "2: targets = {a}, decl\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -448,8 +448,15 @@
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))
 return;
-  Refs.push_back(ReferenceLoc{
-  getQualifierLoc(*ND), ND->getLocation(), /*IsDecl=*/true, {ND}});
+  // Filter anonymous decls, name location will point outside the name token
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())
+return;
+  Refs.push_back(ReferenceLoc{getQualifier

[clang-tools-extra] 4c430a7 - [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-10-28T14:41:34+01:00
New Revision: 4c430a7c6f6b11105963c6a0ff1e6ee31517a1c8

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

LOG: [clangd] Do not report anonymous entities in findExplicitReferences

Summary:
Otherwise every client dealing with name location should handle
anonymous names in a special manner.

This seems too error-prone, clients can probably handle anonymous
entities they care about differently.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 7dc7fd906be9..1ab80b72a90b 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -448,8 +448,15 @@ llvm::SmallVector refInDecl(const Decl 
*D) {
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))
 return;
-  Refs.push_back(ReferenceLoc{
-  getQualifierLoc(*ND), ND->getLocation(), /*IsDecl=*/true, {ND}});
+  // Filter anonymous decls, name location will point outside the name 
token
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())
+return;
+  Refs.push_back(ReferenceLoc{getQualifierLoc(*ND),
+  ND->getLocation(),
+  /*IsDecl=*/true,
+  {ND}});
 }
   };
 

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f7095aebd868..6b0e51b228b8 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -852,8 +852,8 @@ TEST_F(FindExplicitReferencesTest, All) {
};
// delegating initializer
class $10^Foo {
- $11^Foo(int$12^);
- $13^Foo(): $14^Foo(111) {}
+ $11^Foo(int);
+ $12^Foo(): $13^Foo(111) {}
};
  }
)cpp",
@@ -869,11 +869,19 @@ TEST_F(FindExplicitReferencesTest, All) {
"9: targets = {Base}\n"
"10: targets = {Foo}, decl\n"
"11: targets = {foo()::Foo::Foo}, decl\n"
-   // FIXME: we should exclude the built-in type.
-   "12: targets = {}, decl\n"
-   "13: targets = {foo()::Foo::Foo}, decl\n"
-   "14: targets = {Foo}\n"},
-
+   "12: targets = {foo()::Foo::Foo}, decl\n"
+   "13: targets = {Foo}\n"},
+  // Anonymous entities should not be reported.
+  {
+  R"cpp(
+ void foo() {
+  class {} $0^x;
+  int (*$1^fptr)(int $2^a, int) = nullptr;
+ }
+   )cpp",
+  "0: targets = {x}, decl\n"
+  "1: targets = {fptr}, decl\n"
+  "2: targets = {a}, decl\n"},
   };
 
   for (const auto &C : Cases) {



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


[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:453
+  // and the clients are not prepared to handle that.
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())

kadircet wrote:
> i believe this will break D68937, which relies on findExplicitReferences to 
> even rename unnamed parameters.
That's true, we'll have to handle them separately.

It's a bit more code, but I think it's worth it: having a name location 
pointing to commas or closing parentheses is super unexpected, having some 
custom logic to name unnamed things is probably a bit more code, but it should 
be less surprising.
Sorry about that.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:454
+  if (ND->getDeclName().isIdentifier() &&
+  !ND->getDeclName().getAsIdentifierInfo())
+return;

hokein wrote:
> nit: I think `if (!ND->getDeclName().getAsIdentifierInfo())` is enough, 
> getAsIdentifierInfo returns null if the name is not an identifier.
Good point, I've also tried that, but ended up with the current version.

The proposed solution also removes references to constructors (and I presume 
various special names like `operator+`, etc.)
I'm not sure what to do with those, they pose a different problem: unlike 
anonymous names, they're actually spelled out in the source code.

However, having a single `SourceLocation` is definitely not enough to figure 
out the interesting source ranges, so we'll have to send more information about 
the name location to the clients...

I'm currently considering saving a `DeclarationNameInfo` in the `ReferenceLoc`, 
but I'll need to check whether that's actually possible in all cases, so 
decided to move this into a separate change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69511



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


[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

D69511  broke the anonymous parameters. Sorry 
about that, I hope that's for the best in the long run :-)
We'll need some code to update this patch. Other than that, I think this patch 
is good to go!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:51
   }
+  if (auto *UD = dyn_cast(D)) {
+if (UD->shadow_size() == 0)

Could we reuse `kindForCandidateDecls` instead?
It's best to keep one way to highlight multiple decls.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:60
+});
+return kindForDecl(Selected->getTargetDecl());
+  }

Using decls never have any references and we only highlight them at their 
declarations locations.
Therefore `kindForDecl` seems like the wrong place for it. Could we add a 
`VisitUsingDecl` method to the visitor and have this logic there instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69506



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


[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:233
+bool fillTemplateParameterMapping(
+const FunctionDecl *Dest, const FunctionDecl *Source,
+llvm::DenseMap &ParamToNewName) {

NIT: instead of returning whether `Dest` is a template, we could instead:
1. accept a `TemplateDecl* Dest` and `TemplateDecl *Source`,
2. check whether functions are template at the call site and only call 
`fillTemplateParameterMapping`  when they're template.

I believe that would make both functions simpler and more straight-forward. But 
up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937



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


[PATCH] D60220: [CUDA][Windows] Final fix for bug 38811 (Step 3 of 3)

2019-10-28 Thread Gleb Popov via Phabricator via cfe-commits
6yearold added a comment.

I'm seeing quite similar errors on FreeBSD with Clang 8 and 9:

  In file included from :1:
  In file included from 
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204:
  
/usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7:
 error: no matching function for call to '__isnan'
if (__isnan(a)) {
^~~
  
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); }
 ^
  In file included from :1:
  In file included from 
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204:
  
/usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2934:7:
 error: no matching function for call to '__isnan'
if (__isnan(a)) {
^~~
  
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); }
 ^
  In file included from :1:
  In file included from 
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204:
  
/usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2960:7:
 error: no matching function for call to '__isnan'
if (__isnan(a)) {
^~~
  
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); }
 ^
  In file included from :1:
  In file included from 
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204:
  
/usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:3090:7:
 error: no matching function for call to '__isnan'
if (__isnan(a)) {
^~~
  
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); }
 ^
  In file included from :1:
  In file included from 
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204:
  
/usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:3196:7:
 error: no matching function for call to '__isnan'
if (__isnan(a)) {
^~~
  
/usr/local/llvm90/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); }
 ^

Any idea how to fix this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60220



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


[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2019-10-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

After this, Class can no longer be used as a key type in an Obj-C dictionary 
literal. Is that intentional?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[PATCH] D68937: [clangd] Add parameter renaming to define-inline code action

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

Build result: fail - 59657 tests passed, 2 failed and 805 were skipped.

  failed: 
libc++.libcxx/thread/thread_threads/thread_thread_this/sleep_for.pass.cpp
  failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68937



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


[PATCH] D69181: [clang-tidy] Adding misc-signal-terminated-thread check

2019-10-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

You should also add actual alias code to //cert// module.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69181



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


[PATCH] D60220: [CUDA][Windows] Final fix for bug 38811 (Step 3 of 3)

2019-10-28 Thread Evgeny Mankov via Phabricator via cfe-commits
emankov added a comment.

In D60220#1723350 , @6yearold wrote:

> I'm seeing quite similar errors on FreeBSD with Clang 8 and 9:
>  Any idea how to fix this?


It looks like CUDA doesn't support `double` argument for device function 
__isnan on FreeBSD.

1. I'd look at LLVM trunk (10.0.0svn).
2. If the issue were not eliminated in the trunk, I'd make a change for FreeBSD 
similar to https://reviews.llvm.org/rL358654 to provide declarations for that 
function, allowing math_functions.hpp to compile, but with preventing from any 
use of it on the device side.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60220



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


[PATCH] D65761: Add Windows Control Flow Guard checks (/guard:cf).

2019-10-28 Thread David Chisnall via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd157a9bc8ba1: Add Windows Control Flow Guard checks 
(/guard:cf). (authored by ajpaverd, committed by theraven).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65761

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/cfguardtable.c
  clang/test/Driver/cl-fallback.c
  clang/test/Driver/cl-options.c
  llvm/docs/LangRef.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/MachineFunction.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/CodeGen/TargetCallingConv.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/CallingConv.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/include/llvm/Target/TargetCallingConv.td
  llvm/include/llvm/Transforms/CFGuard.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
  llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h
  llvm/lib/CodeGen/CFGuardLongjmp.cpp
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Target/AArch64/AArch64CallingConvention.h
  llvm/lib/Target/AArch64/AArch64CallingConvention.td
  llvm/lib/Target/AArch64/AArch64FastISel.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/AArch64/LLVMBuild.txt
  llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
  llvm/lib/Target/ARM/ARMCallingConv.h
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/ARM/LLVMBuild.txt
  llvm/lib/Target/X86/LLVMBuild.txt
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86CallingConv.td
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Transforms/CFGuard/CFGuard.cpp
  llvm/lib/Transforms/CFGuard/CMakeLists.txt
  llvm/lib/Transforms/CFGuard/LLVMBuild.txt
  llvm/lib/Transforms/CMakeLists.txt
  llvm/lib/Transforms/LLVMBuild.txt
  llvm/test/Bitcode/calling-conventions.3.2.ll
  llvm/test/Bitcode/calling-conventions.3.2.ll.bc
  llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
  llvm/test/CodeGen/AArch64/cfguard-checks.ll
  llvm/test/CodeGen/AArch64/cfguard-module-flag.ll
  llvm/test/CodeGen/ARM/cfguard-checks.ll
  llvm/test/CodeGen/ARM/cfguard-module-flag.ll
  llvm/test/CodeGen/WinCFGuard/cfguard.ll
  llvm/test/CodeGen/X86/cfguard-checks.ll
  llvm/test/CodeGen/X86/cfguard-module-flag.ll
  llvm/test/CodeGen/X86/cfguard-x86-64-vectorcall.ll
  llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll

Index: llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll
@@ -0,0 +1,43 @@
+; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32
+; Control Flow Guard is currently only available on Windows
+
+
+; Test that Control Flow Guard checks are correctly added for x86 vector calls.
+define void @func_cf_vector_x86(void (%struct.HVA)* %0, %struct.HVA* %1) #0 {
+entry:
+  %2 = alloca %struct.HVA, align 8
+  %3 = bitcast %struct.HVA* %2 to i8*
+  %4 = bitcast %struct.HVA* %1 to i8*
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 32, i1 false)
+  %5 = load %struct.HVA, %struct.HVA* %2, align 8
+  call x86_vectorcallcc void %0(%struct.HVA inreg %5)
+  ret void
+
+  ; X32-LABEL: func_cf_vector_x86
+  ; X32: 	 movl 12(%ebp), %eax
+  ; X32: 	 movl 8(%ebp), %ecx
+  ; X32: 	 movsd 24(%eax), %xmm4 # xmm4 = mem[0],zero
+  ; X32: 	 movsd %xmm4, 24(%esp)
+  ; X32: 	 movsd 16(%eax), %xmm5 # xmm5 = mem[0],zero
+  ; X32: 	 movsd %xmm5, 16(%esp)
+  ; X32: 	 movsd (%eax), %xmm6   # xmm6 = mem[0],zero
+  ; X32: 	 movsd 8(%eax), %xmm7  # xmm7 = mem[0],zero
+  ; X32: 	 movsd %xmm7, 8(%esp)
+  ; X32: 	 movsd %xmm6, (%esp)
+  ; X32: 

[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2019-10-28 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D67983#1723376 , @thakis wrote:

> After this, Class can no longer be used as a key type in an Obj-C dictionary 
> literal. Is that intentional?


Such code was already an on by default incompatible-pointer-types warning in 
ObjC mode. That it worked in ObjC++ was accidental.

For example:

foo.m:

  #import 
  
  int main() {
NSDictionary* d = @{[NSArray class] : @"bar"};
  }

Compiling:

  $ clang -framework Foundation -o foo foo.m
  foo.m:4:23: warning: incompatible pointer types passing 'Class' to parameter 
of type 'id _Nonnull' [-Wincompatible-pointer-types]
NSDictionary* d = @{[NSArray class] : @"bar"};
^~~
  1 warning generated.

While the default metaclass does in fact implement the one method NSCopying 
declares, it's not possible within the language to declare that the Class -- 
itself, as an instance -- implements the instance methods from the NSCopying 
protocol.

You can fix the code just by doing `@{(id)clz : val}`, since id is freely 
castable to anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[PATCH] D68877: [AArch64][SVE] Implement masked load intrinsics

2019-10-28 Thread Yi-Hong Lyu via Phabricator via cfe-commits
Yi-Hong.Lyu added a comment.

Seem this commit broke buildbot 
http://lab.llvm.org:8011/builders/ppc64le-lld-multistage-test/builds/6881


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68877



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


[PATCH] D69238: Fix clang-tidy readability-redundant-string-init for c++17/c++2a

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp:75
+// and if found, extend the SourceRange to start at 'Name'.
+std::pair
+CtorSourceRange(const MatchFinder::MatchResult &Result,

You can drop the `clang::` everywhere -- the code is within the correct 
namespace already.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp:79-80
+  const SourceManager &SM = *Result.SourceManager;
+  const StringRef Name = Decl->getName();
+  const int NameLength = Name.size();
+  const SourceLocation CtorStartLoc(CtorExpr->getSourceRange().getBegin());

Please drop top-level `const` qualifiers unless it's a pointer or reference 
declaration (that's not a style we typically use).



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp:128
+  diag(CtorExprRange.first.getBegin(), "redundant string initialization");
+  if (CtorExprRange.second) {
+Diag << FixItHint::CreateReplacement(CtorExprRange.first, Decl->getName());

Elide braces per coding style.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp:106
   DECL_STRING(e, "");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-1]]:1{{[58]}}: warning: redundant string 
initialization
 

Why does this need a regex?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69238



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 226673.
hokein marked 3 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69506

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -584,6 +584,11 @@
   return $TemplateParameter[[T]]::$DependentName[[Field]];
 }
   };
+)cpp",
+  // Highlighting the using decl as the underlying using shadow decl.
+  R"cpp(
+  void $Function[[foo]]();
+  using ::$Function[[foo]];
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -48,6 +48,9 @@
 // And fallback to a generic kind if this fails.
 return HighlightingKind::Typedef;
   }
+  if (auto *USD = dyn_cast(D))
+return kindForDecl(USD->getTargetDecl());
+
   // We highlight class decls, constructor decls and destructor decls as
   // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
   // will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
@@ -99,11 +102,10 @@
 return kindForDecl(TD);
   return llvm::None;
 }
-// Given a set of candidate declarations for an unresolved name,
-// if the declarations all have the same highlighting kind, return
-// that highlighting kind, otherwise return None.
-llvm::Optional
-kindForCandidateDecls(llvm::iterator_range Decls) {
+// Given a set of candidate declarations, if the declarations all have the same
+// highlighting kind, return that highlighting kind, otherwise return None.
+template 
+llvm::Optional kindForCandidateDecls(IteratorRange Decls) {
   llvm::Optional Result;
   for (NamedDecl *Decl : Decls) {
 auto Kind = kindForDecl(Decl);
@@ -196,6 +198,12 @@
 return true;
   }
 
+  bool VisitUsingDecl(UsingDecl *UD) {
+if (auto K = kindForCandidateDecls(UD->shadows()))
+  addToken(UD->getLocation(), *K);
+return true;
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *Ref) {
 if (canHighlightName(Ref->getNameInfo().getName()))
   addToken(Ref->getLocation(), Ref->getDecl());


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -584,6 +584,11 @@
   return $TemplateParameter[[T]]::$DependentName[[Field]];
 }
   };
+)cpp",
+  // Highlighting the using decl as the underlying using shadow decl.
+  R"cpp(
+  void $Function[[foo]]();
+  using ::$Function[[foo]];
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -48,6 +48,9 @@
 // And fallback to a generic kind if this fails.
 return HighlightingKind::Typedef;
   }
+  if (auto *USD = dyn_cast(D))
+return kindForDecl(USD->getTargetDecl());
+
   // We highlight class decls, constructor decls and destructor decls as
   // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
   // will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
@@ -99,11 +102,10 @@
 return kindForDecl(TD);
   return llvm::None;
 }
-// Given a set of candidate declarations for an unresolved name,
-// if the declarations all have the same highlighting kind, return
-// that highlighting kind, otherwise return None.
-llvm::Optional
-kindForCandidateDecls(llvm::iterator_range Decls) {
+// Given a set of candidate declarations, if the declarations all have the same
+// highlighting kind, return that highlighting kind, otherwise return None.
+template 
+llvm::Optional kindForCandidateDecls(IteratorRange Decls) {
   llvm::Optional Result;
   for (NamedDecl *Decl : Decls) {
 auto Kind = kindForDecl(Decl);
@@ -196,6 +198,12 @@
 return true;
   }
 
+  bool VisitUsingDecl(UsingDecl *UD) {
+if (auto K = kindForCandidateDecls(UD->shadows()))
+  addToken(UD->getLocation(), *K);
+return true;
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *Ref) {
 if (canHighlightName(Ref->getNameInfo().getName()))
   addTok

[PATCH] D69498: IR: Invert convergent attribute handling

2019-10-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This certainly seems like a more tractable representation, although I suppose 
it'd be a thorn in the side of (IR-level) outlining.

A note on spelling: the `no` prefix seems to be used largely with verbs; it's 
weird to use it here with an adjective, especially since `noncovergent` is just 
a letter away.




Comment at: clang/lib/CodeGen/CGObjCMac.cpp:4259
   call->setDoesNotThrow();
+  call->setNoConvergent();
   call->setCallingConv(CGF.getRuntimeCC());

I don't think GPU thread convergence is a concept that could ever really be 
applied to a program containing ObjC exceptions, so while this seems correct, 
it also seems pointless.



Comment at: clang/lib/CodeGen/CGStmt.cpp:1949
 Result.addAttribute(llvm::AttributeList::FunctionIndex,
-llvm::Attribute::Convergent);
+llvm::Attribute::NoConvergent);
   // Extract all of the register value results from the asm.

The comment here seems to no longer match the code.


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

https://reviews.llvm.org/D69498



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

2019-10-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:51
   }
+  if (auto *UD = dyn_cast(D)) {
+if (UD->shadow_size() == 0)

ilya-biryukov wrote:
> Could we reuse `kindForCandidateDecls` instead?
> It's best to keep one way to highlight multiple decls.
Yes, but note that we need to handle the `UsingShadowDecl` in this function.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:60
+});
+return kindForDecl(Selected->getTargetDecl());
+  }

ilya-biryukov wrote:
> Using decls never have any references and we only highlight them at their 
> declarations locations.
> Therefore `kindForDecl` seems like the wrong place for it. Could we add a 
> `VisitUsingDecl` method to the visitor and have this logic there instead?
good point. done. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69506



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


[PATCH] D68028: [clang] Add no_builtin attribute

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D69388: [clang-tidy] Fix modernize-use-nodiscard check for classes marked as [[nodiscard]]

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

Thank you for the patch, and welcome! LGTM aside from a minor nit. Do you need 
someone to commit this on your behalf?




Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:97
 
+  using clang::attr::WarnUnusedResult;
+

I'd just sink this down into the matcher itself rather than use a `using` 
declaration for it.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69388



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


[PATCH] D69517: [clangd] Add a hidden tweak to dump symbol under the curosr.

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

This provides a convenient way to see the SymbolID/USR of the symbol, mainly
for debugging purpose.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69517

Files:
  clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -133,6 +133,15 @@
 HasSubstr(" 'int' 2")));
 }
 
+TWEAK_TEST(DumpSymbol);
+TEST_F(DumpSymbolTest, Test) {
+  std::string ID = R"("id":"CA2EBE44A1D76D2A")";
+  std::string USR = R"("usr":"c:@F@foo#")";
+  EXPECT_THAT(apply("void f^oo();"),
+  AllOf(StartsWith("message:"), testing::HasSubstr(ID),
+testing::HasSubstr(USR)));
+}
+
 TWEAK_TEST(ShowSelectionTree);
 TEST_F(ShowSelectionTreeTest, Test) {
   EXPECT_AVAILABLE("^int f^oo() { re^turn 2 ^+ 2; }");
Index: clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
@@ -9,6 +9,7 @@
 // Some of these are fairly clang-specific and hidden (e.g. textual AST dumps).
 // Others are more generally useful (class layout) and are exposed by default.
 
//===--===//
+#include "XRefs.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Type.h"
@@ -94,6 +95,32 @@
 };
 REGISTER_TWEAK(ShowSelectionTree)
 
+/// Dumps the symbol under the cursor.
+/// Inputs:
+/// void foo();
+///  ^^^
+/// Message:
+///  foo -
+///  
{"containerName":null,"id":"CA2EBE44A1D76D2A","name":"foo","usr":"c:@F@foo#"}
+class DumpSymbol : public Tweak {
+  const char *id() const override final;
+  bool prepare(const Selection &Inputs) override { return true; }
+  Expected apply(const Selection &Inputs) override {
+std::string Storage;
+llvm::raw_string_ostream Out(Storage);
+
+for (auto &Sym : getSymbolInfo(
+ Inputs.AST,
+ sourceLocToPosition(Inputs.AST.getSourceManager(), 
Inputs.Cursor)))
+  Out << Sym;
+return Effect::showMessage(Out.str());
+  }
+  std::string title() const override { return "Dump symbol under the cursor"; }
+  Intent intent() const override { return Info; }
+  bool hidden() const override { return true; }
+};
+REGISTER_TWEAK(DumpSymbol)
+
 /// Shows the layout of the RecordDecl under the cursor.
 /// Input:
 /// struct X { int foo; };


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -133,6 +133,15 @@
 HasSubstr(" 'int' 2")));
 }
 
+TWEAK_TEST(DumpSymbol);
+TEST_F(DumpSymbolTest, Test) {
+  std::string ID = R"("id":"CA2EBE44A1D76D2A")";
+  std::string USR = R"("usr":"c:@F@foo#")";
+  EXPECT_THAT(apply("void f^oo();"),
+  AllOf(StartsWith("message:"), testing::HasSubstr(ID),
+testing::HasSubstr(USR)));
+}
+
 TWEAK_TEST(ShowSelectionTree);
 TEST_F(ShowSelectionTreeTest, Test) {
   EXPECT_AVAILABLE("^int f^oo() { re^turn 2 ^+ 2; }");
Index: clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
@@ -9,6 +9,7 @@
 // Some of these are fairly clang-specific and hidden (e.g. textual AST dumps).
 // Others are more generally useful (class layout) and are exposed by default.
 //===--===//
+#include "XRefs.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Type.h"
@@ -94,6 +95,32 @@
 };
 REGISTER_TWEAK(ShowSelectionTree)
 
+/// Dumps the symbol under the cursor.
+/// Inputs:
+/// void foo();
+///  ^^^
+/// Message:
+///  foo -
+///  {"containerName":null,"id":"CA2EBE44A1D76D2A","name":"foo","usr":"c:@F@foo#"}
+class DumpSymbol : public Tweak {
+  const char *id() const override final;
+  bool prepare(const Selection &Inputs) override { return true; }
+  Expected apply(const Selection &Inputs) override {
+std::string Storage;
+llvm::raw_string_ostream Out(Storage);
+
+for (auto &Sym : getSymbolInfo(
+ Inputs.AST,
+ sourceLocToPosition(Inputs.AST.getSourceManager(), Inputs.Cursor)))
+  Out << Sym;
+return Effect::showMessage(Out.str());
+  }
+  std::string tit

[PATCH] D69498: IR: Invert convergent attribute handling

2019-10-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D69498#1723553 , @rjmccall wrote:

> This certainly seems like a more tractable representation, although I suppose 
> it'd be a thorn in the side of (IR-level) outlining.


Sorry, I mis-clicked and sent this review while I was still editing it.

I agree that this is a theoretically better representation for targets that 
care about convergence, since it biases compilation towards the more 
conservative assumption.  On the other hand, since the default language mode is 
apparently to assume non-convergence of user functions, and since the vast 
majority of targets do not include convergence as a meaningful concept, you're 
also just gratuitously breaking a ton of existing test cases, as well as adding 
compile time for manipulating this attribute.  Perhaps there should be a global 
metadata, or something in the increasingly-misnamed "data layout" string, which 
says that convergence is meaningful, and we should only add the attribute in 
appropriately-annotated modules?


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

https://reviews.llvm.org/D69498



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


[PATCH] D69145: Give readability-redundant-member-init an option IgnoreBaseInCopyConstructors to avoid breaking code with gcc -Werror=extra

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D69145#1720254 , @poelmanc wrote:

> What do @malcolm.parsons, @alexfh, @hokein, @aaron.ballman, @lebedev.ri think 
> of @mgehre's suggestion to enable `IgnoreBaseInCopyConstructors` as the 
> default setting, so gcc users won't experience build errors and think 
> "clang-tidy broke my code!"
>
> I could go either way and appreciate any input.


I think GCC is being overly pedantic, but I don't see much harm in enabling the 
option by default.




Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp:60
+  if (IgnoreBaseInCopyConstructors && ConstructorDecl->isCopyConstructor() &&
+  Init->isBaseInitializer()) {
+return;

You should elide the braces here per our coding standard.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69145



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-28 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

In D68028#1723568 , @aaron.ballman 
wrote:

> LGTM!


Thx a lot for bearing with me and for your valuable comments !
Really appreciate it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

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

Build result: pass - 59702 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69506



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


[PATCH] D69506: [clangd] Add missing highlights for using decls.

2019-10-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM. See the NITs, though




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:51
   }
+  if (auto *USD = dyn_cast(D))
+return kindForDecl(USD->getTargetDecl());

Maybe put this at the first line? This looks like a very good first step.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:52
+  if (auto *USD = dyn_cast(D))
+return kindForDecl(USD->getTargetDecl());
+

Maybe do `D = USD->getTargetDecl()` instead?
This would align with how we handle templates in this function and avoid 
recursive calls (which always look a bit suspicious, e.g. require more thought 
to ensure the function does not recurse indefinitely)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69506



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


[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D69292#1722162 , @thakis wrote:

> This is imho basic enough that it doesn't need a test. A test for this 
> doesn't add any value that I can see.


The value comes from having an explicit test to demonstrate the behavior is not 
an accident, so when someone asks "is this behavior intentional?" the answer is 
more obvious from the test.

In D69292#1722102 , @rtrieu wrote:

> In D69292#1719093 , @aaron.ballman 
> wrote:
>
> > I agree with the changes and want to see this go in, but it needs a test 
> > case.
>
>
> Would this be better if we had a specific test to verify all the warning 
> groups in -Wall?  I could see something using diagtool to list and check all 
> the warnings.


Yeah, I think that would be better but I don't think the full -Wall testing is 
necessary for this change. I was mostly hoping for a trivial test that shows 
-Wall is sufficient to enable at least one of the tautological checks that was 
previously disabled.


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

https://reviews.llvm.org/D69292



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


[PATCH] D69388: [clang-tidy] Fix modernize-use-nodiscard check for classes marked as [[nodiscard]]

2019-10-28 Thread Eugene Sedykh via Phabricator via cfe-commits
sedykh.eugene updated this revision to Diff 226677.
sedykh.eugene added a comment.

I removed using. Not a big deal. Thank you for the reviews!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69388

Files:
  clang-tidy/modernize/UseNodiscardCheck.cpp
  test/clang-tidy/checkers/modernize-use-nodiscard.cpp


Index: test/clang-tidy/checkers/modernize-use-nodiscard.cpp
===
--- test/clang-tidy/checkers/modernize-use-nodiscard.cpp
+++ test/clang-tidy/checkers/modernize-use-nodiscard.cpp
@@ -23,6 +23,8 @@
 typedef unsigned &my_unsigned_reference;
 typedef const unsigned &my_unsigned_const_reference;
 
+struct NO_DISCARD NoDiscardStruct{};
+
 class Foo {
 public:
 using size_type = unsigned;
@@ -160,6 +162,9 @@
 
 // Do not add ``[[nodiscard]]`` to conversion functions.
 // explicit operator bool() const { return true; }
+
+// Do not add ``[[nodiscard]]`` to functions returning types marked 
[[nodiscard]].
+NoDiscardStruct f50() const;
 };
 
 // Do not add ``[[nodiscard]]`` to Lambda.
Index: clang-tidy/modernize/UseNodiscardCheck.cpp
===
--- clang-tidy/modernize/UseNodiscardCheck.cpp
+++ clang-tidy/modernize/UseNodiscardCheck.cpp
@@ -100,7 +100,9 @@
   cxxMethodDecl(
   allOf(isConst(), isDefinitionOrInline(),
 unless(anyOf(
-returns(voidType()), isNoReturn(), isOverloadedOperator(),
+returns(voidType()),
+
returns(hasDeclaration(decl(hasAttr(clang::attr::WarnUnusedResult,
+isNoReturn(), isOverloadedOperator(),
 isVariadic(), hasTemplateReturnType(),
 hasClassMutableFields(), isConversionOperator(),
 hasAttr(clang::attr::WarnUnusedResult),


Index: test/clang-tidy/checkers/modernize-use-nodiscard.cpp
===
--- test/clang-tidy/checkers/modernize-use-nodiscard.cpp
+++ test/clang-tidy/checkers/modernize-use-nodiscard.cpp
@@ -23,6 +23,8 @@
 typedef unsigned &my_unsigned_reference;
 typedef const unsigned &my_unsigned_const_reference;
 
+struct NO_DISCARD NoDiscardStruct{};
+
 class Foo {
 public:
 using size_type = unsigned;
@@ -160,6 +162,9 @@
 
 // Do not add ``[[nodiscard]]`` to conversion functions.
 // explicit operator bool() const { return true; }
+
+// Do not add ``[[nodiscard]]`` to functions returning types marked [[nodiscard]].
+NoDiscardStruct f50() const;
 };
 
 // Do not add ``[[nodiscard]]`` to Lambda.
Index: clang-tidy/modernize/UseNodiscardCheck.cpp
===
--- clang-tidy/modernize/UseNodiscardCheck.cpp
+++ clang-tidy/modernize/UseNodiscardCheck.cpp
@@ -100,7 +100,9 @@
   cxxMethodDecl(
   allOf(isConst(), isDefinitionOrInline(),
 unless(anyOf(
-returns(voidType()), isNoReturn(), isOverloadedOperator(),
+returns(voidType()),
+returns(hasDeclaration(decl(hasAttr(clang::attr::WarnUnusedResult,
+isNoReturn(), isOverloadedOperator(),
 isVariadic(), hasTemplateReturnType(),
 hasClassMutableFields(), isConversionOperator(),
 hasAttr(clang::attr::WarnUnusedResult),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69414: [clang-tidy] Regenerate clang-tidy check list 📋

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69414



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


[PATCH] D69388: [clang-tidy] Fix modernize-use-nodiscard check for classes marked as [[nodiscard]]

2019-10-28 Thread Eugene Sedykh via Phabricator via cfe-commits
sedykh.eugene added a comment.

In D69388#1723589 , @aaron.ballman 
wrote:

> Thank you for the patch, and welcome! LGTM aside from a minor nit. Do you 
> need someone to commit this on your behalf?


Thank you. You mean I don't rights? Then, yes, I need someone to commit.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69388



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


[PATCH] D68539: [clang-tidy] fix for readability-identifier-naming incorrectly fixes variables which become keywords

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Do you need someone to commit this on your behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68539



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


[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Does this analysis require CFG support or have a high false positive rate? We 
typically keep those out of `-Wall` because of performance concerns, so I am 
wondering if the diagnostic was kept out of `-Wall` for a reason.


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

https://reviews.llvm.org/D68912



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


[PATCH] D69517: [clangd] Add a hidden tweak to dump symbol under the curosr.

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

Build result: fail - 59659 tests passed, 2 failed and 805 were skipped.

  failed: 
libc++.libcxx/thread/thread_threads/thread_thread_this/sleep_for.pass.cpp
  failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69517



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


[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2019-10-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> While the default metaclass does in fact implement the one method NSCopying 
> declares, it's not possible within the language to declare that the Class -- 
> itself, as an instance -- implements the instance methods from the NSCopying 
> protocol.

Should the compiler just know that then?

> You can fix the code just by doing `@{(id)clz : val}`, since id is freely 
> castable to anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[clang] bd87916 - [clang] Add no_builtin attribute

2019-10-28 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2019-10-28T17:30:11+01:00
New Revision: bd87916109483d33455cbf20da2309197b983cdd

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

LOG: [clang] Add no_builtin attribute

Summary:
This is a follow up on https://reviews.llvm.org/D61634
This patch is simpler and only adds the no_builtin attribute.

Reviewers: tejohnson, courbet, theraven, t.p.northover, jdoerfert

Subscribers: mgrang, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/no-builtin.cpp
clang/test/Sema/no-builtin.cpp

Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index b3e7a570fd6d..16094c0988fa 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2031,6 +2031,10 @@ class FunctionDecl : public DeclaratorDecl,
   ///
   /// This does not determine whether the function has been defined (e.g., in a
   /// previous definition); for that information, use isDefined.
+  ///
+  /// Note: the function declaration does not become a definition until the
+  /// parser reaches the definition, if called before, this function will 
return
+  /// `false`.
   bool isThisDeclarationADefinition() const {
 return isDeletedAsWritten() || isDefaulted() || Body || hasSkippedBody() ||
isLateTemplateParsed() || willHaveBody() || hasDefiningAttr();

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4557a614d361..d5018f444e1c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3427,3 +3427,10 @@ def ObjCExternallyRetained : InheritableAttr {
   let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
   let Documentation = [ObjCExternallyRetainedDocs];
 }
+
+def NoBuiltin : Attr {
+  let Spellings = [Clang<"no_builtin">];
+  let Args = [VariadicStringArgument<"BuiltinNames">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoBuiltinDocs];
+}

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 6e79d0bb3631..9d0d27407573 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4413,3 +4413,40 @@ and is not a general mechanism for declaring arbitrary 
aliases for
 clang builtin functions.
   }];
 }
+
+def NoBuiltinDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+.. Note:: This attribute is not yet fully implemented, it is validated but has
+no effect on the generated code.
+
+The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin`` flag
+except it is specific to the body of a function. The attribute may also be
+applied to a virtual function but has no effect on the behavior of overriding
+functions in a derived class.
+
+It accepts one or more strings corresponding to the specific names of the
+builtins to disable (e.g. "memcpy", "memset").
+If the attribute is used without parameters it will disable all buitins at
+once.
+
+.. code-block:: c++
+
+  // The compiler is not allowed to add any builtin to foo's body.
+  void foo(char* data, size_t count) __attribute__((no_builtin)) {
+// The compiler is not allowed to convert the loop into
+// `__builtin_memset(data, 0xFE, count);`.
+for (size_t i = 0; i < count; ++i)
+  data[i] = 0xFE;
+  }
+
+  // The compiler is not allowed to add the `memcpy` builtin to bar's body.
+  void bar(char* data, size_t count) __attribute__((no_builtin("memcpy"))) {
+// The compiler is allowed to convert the loop into
+// `__builtin_memset(data, 0xFE, count);` but cannot generate any
+// `__builtin_memcpy`
+for (size_t i = 0; i < count; ++i)
+  data[i] = 0xFE;
+  }
+  }];
+}

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index db877a46c300..20670a98fe03 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3624,6 +3624,15 @@ def err_attribute_overloadable_no_prototype : Error<
 def err_attribute_overloadable_multiple_unmarked_overloads : Error<
   "at most one overload for a given name may lack the 'overloadable' "
   "attribute">;
+def warn_attribute_no_builtin_invalid_builtin_name : Warning<
+  "'%0' is not a valid builtin name for %1">,
+  InGroup>;
+def err_attribute_no_builtin_wil

[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-28 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd8791610948: [clang] Add no_builtin attribute (authored by 
gchatelet).

Changed prior to commit:
  https://reviews.llvm.org/D68028?vs=225618&id=226687#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  void whatever() __attribute__((no_builtin("memcpy")));
+  // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -75,6 +75,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo

[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2019-10-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We could probably do a quick check to see if the class informally conforms to 
the protocol.  `+copyWithZone` seems to be marked unavailable in ARC; not sure 
if that would cause problems for such a check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983



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


[clang-tools-extra] 93a3128 - Remove extra ';'. NFCI.

2019-10-28 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2019-10-28T16:32:02Z
New Revision: 93a3128a67cc4372696eb3199bed23d7bac4a183

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

LOG: Remove extra ';'. NFCI.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
index 8785db1a292b..6bce81bae306 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -386,7 +386,7 @@ class DefineInline : public Tweak {
   const FunctionDecl *Target = nullptr;
 };
 
-REGISTER_TWEAK(DefineInline);
+REGISTER_TWEAK(DefineInline)
 
 } // namespace
 } // namespace clangd



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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

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

LGTM aside from a minor testing nit.




Comment at: clang/test/CodeGen/memccpy-libcall.c:13
+// CHECK: attributes #2 = { nobuiltin }
\ No newline at end of file


Please add the newline to the end of the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68377



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


[PATCH] D69478: [Sema] Allow warnStackExhausted to show more info

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I sort of feel like we don't want to go this route because we want to avoid 
calling `runWithSufficientStackSpace` whenever possible, but I am not strongly 
opposed to this patch. It should be combined with the usage of the new 
functionality, however, so that it gets adequate test coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69478



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


[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2019-10-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 requested changes to this revision.
xbolva00 added a comment.
This revision now requires changes to proceed.

>> Does this analysis require CFG support

https://reviews.llvm.org/D69292 also requires CFG support.

Generally, is CFG support ok for -Wall if the warning has few false positives?

>> I am wondering if the diagnostic was kept out of -Wall for a reason.

Yes, it would be good to find why this was disabled (never enabled?).

@Mordante can you compile LLVM itself with this patch?


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

https://reviews.llvm.org/D68912



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


[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall

2019-10-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Just use

// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s

in

clang/test/SemaCXX/warn-bitwise-compare.cpp

?


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

https://reviews.llvm.org/D69292



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


[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D68912#1723691 , @xbolva00 wrote:

> >> Does this analysis require CFG support
>
> https://reviews.llvm.org/D69292 also requires CFG support.


Yes, it does.

> Generally, is CFG support ok for -Wall if the warning has few false positives?

I think it also depends on the performance of the diagnostic.

>>> I am wondering if the diagnostic was kept out of -Wall for a reason.
> 
> Yes, it would be good to find why this was disabled (never enabled?).
> 
> @Mordante can you compile LLVM itself with this patch?

I'd be curious to know how the timing changes between compilations as well; 
does this regress performance considerably?


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

https://reviews.llvm.org/D68912



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


[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall

2019-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D69292#1723720 , @xbolva00 wrote:

> Just use
>
>   // RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
>   // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s
>
>
> in
>
> clang/test/SemaCXX/warn-bitwise-compare.cpp
>
> ?


Yup, that's all I really need.


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

https://reviews.llvm.org/D69292



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


[PATCH] D68539: [clang-tidy] fix for readability-identifier-naming incorrectly fixes variables which become keywords

2019-10-28 Thread Daniel via Phabricator via cfe-commits
Daniel599 added a comment.

In D68539#1723629 , @aaron.ballman 
wrote:

> Do you need someone to commit this on your behalf?


Yes I would like to.
Thank you :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68539



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


[PATCH] D68733: Use -fdebug-compilation-dir to form absolute paths in coverage mappings

2019-10-28 Thread Yuke Liao via Phabricator via cfe-commits
liaoyuke added a comment.

In D68733#1702609 , @vsk wrote:

> Thanks, lgtm!
>
> In PR43614 I mentioned adding an extra argument to llvm-cov to specify the 
> base directory. On second thought, the existing `-path-equivalence` option 
> should make that unnecessary.


I just tested out this CL, and I don't think it's working correctly (even with 
-path-equivalence flag)

The command I used is:
/usr/local/google/home/liaoyuke/chromium/src/third_party/llvm-build/Release+Asserts/bin/llvm-cov
 show -format=html 
-output-dir=/usr/local/google/home/liaoyuke/chromium/src/out/output_test_path 
-instr-profile=/usr/local/google/home/liaoyuke/chromium/src/out/output_test_path/linux/coverage.profdata
 -path-equivalence=../..,/usr/local/google/home/liaoyuke/chromium/src 
out/coverage/base_unittests

And the generated html files are as following: https://imgur.com/gallery/dlgQXhy
Specifically, there are a few problems:

1. The index.html files still show relative paths, but I'm expecting an 
absolute path given that I passed in the -path-equivalence flag.
2. The file level line-by-line view's styling is completely off, there is no 
table and no highlights.
3. I also tried the "llvm-cov export" command, it seems that it doesn't respect 
the -path-equivalence flag at all, and the produced json still uses relative 
paths in them. (I'm guessing the root cause is the same as 1)

Am I using the -path-equivalence flag correctly? And any other suggestions to 
work this around?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68733



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-10-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please take a look on PR43827.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67567



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


[PATCH] D69238: Fix clang-tidy readability-redundant-string-init for c++17/c++2a

2019-10-28 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 226695.
poelmanc added a comment.

Remove extra `const`, braces for one-line `if` statements, and `clang::`. Added 
a comment explaining the need for a regex on a warning test line.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69238

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
 
 namespace std {
 template 
@@ -104,7 +103,8 @@
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: redundant string initialization
   // CHECK-FIXES: STRING d;
   DECL_STRING(e, "");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // Warning at position :15 with -std=c++11/14, position :18 for -std=c++17/2x
+  // CHECK-MESSAGES: [[@LINE-2]]:1{{[58]}}: warning: redundant string initialization
 
   MyString f = "u";
   STRING g = "u";
Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
 
 namespace std {
 template 
Index: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -57,12 +57,73 @@
   this);
 }
 
+// Returns the SourceRange for the string constructor expression and a bool
+// indicating whether to fix it (by replacing it with just the variable name)
+// or just issue a diagnostic warning. CtorExpr's SourceRange includes:
+//   foo = ""
+//   bar("")
+//   ""(only in C++17 and later)
+//
+// With -std c++14 or earlier (!LangOps.CPlusPlus17), it was sufficient to
+// return CtorExpr->getSourceRange(). However, starting with c++17, parsing
+// the expression 'std::string Name = ""' results in a CtorExpr whose
+// SourceRange includes just '""' rather than the previous 'Name = ""'.
+//
+// So if the CtorExpr's SourceRange doesn't already start with 'Name', we
+// search leftward for 'Name\b*=\b*' (where \b* represents optional whitespace)
+// and if found, extend the SourceRange to start at 'Name'.
+std::pair
+CtorSourceRange(const MatchFinder::MatchResult &Result, const NamedDecl *Decl,
+const Expr *CtorExpr) {
+  const SourceManager &SM = *Result.SourceManager;
+  StringRef Name = Decl->getName();
+  int NameLength = Name.size();
+  SourceLocation CtorStartLoc(CtorExpr->getSourceRange().getBegin());
+  std::pair CtorLocInfo = SM.getDecomposedLoc(
+  CtorStartLoc.isMacroID() ? SM.getImmediateMacroCallerLoc(CtorStartLoc)
+   : CtorStartLoc);
+  int CtorStartPos = CtorLocInfo.second;
+  StringRef File = SM.getBufferData(CtorLocInfo.first);
+  StringRef CtorCheckName = File.substr(CtorStartPos, NameLength);
+  if (CtorCheckName == Name)
+// For 'std::string foo("");', CtorExpr is 'foo("")'
+return std::make_pair(CtorExpr->getSourceRange(), true);
+  // Scan backwards from CtorStartPos.
+  // If find "Name\b*=\b*", extend CtorExpr SourceRange leftwards to include it.
+  bool FoundEquals = false;
+  for (int Pos = CtorStartPos - 1; Pos >= 0; Pos--) {
+char Char = File.data()[Pos];
+if (Char == '=') {
+  if (FoundEquals)
+break; // Only allow one equals sign
+  FoundEquals = true;
+} else if (!isWhitespace(Char)) {
+  // First non-whitespace/non-equals char. Check for Name ending with it.
+  int CheckNameStart = Pos - NameLength + 1;
+  StringRef CheckName(File.data() + CheckNameStart, NameLength);
+  if (FoundEquals && Name == CheckName) {
+return std::make_pair(SourceRange(CtorStartLoc.getLocWithOffset(
+  CheckNameStart - CtorStartPos),
+  

[PATCH] D69238: Fix clang-tidy readability-redundant-string-init for c++17/c++2a

2019-10-28 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc marked 5 inline comments as done.
poelmanc added a comment.

Thanks for the feedback, the new patch removes the extra `const`, `clang::`, 
and braces on one-line `if` statements, and now explains the regex in 
readability-redundant-string-init.cpp.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp:106
   DECL_STRING(e, "");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-1]]:1{{[58]}}: warning: redundant string 
initialization
 

aaron.ballman wrote:
> Why does this need a regex?
Thanks, I added a comment explaining that the character position of the warning 
differs slightly between C++11/14 (reports at the 'e') and C++17/2x (reports at 
the '"'), since the underlying parsing code has changed.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69238



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


[PATCH] D60220: [CUDA][Windows] Final fix for bug 38811 (Step 3 of 3)

2019-10-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D60220#1723458 , @emankov wrote:

> In D60220#1723350 , @6yearold wrote:
>
> > I'm seeing quite similar errors on FreeBSD with Clang 8 and 9:
> >  Any idea how to fix this?
>
>
> It looks like CUDA doesn't support `double` argument for device function 
> __isnan on FreeBSD.


It's actually the opposite -- FreeBSD does not provide *host*-side 
`__isnan(double)` -- the error complains that it's the host code that tried to 
use `__isnan` and failed when overload resolution produced a device variant.

FreeBSD does have host-side implementation of isnan, only it's apparently 
called `__inline_isnan()` 
https://github.com/freebsd/freebsd/blob/master/lib/msun/src/math.h#L197
I think the right thing to do here would probably be to define a wrapper 
__isnan(double) which would call it.

> 
> 
> 1. I'd look at LLVM trunk (10.0.0svn).
> 2. If the issue were not eliminated in the trunk, I'd make a change for 
> FreeBSD similar to https://reviews.llvm.org/rL358654 to provide declarations 
> for that function, allowing math_functions.hpp to compile, but with 
> preventing from any use of it on the device side.




Repository:
  rC Clang

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

https://reviews.llvm.org/D60220



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


[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

2019-10-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69518

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/warn-std-is-constant-evaluated-constexpr.cpp


Index: clang/test/SemaCXX/warn-std-is-constant-evaluated-constexpr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-std-is-constant-evaluated-constexpr.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -verify -Wtautological-compare %s
+
+namespace std {
+constexpr bool is_constant_evaluated() noexcept {
+  return __builtin_is_constant_evaluated();
+}
+}
+
+constexpr int fn1() {
+  if constexpr (std::is_constant_evaluated()) // expected-warning 
{{'std::is_constant_evaluated' will always evaluate to 'true' in constexpr 
mode}}
+return 0;
+  else
+return 1;
+}
+
+constexpr int fn2() {
+  if (std::is_constant_evaluated())
+return 0;
+  else
+return 1;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3675,6 +3675,10 @@
   // expression, implicitly converted to bool.
   //
   // FIXME: Return this value to the caller so they don't need to recompute it.
+  CallExpr *Call = dyn_cast(CondExpr->IgnoreParens());
+  if (IsConstexpr && Call && Call->isCallToStdIsConstantEvaluated())
+Diag(Call->getBeginLoc(),
+ diag::warn_std_is_constant_evaluated_always_true_constexpr);
   llvm::APSInt Value(/*BitWidth*/1);
   return (IsConstexpr && !CondExpr->isValueDependent())
  ? CheckConvertedConstantExpression(CondExpr, Context.BoolTy, 
Value,
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8405,6 +8405,9 @@
   "%select{self-|array }0comparison always evaluates to "
   "%select{a constant|true|false|'std::strong_ordering::equal'}1">,
   InGroup;
+def warn_std_is_constant_evaluated_always_true_constexpr : Warning<
+  "'std::is_constant_evaluated' will always evaluate to "
+  "'true' in constexpr mode">, InGroup;
 def warn_comparison_bitwise_always : Warning<
   "bitwise comparison always evaluates to %select{false|true}0">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -2777,6 +2777,13 @@
FD->getIdentifier() && FD->getIdentifier()->isStr("move");
   }
 
+  bool isCallToStdIsConstantEvaluated() const {
+const FunctionDecl *FD = getDirectCallee();
+return getNumArgs() == 0 && FD && FD->isInStdNamespace() &&
+   FD->getIdentifier() &&
+   FD->getIdentifier()->isStr("is_constant_evaluated");
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() >= firstCallExprConstant &&
T->getStmtClass() <= lastCallExprConstant;


Index: clang/test/SemaCXX/warn-std-is-constant-evaluated-constexpr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-std-is-constant-evaluated-constexpr.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -verify -Wtautological-compare %s
+
+namespace std {
+constexpr bool is_constant_evaluated() noexcept {
+  return __builtin_is_constant_evaluated();
+}
+}
+
+constexpr int fn1() {
+  if constexpr (std::is_constant_evaluated()) // expected-warning {{'std::is_constant_evaluated' will always evaluate to 'true' in constexpr mode}}
+return 0;
+  else
+return 1;
+}
+
+constexpr int fn2() {
+  if (std::is_constant_evaluated())
+return 0;
+  else
+return 1;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3675,6 +3675,10 @@
   // expression, implicitly converted to bool.
   //
   // FIXME: Return this value to the caller so they don't need to recompute it.
+  CallExpr *Call = dyn_cast(CondExpr->IgnoreParens());
+  if (IsConstexpr && Call && Call->isCallToStdIsConstantEvaluated())
+Diag(Call->getBeginLoc(),
+ diag::warn_std_is_constant_evaluated_always_true_constexpr);
   llvm::APSInt Value(/*BitWidth*/1);
   return (IsConstexpr && !CondExpr->isValueDependent())
  ? CheckConvertedConstantExpression(CondExpr, Context.BoolTy, Value,
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
==

[clang] 7c86069 - [OPENMP]Fix PR43771: Do not capture contexprs variables.

2019-10-28 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-10-28T13:29:02-04:00
New Revision: 7c860698208aee32df1883601b94924fa4a3d531

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

LOG: [OPENMP]Fix PR43771: Do not capture contexprs variables.

If the variable is a constexpr variable, it should not be captured in the 
OpenMP region.

Added: 
clang/test/OpenMP/constexpr_capture.cpp

Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index c7e0d2aee036..8b1fca89dee8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1894,6 +1894,11 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool 
CheckScopeInfo,
   assert(LangOpts.OpenMP && "OpenMP is not allowed");
   D = getCanonicalDecl(D);
 
+  auto *VD = dyn_cast(D);
+  // Do not capture constexpr variables.
+  if (VD && VD->isConstexpr())
+return nullptr;
+
   // If we want to determine whether the variable should be captured from the
   // perspective of the current capturing scope, and we've already left all the
   // capturing scopes of the top directive on the stack, check from the
@@ -1904,7 +1909,6 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool 
CheckScopeInfo,
   // If we are attempting to capture a global variable in a directive with
   // 'target' we return true so that this global is also mapped to the device.
   //
-  auto *VD = dyn_cast(D);
   if (VD && !VD->hasLocalStorage() &&
   (getCurCapturedRegion() || getCurBlock() || getCurLambda())) {
 if (isInOpenMPDeclareTargetContext()) {

diff  --git a/clang/test/OpenMP/constexpr_capture.cpp 
b/clang/test/OpenMP/constexpr_capture.cpp
new file mode 100644
index ..9577f6e0c0fe
--- /dev/null
+++ b/clang/test/OpenMP/constexpr_capture.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux 
-S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// expected-no-diagnostics
+
+template  struct integral_constant {
+  static constexpr int value = __v;
+};
+
+template ::value>
+struct decay {
+  typedef int type;
+};
+struct V {
+  template ::type> V();
+};
+int main() {
+#pragma omp target
+  V v;
+  return 0;
+}
+
+// CHECK: call void @__omp_offloading_{{.+}}_main_l16()



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


[PATCH] D69493: Add -fconvergent-functions flag

2019-10-28 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.

> The CUDA builtin library is apparently compiled in C++ mode, so the
>  assumption of convergent needs to be made in a typically non-SPMD
>  language.

I think the key here is that we sometimes may need to compile things for device 
**without** `-x cuda` and that changes the default assumption about 
convergence. This flag allows controlling the assumption explicitly without 
relying on input language.


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

https://reviews.llvm.org/D69493



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


[PATCH] D69498: IR: Invert convergent attribute handling

2019-10-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked an inline comment as done.
arsenm added a comment.

In D69498#1723606 , @rjmccall wrote:

> A note on spelling: the no prefix seems to be used largely with verbs; it's 
> weird to use it here with an adjective, especially since noncovergent is just 
> a letter away.


I don't think it reads any different to me than, say nofree->no free calls. 
noconvergent-> no convergent operations. nonconvergent sounds odder to me

> In D69498#1723553 , @rjmccall wrote:
> 
>> This certainly seems like a more tractable representation, although I 
>> suppose it'd be a thorn in the side of (IR-level) outlining.
> 
> 
> Sorry, I mis-clicked and sent this review while I was still editing it.
> 
> I agree that this is a theoretically better representation for targets that 
> care about convergence, since it biases compilation towards the more 
> conservative assumption.  On the other hand, since the default language mode 
> is apparently to assume non-convergence of user functions, and since the vast 
> majority of targets do not include convergence as a meaningful concept, 
> you're also just gratuitously breaking a ton of existing test cases, as well 
> as adding compile time for manipulating this attribute.  Perhaps there should 
> be a global metadata, or something in the increasingly-misnamed "data layout" 
> string, which says that convergence is meaningful, and we should only add the 
> attribute in appropriately-annotated modules?

The default language mode for the non-parallel languages. The set of languages 
not setting this does need to grow (SYCL and OpenMP device code are both 
currently broken).

I don't think there are other attributes with weird connections to some global 
construct. Part of the point of attributes is that they are function level 
context. I don't really understand the compile time concern; the cost of the 
attribute is one bit in a bitset. We have quite a few attributes already that 
will be inferred for a large percentage of functions anyway. The case that's 
really important to add in frontend is external declarations and other opaque 
cases, others will be inferred anyway. You could make the same argument with 
nounwind, since most languages don't have exceptions.




Comment at: clang/lib/CodeGen/CGObjCMac.cpp:4259
   call->setDoesNotThrow();
+  call->setNoConvergent();
   call->setCallingConv(CGF.getRuntimeCC());

rjmccall wrote:
> I don't think GPU thread convergence is a concept that could ever really be 
> applied to a program containing ObjC exceptions, so while this seems correct, 
> it also seems pointless.
It doesn't apply, so this needs to be explicitly marked as not having it. This 
bypasses the place that emits the language assumed default attribute so this is 
needed. A handful of tests do fail without this from control flow changes not 
happening


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

https://reviews.llvm.org/D69498



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


[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

2019-10-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3679
+  CallExpr *Call = dyn_cast(CondExpr->IgnoreParens());
+  if (IsConstexpr && Call && Call->isCallToStdIsConstantEvaluated())
+Diag(Call->getBeginLoc(),

Not ideal place. Missing !E case, etc...


Maybe in ActOnCompletedExpr?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69518



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


[PATCH] D60220: [CUDA][Windows] Final fix for bug 38811 (Step 3 of 3)

2019-10-28 Thread Evgeny Mankov via Phabricator via cfe-commits
emankov added a comment.

>> It looks like CUDA doesn't support `double` argument for device function 
>> __isnan on FreeBSD.
> 
> It's actually the opposite -- FreeBSD does not provide *host*-side 
> `__isnan(double)` -- the error complains that it's the host code that tried 
> to use `__isnan` and failed when overload resolution produced a device 
> variant.

Sure, you right, quite opposite: `call to __device__ function from __host__ 
function`. I agree: the wrapper for the existing `__inline_isnan()` is the 
solution.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60220



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


[PATCH] D69520: [libc++] Disallow dynamic -> static span conversions

2019-10-28 Thread Jan Wilken Dörrie via Phabricator via cfe-commits
jdoerrie created this revision.
jdoerrie added reviewers: mclow.lists, ldionne.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, christof.

[libc++] Disallow dynamic -> static span conversions

This change disallows dynamic to static span conversions. This complies
with the standard, which lists the following constaint in
views.span#span.cons-20.1 [1]:

  Extent == dynamic_extent || Extent == OtherExtent

Thus this should fail if Extent != dynamic_extent && Extent !=
OtherExtent, which is the case when trying to construct a static span
from a dynamic span.

[1] https://eel.is/c++draft/views.span#span.cons-20.1


Repository:
  rCXX libc++

https://reviews.llvm.org/D69520

Files:
  libcxx/include/span
  libcxx/test/std/containers/views/span.cons/span.fail.cpp
  libcxx/test/std/containers/views/span.cons/span.pass.cpp

Index: libcxx/test/std/containers/views/span.cons/span.pass.cpp
===
--- libcxx/test/std/containers/views/span.cons/span.pass.cpp
+++ libcxx/test/std/containers/views/span.cons/span.pass.cpp
@@ -62,48 +62,41 @@
 std::span s4{ vsp0};// a span pointing at volatile int.
 assert(s1.size() + s2.size() + s3.size() + s4.size() == 0);
 }
-
-//  dynamic -> static
-{
-std::span s1{  sp};  // a span pointing at int.
-std::span<  volatile int, 0> s2{  sp};  // a span<  volatile int> pointing at int.
-std::span s3{  sp};  // a span pointing at int.
-std::span s4{ vsp};  // a span pointing at volatile int.
-assert(s1.size() + s2.size() + s3.size() + s4.size() == 0);
-}
 }
 
 
 template 
 constexpr bool testConstexprSpan()
 {
-std::spans0{};
-std::span s1(s0); // dynamic -> static
-std::spans2(s1); // static -> dynamic
-ASSERT_NOEXCEPT(std::span   {s0});
-ASSERT_NOEXCEPT(std::span{s1});
-ASSERT_NOEXCEPT(std::span   {s1});
-ASSERT_NOEXCEPT(std::span{s0});
-
-return
-s1.data() == nullptr && s1.size() == 0
-&&  s2.data() == nullptr && s2.size() == 0;
+  std::span s0d{};
+  std::span s0s{};
+  std::span s1(s0d);// dynamic -> dynamic
+  std::span s2(s0s); // static -> static
+  std::span s3(s2); // static -> dynamic
+  ASSERT_NOEXCEPT(std::span{s0d});
+  ASSERT_NOEXCEPT(std::span{s0s});
+  ASSERT_NOEXCEPT(std::span{s0s});
+
+  return s1.data() == nullptr && s1.size() == 0 && s2.data() == nullptr &&
+ s2.size() == 0 && s3.data() == nullptr && s3.size() == 0;
 }
 
 
 template 
 void testRuntimeSpan()
 {
-std::spans0{};
-std::span s1(s0); // dynamic -> static
-std::spans2(s1); // static -> dynamic
-ASSERT_NOEXCEPT(std::span   {s0});
-ASSERT_NOEXCEPT(std::span{s1});
-ASSERT_NOEXCEPT(std::span   {s1});
-ASSERT_NOEXCEPT(std::span{s0});
-
-assert(s1.data() == nullptr && s1.size() == 0);
-assert(s2.data() == nullptr && s2.size() == 0);
+  std::span s0d{};
+  std::span s0s{};
+  std::span s1(s0d);// dynamic -> dynamic
+  std::span s2(s0s); // static -> static
+  std::span s3(s2); // static -> dynamic
+  ASSERT_NOEXCEPT(std::span{s0d});
+  ASSERT_NOEXCEPT(std::span{s0s});
+  ASSERT_NOEXCEPT(std::span{s0s});
+
+  assert(s1.data() == nullptr && s1.size() == 0);
+  assert(s2.data() == nullptr && s2.size() == 0);
+  assert(s3.data() == nullptr && s3.size() == 0);
 }
 
 
@@ -113,10 +106,12 @@
 static_assert(std::is_convertible_v, "Bad input types to 'testConversionSpan");
 std::spans0d{};
 std::spans0s{};
-std::span s1(s0d); // dynamic -> static
-std::spans2(s0s); // static -> dynamic
-s1.data() == nullptr && s1.size() == 0
-&&  s2.data() == nullptr && s2.size() == 0;
+std::span s1(s0d);// dynamic -> dynamic
+std::span s2(s0s); // static -> static
+std::span s3(s0d);// static -> dynamic
+s1.data() == nullptr&& s1.size() == 0 &&
+s2.data() == nullptr&& s2.size() == 0 &&
+s3.data() == nullptr&& s3.size() == 0;
 }
 
 struct A{};
Index: libcxx/test/std/containers/views/span.cons/span.fail.cpp
===
--- libcxx/test/std/containers/views/span.cons/span.fail.cpp
+++ libcxx/test/std/containers/views/span.cons/span.fail.cpp
@@ -74,19 +74,6 @@
 std::span<  volatile int> s6{ csp0}; // expected-error {{no matching constructor for initialization of 'std::span'}}
 std::span<  volatile int> s7{cvsp0}; // expected-error {{no matching constructor for initialization of 'std::span'}}
 }
-
-//  Try to remove const and/or volatile (static -> static)
-{
-std::span<   int, 0> s1{ csp}; // expected-error {{no matching constructor for initialization of 'std::span'}}
-std::span<   int, 0> s2{ vsp}; // expected-error {{no matching constructor for initialization of 'std::span'}}
-std::span<   int, 0> s3{cvsp}; // expected-error {{no matching constr

  1   2   >