[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

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

there is a slight behavior change in this patch:

- before: `in^t a;`, returns our internal error message (no symbol at given 
location)
- after: `in^t a, returns null, and client displays their message (e.g. e.g. 
"the element can't be renamed" in vscode).

both are sensible according LSP, and we'd save one `rename` call in the later 
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73610

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/test/rename.test

Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 {"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -448,11 +448,8 @@
 return (*Content)->getBuffer().str();
   };
   // Try to find the tokens adjacent to the cursor position.
-  auto Loc = sourceLocationInMainFile(SM, RInputs.Pos);
-  if (!Loc)
-return Loc.takeError();
   const syntax::Token *IdentifierToken =
-  spelledIdentifierTouching(*Loc, AST.getTokens());
+  getTouchingIdentifier(RInputs.Pos, SM, AST.getTokens());
   // Renames should only triggered on identifiers.
   if (!IdentifierToken)
 return makeError(ReasonToReject::NoSymbolFound);
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -21,6 +21,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
@@ -298,6 +299,12 @@
 bool isHeaderFile(llvm::StringRef FileName,
   llvm::Optional LangOpts = llvm::None);
 
+/// Returns the identifier token that touches the given \p Pos
+/// Redturns nullptr if there is none.
+const syntax::Token *getTouchingIdentifier(Position Pos,
+   const SourceManager &SM,
+   const syntax::TokenBuffer &Tokens);
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -1127,5 +1127,15 @@
   return Lang != types::TY_INVALID && types::onlyPrecompileType(Lang);
 }
 
+const syntax::Token *getTouchingIdentifier(Position Pos,
+   const SourceManager &SM,
+   const syntax::TokenBuffer &Tokens) {
+  auto Loc = sourceLocationInMainFile(SM, Pos);
+  if (!Loc) {
+elog("Failed to convert position to source location: {0}", Loc.takeError());
+return nullptr;
+  }
+  return spelledIdentifierTouching(*Loc, Tokens);
+}
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,10 +316,13 @@
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
+const auto *TouchingIdentifier =
+getTouchingIdentifier(Pos, SM, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+

[clang] 757bdc6 - Fix clang unnittest build with GCC 5

2020-01-29 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-01-29T10:30:36+01:00
New Revision: 757bdc64d33df61467a7122f22ea76cf163c8dca

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

LOG: Fix clang unnittest build with GCC 5

Added: 


Modified: 
clang/unittests/Frontend/PCHPreambleTest.cpp
clang/unittests/Tooling/TransformerTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/PCHPreambleTest.cpp 
b/clang/unittests/Frontend/PCHPreambleTest.cpp
index 6136b0959497..d253d937ace9 100644
--- a/clang/unittests/Frontend/PCHPreambleTest.cpp
+++ b/clang/unittests/Frontend/PCHPreambleTest.cpp
@@ -117,7 +117,7 @@ class PCHPreambleTest : public ::testing::Test {
 for (const auto &RemappedFile : RemappedFiles) {
   std::unique_ptr buf = MemoryBuffer::getMemBufferCopy(
 RemappedFile.second, RemappedFile.first());
-  Remapped.emplace_back(RemappedFile.first(), buf.release());
+  Remapped.emplace_back(std::string(RemappedFile.first()), buf.release());
 }
 return Remapped;
   }

diff  --git a/clang/unittests/Tooling/TransformerTest.cpp 
b/clang/unittests/Tooling/TransformerTest.cpp
index 454615c673de..1d955cf5e9b8 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -81,7 +81,7 @@ class ClangRefactoringTestBase : public testing::Test {
   void appendToHeader(StringRef S) { FileContents[0].second += S; }
 
   void addFile(StringRef Filename, StringRef Content) {
-FileContents.emplace_back(Filename, Content);
+FileContents.emplace_back(std::string(Filename), std::string(Content));
   }
 
   llvm::Optional rewrite(StringRef Input) {



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


[clang-tools-extra] 0d893fd - [clangd] Add a symbol-name-based blacklist for rename.

2020-01-29 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-29T10:32:40+01:00
New Revision: 0d893fda4305f19be18bc60f56839f2143c78b38

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

LOG: [clangd] Add a symbol-name-based blacklist for rename.

Summary:
This patch adds a simple mechanism to disallow global rename
on std symbols. We might extend it to other symbols, e.g. protobuf.

Reviewers: kadircet

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 9518d848eff5..83f3a02d80d7 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -75,8 +75,8 @@ llvm::Optional getOtherRefFile(const Decl &D, 
StringRef MainFile,
   return OtherFile;
 }
 
-llvm::DenseSet locateDeclAt(ParsedAST &AST,
-  SourceLocation TokenStartLoc) {
+llvm::DenseSet locateDeclAt(ParsedAST &AST,
+   SourceLocation TokenStartLoc) {
   unsigned Offset =
   AST.getSourceManager().getDecomposedSpellingLoc(TokenStartLoc).second;
 
@@ -85,7 +85,7 @@ llvm::DenseSet locateDeclAt(ParsedAST &AST,
   if (!SelectedNode)
 return {};
 
-  llvm::DenseSet Result;
+  llvm::DenseSet Result;
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
@@ -96,6 +96,15 @@ llvm::DenseSet locateDeclAt(ParsedAST &AST,
   return Result;
 }
 
+bool isBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
 enum ReasonToReject {
   NoSymbolFound,
   NoIndexProvided,
@@ -105,7 +114,7 @@ enum ReasonToReject {
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
@@ -120,6 +129,9 @@ llvm::Optional renameable(const Decl 
&RenameDecl,
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  if (isBlacklisted(RenameDecl))
+return ReasonToReject::UnsupportedSymbol;
+
   // Check whether the symbol being rename is indexable.
   auto &ASTCtx = RenameDecl.getASTContext();
   bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
@@ -131,12 +143,10 @@ llvm::Optional renameable(const Decl 
&RenameDecl,
 IsMainFileOnly = false;
   else if (!DeclaredInMainFile)
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
-  if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
+  // If the symbol is not indexable, we disallow rename.
+  if (!SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly))
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
@@ -467,13 +477,10 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
 
-  const auto *RenameDecl = 
llvm::dyn_cast(*DeclsUnderCursor.begin());
-  if (!RenameDecl)
-return makeError(ReasonToReject::UnsupportedSymbol);
-
-  auto Reject =
-  renameable(*RenameDecl->getCanonicalDecl(), RInputs.MainFilePath,
- RInputs.Index, RInputs.AllowCrossFile);
+  const auto &RenameDecl =
+  llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index,
+   RInputs.AllowCrossFile);
   if (Reject)
 return makeError(*Reject);
 
@@ -486,7 +493,7 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
   // To make cross-file rename work for local symbol, we use a hybrid solution:
   //   - run AST-based rename on the main file;
   //   - run index-based rename on other affected files;
-  auto MainFileRenameEdit = renameWithinFile(AST, *RenameDecl, 
RInputs.NewName);
+  auto MainFileRenameEdit = renameWithinFile(AST, RenameDecl,

[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG0d893fda4305: [clangd] Add a symbol-name-based blacklist for 
rename. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D73450?vs=240853&id=241068#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450

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

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -383,12 +383,12 @@
 
   // Typedef.
   R"cpp(
-namespace std {
+namespace ns {
 class basic_string {};
 typedef basic_string [[s^tring]];
-} // namespace std
+} // namespace ns
 
-std::[[s^tring]] foo();
+ns::[[s^tring]] foo();
   )cpp",
 
   // Variable.
@@ -540,6 +540,13 @@
  void fo^o() {})cpp",
"used outside main file", !HeaderFile, nullptr /*no index*/},
 
+  {R"cpp(// disallow rename on blacklisted symbols (e.g. std symbols)
+ namespace std {
+ class str^ing {};
+ }
+   )cpp",
+   "not a supported kind", !HeaderFile, Index},
+
   {R"cpp(
  void foo(int);
  void foo(char);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -75,8 +75,8 @@
   return OtherFile;
 }
 
-llvm::DenseSet locateDeclAt(ParsedAST &AST,
-  SourceLocation TokenStartLoc) {
+llvm::DenseSet locateDeclAt(ParsedAST &AST,
+   SourceLocation TokenStartLoc) {
   unsigned Offset =
   AST.getSourceManager().getDecomposedSpellingLoc(TokenStartLoc).second;
 
@@ -85,7 +85,7 @@
   if (!SelectedNode)
 return {};
 
-  llvm::DenseSet Result;
+  llvm::DenseSet Result;
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
@@ -96,6 +96,15 @@
   return Result;
 }
 
+bool isBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
 enum ReasonToReject {
   NoSymbolFound,
   NoIndexProvided,
@@ -105,7 +114,7 @@
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
@@ -120,6 +129,9 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  if (isBlacklisted(RenameDecl))
+return ReasonToReject::UnsupportedSymbol;
+
   // Check whether the symbol being rename is indexable.
   auto &ASTCtx = RenameDecl.getASTContext();
   bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
@@ -131,12 +143,10 @@
 IsMainFileOnly = false;
   else if (!DeclaredInMainFile)
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
-  if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
+  // If the symbol is not indexable, we disallow rename.
+  if (!SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly))
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
@@ -467,13 +477,10 @@
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
 
-  const auto *RenameDecl = llvm::dyn_cast(*DeclsUnderCursor.begin());
-  if (!RenameDecl)
-return makeError(ReasonToReject::UnsupportedSymbol);
-
-  auto Reject =
-  renameable(*RenameDecl->getCanonicalDecl(), RInputs.MainFilePath,
- RInputs.Index, RInputs.AllowCrossFile);
+  const auto &RenameDecl =
+  llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index,
+   RInputs.AllowCrossFile);
   if (Reject)
 return makeError(*Reject);
 
@@ -486,7 +493,7 @@
   // To make cross-file rename work for local symbol, we use a hybrid solution:
   //   - run AST-based rename on the main 

[clang-tools-extra] 4e3f4f0 - [ASTMatchers] StringRef'ify hasName

2020-01-29 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-01-29T10:53:08+01:00
New Revision: 4e3f4f03f3e4dccfac6212a66d54d584fea328a2

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

LOG: [ASTMatchers] StringRef'ify hasName

This was just inconvenient, and we make a copy anyways.

Added: 


Modified: 
clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/AST/DeclPrinterTest.cpp
clang/unittests/AST/NamedDeclPrinterTest.cpp
clang/unittests/AST/StmtPrinterTest.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
clang/unittests/StaticAnalyzer/Reusables.h

Removed: 




diff  --git a/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp 
b/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
index f3bcc2a220fb..4bcb46b39032 100644
--- a/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
+++ b/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
@@ -36,8 +36,7 @@ using llvm::SmallSetVector;
 static const RecordDecl *findDefinition(StringRef RecordName,
 ASTContext &Context) {
   auto Results =
-  match(recordDecl(hasName(std::string(RecordName)), isDefinition())
-.bind("recordDecl"),
+  match(recordDecl(hasName(RecordName), isDefinition()).bind("recordDecl"),
 Context);
   if (Results.empty()) {
 llvm::errs() << "Definition of " << RecordName << "  not found\n";

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp 
b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index d4db02174f50..3466cdbbdcff 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -91,8 +91,7 @@ rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
DurationScale Scale, const Expr &Node) {
   llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
   if (const auto *MaybeCallArg = selectFirst(
-  "e", match(callExpr(callee(functionDecl(
-  hasName(std::string(InverseFunction,
+  "e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
   hasArgument(0, expr().bind("e"))),
  Node, *Result.Context))) {
 return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();

diff  --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
index 78ef1cca36e9..a3866651dced 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
@@ -108,11 +108,11 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder 
*Finder) {
 // a 'Duration'. If we know the result is a 'Duration', we can then infer
 // that the second operand must be a 'Time'.
 auto CallMatcher =
-callExpr(callee(functionDecl(
- 
hasName(std::string(getDurationFactoryForScale(*Scale),
- hasArgument(0, binaryOperator(hasOperatorName("-"),
-   hasLHS(TimeInverseMatcher))
-.bind("binop")))
+callExpr(
+callee(functionDecl(hasName(getDurationFactoryForScale(*Scale,
+hasArgument(0, binaryOperator(hasOperatorName("-"),
+  hasLHS(TimeInverseMatcher))
+   .bind("binop")))
 .bind("outer_call");
 Finder->addMatcher(CallMatcher, this);
 
@@ -160,8 +160,8 @@ void TimeSubtractionCheck::check(const 
MatchFinder::MatchResult &Result) {
 // latter case (addressed first), we also need to worry about parenthesis.
 const auto *MaybeCallArg = selectFirst(
 "arg", match(expr(hasAncestor(
- callExpr(callee(functionDecl(hasName(std::string(
-  getDurationFactoryForScale(*Scale))
+ callExpr(callee(functionDecl(hasName(
+  getDurationFactoryForScale(*Scale)
  .bind("arg"))),
  *BinOp, *Result.Context));
 if (MaybeCallArg && MaybeCallArg->getArg(0)->IgnoreImpCasts() == BinOp &&

diff  --git 
a/clang-tools-extra/clang-tidy/google/UpgradeG

[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62257 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D72829#1846157 , @serge-sans-paille 
wrote:

> @arichardson doc updated, any other advice?


No comments on the code just wondering if the documentation should be expanded.
I just came across this review by chance and it was not clear to me what 
"Enable semantic interposition" means.
I had to read the code and look the GCC documentation+llvm mailing list posts 
to understand it.

As this is user-facing documentation I feel like there should be a slightly 
longer explaning what the option does.

For comparison here is the GCC command line flag documentation

  -fsemantic-interposition
  Some object formats, like ELF, allow interposing of symbols by the dynamic 
linker. This means that for symbols exported from the DSO, the compiler cannot 
perform interprocedural propagation, inlining and other optimizations in 
anticipation that the function or variable in question may change. While this 
feature is useful, for example, to rewrite memory allocation functions by a 
debugging implementation, it is expensive in the terms of code quality. With 
-fno-semantic-interposition the compiler assumes that if interposition happens 
for functions the overwriting function will have precisely the same semantics 
(and side effects). Similarly if interposition happens for variables, the 
constructor of the variable will be the same. The flag has no effect for 
functions explicitly declared inline (where it is never allowed for 
interposition to change semantics) and for symbols explicitly declared weak.

Other than this, the change looks good to me.




Comment at: clang/docs/ClangCommandLineReference.rst:907
+
+.. option:: -fsemantic-interposition, -fno-semantic-interposition
+

arichardson wrote:
> This looks like it should be reordered?
Sorry I mean that it looks like all other entries are `.. option::` followed by 
the description but here it's the other way around. It seems like this change 
will make the documention of -fsanitize-* be `Enable semantic interposition`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73457: [Clang] Warn about 'z' printf modifier in old MSVC.

2020-01-29 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

I now realise that my previous comment was nonsense: looking at @thakis's link 
more carefully, there are actually 5 failing tests that are nothing to do with 
the one I modified, and a lot of them don't even have any obvious 
`-fms-extension` option in the cc1 command line at all. (Perhaps clang will 
even turn //that// on automatically when it autodetects MSVC in the 
environment?) So just fixing my own test differently wouldn't help.

So I don't know what to propose. I'd like to see this error check reland, but I 
see that it will take some work before the test suite is sufficiently 
environment-independent to not make it cause this kind of problem all over the 
place.

Right off the top of my head, one thought that strikes me is: why is 
auto-detection of MS compat mode from the environment happening in //cc1?// 
(Which I assume it must be, if those cc1 tests are failing.) If the point of it 
is to make clang-cl a drop-in replacement for the `cl.exe` installed on the 
same system, would it not make more sense to do the auto-detection in the 
clang-cl driver, and pass explicit options to cc1 containing whatever was 
detected (if it wasn't overridden by the driver command line)? Then cc1 would 
behave the same everywhere given the same command line, and all the cc1 runs in 
the test suite would be automatically stable, and the only place you'd have to 
take care would be in tests of the clang-cl driver itself. But that's the kind 
of structural change that would surely cause a completely different collection 
of failures in places nobody would have thought of :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73457



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


[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Nice, thanks!




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:322
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+

Agree that this behavior is OK per the spec, but do we actually prefer it/why 
the change?

Seems like clients are marginally more likely to handle null 
incorrectly/silently, and we give up control over the message.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:324
+
+auto Range = getTokenRange(AST.getSourceManager(), AST.getLangOpts(),
+   TouchingIdentifier->location());

this runs the lexer to compute token boundaries. We actually already have them: 
syntax::Token has endLocation/length



Comment at: clang-tools-extra/clangd/SourceCode.h:302
 
+/// Returns the identifier token that touches the given \p Pos
+/// Redturns nullptr if there is none.

I don't think this function improves things vs keeping it inline:
 - wrapping clang functions to adapt them to our data types doesn't seem 
sustainable
 - it's hard to draw the line, but this one neither hides logic (saves 2 
trivial lines) nor is very commonly used (yet)
 - this breaks a (minor) error-handling path: an invalid range is no longer 
reported to the client as an error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610



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


[PATCH] D73612: [clangd] Update lsp dependencies to pickup the progress support in LSP 3.15

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73612

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json


Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",


Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73613

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -581,6 +581,9 @@
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
@@ -1587,6 +1590,26 @@
 HI.Parameters = {
 {std::string("int"), std::string("x"), llvm::None}};
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1604,6 +1627,9 @@
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-Wno-gnu-designator");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), Index.get());
@@ -1836,46 +1862,6 @@
 def)pt";
   EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
-
-TEST(Hover, ExprTests) {
-  struct {
-const char *const Code;
-const std::function ExpectedBuilder;
-  } Cases[] = {
-  {
-  R"cpp(// sizeof expr
-  void foo() {
-(void)[[size^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  {
-  R"cpp(// alignof expr
-  void foo() {
-(void)[[align^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  };
-  for (const auto &C : Cases) {
-Annotations T(C.Code);
-TestTU TU = TestTU::withCode(T.code());
-auto AST = TU.build();
-auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
-ASSERT_TRUE(H);
-HoverInfo ExpectedHover;
-C.ExpectedBuilder(ExpectedHover);
-// We don't check for Type as it might differ on different platforms.
-EXPECT_EQ(H->Name, ExpectedHover.Name);
-EXPECT_EQ(H->Value, ExpectedHover.Value);
-  }
-}
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -581,6 +581,9 @@
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
@@ -1587,6 +1590,26 @@
 HI.Parameters = {
 {std::string("int"), std::string("x"), llvm::None}};
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "u

[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:583
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be different depending on the target triplet, we chose a

Is this redundant now? I think the default value here comes from the triple.
(Maybe want to leave it so we have the most-trivial-possible-change for the 
branch, but add a FIXME)



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:586
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();

this is a good fix for the branch.
For trunk, should we do this in TestTU (i.e. for everything?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613



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


[PATCH] D73612: [clangd] Update lsp dependencies to pickup the progress support in LSP 3.15

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62283 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73612



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


[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62269 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613



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


[PATCH] D73347: [AArch64][SVE] Add SVE2 intrinsics for pairwise arithmetic

2020-01-29 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd33a46213d3: [AArch64][SVE] Add SVE2 intrinsics for 
pairwise arithmetic (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73347

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-pairwise-arith.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-pairwise-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-pairwise-arith.ll
@@ -0,0 +1,77 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SADALP
+;
+
+define  @sadalp_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: sadalp_i8:
+; CHECK: sadalp z0.h, p0/m, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sadalp.nxv8i16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @sadalp_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: sadalp_i16:
+; CHECK: sadalp z0.s, p0/m, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sadalp.nxv4i32( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @sadalp_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: sadalp_i32:
+; CHECK: sadalp z0.d, p0/m, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sadalp.nxv2i64( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+;
+; UADALP
+;
+
+define  @uadalp_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: uadalp_i8:
+; CHECK: uadalp z0.h, p0/m, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uadalp.nxv8i16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @uadalp_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: uadalp_i16:
+; CHECK: uadalp z0.s, p0/m, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uadalp.nxv4i32( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @uadalp_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: uadalp_i32:
+; CHECK: uadalp z0.d, p0/m, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uadalp.nxv2i64( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.sadalp.nxv8i16(, , )
+declare  @llvm.aarch64.sve.sadalp.nxv4i32(, , )
+declare  @llvm.aarch64.sve.sadalp.nxv2i64(, , )
+
+declare  @llvm.aarch64.sve.uadalp.nxv8i16(, , )
+declare  @llvm.aarch64.sve.uadalp.nxv4i32(, , )
+declare  @llvm.aarch64.sve.uadalp.nxv2i64(, , )
Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll
===
--- llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll
@@ -1,6 +1,50 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
 
 ;
+; ADDP
+;
+
+define  @addp_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: addp_i8:
+; CHECK: addp z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.addp.nxv16i8( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @addp_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: addp_i16:
+; CHECK: addp z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.addp.nxv8i16( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @addp_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: addp_i32:
+; CHECK: addp z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.addp.nxv4i32( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @addp_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: addp_i64:
+; CHECK: addp z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.addp.nxv2i64( %pg,
+ %a,
+  

[clang] ac21535 - [ARM] Add documentation for -march= and -mfpu= command line options

2020-01-29 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2020-01-29T10:39:01Z
New Revision: ac215354607450191b9d63be72c00efe36b53a1c

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

LOG: [ARM] Add documentation for -march= and -mfpu= command line options

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 5b8a96b61b3d..eb0519988fa2 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2445,10 +2445,150 @@ ARM
 
 Reserve the r9 register (ARM only)
 
+.. option:: -march=[+...]
+
+Specify the target Arm ISA.
+
+The list of accepted architecture names is as follows:
+``armv2``, ``armv2a``,
+``armv3``, ``armv3m``,
+``armv4``, ``armv4t``,
+``armv5t``, ``armv5te``,
+``armv6``, ``armv6k``, ``armv6t2``, ``armv6kz``, ``armv6-m``,
+``armv7-a``, ``armv7ve``, ``armv7-r``, ``armv7-m``, ``armv7e-m``,
+``armv8-a``, ``armv8.1-a``, ``armv8.2-a``, ``armv8.3-a``, ``armv8.5-a``, 
``armv8-r``,
+``armv8-m.base``, ``armv8-m.main``, ``armv8.1-m.main``,
+``iwmmxt``,
+``iwmmxt2``,
+``xscale``,
+``armv7s``,
+``armv7k``
+
+Extension modifiers can be used to enable optional architecture features. The
+syntax ``+no`` can be used to disable previously enabled features.
+
+Some of the extension names are generic, but have an architecture specific
+effect.  For example, the extension syntax ``+fp`` might enable FPv4-SP-D16 for
+the Armv7-M architecture, but VFPv3-D16 for the Armv7-A arrchitecture.
+
+The following extension names are recognised:
+
+``+crc``
+Enable Cyclic Redundancy Check instructions
+``+crypto``
+Enable cryptographic instructions
+``+sha2``
+Enable SHA1 and SHA256 support instructions
+``+aes``
+Enable AES support instructions
+``+dotprod``
+Enable dot product instructions
+``+dsp``
+Enable digital signal processing (DSP) instructions in ARM and Thumb2
+``+fp``
+Enable floating-point instructions for the baseline FPU implementation
+available for the given architecture
+``+fp.dp``
+Enable optional double-precision floating-point instructions
+``+mve``
+Enable integer-only MVE instructions. This extension also implicitly 
enables
+the DSP extension.
+``+mve.fp``
+Enable floating-point MVE instructions. This extension also implicitly
+enables the MVE, DSP, FP16, and FPv5-sp-d16 extensions.
+``+idiv``
+Enables the interget divide instructions in ARM and Thumb2
+``+mp``
+Enabled the Multiprocessing extension
+``+simd``
+Enables the baseline SIMD instructions for the given architecture
+``+sec``
+Enable TrustZone security extension
+``+virt``
+Enable Viritualization extensions
+``+fp16``
+Enable half-precision floating-point instructions
+``+ras``
+Enable Reliability, Availability, and Serviceability extensions
+``+fp16fml``
+Enable half-precision floating-point fused multiply-add/sub instructions
+``+sb``
+Enable v8.5a Speculation Barrier
+``+lob``
+   Enable Low Overhead Branch extensions
+
 .. option:: -mexecute-only, -mno-execute-only, -mpure-code
 
 Disallow generation of data access to code sections (ARM only)
 
+.. option:: -mfpu=
+
+Specify floating-point unit (or lack thereof) that is available on the target.
+
+The accepted values for  are:
+
+``none``
+Prevent the compiler from using floating-point instructions.
+``vfp``
+
+``vfpv2``
+Enable VFPv2 instructions. Disable the Advanced SIMD extension.
+``vfpv3``
+Enable VFPv3 instructions. Disable the Advanced SIMD extension.
+``vfpv3-fp16``
+Enable VFPv3 instructions, including optional half-precision instructions.
+Disable the Advanced SIMD extension.
+``vfpv3-d16``
+Enable VFPv3 instructions, with access to only 16 double-precision
+registers. Disable the Advanced SIMD extension.
+``vfpv3-d16-fp16``
+Enable VFPv3 instructions, including optional half-precision instructions,
+with access to only 16 double-precision registers. Disable the Advanced
+SIMD extension.
+``vfpv3xd``
+Enable VFPv3 insructions, with single-precision floating-point operations
+only and just 16 double-precision registers. Disable the Advanced SIMD
+extension.
+``vfpv3xd-fp16``
+Enable VFPv3 instructions, with single-precision and half-precision,
+floating-point operations only. Disable the Advanced SIMD extension.
+``vfpv4``
+Enable VFPv4 instructions. Disable the Advanced SIMD extension.
+``vfpv4-d16``
+Enable VFPv4 instructions, with access to only 16 double-precision
+registers. Disable the Advanced SIMD extension.
+``fpv4-sp-d16``
+Enable the Armv7-M FPv4-SP-D16 floating-point extension, with

[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-29 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 4 inline comments as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:41
+   auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+

aaron.ballman wrote:
> njames93 wrote:
> > Quuxplusone wrote:
> > > Is it worth adding an example of a double pointer?
> > > 
> > > auto BarN = cast(FooN);
> > > 
> > > Does that become `auto*` or `auto**` (and why)? My wild guess is that it 
> > > becomes `auto*` (and because nobody cares about double pointers), but I 
> > > could be wrong.
> > Double pointers are just resolved to `auto *`.
> They resolve to `auto *` today but I could see a real argument that they 
> should resolve to `auto **` instead based on the same logic of: don't make 
> the reader infer pointer/references and qualifiers.
One change per patch...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73459: [ARM] Add documentation for -march= and -mfpu= command line options

2020-01-29 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac2153546074: [ARM] Add documentation for -march= and -mfpu= 
command line options (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73459

Files:
  clang/docs/ClangCommandLineReference.rst

Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -2445,10 +2445,150 @@
 
 Reserve the r9 register (ARM only)
 
+.. option:: -march=[+...]
+
+Specify the target Arm ISA.
+
+The list of accepted architecture names is as follows:
+``armv2``, ``armv2a``,
+``armv3``, ``armv3m``,
+``armv4``, ``armv4t``,
+``armv5t``, ``armv5te``,
+``armv6``, ``armv6k``, ``armv6t2``, ``armv6kz``, ``armv6-m``,
+``armv7-a``, ``armv7ve``, ``armv7-r``, ``armv7-m``, ``armv7e-m``,
+``armv8-a``, ``armv8.1-a``, ``armv8.2-a``, ``armv8.3-a``, ``armv8.5-a``, ``armv8-r``,
+``armv8-m.base``, ``armv8-m.main``, ``armv8.1-m.main``,
+``iwmmxt``,
+``iwmmxt2``,
+``xscale``,
+``armv7s``,
+``armv7k``
+
+Extension modifiers can be used to enable optional architecture features. The
+syntax ``+no`` can be used to disable previously enabled features.
+
+Some of the extension names are generic, but have an architecture specific
+effect.  For example, the extension syntax ``+fp`` might enable FPv4-SP-D16 for
+the Armv7-M architecture, but VFPv3-D16 for the Armv7-A arrchitecture.
+
+The following extension names are recognised:
+
+``+crc``
+Enable Cyclic Redundancy Check instructions
+``+crypto``
+Enable cryptographic instructions
+``+sha2``
+Enable SHA1 and SHA256 support instructions
+``+aes``
+Enable AES support instructions
+``+dotprod``
+Enable dot product instructions
+``+dsp``
+Enable digital signal processing (DSP) instructions in ARM and Thumb2
+``+fp``
+Enable floating-point instructions for the baseline FPU implementation
+available for the given architecture
+``+fp.dp``
+Enable optional double-precision floating-point instructions
+``+mve``
+Enable integer-only MVE instructions. This extension also implicitly enables
+the DSP extension.
+``+mve.fp``
+Enable floating-point MVE instructions. This extension also implicitly
+enables the MVE, DSP, FP16, and FPv5-sp-d16 extensions.
+``+idiv``
+Enables the interget divide instructions in ARM and Thumb2
+``+mp``
+Enabled the Multiprocessing extension
+``+simd``
+Enables the baseline SIMD instructions for the given architecture
+``+sec``
+Enable TrustZone security extension
+``+virt``
+Enable Viritualization extensions
+``+fp16``
+Enable half-precision floating-point instructions
+``+ras``
+Enable Reliability, Availability, and Serviceability extensions
+``+fp16fml``
+Enable half-precision floating-point fused multiply-add/sub instructions
+``+sb``
+Enable v8.5a Speculation Barrier
+``+lob``
+   Enable Low Overhead Branch extensions
+
 .. option:: -mexecute-only, -mno-execute-only, -mpure-code
 
 Disallow generation of data access to code sections (ARM only)
 
+.. option:: -mfpu=
+
+Specify floating-point unit (or lack thereof) that is available on the target.
+
+The accepted values for  are:
+
+``none``
+Prevent the compiler from using floating-point instructions.
+``vfp``
+
+``vfpv2``
+Enable VFPv2 instructions. Disable the Advanced SIMD extension.
+``vfpv3``
+Enable VFPv3 instructions. Disable the Advanced SIMD extension.
+``vfpv3-fp16``
+Enable VFPv3 instructions, including optional half-precision instructions.
+Disable the Advanced SIMD extension.
+``vfpv3-d16``
+Enable VFPv3 instructions, with access to only 16 double-precision
+registers. Disable the Advanced SIMD extension.
+``vfpv3-d16-fp16``
+Enable VFPv3 instructions, including optional half-precision instructions,
+with access to only 16 double-precision registers. Disable the Advanced
+SIMD extension.
+``vfpv3xd``
+Enable VFPv3 insructions, with single-precision floating-point operations
+only and just 16 double-precision registers. Disable the Advanced SIMD
+extension.
+``vfpv3xd-fp16``
+Enable VFPv3 instructions, with single-precision and half-precision,
+floating-point operations only. Disable the Advanced SIMD extension.
+``vfpv4``
+Enable VFPv4 instructions. Disable the Advanced SIMD extension.
+``vfpv4-d16``
+Enable VFPv4 instructions, with access to only 16 double-precision
+registers. Disable the Advanced SIMD extension.
+``fpv4-sp-d16``
+Enable the Armv7-M FPv4-SP-D16 floating-point extension, with
+single-precision floating-point operations only, and only 16
+double-precision registers.
+``fpv5-d16``
+Enable the Armv7-M FPv5-D16 floating-point extension,

[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 241082.
njames93 added a comment.

- Always add const to `auto` typed variable.

This update adds const to variables just typed with `auto`, but wont enforce 
checking on `auto *` or `auto &` unless `AddConstToQualified` is set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548

Files:
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
  clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s llvm-qualified-auto %t
+
+// This check just ensures by default the llvm alias doesn't add const
+// qualifiers to decls, so no need to copy the entire test file from
+// readability-qualified-auto.
+
+int *getIntPtr();
+const int *getCIntPtr();
+
+void foo() {
+  auto NakedPtr = getIntPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedPtr' can be declared as 'auto *NakedPtr'
+  // CHECK-FIXES: {{^}}  auto *NakedPtr = getIntPtr();
+  auto NakedConstPtr = getCIntPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedConstPtr' can be declared as 'const auto *NakedConstPtr'
+  // CHECK-FIXES: {{^}}  const auto *NakedConstPtr = getCIntPtr();
+  auto *Ptr = getIntPtr();
+  auto *ConstPtr = getCIntPtr();
+  auto &NakedRef = *getIntPtr();
+  auto &NakedConstRef = *getCIntPtr();
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
@@ -3,23 +3,16 @@
 readability-qualified-auto
 ==
 
-Adds pointer and ``const`` qualifications to ``auto``-typed variables that are deduced
-to pointers and ``const`` pointers.
+Adds pointer qualifications to ``auto``-typed variables that are deduced to 
+pointers.
 
-`LLVM Coding Standards `_ advises to
-make it obvious if a ``auto`` typed variable is a pointer, constant pointer or 
-constant reference. This check will transform ``auto`` to ``auto *`` when the 
-type is deduced to be a pointer, as well as adding ``const`` when applicable to
-``auto`` pointers or references
+`LLVM Coding Standards `_
+advises to make it obvious if a ``auto`` typed variable is a pointer. This 
+check will transform ``auto`` to ``auto *`` when the type is deduced to be a
+pointer.
 
 .. code-block:: c++
 
-  for (auto &Data : MutatableContainer) {
-change(Data);
-  }
-  for (auto &Data : ConstantContainer) {
-observe(Data);
-  }
   for (auto Data : MutatablePtrContainer) {
 change(*Data);
   }
@@ -31,12 +24,6 @@
 
 .. code-block:: c++
 
-  for (auto &Data : MutatableContainer) {
-change(Data);
-  }
-  for (const auto &Data : ConstantContainer) {
-observe(Data);
-  }
   for (auto *Data : MutatablePtrContainer) {
 change(*Data);
   }
@@ -48,17 +35,47 @@
 
 .. code-block:: c++
 
-  const auto Foo = cast(Baz1);
-  const auto Bar = cast(Baz2);
-  volatile auto FooBar = cast(Baz3);
+   const auto Foo = cast(Baz1);
+   const auto Bar = cast(Baz2);
+   volatile auto FooBar = cast(Baz3);
 
 Would be transformed into:
 
 .. code-block:: c++
 
-  auto *const Foo = cast(Baz1);
-  const auto *const Bar = cast(Baz2);
-  auto *volatile FooBar = cast(Baz3);
+   auto *const Foo = cast(Baz1);
+   const auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+
+Options
+---
+
+.. option:: AddConstToQualified
+   
+   When set to `1` the check will add const qualifiers variables defined as
+   ``auto *`` or ``auto &`` when applicable.
+   Default value is '1'.
+
+.. code-block:: c++
+
+   auto Foo1 = cast(Bar1);
+   auto *Foo2 = cast(Bar2);
+   auto &Foo3 = cast(Bar3);
+
+   If AddConstToQualified is set to `0`,  it will be transformed into:
+
+.. code-block:: c++
+
+   const auto *Foo1 = cast(Bar1);
+   auto *Foo2 = cast(Bar2);
+   auto &Foo3 = cast(Bar3);
+
+   Otherwise it will be transformed into:
+
+.. code-block:: c++
+
+   const auto *Foo1 = cast(Bar1);
+   const auto *Foo2 = cast(Bar2);
+   const auto &Foo3 = cast(Bar3);
 
-This check helps to enforce this `LLVM Coding Standards recommendation
-`_.
+   Note in the LLVM alias, the default value is

[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:583
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be different depending on the target triplet, we chose a

sammccall wrote:
> Is this redundant now? I think the default value here comes from the triple.
> (Maybe want to leave it so we have the most-trivial-possible-change for the 
> branch, but add a FIXME)
right adding a fixme and sending a follow-up patch



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:586
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();

sammccall wrote:
> this is a good fix for the branch.
> For trunk, should we do this in TestTU (i.e. for everything?)
it depends, as you've noted this will result in not testing some of the 
platform dependent bits in other tests as well.
e.g. code completion, some code actions behaves differently on templates on 
windows, we currently don't act on them(apart from putting necessary flags to 
make behavior similar to what we care). But at least we notice them via 
breakages in buildbots, if we put that into TestTU we might not notice such 
differences until users report so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613



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


[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 241085.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Add fixme for delayed-template-parsing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,7 +580,12 @@
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
+// FIXME: This is no longer necessary, as the default behavior is no delayed
+// parsing in the triplet below.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
@@ -1587,6 +1592,26 @@
 HI.Parameters = {
 {std::string("int"), std::string("x"), llvm::None}};
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1604,6 +1629,9 @@
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-Wno-gnu-designator");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), Index.get());
@@ -1836,46 +1864,6 @@
 def)pt";
   EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
-
-TEST(Hover, ExprTests) {
-  struct {
-const char *const Code;
-const std::function ExpectedBuilder;
-  } Cases[] = {
-  {
-  R"cpp(// sizeof expr
-  void foo() {
-(void)[[size^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  {
-  R"cpp(// alignof expr
-  void foo() {
-(void)[[align^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  };
-  for (const auto &C : Cases) {
-Annotations T(C.Code);
-TestTU TU = TestTU::withCode(T.code());
-auto AST = TU.build();
-auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
-ASSERT_TRUE(H);
-HoverInfo ExpectedHover;
-C.ExpectedBuilder(ExpectedHover);
-// We don't check for Type as it might differ on different platforms.
-EXPECT_EQ(H->Name, ExpectedHover.Name);
-EXPECT_EQ(H->Value, ExpectedHover.Value);
-  }
-}
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62275 tests passed, 1 failed 
and 827 were skipped.

  failed: Clang.CodeGenOpenCL/amdgpu-features.cl

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[clang-tools-extra] 0ee4b02 - Fix an implicit conversion in clang-tidy. GCC 5 complains about it.

2020-01-29 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-01-29T12:05:35+01:00
New Revision: 0ee4b027d37e45391bdd872911c61756d0958722

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

LOG: Fix an implicit conversion in clang-tidy. GCC 5 complains about it.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 28d923d9d543..163c353681bc 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -174,7 +174,8 @@ class ClangTidyContext {
 return DiagLevelAndFormatString(
 static_cast(
 DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
-DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID));
+std::string(
+DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
   }
 
 private:



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


[PATCH] D73615: [clangd] Get rid of delayed template parsing

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

No need to pass fno-delayed-template-parsing as the opposite flag is
only passed to cc1 when abi is set to msvc. Sending as a follow-up to D73613 
 to
keep changes in the release branch minimal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73615

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,9 +580,6 @@
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
-// FIXME: This is no longer necessary, as the default behavior is no 
delayed
-// parsing in the triplet below.
-TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
 // Types might be different depending on the target triplet, we chose a
 // fixed one to make sure tests passes on different platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,9 +580,6 @@
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
-// FIXME: This is no longer necessary, as the default behavior is no delayed
-// parsing in the triplet below.
-TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
 // Types might be different depending on the target triplet, we chose a
 // fixed one to make sure tests passes on different platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73612: [clangd] Update lsp dependencies to pickup the progress support in LSP 3.15

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG. (The internal google mirror of VSCode is stuck at 1.38, but this should 
just fail to update the extension I think)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73612



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


[PATCH] D73615: [clangd] Get rid of delayed template parsing

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73615



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


[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:586
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();

kadircet wrote:
> sammccall wrote:
> > this is a good fix for the branch.
> > For trunk, should we do this in TestTU (i.e. for everything?)
> it depends, as you've noted this will result in not testing some of the 
> platform dependent bits in other tests as well.
> e.g. code completion, some code actions behaves differently on templates on 
> windows, we currently don't act on them(apart from putting necessary flags to 
> make behavior similar to what we care). But at least we notice them via 
> breakages in buildbots, if we put that into TestTU we might not notice such 
> differences until users report so.
Currently we fix such issues by slapping -fno-delayed-template-parsing 
everywhere though. (Or often other people do it for us).

Heh, we could have TestTU grab a CLANGD_EXTRA_FLAGS environment variable, and 
make it easy to test delayed parsing on linux occasionally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613



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


[clang-tools-extra] 7830c2d - [clangd] Get rid of delayed template parsing

2020-01-29 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-29T12:12:45+01:00
New Revision: 7830c2d44f531bbe09f997436b6608a140db46fb

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

LOG: [clangd] Get rid of delayed template parsing

Summary:
No need to pass fno-delayed-template-parsing as the opposite flag is
only passed to cc1 when abi is set to msvc. Sending as a follow-up to D73613 to
keep changes in the release branch minimal.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 5f8f0560a3ee..894de7dfc251 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,9 +580,6 @@ class Foo {})cpp";
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
-// FIXME: This is no longer necessary, as the default behavior is no 
delayed
-// parsing in the triplet below.
-TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
 // Types might be 
diff erent depending on the target triplet, we chose a
 // fixed one to make sure tests passes on 
diff erent platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");



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


[clang-tools-extra] 55b0e9c - [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-29T12:12:45+01:00
New Revision: 55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b

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

LOG: [clangd][Hover] Make tests hermetic by setting target triplet

Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=44696

Reviewers: sammccall

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 758c64208fd8..5f8f0560a3ee 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,7 +580,12 @@ class Foo {})cpp";
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
+// FIXME: This is no longer necessary, as the default behavior is no 
delayed
+// parsing in the triplet below.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be 
diff erent depending on the target triplet, we chose a
+// fixed one to make sure tests passes on 
diff erent platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
@@ -1587,6 +1592,26 @@ TEST(Hover, All) {
 HI.Parameters = {
 {std::string("int"), std::string("x"), llvm::None}};
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1604,6 +1629,9 @@ TEST(Hover, All) {
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-Wno-gnu-designator");
+// Types might be 
diff erent depending on the target triplet, we chose a
+// fixed one to make sure tests passes on 
diff erent platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), Index.get());
@@ -1836,46 +1864,6 @@ Value = val
 def)pt";
   EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
-
-TEST(Hover, ExprTests) {
-  struct {
-const char *const Code;
-const std::function ExpectedBuilder;
-  } Cases[] = {
-  {
-  R"cpp(// sizeof expr
-  void foo() {
-(void)[[size^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  {
-  R"cpp(// alignof expr
-  void foo() {
-(void)[[align^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  };
-  for (const auto &C : Cases) {
-Annotations T(C.Code);
-TestTU TU = TestTU::withCode(T.code());
-auto AST = TU.build();
-auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
-ASSERT_TRUE(H);
-HoverInfo ExpectedHover;
-C.ExpectedBuilder(ExpectedHover);
-// We don't check for Type as it might 
diff er on 
diff erent platforms.
-EXPECT_EQ(H->Name, ExpectedHover.Name);
-EXPECT_EQ(H->Value, ExpectedHover.Value);
-  }
-}
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62269 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613



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


[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG55b0e9c9d5de: [clangd][Hover] Make tests hermetic by setting 
target triplet (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73613

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,7 +580,12 @@
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
+// FIXME: This is no longer necessary, as the default behavior is no delayed
+// parsing in the triplet below.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
@@ -1587,6 +1592,26 @@
 HI.Parameters = {
 {std::string("int"), std::string("x"), llvm::None}};
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1604,6 +1629,9 @@
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
 TU.ExtraArgs.push_back("-Wno-gnu-designator");
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
 auto AST = TU.build();
 
 auto H = getHover(AST, T.point(), format::getLLVMStyle(), Index.get());
@@ -1836,46 +1864,6 @@
 def)pt";
   EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
-
-TEST(Hover, ExprTests) {
-  struct {
-const char *const Code;
-const std::function ExpectedBuilder;
-  } Cases[] = {
-  {
-  R"cpp(// sizeof expr
-  void foo() {
-(void)[[size^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  {
-  R"cpp(// alignof expr
-  void foo() {
-(void)[[align^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  };
-  for (const auto &C : Cases) {
-Annotations T(C.Code);
-TestTU TU = TestTU::withCode(T.code());
-auto AST = TU.build();
-auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
-ASSERT_TRUE(H);
-HoverInfo ExpectedHover;
-C.ExpectedBuilder(ExpectedHover);
-// We don't check for Type as it might differ on different platforms.
-EXPECT_EQ(H->Name, ExpectedHover.Name);
-EXPECT_EQ(H->Value, ExpectedHover.Value);
-  }
-}
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73615: [clangd] Get rid of delayed template parsing

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7830c2d44f53: [clangd] Get rid of delayed template parsing 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73615

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,9 +580,6 @@
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
-// FIXME: This is no longer necessary, as the default behavior is no 
delayed
-// parsing in the triplet below.
-TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
 // Types might be different depending on the target triplet, we chose a
 // fixed one to make sure tests passes on different platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -580,9 +580,6 @@
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.ExtraArgs.push_back("-std=c++17");
-// FIXME: This is no longer necessary, as the default behavior is no delayed
-// parsing in the triplet below.
-TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
 // Types might be different depending on the target triplet, we chose a
 // fixed one to make sure tests passes on different platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73617: [clangd] Don't mmap source files on all platforms --> don't crash on git checkout

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
sammccall added reviewers: ilya-biryukov, kadircet.
sammccall edited the summary of this revision.

Previously we mmapped on unix and not on windows: on windows mmap takes
an exclusive lock on the file and prevents the user saving changes!

The failure mode on linux is a bit more subtle: if the file is changed on disk
but the SourceManager sticks around, then subsequent operations on the
SourceManager will fail as invariants are violated (e.g. null-termination).

This commonly manifests as crashes after switching git branches with many files
open in clangd.

Nominally mmap is for performance here, and we should be willing to give some
up to stop crashing. Measurements on my system (linux+desktop+SSD) at least
show no measurable regression on an a fairly IO-heavy workload: drop disk 
caches,
open SemaOverload.cpp, wait for first diagnostics.

  for i in `seq 100`; do
for variant in mmap volatile; do
  echo 3 | sudo tee /proc/sys/vm/drop_caches
  /usr/bin/time --append --quiet -o ~/timings -f "%C %E" \
  bin/clangd.$variant -sync -background-index=0 < /tmp/mirror > /dev/null
done
  done

bin/clangd.mmap -sync -background-index=0 0:07.60
bin/clangd.volatile -sync -background-index=0 0:07.89
bin/clangd.mmap -sync -background-index=0 0:07.44
bin/clangd.volatile -sync -background-index=0 0:07.89
bin/clangd.mmap -sync -background-index=0 0:07.42
bin/clangd.volatile -sync -background-index=0 0:07.50
bin/clangd.mmap -sync -background-index=0 0:07.90
bin/clangd.volatile -sync -background-index=0 0:07.53
bin/clangd.mmap -sync -background-index=0 0:07.64
bin/clangd.volatile -sync -background-index=0 0:07.55
bin/clangd.mmap -sync -background-index=0 0:07.75
bin/clangd.volatile -sync -background-index=0 0:07.47
bin/clangd.mmap -sync -background-index=0 0:07.90
bin/clangd.volatile -sync -background-index=0 0:07.50
bin/clangd.mmap -sync -background-index=0 0:07.81
bin/clangd.volatile -sync -background-index=0 0:07.95
bin/clangd.mmap -sync -background-index=0 0:07.55
bin/clangd.volatile -sync -background-index=0 0:07.65
bin/clangd.mmap -sync -background-index=0 0:08.15
bin/clangd.volatile -sync -background-index=0 0:07.54
bin/clangd.mmap -sync -background-index=0 0:07.78
bin/clangd.volatile -sync -background-index=0 0:07.61
bin/clangd.mmap -sync -background-index=0 0:07.78
bin/clangd.volatile -sync -background-index=0 0:07.55
bin/clangd.mmap -sync -background-index=0 0:07.41
bin/clangd.volatile -sync -background-index=0 0:07.40
bin/clangd.mmap -sync -background-index=0 0:07.54
bin/clangd.volatile -sync -background-index=0 0:07.42
bin/clangd.mmap -sync -background-index=0 0:07.45
bin/clangd.volatile -sync -background-index=0 0:07.49
bin/clangd.mmap -sync -background-index=0 0:07.95
bin/clangd.volatile -sync -background-index=0 0:07.66
bin/clangd.mmap -sync -background-index=0 0:08.04


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73617

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


Index: clang-tools-extra/clangd/FSProvider.h
===
--- clang-tools-extra/clangd/FSProvider.h
+++ clang-tools-extra/clangd/FSProvider.h
@@ -30,7 +30,6 @@
 
 class RealFileSystemProvider : public FileSystemProvider {
 public:
-  // FIXME: returns the single real FS instance, which is not threadsafe.
   llvm::IntrusiveRefCntPtr
   getFileSystem() const override;
 };
Index: clang-tools-extra/clangd/FSProvider.cpp
===
--- clang-tools-extra/clangd/FSProvider.cpp
+++ clang-tools-extra/clangd/FSProvider.cpp
@@ -19,7 +19,10 @@
 
 namespace {
 /// Always opens files in the underlying filesystem as "volatile", meaning they
-/// won't be memory-mapped. This avoid locking the files on Windows.
+/// won't be memory-mapped. Memory-mapping isn't desirable for clangd:
+///   - edits to the underlying files change contents MemoryBuffers owned by
+//  SourceManager, breaking its invariants and leading to crashes
+///   - it locks files on windows, preventing edits
 class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
 public:
   explicit VolatileFileSystem(llvm::IntrusiveRefCntPtr FS)
@@ -34,7 +37,7 @@
 if (!File)
   return File;
 // Try to guess preamble files, they can be memory-mapped even on Windows 
as
-// clangd has exclusive access to those.
+// clangd has exclusive access to those and nothing else should touch them.
 llvm::StringRef FileName = llvm::sys::path::filename(Path);
 if (FileName.startswith("preamble-") && FileName.endswith(".pch"))
   return File;
@@ -70,15 +73,11 @@
 
 llvm::IntrusiveRefCntPtr
 clang::clangd::RealFileSystemProvider::getFileSystem() const {
-// Avoid using memory-mapped files on Windows, they cause file locking i

[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241095.
hokein marked 4 inline comments as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/test/rename.test


Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the 
given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 
{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -21,6 +21,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,16 +316,21 @@
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
-if (!Range)
-  return CB(llvm::None); // "rename" is not valid at the position.
+auto Loc = sourceLocationInMainFile(SM, Pos);
+if (!Loc)
+  return CB(Loc.takeError());
+const auto *TouchingIdentifier =
+spelledIdentifierTouching(*Loc, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+auto Range = halfOpenToRange(
+SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
+  TouchingIdentifier->endLocation()));
 
 if (CrossFileRename)
   // FIXME: we now assume cross-file rename always succeeds, revisit this.
-  return CB(*Range);
+  return CB(Range);
 
 // Performing the local rename isn't substantially more expensive than
 // doing an AST-based check, so we just rename and throw away the results.
@@ -338,7 +343,7 @@
   // the message to users (VSCode does).
   return CB(Changes.takeError());
 }
-return CB(*Range);
+return CB(Range);
   };
   WorkScheduler.runWithAST("PrepareRename", File, std::move(Action));
 }


Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 {"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -21,6 +21,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
Index: clang-tools-extra/clangd/ClangdServer.cpp
=

[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:322
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+

sammccall wrote:
> Agree that this behavior is OK per the spec, but do we actually prefer it/why 
> the change?
> 
> Seems like clients are marginally more likely to handle null 
> incorrectly/silently, and we give up control over the message.
> Agree that this behavior is OK per the spec, but do we actually prefer it/why 
> the change?

I checked with VSCode, it seems fine (`the element can't be renamed`), and YCM 
(but it doesn't support prepare rename yet). Are you suggesting that we return 
our message here?




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:324
+
+auto Range = getTokenRange(AST.getSourceManager(), AST.getLangOpts(),
+   TouchingIdentifier->location());

sammccall wrote:
> this runs the lexer to compute token boundaries. We actually already have 
> them: syntax::Token has endLocation/length
removed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610



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


[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241096.
hokein added a comment.

revert an accident change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/test/rename.test


Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the 
given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 
{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,16 +316,21 @@
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
-if (!Range)
-  return CB(llvm::None); // "rename" is not valid at the position.
+auto Loc = sourceLocationInMainFile(SM, Pos);
+if (!Loc)
+  return CB(Loc.takeError());
+const auto *TouchingIdentifier =
+spelledIdentifierTouching(*Loc, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+auto Range = halfOpenToRange(
+SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
+  TouchingIdentifier->endLocation()));
 
 if (CrossFileRename)
   // FIXME: we now assume cross-file rename always succeeds, revisit this.
-  return CB(*Range);
+  return CB(Range);
 
 // Performing the local rename isn't substantially more expensive than
 // doing an AST-based check, so we just rename and throw away the results.
@@ -338,7 +343,7 @@
   // the message to users (VSCode does).
   return CB(Changes.takeError());
 }
-return CB(*Range);
+return CB(Range);
   };
   WorkScheduler.runWithAST("PrepareRename", File, std::move(Action));
 }


Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 {"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,16 +316,21 @@
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
-if (!Range)
-  return CB(llvm::None); // "rename" is not valid at the position.
+auto Loc = sourceLocationInMainFile(SM, Pos);
+if (!Loc)
+  return CB(Loc.takeError());
+const auto *TouchingIdentifier =
+spelledIdentifierTouching(*Loc, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+auto Range = halfOpenToRange(
+SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
+  TouchingIdentifier->endLocation()));
 

[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:322
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+

hokein wrote:
> sammccall wrote:
> > Agree that this behavior is OK per the spec, but do we actually prefer 
> > it/why the change?
> > 
> > Seems like clients are marginally more likely to handle null 
> > incorrectly/silently, and we give up control over the message.
> > Agree that this behavior is OK per the spec, but do we actually prefer 
> > it/why the change?
> 
> I checked with VSCode, it seems fine (`the element can't be renamed`), and 
> YCM (but it doesn't support prepare rename yet). Are you suggesting that we 
> return our message here?
> 
Doh, I had this confused with rename where the spec is more ambiguous (and e.g. 
eglot doesn't handle null well). Nevermind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610



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


[PATCH] D73617: [clangd] Don't mmap source files on all platforms --> don't crash on git checkout

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62284 tests passed, 0 failed 
and 831 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73617



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


[PATCH] D73612: [clangd] Update lsp dependencies to pickup the progress support in LSP 3.15

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241097.
hokein added a comment.

update the required minimal vscode version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73612

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json


Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.36.0"
+"vscode": "^1.41.0"
 },
 "categories": [
 "Programming Languages",
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",


Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.36.0"
+"vscode": "^1.41.0"
 },
 "categories": [
 "Programming Languages",
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73537: [clangd] add CODE_OWNERS

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f6952780ba9: [clangd] add CODE_OWNERS (authored by 
sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73537

Files:
  clang-tools-extra/CODE_OWNERS.TXT


Index: clang-tools-extra/CODE_OWNERS.TXT
===
--- clang-tools-extra/CODE_OWNERS.TXT
+++ clang-tools-extra/CODE_OWNERS.TXT
@@ -23,3 +23,7 @@
 N: Julie Hockett
 E: juliehock...@google.com
 D: clang-doc
+
+N: Sam McCall
+E: sammcc...@google.com
+D: clangd


Index: clang-tools-extra/CODE_OWNERS.TXT
===
--- clang-tools-extra/CODE_OWNERS.TXT
+++ clang-tools-extra/CODE_OWNERS.TXT
@@ -23,3 +23,7 @@
 N: Julie Hockett
 E: juliehock...@google.com
 D: clang-doc
+
+N: Sam McCall
+E: sammcc...@google.com
+D: clangd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 6f69527 - [clangd] add CODE_OWNERS

2020-01-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-01-29T12:43:19+01:00
New Revision: 6f6952780ba92782c38b37b7bf65a079c1d1215f

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

LOG: [clangd] add CODE_OWNERS

Reviewers: klimek

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/CODE_OWNERS.TXT

Removed: 




diff  --git a/clang-tools-extra/CODE_OWNERS.TXT 
b/clang-tools-extra/CODE_OWNERS.TXT
index 1aee7e4a9eb0..3dc3ddd7c78d 100644
--- a/clang-tools-extra/CODE_OWNERS.TXT
+++ b/clang-tools-extra/CODE_OWNERS.TXT
@@ -23,3 +23,7 @@ D: clang-tidy
 N: Julie Hockett
 E: juliehock...@google.com
 D: clang-doc
+
+N: Sam McCall
+E: sammcc...@google.com
+D: clangd



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


[clang-tools-extra] bcb3e42 - [clangd] Go-to-definition on 'override' jumps to overridden method(s)

2020-01-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-01-29T12:43:52+01:00
New Revision: bcb3e42fdfb30f516fefd56609a969059b60a982

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

LOG: [clangd] Go-to-definition on 'override' jumps to overridden method(s)

Reviewers: kadircet

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 6e625d89cf1e..b302a0d5396c 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -21,6 +21,7 @@
 #include "index/Relation.h"
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -249,31 +250,17 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
 return Result;
   }
 
-  // Emit all symbol locations (declaration or definition) from AST.
-  DeclRelationSet Relations =
-  DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
 
-// If we're at the point of declaration of a template specialization,
-// it's more useful to navigate to the template declaration.
-if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
-IdentStartLoc) {
-  if (auto *CTSD = dyn_cast(Preferred)) {
-D = CTSD->getSpecializedTemplate();
-Def = getDefinition(D);
-Preferred = Def ? Def : D;
-  }
-}
-
 auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
 *MainFilePath);
 if (!Loc)
-  continue;
+  return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *D);
+Result.back().Name = printName(AST.getASTContext(), *Preferred);
 Result.back().PreferredDeclaration = *Loc;
 // Preferred is always a definition if possible, so this check works.
 if (Def == Preferred)
@@ -282,6 +269,37 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
 // Record SymbolID for index lookup later.
 if (auto ID = getSymbolID(Preferred))
   ResultIndex[*ID] = Result.size() - 1;
+  };
+
+  // Emit all symbol locations (declaration or definition) from AST.
+  DeclRelationSet Relations =
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
+  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+// Special case: void foo() ^override: jump to the overridden method.
+if (const auto *CMD = llvm::dyn_cast(D)) {
+  const auto *Attr = D->getAttr();
+  const syntax::Token *Tok =
+  spelledIdentifierTouching(SourceLoc, AST.getTokens());
+  if (Attr && Tok &&
+  SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
+// We may be overridding multiple methods - offer them all.
+for (const NamedDecl *ND : CMD->overridden_methods())
+  AddResultDecl(ND);
+continue;
+  }
+}
+
+// Special case: the point of declaration of a template specialization,
+// it's more useful to navigate to the template declaration.
+if (SM.getMacroArgExpandedLocation(D->getLocation()) == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(D)) {
+AddResultDecl(CTSD->getSpecializedTemplate());
+continue;
+  }
+}
+
+// Otherwise the target declaration is the right one.
+AddResultDecl(D);
   }
 
   // Now query the index for all Symbol IDs we found in the AST.

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 616e204dd631..348613954a27 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -447,6 +447,11 @@ TEST(LocateSymbol, All) {
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// Override specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^override {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-29 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 2 inline comments as done.
mprobst added inline comments.



Comment at: clang/lib/Format/Format.cpp:2531
+});
+
   auto Env =

MyDeveloperDay wrote:
> Ok, this comment is more a discussion point rather than a review comment. Was 
> there a reason you needed to put the TrailingCommaInserter pass after the 
> Formatter pass? (maybe you needed the Tokens annotated?)
> 
> From my understanding of some of the other conversations, it seemed the 
> reason for ignoring the Column limit was because the "," insertion came after 
> it had been formatted (is that correct?)
> 
> If there was a good reason that's also fine, I was just interested to learn 
> if there was some part of the Formatter that perhaps needs to be pulled out 
> into its own separate pass.
> 
> 
The problem with inserting the comma during formatting is that it'd need to be 
inserted during the state exploration as part of Dijkstra's implemented in 
clang-format. I've considered that, but it'd be complex (if we make formatting 
decision X, we now add a token, which might invalidate the formatting 
decision). Keeping it as a separate pass has drawbacks, such as potentially not 
ending up with perfect formatting, thus the backing off to insert over 
ColumnLimit, but seems overall simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.
hokein added a comment.

We have updated our internal code to use the new name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73619

Files:
  clang-tools-extra/clangd/ClangdServer.h


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -359,9 +359,6 @@
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -359,9 +359,6 @@
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73367: [clangd] Go-to-definition on 'override' jumps to overridden method(s)

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbcb3e42fdfb3: [clangd] Go-to-definition on 
'override' jumps to overridden method(s) (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73367

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -447,6 +447,11 @@
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// Override specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^override {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -21,6 +21,7 @@
 #include "index/Relation.h"
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -249,31 +250,17 @@
 return Result;
   }
 
-  // Emit all symbol locations (declaration or definition) from AST.
-  DeclRelationSet Relations =
-  DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
 
-// If we're at the point of declaration of a template specialization,
-// it's more useful to navigate to the template declaration.
-if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
-IdentStartLoc) {
-  if (auto *CTSD = dyn_cast(Preferred)) {
-D = CTSD->getSpecializedTemplate();
-Def = getDefinition(D);
-Preferred = Def ? Def : D;
-  }
-}
-
 auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
 *MainFilePath);
 if (!Loc)
-  continue;
+  return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *D);
+Result.back().Name = printName(AST.getASTContext(), *Preferred);
 Result.back().PreferredDeclaration = *Loc;
 // Preferred is always a definition if possible, so this check works.
 if (Def == Preferred)
@@ -282,6 +269,37 @@
 // Record SymbolID for index lookup later.
 if (auto ID = getSymbolID(Preferred))
   ResultIndex[*ID] = Result.size() - 1;
+  };
+
+  // Emit all symbol locations (declaration or definition) from AST.
+  DeclRelationSet Relations =
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
+  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+// Special case: void foo() ^override: jump to the overridden method.
+if (const auto *CMD = llvm::dyn_cast(D)) {
+  const auto *Attr = D->getAttr();
+  const syntax::Token *Tok =
+  spelledIdentifierTouching(SourceLoc, AST.getTokens());
+  if (Attr && Tok &&
+  SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
+// We may be overridding multiple methods - offer them all.
+for (const NamedDecl *ND : CMD->overridden_methods())
+  AddResultDecl(ND);
+continue;
+  }
+}
+
+// Special case: the point of declaration of a template specialization,
+// it's more useful to navigate to the template declaration.
+if (SM.getMacroArgExpandedLocation(D->getLocation()) == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(D)) {
+AddResultDecl(CTSD->getSpecializedTemplate());
+continue;
+  }
+}
+
+// Otherwise the target declaration is the right one.
+AddResultDecl(D);
   }
 
   // Now query the index for all Symbol IDs we found in the AST.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

We have updated our internal code to use the new name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73619



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


[clang-tools-extra] e864f93 - [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-29T12:57:18+01:00
New Revision: e864f937669c996b4dc15db7d0ebe4073527c165

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

LOG: [clangd] Replace raw lexer code with token buffer in prepare rename.

Summary:
there is a slight behavior change in this patch:

- before: `in^t a;`, returns our internal error message (no symbol at given 
location)
- after: `in^t a, returns null, and client displays their message (e.g.
   e.g. "the element can't be renamed" in vscode).

both are sensible according LSP, and we'd save one `rename` call in the later 
case.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/test/rename.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 7ead45c61458..cf883f130da8 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,16 +316,21 @@ void ClangdServer::prepareRename(PathRef File, Position 
Pos,
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
-if (!Range)
-  return CB(llvm::None); // "rename" is not valid at the position.
+auto Loc = sourceLocationInMainFile(SM, Pos);
+if (!Loc)
+  return CB(Loc.takeError());
+const auto *TouchingIdentifier =
+spelledIdentifierTouching(*Loc, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+auto Range = halfOpenToRange(
+SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
+  TouchingIdentifier->endLocation()));
 
 if (CrossFileRename)
   // FIXME: we now assume cross-file rename always succeeds, revisit this.
-  return CB(*Range);
+  return CB(Range);
 
 // Performing the local rename isn't substantially more expensive than
 // doing an AST-based check, so we just rename and throw away the results.
@@ -338,7 +343,7 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
   // the message to users (VSCode does).
   return CB(Changes.takeError());
 }
-return CB(*Range);
+return CB(Range);
   };
   WorkScheduler.runWithAST("PrepareRename", File, std::move(Action));
 }

diff  --git a/clang-tools-extra/clangd/test/rename.test 
b/clang-tools-extra/clangd/test/rename.test
index 527b4263443a..214efb2b5e39 100644
--- a/clang-tools-extra/clangd/test/rename.test
+++ b/clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the 
given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 
{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {



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


[clang-tools-extra] 17fadef - [clangd][vscode] Update lsp dependencies to pickup the progress support in LSP 3.15

2020-01-29 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-29T12:58:53+01:00
New Revision: 17fadeffcce97d79f5f132dacb143364622b6428

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

LOG: [clangd][vscode] Update lsp dependencies to pickup the progress support in 
LSP 3.15

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/clients/clangd-vscode/package.json

Removed: 




diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/package.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/package.json
index 8abf7e743e6f..02da3f833068 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.36.0"
+"vscode": "^1.41.0"
 },
 "categories": [
 "Programming Languages",
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",



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


[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe864f937669c: [clangd] Replace raw lexer code with token 
buffer in prepare rename. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/test/rename.test


Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the 
given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 
{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,16 +316,21 @@
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
-if (!Range)
-  return CB(llvm::None); // "rename" is not valid at the position.
+auto Loc = sourceLocationInMainFile(SM, Pos);
+if (!Loc)
+  return CB(Loc.takeError());
+const auto *TouchingIdentifier =
+spelledIdentifierTouching(*Loc, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+auto Range = halfOpenToRange(
+SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
+  TouchingIdentifier->endLocation()));
 
 if (CrossFileRename)
   // FIXME: we now assume cross-file rename always succeeds, revisit this.
-  return CB(*Range);
+  return CB(Range);
 
 // Performing the local rename isn't substantially more expensive than
 // doing an AST-based check, so we just rename and throw away the results.
@@ -338,7 +343,7 @@
   // the message to users (VSCode does).
   return CB(Changes.takeError());
 }
-return CB(*Range);
+return CB(Range);
   };
   WorkScheduler.runWithAST("PrepareRename", File, std::move(Action));
 }


Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -21,12 +21,9 @@
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "Cannot rename symbol: there is no symbol at the given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
 ---
 {"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
 #  CHECK:  "error": {
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -316,16 +316,21 @@
   return CB(InpAST.takeError());
 auto &AST = InpAST->AST;
 const auto &SM = AST.getSourceManager();
-SourceLocation Loc =
-SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, AST.getSourceManager(), AST.getLangOpts()));
-auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
-if (!Range)
-  return CB(llvm::None); // "rename" is not valid at the position.
+auto Loc = sourceLocationInMainFile(SM, Pos);
+if (!Loc)
+  return CB(Loc.takeError());
+const auto *TouchingIdentifier =
+spelledIdentifierTouching(*Loc, AST.getTokens());
+if (!TouchingIdentifier)
+  return CB(llvm::None); // no rename on non-identifiers.
+
+auto Range = halfOpenToRange(
+SM, CharSourceRange::getCharRange(TouchingIdent

[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62257 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610



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


[PATCH] D73612: [clangd] Update lsp dependencies to pickup the progress support in LSP 3.15

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17fadeffcce9: [clangd][vscode] Update lsp dependencies to 
pickup the progress support in LSP… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73612

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json


Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.36.0"
+"vscode": "^1.41.0"
 },
 "categories": [
 "Programming Languages",
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",


Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.36.0"
+"vscode": "^1.41.0"
 },
 "categories": [
 "Programming Languages",
@@ -40,9 +40,9 @@
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
-"vscode-languageclient": "^6.0.0-next.1",
-"vscode-languageserver": "^6.0.0-next.1",
-"vscode-languageserver-types": "^3.15.0-next.5"
+"vscode-languageclient": "^6.1.0",
+"vscode-languageserver": "^6.1.0",
+"vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73612: [clangd] Update lsp dependencies to pickup the progress support in LSP 3.15

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62283 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73612



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


[PATCH] D73610: [clangd] Replace raw lexer code with token buffer in prepare rename.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62257 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73610



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


[PATCH] D73493: [AArch64][SVE] Add SVE2 intrinsics for uniform DSP operations

2020-01-29 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3cf80822a906: [AArch64][SVE] Add SVE2 intrinsics for uniform 
DSP operations (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73493

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll
@@ -0,0 +1,869 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; SHADD
+;
+
+define  @shadd_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: shadd_i8:
+; CHECK: shadd z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shadd.nxv16i8( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @shadd_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: shadd_i16:
+; CHECK: shadd z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shadd.nxv8i16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @shadd_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: shadd_i32:
+; CHECK: shadd z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shadd.nxv4i32( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @shadd_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: shadd_i64:
+; CHECK: shadd z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shadd.nxv2i64( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+;
+; SHSUB
+;
+
+define  @shsub_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: shsub_i8:
+; CHECK: shsub z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsub.nxv16i8( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @shsub_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: shsub_i16:
+; CHECK: shsub z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsub.nxv8i16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @shsub_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: shsub_i32:
+; CHECK: shsub z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsub.nxv4i32( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @shsub_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: shsub_i64:
+; CHECK: shsub z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsub.nxv2i64( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+;
+; SHSUBR
+;
+
+define  @shsubr_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: shsubr_i8:
+; CHECK: shsubr z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsubr.nxv16i8( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @shsubr_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: shsubr_i16:
+; CHECK: shsubr z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsubr.nxv8i16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @shsubr_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: shsubr_i32:
+; CHECK: shsubr z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsubr.nxv4i32( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @shsubr_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: shsubr_i64:
+; CHECK: shsubr z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.shsubr.nxv2i64( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+;
+; SQABS
+;
+
+define  @sqa

[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62283 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73619



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

(Maybe we should have a basic test for C++, but I'm not sure how this usually 
goes)

BTW it occurs to me that turning this on by default may be a surprising 
breakage for:

- people who use clang-format to format JSON, where the comma is illegal.
- people who care about IE8 or something




Comment at: clang/include/clang/Format/Format.h:42
+  Unsuitable,
+  BinBackTrailingCommaConflict
+};

Back->Pack?



Comment at: clang/lib/Format/Format.cpp:2531
+});
+
   auto Env =

mprobst wrote:
> MyDeveloperDay wrote:
> > Ok, this comment is more a discussion point rather than a review comment. 
> > Was there a reason you needed to put the TrailingCommaInserter pass after 
> > the Formatter pass? (maybe you needed the Tokens annotated?)
> > 
> > From my understanding of some of the other conversations, it seemed the 
> > reason for ignoring the Column limit was because the "," insertion came 
> > after it had been formatted (is that correct?)
> > 
> > If there was a good reason that's also fine, I was just interested to learn 
> > if there was some part of the Formatter that perhaps needs to be pulled out 
> > into its own separate pass.
> > 
> > 
> The problem with inserting the comma during formatting is that it'd need to 
> be inserted during the state exploration as part of Dijkstra's implemented in 
> clang-format. I've considered that, but it'd be complex (if we make 
> formatting decision X, we now add a token, which might invalidate the 
> formatting decision). Keeping it as a separate pass has drawbacks, such as 
> potentially not ending up with perfect formatting, thus the backing off to 
> insert over ColumnLimit, but seems overall simpler.
> Ok, this comment is more a discussion point rather than a review comment. Was 
> there a reason you needed to put the TrailingCommaInserter pass after the 
> Formatter pass? (maybe you needed the Tokens annotated?)

The comma must only be inserted when the items are wrapped one-per-line (i.e. 
the last item is not on the same line as the closing bracket). This wrapping is 
a decision taken by the formatter, so we need to run it first to know.
(Apologies if this is obvious, but maybe missed)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[clang] a324fcf - clang-format: insert trailing commas into containers.

2020-01-29 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-01-29T13:23:54+01:00
New Revision: a324fcf1ae62d065b957e66a9d2f5c18b6259d27

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

LOG: clang-format: insert trailing commas into containers.

Summary:
This change adds an option to insert trailing commas into container
literals. For example, in JavaScript:

const x = [
  a,
  b,
   ^ inserted if missing.
]

This is implemented as a seperate post-processing pass after formatting
(because formatting might change whether the container literal does or
does not wrap). This keeps the code relatively simple and orthogonal,
though it has the notable drawback that the newly inserted comma is not
taken into account for formatting decisions (e.g. it might exceed the 80
char limit). To avoid exceeding the ColumnLimit, a comma is only
inserted if it fits into the limit.

Trailing comma insertion conceptually conflicts with argument
bin-packing: inserting a comma disables bin-packing, so we cannot do
both. clang-format rejects FormatStyle configurations that do both with
this change.

Reviewers: krasimir, MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang

Added: 


Modified: 
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 09a0556ab4c6..3891029a6f3a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -35,7 +35,12 @@ class DiagnosticConsumer;
 
 namespace format {
 
-enum class ParseError { Success = 0, Error, Unsuitable };
+enum class ParseError {
+  Success = 0,
+  Error,
+  Unsuitable,
+  BinPackTrailingCommaConflict
+};
 class ParseErrorCategory final : public std::error_category {
 public:
   const char *name() const noexcept override;
@@ -544,6 +549,20 @@ struct FormatStyle {
   /// \endcode
   bool BinPackArguments;
 
+  /// The style of inserting trailing commas into container literals.
+  enum TrailingCommaStyle {
+/// Do not insert trailing commas.
+TCS_None,
+/// Insert trailing commas in container literals that were wrapped over
+/// multiple lines. Note that this is conceptually incompatible with
+/// bin-packing, because the trailing comma is used as an indicator
+/// that a container should be formatted one-per-line (i.e. not 
bin-packed).
+/// So inserting a trailing comma counteracts bin-packing.
+TCS_Wrapped,
+  };
+
+  TrailingCommaStyle InsertTrailingCommas;
+
   /// If ``false``, a function declaration's or function definition's
   /// parameters will either all be on the same line or will have one line 
each.
   /// \code

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index dd131a93362c..6f585ae915a5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -157,6 +157,13 @@ template <> struct 
ScalarEnumerationTraits {
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::TrailingCommaStyle &Value) {
+IO.enumCase(Value, "None", FormatStyle::TCS_None);
+IO.enumCase(Value, "Wrapped", FormatStyle::TCS_Wrapped);
+  }
+};
+
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) {
 IO.enumCase(Value, "All", FormatStyle::BOS_All);
@@ -486,6 +493,7 @@ template <> struct MappingTraits {
 IO.mapOptional("IndentWidth", Style.IndentWidth);
 IO.mapOptional("IndentWrappedFunctionNames",
Style.IndentWrappedFunctionNames);
+IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
 IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
 IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes);
 IO.mapOptional("JavaScriptWrapImports", Style.JavaScriptWrapImports);
@@ -644,6 +652,8 @@ std::string ParseErrorCategory::message(int EV) const {
 return "Invalid argument";
   case ParseError::Unsuitable:
 return "Unsuitable";
+  case ParseError::BinPackTrailingCommaConflict:
+return "trailing comma insertion cannot be used with bin packing";
   }
   llvm_unreachable("unexpected parse error");
 }
@@ -788,6 +798,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
+  LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
   LLVMStyle.TabWidth = 8;
@@ -946,6 +957,9 @@ FormatStyle getGoogleStyle(FormatStyle::Langua

[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-29 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 4 inline comments as done.
mprobst added inline comments.



Comment at: clang/include/clang/Format/Format.h:42
+  Unsuitable,
+  BinBackTrailingCommaConflict
+};

sammccall wrote:
> Back->Pack?
That's what you get when you fix my auto-complete: consistent misspelling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73617: [clangd] Don't mmap source files on all platforms --> don't crash on git checkout

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Also I'd like to put this onto the 10 release branch because this is a big 
crasher, fix seems safe, we've run this code on windows for a while.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73617



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


[clang] d5dfd13 - Add TagDecl AST matcher

2020-01-29 Thread Aaron Ballman via cfe-commits

Author: Karasev Nikita
Date: 2020-01-29T07:58:31-05:00
New Revision: d5dfd1350efb80f9674db322999dd883fb36a6ad

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

LOG: Add TagDecl AST matcher

Added: 


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

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 837f74ea0d41..907353d1d9bb 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -502,6 +502,20 @@ Node Matchers
 
 
 
+MatcherDecl>tagDeclMatcherTagDecl>...
+Matches tag declarations.
+
+Example matches X, Z, U, S, E
+  class X;
+  template class Z {};
+  struct S {};
+  union U {};
+  enum E {
+A, B, C
+  };
+
+
+
 MatcherDecl>templateTypeParmDeclMatcherTemplateTypeParmDecl>...
 Matches 
template type parameter declarations.
 
@@ -3957,36 +3971,6 @@ Narrowing Matchers
 
 
 
-MatcherRecordDecl>isClass
-Matches RecordDecl object 
that are spelled with "class."
-
-Example matches C, but not S or U.
-  struct S {};
-  class C {};
-  union U {};
-
-
-
-MatcherRecordDecl>isStruct
-Matches RecordDecl object 
that are spelled with "struct."
-
-Example matches S, but not C or U.
-  struct S {};
-  class C {};
-  union U {};
-
-
-
-MatcherRecordDecl>isUnion
-Matches RecordDecl object 
that are spelled with "union."
-
-Example matches U, but not C or S.
-  struct S {};
-  class C {};
-  union U {};
-
-
-
 MatcherStmt>equalsBoundNodestd::string 
ID
 Matches if a node 
equals a previously bound node.
 
@@ -4090,6 +4074,17 @@ Narrowing Matchers
 
 
 
+MatcherTagDecl>isClass
+Matches TagDecl object that 
are spelled with "class."
+
+Example matches C, but not S, U or E.
+  struct S {};
+  class C {};
+  union U {};
+  enum E {};
+
+
+
 MatcherTagDecl>isDefinition
 Matches if a 
declaration has a body attached.
 
@@ -4112,6 +4107,39 @@ Narrowing Matchers
 
 
 
+MatcherTagDecl>isEnum
+Matches TagDecl object that 
are spelled with "enum."
+
+Example matches E, but not C, S or U.
+  struct S {};
+  class C {};
+  union U {};
+  enum E {};
+
+
+
+MatcherTagDecl>isStruct
+Matches TagDecl object 
that are spelled with "struct."
+
+Example matches S, but not C, U or E.
+  struct S {};
+  class C {};
+  union U {};
+  enum E {};
+
+
+
+MatcherTagDecl>isUnion
+Matches TagDecl object that 
are spelled with "union."
+
+Example matches U, but not C, S or E.
+  struct S {};
+  class C {};
+  union U {};
+  enum E {};
+
+
+
 MatcherTemplateArgument>equalsIntegralValuestd::string 
Value
 Matches a 
TemplateArgument of integral type with a given value.
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ac6ce076d60d..f105586a4d62 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1195,6 +1195,20 @@ extern const internal::VariadicDynCastAllOfMatcher enumDecl;
 extern const internal::VariadicDynCastAllOfMatcher
 enumConstantDecl;
 
+/// Matches tag declarations.
+///
+/// Example matches X, Z, U, S, E
+/// \code
+///   class X;
+///   template class Z {};
+///   struct S {};
+///   union U {};
+///   enum E {
+/// A, B, C
+///   };
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher tagDecl;
+
 /// Matches method declarations.
 ///
 /// Example matches y
@@ -4863,42 +4877,58 @@ AST_MATCHER_P(ImplicitCastExpr, 
hasImplicitDestinationType,
   return InnerMatcher.matches(Node.getType(), Finder, Builder);
 }
 
-/// Matches RecordDecl object that are spelled with "struct."
+/// Matches TagDecl object that are spelled with "st

[clang] 4ec2a26 - Fix clang test build

2020-01-29 Thread Sanne Wouda via cfe-commits

Author: Sanne Wouda
Date: 2020-01-29T13:03:27Z
New Revision: 4ec2a267321124a7fe8efe794ce40da67ce1d6bd

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

LOG: Fix clang test build

Added: 


Modified: 
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 63f83f7ca23c..ea064305091a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -13036,7 +13036,7 @@ TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
   EXPECT_EQ(parseConfiguration("BinPackArguments: true\n"
"InsertTrailingCommas: Wrapped",
&BinPackedTCS),
-ParseError::BinBackTrailingCommaConflict);
+ParseError::BinPackTrailingCommaConflict);
   EXPECT_EQ(12u, Style.IndentWidth);
   CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);



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


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:41
+   auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+

njames93 wrote:
> aaron.ballman wrote:
> > njames93 wrote:
> > > Quuxplusone wrote:
> > > > Is it worth adding an example of a double pointer?
> > > > 
> > > > auto BarN = cast(FooN);
> > > > 
> > > > Does that become `auto*` or `auto**` (and why)? My wild guess is that 
> > > > it becomes `auto*` (and because nobody cares about double pointers), 
> > > > but I could be wrong.
> > > Double pointers are just resolved to `auto *`.
> > They resolve to `auto *` today but I could see a real argument that they 
> > should resolve to `auto **` instead based on the same logic of: don't make 
> > the reader infer pointer/references and qualifiers.
> One change per patch...
I wasn't suggesting a change to this patch, I was checking to see if there's 
sentiment that we missed this case in the first place. Sorry for not making 
that more clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73464: [clang] Add TagDecl AST matcher

2020-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've committed on your behalf in d5dfd1350efb80f9674db322999dd883fb36a6ad 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73464



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


[PATCH] D73562: [ASTMatchers] Add hasPlacementArg and hasAnyPlacementArg traversal matcher for CXXNewExpr

2020-01-29 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/D73562/new/

https://reviews.llvm.org/D73562



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


[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241122.
hokein added a comment.

remove the deprecated contructor as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73619

Files:
  clang-tools-extra/clangd/ClangdServer.h


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -165,12 +165,6 @@
const FileSystemProvider &FSProvider, const Options &Opts,
Callbacks *Callbacks = nullptr);
 
-  // FIXME: remove this compatibility alias.
-  ClangdServer(const GlobalCompilationDatabase &CDB,
-   const FileSystemProvider &FSProvider, Callbacks &Callbacks,
-   const Options &Opts)
-  : ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}
-
   /// Add a \p File to the list of tracked C++ files or update the contents if
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -359,9 +353,6 @@
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -165,12 +165,6 @@
const FileSystemProvider &FSProvider, const Options &Opts,
Callbacks *Callbacks = nullptr);
 
-  // FIXME: remove this compatibility alias.
-  ClangdServer(const GlobalCompilationDatabase &CDB,
-   const FileSystemProvider &FSProvider, Callbacks &Callbacks,
-   const Options &Opts)
-  : ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}
-
   /// Add a \p File to the list of tracked C++ files or update the contents if
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -359,9 +353,6 @@
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-01-29 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere accepted this revision.
jeroen.dobbelaere added a comment.

This patch looks good to me.

I do agree with John that it would be good to add the warning to a warning 
group.


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

https://reviews.llvm.org/D73360



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


[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for the cleanup!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73619



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


[clang] 2939fc1 - [AArch64] Add IR intrinsics for sq(r)dmulh_lane(q)

2020-01-29 Thread Sanne Wouda via cfe-commits

Author: Sanne Wouda
Date: 2020-01-29T13:25:23Z
New Revision: 2939fc13c8f6a5dbd1be77c1d19dc2720253b8c5

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

LOG: [AArch64] Add IR intrinsics for sq(r)dmulh_lane(q)

Summary:
Currently, sqdmulh_lane and friends from the ACLE (implemented in arm_neon.h),
are represented in LLVM IR as a (by vector) sqdmulh and a vector of (repeated)
indices, like so:

   %shuffle = shufflevector <4 x i16> %v, <4 x i16> undef, <4 x i32> 
   %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.v4i16(<4 x i16> 
%a, <4 x i16> %shuffle)

When %v's values are known, the shufflevector is optimized away and we are no
longer able to select the lane variant of sqdmulh in the backend.

This defeats a (hand-coded) optimization that packs several constants into a
single vector and uses the lane intrinsics to reduce register pressure and
trade-off materialising several constants for a single vector load from the
constant pool, like so:

   int16x8_t v = {2,3,4,5,6,7,8,9};
   a = vqdmulh_laneq_s16(a, v, 0);
   b = vqdmulh_laneq_s16(b, v, 1);
   c = vqdmulh_laneq_s16(c, v, 2);
   d = vqdmulh_laneq_s16(d, v, 3);
   [...]

In one microbenchmark from libjpeg-turbo this accounts for a 2.5% to 4%
performance difference.

We could teach the compiler to recover the lane variants, but this would likely
require its own pass.  (Alternatively, "volatile" could be used on the constants
vector, but this is a bit ugly.)

This patch instead implements the following LLVM IR intrinsics for AArch64 to
maintain the original structure through IR optmization and into instruction
selection:
- sqdmulh_lane
- sqdmulh_laneq
- sqrdmulh_lane
- sqrdmulh_laneq.

These 'lane' variants need an additional register class.  The second argument
must be in the lower half of the 64-bit NEON register file, but only when
operating on i16 elements.

Note that the existing patterns for shufflevector and sqdmulh into sqdmulh_lane
(etc.) remain, so code that does not rely on NEON intrinsics to generate these
instructions is not affected.

This patch also changes clang to emit these IR intrinsics for the corresponding
NEON intrinsics (AArch64 only).

Reviewers: SjoerdMeijer, dmgreen, t.p.northover, rovka, rengolin, efriedma

Reviewed By: efriedma

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

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-neon-2velem.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
llvm/lib/Target/AArch64/AArch64RegisterInfo.td
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index a4dc21b64311..380a2a0a5fa6 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -528,9 +528,16 @@ def VMULL_LANE: SOpInst<"vmull_lane", "(>Q)..I", 
"siUsUi", OP_MULL_LN>;
 def VQDMULL_N : SOpInst<"vqdmull_n", "(>Q).1", "si", OP_QDMULL_N>;
 def VQDMULL_LANE  : SOpInst<"vqdmull_lane", "(>Q)..I", "si", OP_QDMULL_LN>;
 def VQDMULH_N : SOpInst<"vqdmulh_n", "..1", "siQsQi", OP_QDMULH_N>;
-def VQDMULH_LANE  : SOpInst<"vqdmulh_lane", "..qI", "siQsQi", OP_QDMULH_LN>;
 def VQRDMULH_N: SOpInst<"vqrdmulh_n", "..1", "siQsQi", OP_QRDMULH_N>;
+
+let ArchGuard = "!defined(__aarch64__)" in {
+def VQDMULH_LANE  : SOpInst<"vqdmulh_lane", "..qI", "siQsQi", OP_QDMULH_LN>;
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
+}
+let ArchGuard = "defined(__aarch64__)" in {
+def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..qI", "siQsQi">;
+def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..qI", "siQsQi">;
+}
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {
 def VQRDMLAH_LANE : SOpInst<"vqrdmlah_lane", "...qI", "siQsQi", OP_QRDMLAH_LN>;
@@ -951,9 +958,10 @@ def VQDMULL_HIGH_LANE   : SOpInst<"vqdmull_high_lane", 
"(>Q)Q.I", "si",
 def VQDMULL_HIGH_LANEQ  : SOpInst<"vqdmull_high_laneq", "(>Q)QQI", "si",
   OP_QDMULLHi_LN>;
 
-def VQDMULH_LANEQ  : SOpInst<"vqdmulh_laneq", "..QI", "siQsQi", OP_QDMULH_LN>;
-def VQRDMULH_LANEQ : SOpInst<"vqrdmulh_laneq", "..QI", "siQsQi", 
OP_QRDMULH_LN>;
-
+let isLaneQ = 1 in {
+def VQDMULH_LANEQ  : SInst<"vqdmulh_laneq", "..QI", "siQsQi">;
+def VQRDMULH_LANEQ : SInst<"vqrdmulh_laneq", "..QI", "siQsQi">;
+}
 let ArchGuard = "defi

[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62283 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73619



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


[PATCH] D72153: [libTooling] Add function to determine associated text of a declaration.

2020-01-29 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 241124.
ymandel marked 4 inline comments as done.
ymandel added a comment.

addressed comments, with significant reworking of tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72153

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -20,6 +20,7 @@
 using llvm::Failed;
 using llvm::Succeeded;
 using llvm::ValueIs;
+using tooling::getAssociatedRange;
 using tooling::getExtendedText;
 using tooling::getRangeForEdit;
 using tooling::getText;
@@ -51,6 +52,28 @@
  arg.getBegin() == R.getBegin() && arg.getEnd() == R.getEnd();
 }
 
+MATCHER_P2(EqualsAnnotatedRange, SM, R, "") {
+  if (arg.getBegin().isMacroID()) {
+*result_listener << "which starts in a macro";
+return false;
+  }
+  if (arg.getEnd().isMacroID()) {
+*result_listener << "which ends in a macro";
+return false;
+  }
+
+  unsigned Begin = SM->getFileOffset(arg.getBegin());
+  unsigned End = SM->getFileOffset(arg.getEnd());
+
+  *result_listener << "which is [" << Begin << ",";
+  if (arg.isTokenRange()) {
+*result_listener << End << "]";
+return Begin == R.Begin && End + 1 == R.End;
+  }
+  *result_listener << End << ")";
+  return Begin == R.Begin && End == R.End;
+}
+
 static ::testing::Matcher AsRange(const SourceManager &SM,
llvm::Annotations::Range R) {
   return EqualsRange(CharSourceRange::getCharRange(
@@ -58,6 +81,37 @@
   SM.getLocForStartOfFile(SM.getMainFileID()).getLocWithOffset(R.End)));
 }
 
+// Base class for visitors that expect a single match corresponding to a
+// specific annotated range.
+template 
+class AnnotatedCodeVisitor : public TestVisitor {
+  llvm::Annotations Code;
+  int MatchCount = 0;
+
+ public:
+  AnnotatedCodeVisitor() : Code("$r[[]]") {}
+  bool VisitDeclHelper(Decl *Decl) {
+// Only consider explicit declarations.
+if (Decl->isImplicit())
+  return true;
+
+++MatchCount;
+EXPECT_THAT(
+getAssociatedRange(*Decl, *this->Context),
+EqualsAnnotatedRange(&this->Context->getSourceManager(), Code.range("r")))
+<< Code.code();
+return true;
+  }
+
+  bool runOverAnnotated(llvm::StringRef AnnotatedCode) {
+Code = llvm::Annotations(AnnotatedCode);
+MatchCount = 0;
+bool result = this->runOver(Code.code());
+EXPECT_EQ(MatchCount, 1);
+return result;
+  }
+};
+
 TEST(SourceCodeTest, getText) {
   CallsVisitor Visitor;
 
@@ -126,6 +180,237 @@
   Visitor.runOver("int foo() { return foo() + 3; }");
 }
 
+TEST(SourceCodeTest, getAssociatedRange) {
+  struct VarDeclsVisitor : AnnotatedCodeVisitor {
+bool VisitVarDecl(VarDecl *Decl) {
+  return VisitDeclHelper(Decl);
+}
+  };
+  VarDeclsVisitor Visitor;
+
+  // Includes semicolon.
+  Visitor.runOverAnnotated("$r[[int x = 4;]]");
+
+  // Includes newline and semicolon.
+  Visitor.runOverAnnotated("$r[[int x = 4;\n]]");
+
+  // Includes trailing comments.
+  Visitor.runOverAnnotated("$r[[int x = 4; // Comment\n]]");
+  Visitor.runOverAnnotated("$r[[int x = 4; /* Comment */\n]]");
+
+  // Does *not* include trailing comments when another entity appears between
+  // the decl and the comment.
+  Visitor.runOverAnnotated("$r[[int x = 4;]] class C {}; // Comment\n");
+
+  // Includes attributes.
+  Visitor.runOverAnnotated(R"cpp(
+  #define ATTR __attribute__((deprecated("message")))
+  $r[[ATTR
+  int x;]])cpp");
+
+  // Includes attributes and comments together.
+  Visitor.runOverAnnotated(R"cpp(
+  #define ATTR __attribute__((deprecated("message")))
+  $r[[ATTR
+  // Commment.
+  int x;]])cpp");
+}
+
+TEST(SourceCodeTest, getAssociatedRangeClasses) {
+  struct RecordDeclsVisitor : AnnotatedCodeVisitor {
+bool VisitRecordDecl(RecordDecl *Decl) {
+  return VisitDeclHelper(Decl);
+}
+  };
+  RecordDeclsVisitor Visitor;
+
+  Visitor.runOverAnnotated("$r[[class A;]]");
+  Visitor.runOverAnnotated("$r[[class A {};]]");
+
+  // Includes leading template annotation.
+  Visitor.runOverAnnotated("$r[[template  class A;]]");
+  Visitor.runOverAnnotated("$r[[template  class A {};]]");
+}
+
+TEST(SourceCodeTest, getAssociatedRangeClassTemplateSpecializations) {
+  struct CXXRecordDeclsVisitor : AnnotatedCodeVisitor {
+bool VisitCXXRecordDecl(CXXRecordDecl *Decl) {
+  return Decl->getTemplateSpecializationKind() !=
+ TSK_ExplicitSpecialization ||
+ VisitDeclHelper(Decl);
+}
+  };
+  CXXRecordDeclsVisitor Visitor;
+
+  Visitor.runOverAnnotated(R"cpp(
+  template  class A{};
+  $r[[template <> class A;]])cpp"

[PATCH] D71469: [AArch64] Add IR intrinsics for sq(r)dmulh_lane(q)

2020-01-29 Thread Sanne Wouda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2939fc13c8f6: [AArch64] Add IR intrinsics for 
sq(r)dmulh_lane(q) (authored by sanwou01).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71469

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.td
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll

Index: llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
===
--- llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
+++ llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
@@ -9,20 +9,36 @@
 declare <2 x float> @llvm.aarch64.neon.fmulx.v2f32(<2 x float>, <2 x float>)
 
 declare <4 x i32> @llvm.aarch64.neon.sqrdmulh.v4i32(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.neon.sqrdmulh.lane.v4i32.v2i32(<4 x i32>, <2 x i32>, i32)
+declare <4 x i32> @llvm.aarch64.neon.sqrdmulh.laneq.v4i32.v4i32(<4 x i32>, <4 x i32>, i32)
 
 declare <2 x i32> @llvm.aarch64.neon.sqrdmulh.v2i32(<2 x i32>, <2 x i32>)
+declare <2 x i32> @llvm.aarch64.neon.sqrdmulh.lane.v2i32.v2i32(<2 x i32>, <2 x i32>, i32)
+declare <2 x i32> @llvm.aarch64.neon.sqrdmulh.laneq.v2i32.v4i32(<2 x i32>, <4 x i32>, i32)
 
 declare <8 x i16> @llvm.aarch64.neon.sqrdmulh.v8i16(<8 x i16>, <8 x i16>)
+declare <8 x i16> @llvm.aarch64.neon.sqrdmulh.lane.v8i16.v4i16(<8 x i16>, <4 x i16>, i32)
+declare <8 x i16> @llvm.aarch64.neon.sqrdmulh.laneq.v8i16.v8i16(<8 x i16>, <8 x i16>, i32)
 
 declare <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x i16>, <4 x i16>)
+declare <4 x i16> @llvm.aarch64.neon.sqrdmulh.lane.v4i16.v4i16(<4 x i16>, <4 x i16>, i32)
+declare <4 x i16> @llvm.aarch64.neon.sqrdmulh.laneq.v4i16.v8i16(<4 x i16>, <8 x i16>, i32)
 
 declare <4 x i32> @llvm.aarch64.neon.sqdmulh.v4i32(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.neon.sqdmulh.lane.v4i32.v2i32(<4 x i32>, <2 x i32>, i32)
+declare <4 x i32> @llvm.aarch64.neon.sqdmulh.laneq.v4i32.v4i32(<4 x i32>, <4 x i32>, i32)
 
 declare <2 x i32> @llvm.aarch64.neon.sqdmulh.v2i32(<2 x i32>, <2 x i32>)
+declare <2 x i32> @llvm.aarch64.neon.sqdmulh.lane.v2i32.v2i32(<2 x i32>, <2 x i32>, i32)
+declare <2 x i32> @llvm.aarch64.neon.sqdmulh.laneq.v2i32.v4i32(<2 x i32>, <4 x i32>, i32)
 
 declare <8 x i16> @llvm.aarch64.neon.sqdmulh.v8i16(<8 x i16>, <8 x i16>)
+declare <8 x i16> @llvm.aarch64.neon.sqdmulh.lane.v8i16.v4i16(<8 x i16>, <4 x i16>, i32)
+declare <8 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v8i16.v8i16(<8 x i16>, <8 x i16>, i32)
 
 declare <4 x i16> @llvm.aarch64.neon.sqdmulh.v4i16(<4 x i16>, <4 x i16>)
+declare <4 x i16> @llvm.aarch64.neon.sqdmulh.lane.v4i16.v4i16(<4 x i16>, <4 x i16>, i32)
+declare <4 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v4i16.v8i16(<4 x i16>, <8 x i16>, i32)
 
 declare <2 x i64> @llvm.aarch64.neon.sqdmull.v2i64(<2 x i32>, <2 x i32>)
 
@@ -1515,6 +1531,37 @@
   ret <4 x i16> %vqdmulh2.i
 }
 
+define <4 x i16> @test_vqdmulh_lane_s16_intrinsic(<4 x i16> %a, <4 x i16> %v) {
+; CHECK-LABEL: test_vqdmulh_lane_s16_intrinsic:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:// kill: def $d1 killed $d1 def $q1
+; CHECK-NEXT:sqdmulh v0.4h, v0.4h, v1.h[3]
+; CHECK-NEXT:ret
+entry:
+  %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.lane.v4i16.v4i16(<4 x i16> %a, <4 x i16> %v, i32 3)
+  ret <4 x i16> %vqdmulh2.i
+}
+
+define <4 x i16> @test_vqdmulh_laneq_s16_intrinsic_lo(<4 x i16> %a, <8 x i16> %v) {
+; CHECK-LABEL: test_vqdmulh_laneq_s16_intrinsic_lo:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sqdmulh v0.4h, v0.4h, v1.h[3]
+; CHECK-NEXT:ret
+entry:
+  %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v4i16.v8i16(<4 x i16> %a, <8 x i16> %v, i32 3)
+  ret <4 x i16> %vqdmulh2.i
+}
+
+define <4 x i16> @test_vqdmulh_laneq_s16_intrinsic_hi(<4 x i16> %a, <8 x i16> %v) {
+; CHECK-LABEL: test_vqdmulh_laneq_s16_intrinsic_hi:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sqdmulh v0.4h, v0.4h, v1.h[7]
+; CHECK-NEXT:ret
+entry:
+  %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v4i16.v8i16(<4 x i16> %a, <8 x i16> %v, i32 7)
+  ret <4 x i16> %vqdmulh2.i
+}
+
 define <8 x i16> @test_vqdmulhq_lane_s16(<8 x i16> %a, <4 x i16> %v) {
 ; CHECK-LABEL: test_vqdmulhq_lane_s16:
 ; CHECK:   // %bb.0: // %entry
@@ -1527,6 +1574,37 @@
   ret <8 x i16> %vqdmulh2.i
 }
 
+define <8 x i16> @test_vqdmulhq_lane_s16_intrinsic(<8 x i16> %a, <4 x i16> %v) {
+; CHECK-LABEL: test_vqdmulhq_lane_s16_intrinsic:
+; CHECK:   // %bb.0: // %entry
+; C

[PATCH] D73570: [FPEnv][X86] Platform-specific builtin constrained FP enablement

2020-01-29 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked 2 inline comments as done.
kpn added inline comments.



Comment at: clang/test/CodeGen/fma-builtins-constrained.c:4
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -S -o - | FileCheck --check-prefix=COMMON 
--check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -ffp-exception-behavior=strict -S -o - | FileCheck 
--check-prefix=COMMON --check-prefix=CHECK-ASM %s
+

craig.topper wrote:
> Technically the fmsub/fnmsub/fnmadd assembly requires optimizations to be 
> enabled. If it appears to work without optimizations its only because 
> fast-isel fell back to SelectionDAG and picked up optimizations due to that. 
> Not something that should be relied on.
Ok. Well, the eventual goal is to ship a product with optimization turned on. 
So I think it makes sense for me to give this a spin with optimizations and see 
what if anything needs to be done. Unless that's overkill I'll start this 
afternoon.



Comment at: clang/test/CodeGen/fma-builtins-constrained.c:6
+
+// FIXME: Several of these tests are broken when constrained.
+

craig.topper wrote:
> Is this just referring to the FIXME-CHECK-ASM?
Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73570



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


[PATCH] D72153: [libTooling] Add function to determine associated text of a declaration.

2020-01-29 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 241127.
ymandel marked 12 inline comments as done.
ymandel added a comment.

tweaks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72153

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -20,6 +20,7 @@
 using llvm::Failed;
 using llvm::Succeeded;
 using llvm::ValueIs;
+using tooling::getAssociatedRange;
 using tooling::getExtendedText;
 using tooling::getRangeForEdit;
 using tooling::getText;
@@ -51,6 +52,28 @@
  arg.getBegin() == R.getBegin() && arg.getEnd() == R.getEnd();
 }
 
+MATCHER_P2(EqualsAnnotatedRange, SM, R, "") {
+  if (arg.getBegin().isMacroID()) {
+*result_listener << "which starts in a macro";
+return false;
+  }
+  if (arg.getEnd().isMacroID()) {
+*result_listener << "which ends in a macro";
+return false;
+  }
+
+  unsigned Begin = SM->getFileOffset(arg.getBegin());
+  unsigned End = SM->getFileOffset(arg.getEnd());
+
+  *result_listener << "which is [" << Begin << ",";
+  if (arg.isTokenRange()) {
+*result_listener << End << "]";
+return Begin == R.Begin && End + 1 == R.End;
+  }
+  *result_listener << End << ")";
+  return Begin == R.Begin && End == R.End;
+}
+
 static ::testing::Matcher AsRange(const SourceManager &SM,
llvm::Annotations::Range R) {
   return EqualsRange(CharSourceRange::getCharRange(
@@ -58,6 +81,37 @@
   SM.getLocForStartOfFile(SM.getMainFileID()).getLocWithOffset(R.End)));
 }
 
+// Base class for visitors that expect a single match corresponding to a
+// specific annotated range.
+template 
+class AnnotatedCodeVisitor : public TestVisitor {
+  llvm::Annotations Code;
+  int MatchCount = 0;
+
+ public:
+  AnnotatedCodeVisitor() : Code("$r[[]]") {}
+  bool VisitDeclHelper(Decl *Decl) {
+// Only consider explicit declarations.
+if (Decl->isImplicit())
+  return true;
+
+++MatchCount;
+EXPECT_THAT(
+getAssociatedRange(*Decl, *this->Context),
+EqualsAnnotatedRange(&this->Context->getSourceManager(), Code.range("r")))
+<< Code.code();
+return true;
+  }
+
+  bool runOverAnnotated(llvm::StringRef AnnotatedCode) {
+Code = llvm::Annotations(AnnotatedCode);
+MatchCount = 0;
+bool result = this->runOver(Code.code());
+EXPECT_EQ(MatchCount, 1);
+return result;
+  }
+};
+
 TEST(SourceCodeTest, getText) {
   CallsVisitor Visitor;
 
@@ -126,6 +180,237 @@
   Visitor.runOver("int foo() { return foo() + 3; }");
 }
 
+TEST(SourceCodeTest, getAssociatedRange) {
+  struct VarDeclsVisitor : AnnotatedCodeVisitor {
+bool VisitVarDecl(VarDecl *Decl) {
+  return VisitDeclHelper(Decl);
+}
+  };
+  VarDeclsVisitor Visitor;
+
+  // Includes semicolon.
+  Visitor.runOverAnnotated("$r[[int x = 4;]]");
+
+  // Includes newline and semicolon.
+  Visitor.runOverAnnotated("$r[[int x = 4;\n]]");
+
+  // Includes trailing comments.
+  Visitor.runOverAnnotated("$r[[int x = 4; // Comment\n]]");
+  Visitor.runOverAnnotated("$r[[int x = 4; /* Comment */\n]]");
+
+  // Does *not* include trailing comments when another entity appears between
+  // the decl and the comment.
+  Visitor.runOverAnnotated("$r[[int x = 4;]] class C {}; // Comment\n");
+
+  // Includes attributes.
+  Visitor.runOverAnnotated(R"cpp(
+  #define ATTR __attribute__((deprecated("message")))
+  $r[[ATTR
+  int x;]])cpp");
+
+  // Includes attributes and comments together.
+  Visitor.runOverAnnotated(R"cpp(
+  #define ATTR __attribute__((deprecated("message")))
+  $r[[ATTR
+  // Commment.
+  int x;]])cpp");
+}
+
+TEST(SourceCodeTest, getAssociatedRangeClasses) {
+  struct RecordDeclsVisitor : AnnotatedCodeVisitor {
+bool VisitRecordDecl(RecordDecl *Decl) {
+  return VisitDeclHelper(Decl);
+}
+  };
+  RecordDeclsVisitor Visitor;
+
+  Visitor.runOverAnnotated("$r[[class A;]]");
+  Visitor.runOverAnnotated("$r[[class A {};]]");
+
+  // Includes leading template annotation.
+  Visitor.runOverAnnotated("$r[[template  class A;]]");
+  Visitor.runOverAnnotated("$r[[template  class A {};]]");
+}
+
+TEST(SourceCodeTest, getAssociatedRangeClassTemplateSpecializations) {
+  struct CXXRecordDeclsVisitor : AnnotatedCodeVisitor {
+bool VisitCXXRecordDecl(CXXRecordDecl *Decl) {
+  return Decl->getTemplateSpecializationKind() !=
+ TSK_ExplicitSpecialization ||
+ VisitDeclHelper(Decl);
+}
+  };
+  CXXRecordDeclsVisitor Visitor;
+
+  Visitor.runOverAnnotated(R"cpp(
+  template  class A{};
+  $r[[template <> class A;]])cpp");
+  Visitor.runOverAnnotated(R"cpp(
+  temp

[clang-tools-extra] fce8983 - [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-29T14:50:58+01:00
New Revision: fce8983a3c03b41c3ba4bdaef72e64e29ff9ecc0

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

LOG: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index c36a2eb6fb1a..7b870e5b300f 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -165,12 +165,6 @@ class ClangdServer {
const FileSystemProvider &FSProvider, const Options &Opts,
Callbacks *Callbacks = nullptr);
 
-  // FIXME: remove this compatibility alias.
-  ClangdServer(const GlobalCompilationDatabase &CDB,
-   const FileSystemProvider &FSProvider, Callbacks &Callbacks,
-   const Options &Opts)
-  : ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}
-
   /// Add a \p File to the list of tracked C++ files or update the contents if
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -359,9 +353,6 @@ class ClangdServer {
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 



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


[PATCH] D73619: [clangd] Remove the temporary alias for clangd::DiagnosticConsumer.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfce8983a3c03: [clangd] Remove the temporary alias for 
clangd::DiagnosticConsumer. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73619

Files:
  clang-tools-extra/clangd/ClangdServer.h


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -165,12 +165,6 @@
const FileSystemProvider &FSProvider, const Options &Opts,
Callbacks *Callbacks = nullptr);
 
-  // FIXME: remove this compatibility alias.
-  ClangdServer(const GlobalCompilationDatabase &CDB,
-   const FileSystemProvider &FSProvider, Callbacks &Callbacks,
-   const Options &Opts)
-  : ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}
-
   /// Add a \p File to the list of tracked C++ files or update the contents if
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -359,9 +353,6 @@
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -165,12 +165,6 @@
const FileSystemProvider &FSProvider, const Options &Opts,
Callbacks *Callbacks = nullptr);
 
-  // FIXME: remove this compatibility alias.
-  ClangdServer(const GlobalCompilationDatabase &CDB,
-   const FileSystemProvider &FSProvider, Callbacks &Callbacks,
-   const Options &Opts)
-  : ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}
-
   /// Add a \p File to the list of tracked C++ files or update the contents if
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -359,9 +353,6 @@
   TUScheduler WorkScheduler;
 };
 
-// FIXME: Remove this compatibility alias.
-using DiagnosticsConsumer = ClangdServer::Callbacks;
-
 } // namespace clangd
 } // namespace clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72153: [libTooling] Add function to determine associated text of a declaration.

2020-01-29 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added a comment.

Thank you for the detailed review. I've significantly expanded and refactored 
the tests. I also lifted `validateEditRange` into its own function and added 
corresponding tests.




Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:169
+  if (contains(Terminators, Tok))
+Terminated = true;
+  End = Tok.getEndLoc();

gribozavr2 wrote:
> What if the token is not a terminator? It seems like the loop will keep 
> looking for a terminator, but I don't understand why -- based on the doc 
> comment, it seems like the intent is that this function will only extend the 
> range with extra terminators.
The intent is also to extend with comments and whitespace.  Since the lexer is 
keeping whitespace (line 116), the whitespace will show up as tokens. I do not 
believe there is any documentation on the semantics of this mode, fwiw -- I had 
to read the code. Let me know if you think it would help to spell out more 
about the operation of the keep-whitespace mode.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:196
+case tok::semi:
+case tok::comma:
+  if (contains(Terminators, Tok)) {

gribozavr2 wrote:
> I don't understand this case. We can only reach this loop if we already found 
> one terminator. If semicolon is a terminator, fine, we can consume an extra 
> one. However, if comma is a terminator, if we enter this "case tok::comma", 
> it means we found two commas in a row, which is probably a syntax error.
I've added comments and additional logic (captured by `TerminatedByMacro`) to 
explain/refine this case. PTAL.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:352
+// If we didn't see '[[' or '__attribute' it's probably coming from a
+// macro expansion which is already handled by getExpansionRange(),
+// below.

gribozavr2 wrote:
> s/getExpansionRange/makeFileCharRange/? Although I don't think it does that, 
> because its comment says "... the function will fail because the range 
> overlaps with only a part of the macro".
> 
> 
`makeFileCharRange` is right, even if it will result in an error. Basically, if 
the attribute is the start of the macro expansion, then `makeFileCharRange` 
will expand it to an valid range. Otherwise, it will return an invalid range, 
so we will as well. I've extended the comments in the header to call out this 
possibility of returning an invalid range.



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:150
+  struct VarDeclsVisitor : TestVisitor {
+llvm::Annotations Code;
+

gribozavr2 wrote:
> If you feel motivated, it could be beneficial to lift this member into 
> TestVisitor itself (and change RunOver to accept llvm::Annotations).
Possibly. For now, I've lifted into a class template shared by most of the new 
tests. I think it would be good to followup with a patch that moves it to 
TestVisitor but that may take more design work than I want to bundle in this 
patch.



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:231
+  // Includes comments even in the presence of trailing whitespace.
+  Visitor.Code = llvm::Annotations("$r[[// Comment.\nint x = 4;]]  ");
+  Visitor.runOverWithComments(Visitor.Code.code());

gribozavr2 wrote:
> But there's no whitespace.
the whitespace trails the *decalaration*.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72153



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

Aewsome, thanks for implementing this. I was on vacation for a bit and somehow 
missed this review in my queue when I cam back but having a look at it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73285: [OpenMP][OMPIRBuilder][BugFix] Handle Unreachable Finalization blocks in `parallel` generation

2020-01-29 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked an inline comment as done.
fghanim added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:661
+AfterIP = InsertPointTy(ForkBB, ForkBB->end());
+  }
 

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > Why do we need all of this? Can't we just *not do it* instead? This is 
> > > code complexity that we should avoid.
> > Depends. 
> > If we want to conform with the way things are done in clang; namely, not 
> > have unreachable blocks, then yes we need to do this. If not, then no, 
> > nothing needs to change. An optimization pass will be executed at some 
> > point later that should clean all that up.
> > 
> > However, we should be careful, for example, The lit test for `critical` 
> > checks that no basic blocks were generated from the rest of the body that 
> > comes after the infinite loop. So if the choice is to not conform with 
> > clang, then we should keep an eye on these lit tests, and disable such 
> > checks for the OMPBuilder.
> > If we want to conform with the way things are done in clang;
> 
> It's not like we introduce much extra code, break anything, or make the final 
> result different.
> 
> 
> >  If not, then no, nothing needs to change. An optimization pass will be 
> > executed at some point later that should clean all that up.
> 
> Let's go with that solution and keep this code here simple, less error prone, 
> and easier to manage.
> 
> 
> > However, we should be careful, for example, The lit test for critical 
> > checks that no basic blocks were generated from the rest of the body that 
> > comes after the infinite loop. So if the choice is to not conform with 
> > clang, then we should keep an eye on these lit tests, and disable such 
> > checks for the OMPBuilder.
> 
> We already do things different and that will only become more evident 
> (TRegions!). For example, to simplify this code we do *not* cache runtime 
> calls (anymore). That is we emit a new get_thread_id call every time. (We 
> know the OpenMPOpt pass will clean it up eventually.) I get that the tests 
> change and for a while we will have clang and OMPBuilder check lines. Though, 
> once the clang CG is gone there is arguably no difference anymore because the 
> OMPBuilder behavior is then the default. As soon as we have the privatization 
> parts properly hooked up we can even start running the OMPBuilder by default 
> and soon after removing clang CG parts. If anything, we should modernize the 
> clang tests as they are a constant critique point that hinders outside 
> involvement. We could start using the llvm/utils/update__checks scripts 
> for example. We could also minimize the check lines and focus on the most 
> important bits only. (I prefer the update scripts with the pending 
> extensions, e.g., D69701)
> 
In that case, This revision is not necessary. The only fix needed is the branch 
erasure/creation change in the body CallBack (a bit more on this later), all 
the rest including the tests is not necessary. The only tests needed are 
already being done by the llvm verifier, which already reports if a BB is used 
by an orphan branch sticking around, or if a BB contains more than one 
terminator.

Regarding the issue of the branch, given that our finalization and body 
callbacks are very similar across different directives (Parallel, master, 
critical), the plan as we discussed on D72304 , is to write helper 
functions/class that we could use instead. So whoever, ends up writing that 
should make sure to include the branch changes, which makes them here redundant.

So, in the interest of everyone's time, my suggestion is to abandon this 
revision entirely for now, and just make sure that the implementation of these 
helper functions takes care of this everywhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73285



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


[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

2020-01-29 Thread Mark Rutland via Phabricator via cfe-commits
mrutland added a comment.

In D7#1839207 , @MaskRay wrote:

> When -mbranch-protection=bti is used, due to 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424 (existing GCC releases 
> have the issue), Linux/arch/arm64 has to make more checks to detect the 
> combination.


As covered in D7#1838988  the plan 
is to detect broken compilers at  build-time and reject the combination of 
options. The Linux patching code will not handle varied behaviours at runtime.

> I changed `nop; nop; bti c` to `bti c; nop; nop` with 2 commits not included 
> in LLVM release/10.x (a72d15e37c5e066f597f13a8ba60aff214ac992d 
>  and 
> 9a24488cb67a90f889529987275c5e411ce01dda 
> ). They 
> make Clang's M!=0 placement (.Lpatch; nop; func: bti c; nop) consistent with 
> GCC.
>  Edit: cherry-picked to release/10.x

That's great; thanks!

> For the M=0 case, Clang does (`func: .Lpatch; bti c; nop; nop`), which is 
> inconsistent with GCC (`func: bti c; .Lpatch: nop; nop`). I'll be happy to 
> try updating the placement of .Lpatch if future M>0 usage does not obsolete 
> M=0 usage (a proof that the proposed GCC layout is indeed superior, not just 
> for simplicity for a not-so-common configuration), otherwise I would feel the 
> clang side is just making changes to appease GCC/Linux compatibility, which 
> would make me sad.

I do not expect future M>0 usage to obsolete M=0 usage, and these will be used 
by distinct configurations of Linux with distinct code paths. I expect that we 
will need M>0 in future to handle very large kernel images and/or live-patching 
where we may need to place PLTs or other metadata close to a function. I expect 
that other cases will continue to use M=0.

I can appreciate the frustration here, but I do think that this is an ABI issue 
if the compilers diverge in behaviour here. Especially as future additions to 
the architecture or PCS could complicate matters, and what could seem benign 
divergence now could turn out to be unreconcilable.

Aligning with the GCC M=0 case here will mean that patching code that works 
with GCC should just work without modification for clang, and I do think that's 
a better position to be in generally.

> (Again: this is our ~5th time adding an option specific to Linux kernel, with 
> a good intention to make it general, but in reality it doesn't 
> https://gcc.gnu.org/ml/gcc/2020-01/msg00067.html) I shall also mention that 
> we are essentially making decisions for x86 people's endbr32/endbr64. I hope 
> you can engage in x86 maintainers. Clang's current layout is recorded at 
> D73071 .

That's a good point w.r.t. x86; I will get in touch with the people working on 
ftrace and live-patching there

Thanks,
Mark.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov, dschuff.
Herald added a project: clang.
hokein updated this revision to Diff 241144.
hokein added a comment.

add trailing blank line.


The vscode module has been deprecated, and it doesn't work anymore after
we require the minimal VSCode version 1.41.0, this patch migrate to the
new @type/vscode and vscode-test modules, see
https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73624

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
===
--- /dev/null
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
@@ -0,0 +1,23 @@
+import * as path from 'path';
+
+import {runTests} from 'vscode-test';
+
+async function main() {
+  try {
+// The folder containing the Extension Manifest package.json
+// Passed to `--extensionDevelopmentPath`
+const extensionDevelopmentPath = path.resolve(__dirname, '../');
+
+// The path to the extension test script
+// Passed to --extensionTestsPath
+const extensionTestsPath = path.resolve(__dirname, './index');
+
+// Download VS Code, unzip it and run the integration test
+await runTests({extensionDevelopmentPath, extensionTestsPath});
+  } catch (err) {
+console.error('Failed to run tests');
+process.exit(1);
+  }
+}
+
+main();
Index: clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
@@ -1,25 +1,35 @@
-//
-// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
-//
-// This file is providing the test runner to use when running extension tests.
-// By default the test runner in use is Mocha based.
-//
-// You can provide your own test runner if you want to override it by exporting
-// a function run(testRoot: string, clb: (error:Error) => void) that the
-// extension host can call to run the tests. The test runner is expected to use
-// console.log to report the results back to the caller. When the tests are
-// finished, return a possible error to the callback or null if none.
+import * as glob from 'glob';
+import * as Mocha from 'mocha';
+import * as path from 'path';
 
-var testRunner = require('vscode/lib/testrunner');
+export function run(): Promise {
+  // Create the mocha test
+  const mocha = new Mocha({ui : 'tdd'});
+  mocha.useColors(true);
 
-// You can directly control Mocha options by uncommenting the following lines
-// See
-// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
-// for more info
-testRunner.configure({
-  ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
-  // etc.)
-  useColors : true // colored output from test results
-});
+  const testsRoot = path.resolve(__dirname, '..');
 
-module.exports = testRunner;
\ No newline at end of file
+  return new Promise((c, e) => {
+glob('**/**.test.js', {cwd : testsRoot}, (err, files) => {
+  if (err) {
+return e(err);
+  }
+
+  // Add files to the test suite
+  files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
+
+  try {
+// Run the mocha test
+mocha.run(failures => {
+  if (failures > 0) {
+e(new Error(`${failures} tests failed.`));
+  } else {
+c();
+  }
+});
+  } catch (err) {
+e(err);
+  }
+});
+  });
+}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -32,9 +32,8 @@
 "scripts": {
 "vscode:prepublish": "tsc -p ./",
 "compile": "tsc -watch -p ./",
-"postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test",
+"test": "tsc -p ./ && node ./out/test/runTest.js",
 "package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
 "publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clang

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-29 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 241141.
awpandey added a comment.

Thanks @dblaikie for figuring out the missing feature. I have added support for 
the non-type template parameter too. Please let me know if further 
modifications are required. I will happily address them.


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

https://reviews.llvm.org/D73462

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2077,16 +2077,16 @@
   StringRef Name = "template";
   DIType *Type = getBasicType("basic");
 
-  auto *N = DITemplateTypeParameter::get(Context, Name, Type);
+  auto *N = DITemplateTypeParameter::get(Context, Name, Type, false);
 
   EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
-  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type));
+  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false));
 
-  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type));
-  EXPECT_NE(N,
-DITemplateTypeParameter::get(Context, Name, getBasicType("other")));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name,
+getBasicType("other"), false));
 
   TempDITemplateTypeParameter Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -2100,21 +2100,23 @@
   DIType *Type = getBasicType("basic");
   Metadata *Value = getConstantAsMetadata();
 
-  auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value);
+  auto *N =
+  DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value);
   EXPECT_EQ(Tag, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
   EXPECT_EQ(Value, N->getValue());
-  EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value));
+  EXPECT_EQ(
+  N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value));
 
   EXPECT_NE(N, DITemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Name,
-   Type, Value));
-  EXPECT_NE(N,
-DITemplateValueParameter::get(Context, Tag, "other", Type, Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name,
- getBasicType("other"), Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type,
+   Type, false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false,
+ Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(
+   Context, Tag, Name, getBasicType("other"), false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false,
  getConstantAsMetadata()));
 
   TempDITemplateValueParameter Temp = N->clone();
Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
@@ -0,0 +1,106 @@
+; RUN: %llc_dwarf  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;template 
+;class foo {
+;};
+;
+;int main() {
+; foo f1;
+; foo f2;
+; foo<> f3;
+; return 0;
+;}
+
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; CHECK: .debug_abbrev contents:
+; CHECK: DW_AT_default_value DW_FORM_flag_present
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "float"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "char"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (

[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241144.
hokein added a comment.

add trailing blank line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
===
--- /dev/null
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
@@ -0,0 +1,23 @@
+import * as path from 'path';
+
+import {runTests} from 'vscode-test';
+
+async function main() {
+  try {
+// The folder containing the Extension Manifest package.json
+// Passed to `--extensionDevelopmentPath`
+const extensionDevelopmentPath = path.resolve(__dirname, '../');
+
+// The path to the extension test script
+// Passed to --extensionTestsPath
+const extensionTestsPath = path.resolve(__dirname, './index');
+
+// Download VS Code, unzip it and run the integration test
+await runTests({extensionDevelopmentPath, extensionTestsPath});
+  } catch (err) {
+console.error('Failed to run tests');
+process.exit(1);
+  }
+}
+
+main();
Index: clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
@@ -1,25 +1,35 @@
-//
-// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
-//
-// This file is providing the test runner to use when running extension tests.
-// By default the test runner in use is Mocha based.
-//
-// You can provide your own test runner if you want to override it by exporting
-// a function run(testRoot: string, clb: (error:Error) => void) that the
-// extension host can call to run the tests. The test runner is expected to use
-// console.log to report the results back to the caller. When the tests are
-// finished, return a possible error to the callback or null if none.
+import * as glob from 'glob';
+import * as Mocha from 'mocha';
+import * as path from 'path';
 
-var testRunner = require('vscode/lib/testrunner');
+export function run(): Promise {
+  // Create the mocha test
+  const mocha = new Mocha({ui : 'tdd'});
+  mocha.useColors(true);
 
-// You can directly control Mocha options by uncommenting the following lines
-// See
-// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
-// for more info
-testRunner.configure({
-  ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
-  // etc.)
-  useColors : true // colored output from test results
-});
+  const testsRoot = path.resolve(__dirname, '..');
 
-module.exports = testRunner;
\ No newline at end of file
+  return new Promise((c, e) => {
+glob('**/**.test.js', {cwd : testsRoot}, (err, files) => {
+  if (err) {
+return e(err);
+  }
+
+  // Add files to the test suite
+  files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
+
+  try {
+// Run the mocha test
+mocha.run(failures => {
+  if (failures > 0) {
+e(new Error(`${failures} tests failed.`));
+  } else {
+c();
+  }
+});
+  } catch (err) {
+e(err);
+  }
+});
+  });
+}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -32,9 +32,8 @@
 "scripts": {
 "vscode:prepublish": "tsc -p ./",
 "compile": "tsc -watch -p ./",
-"postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test",
+"test": "tsc -p ./ && node ./out/test/runTest.js",
 "package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
 "publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },
@@ -45,12 +44,15 @@
 "vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
+"@types/glob": "^7.1.1",
 "@types/mocha": "^2.2.32",
 "@types/node": "^6.0.40",
+"@types/vscode": "^1.41.0",
+"glob": "^7.1.4",
 "clang-format": "1.2.4",
 "mocha": "^5.2.0",
-"typescript": "^2.0.3",
-"vscode": "^1.1.0"
+ 

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 241152.
serge-sans-paille added a comment.

Update user-level documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/semantic-interposition.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Transforms/Inline/inline-semantic-interposition.ll
  llvm/test/Verifier/module-flags-semantic-interposition.ll

Index: llvm/test/Verifier/module-flags-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Verifier/module-flags-semantic-interposition.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 1, align 4
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"SemanticInterposition", float 1.}
+
+; CHECK: SemanticInterposition metadata requires constant integer argument
Index: llvm/test/Transforms/Inline/inline-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-semantic-interposition.ll
@@ -0,0 +1,26 @@
+; Check that @callee1 gets inlined while @callee2 is not, because of
+; SemanticInterposition.
+
+; RUN: opt < %s -inline -S | FileCheck %s
+
+define internal i32 @callee1(i32 %A) {
+  ret i32 %A
+}
+
+define i32 @callee2(i32 %A) {
+  ret i32 %A
+}
+
+; CHECK-LABEL: @caller
+define i32 @caller(i32 %A) {
+; CHECK-NOT: call i32 @callee1(i32 %A)
+  %A1 = call i32 @callee1(i32 %A)
+; CHECK: %A2 = call i32 @callee2(i32 %A)
+  %A2 = call i32 @callee2(i32 %A)
+; CHECK: add i32 %A, %A2
+  %R = add i32 %A1, %A2
+  ret i32 %R
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"SemanticInterposition", i32 1}
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1476,6 +1476,13 @@
"'Linker Options' named metadata no longer supported");
   }
 
+  if (ID->getString() == "SemanticInterposition") {
+ConstantInt *Value =
+mdconst::dyn_extract_or_null(Op->getOperand(2));
+Assert(Value,
+   "SemanticInterposition metadata requires constant integer argument");
+  }
+
   if (ID->getString() == "CG Profile") {
 for (const MDOperand &MDO : cast(Op->getOperand(2))->operands())
   visitModuleFlagCGProfileEntry(MDO);
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -554,6 +554,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  Metadata *MF = getModuleFlag("SemanticInterposition");
+
+  auto *Val = cast_or_null(MF);
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (isInterposableLinkage(getLinkage()))
+return true;
+  return getParent() && getParent()->getSemanticInterposition() &&
+ !isDSOLocal();
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,12 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ 

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

> As this is user-facing documentation I feel like there should be a slightly 
> longer explaning what the option does.

done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62287 tests passed, 0 failed 
and 831 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624



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


[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-29 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 241158.
gchatelet marked 4 inline comments as done.
gchatelet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-memcpy-inline.c
  clang/test/Sema/builtins-memcpy-inline.c
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/IRBuilder.cpp

Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -200,6 +200,30 @@
   return CI;
 }
 
+CallInst *IRBuilderBase::CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign,
+Value *Src, MaybeAlign SrcAlign,
+Value *Size) {
+  Dst = getCastedInt8PtrValue(Dst);
+  Src = getCastedInt8PtrValue(Src);
+  Value *IsVolatile = getInt1(false);
+
+  Value *Ops[] = {Dst, Src, Size, IsVolatile};
+  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
+  Function *F = BB->getParent();
+  Module *M = F->getParent();
+  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys);
+
+  CallInst *CI = createCallHelper(TheFn, Ops, this);
+
+  auto *MCI = cast(CI);
+  if (DstAlign)
+MCI->setDestAlignment(*DstAlign);
+  if (SrcAlign)
+MCI->setSourceAlignment(*SrcAlign);
+
+  return CI;
+}
+
 CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
 uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -560,6 +560,9 @@
  MDNode *ScopeTag = nullptr,
  MDNode *NoAliasTag = nullptr);
 
+  CallInst *CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src,
+   MaybeAlign SrcAlign, Value *Size);
+
   /// Create and insert an element unordered-atomic memcpy between the
   /// specified pointers.
   ///
Index: clang/test/Sema/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/Sema/builtins-memcpy-inline.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NULL ((char *)0)
+
+#if __has_feature(__builtin_memcpy_inline)
+#warning defined as expected
+// expected-warning@-1 {{defined as expected}}
+#endif
+
+void test_memcpy_inline_null_src(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_dst(void *ptr) {
+  __builtin_memcpy_inline(NULL, ptr, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffers() {
+  __builtin_memcpy_inline(NULL, NULL, 4);
+  // expected-warning@-1 {{null passed to a callee that requires a non-null argument}}
+  // expected-warning@-2 {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, /*size */ 0);
+  __builtin_memcpy_inline(NULL, ptr, /*size */ 0);
+  __builtin_memcpy_inline(NULL, NULL, /*size */ 0);
+}
+
+void test_memcpy_inline_non_constant_size(void *dst, const void *src, unsigned size) {
+  __builtin_memcpy_inline(dst, src, size); // expected-error {{expression is not an integer constant expression}}
+}
Index: clang/test/CodeGen/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-memcpy-inline.c
@@ -0,0 +1,26 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define void @test_memcpy_inline_0(i8* %dst, i8* %src)
+void test_memcpy_inline_0(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 0, i1 false)
+  __builtin_memcpy_inline(dst, src, 0);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_1(i8* %dst, i8* %src)
+void test_memcpy_inline_1(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 1, i1 false)
+  __builtin_memcpy_inline(dst, src, 1);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_4(i8* %dst, i8* %src)
+void test_memcpy_inline_4(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 4, i1 false)
+  __builtin_memcpy_inli

[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-29 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2259
+``__builtin_memcpy_inline(dst, src, size)`` is identical to
+``__builtin_memcpy(dst, src, size)`` expect that the generated code is
+guaranteed not to call any external functions. See [LLVM IR 
‘llvm.memcpy.inline’

arichardson wrote:
> Typo: except
Thx :)



Comment at: clang/test/Sema/builtins-memcpy-inline.c:23
+}
+
+void test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {

arichardson wrote:
> Size can only be a constant right? Should there be a test for the error 
> reported in that case?
Thx it caught a bug indeed :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-29 Thread Thibault North via Phabricator via cfe-commits
tnorth updated this revision to Diff 241155.
tnorth added a comment.

- Add release notes
- Update ClangFormat.rst and ClangFormatStyleOption.rst


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14350,6 +14350,61 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9: explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style8 = getStyle("file:/e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(*Style8, getGoogleStyle());
+
+  // Test 10: relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style9 = getStyle("file:../../e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style9);
+  ASSERT_EQ(*Style9, getGoogleStyle());
+
+  // Test 11: missing explicit format file
+  auto Style10 = getStyle("file:/e/missing.clang-format",
+  "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style10);
+  llvm::consumeError(Style10.takeError());
+
+  // Test 12: format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+  "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+  llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  auto Style11 = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style11);
+  ASSERT_EQ(*Style11, getGoogleStyle());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2519,6 +2519,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2568,6 +2570,26 @@
 
 const char *DefaultFallbackStyle = "LLVM";
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS) {
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  std::error_code ReadFileError = Text.getError();
+  if (ReadFileError) {
+return make_string_error("Error reading config file " +
+ ReadFileError.message());
+  }
+  FormatStyle Style = getLLVMStyle();
+  std::error_code ParseFileError =
+  parseConfiguration(Text.get()->getBuffer(), &Style);
+  if (ParseFileError != ParseError::Success) {
+return make_string_error("Error parsing config file " +
+ ParseFileError.message());
+  }
+  return Style;
+}
+
 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyleName,
  StringRef Code,
@@ -2588,6 +2610,12 @@
 return Style;
   }
 
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_lower("file:")) {
+return LoadConfigFile(StyleName.substr(

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-29 Thread Thibault North via Phabricator via cfe-commits
tnorth added a comment.

In D72326#1845342 , @MyDeveloperDay 
wrote:

> Nit: please add a release note and regenerate the ClangFormatStyleOptions.rst 
> (if there are any changes because you modified Format.h).


Hmm, I tried to run docs/tools/dump_format_style.py, but it fails at two 
locations (once because a comment in Format.h has two slashes instead of 3, one 
because of an empty line). After fixing those, it seems that the generated file 
contains less information than the commited one. This file was probably updated 
manually as well. Therefore I also did in the updated diff... one should 
probably fix this separately.
Release note + ClangFormat.rst files update in the diff as well.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73628

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


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }
   return R.first->second;
 }


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }
   return R.first->second;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-29 Thread Jan Včelák via Phabricator via cfe-commits
janvcelak created this revision.
janvcelak added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

`execve` is missing in the list of functions that are allowed after `vfork()`. 
As a result, clang analyzer reports the following false positive:

  #include 
  
  int main(int argc, char *argv[])
  {
char *a[] = {"true", NULL};
char *e[] = {NULL};
if (vfork() == 0) {
execve("/bin/true", a, e);
_exit(1);
}
return 0;
  }



  $ scan-build clang -Wall -c repro.c  
  scan-build: Using '/usr/bin/clang-9' for static analysis
  repro.c:7:6: warning: Call to function 'vfork' is insecure as it can lead to 
denial of service situations in the parent process. Replace calls to vfork with 
calls to the safer 'posix_spawn' function
  if (vfork() == 0) {
  ^
  repro.c:8:3: warning: This function call is prohibited after a successful 
vfork
  execve("/bin/true", a, e);
  ^
  2 warnings generated.
  scan-build: 2 bugs found.
  scan-build: Run 'scan-view /tmp/scan-build-2020-01-29-162705-3770808-1' to 
examine bug reports.

The list of exec functions in the code is take from the `exec(3)` man page 
which are just a fronted for `execve(2)`. Quoting the manual page:

> The  exec() family of functions replaces the current process image with a new 
> process image.  The functions escribed in this manual page are front-ends for 
> execve(2).  (See the manual page for execve(2) for further details about the 
> replacement of the current process image.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73629

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


Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -106,6 +106,7 @@
   "execv",
   "execvp",
   "execvpe",
+  "execve",
   nullptr
 };
 


Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -106,6 +106,7 @@
   "execv",
   "execvp",
   "execvpe",
+  "execve",
   nullptr
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62285 tests passed, 2 failed 
and 831 were skipped.

  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/lock.pass.cpp
  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/try_lock.pass.cpp

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624



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


[clang-tools-extra] 01213f9 - [clang-tidy] Initialize token before handing it to the lexer

2020-01-29 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-01-29T16:48:57+01:00
New Revision: 01213f90700dbb98a0dbcc01da8fdb89f6db5617

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

LOG: [clang-tidy] Initialize token before handing it to the lexer

Found by msan.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 71cb0300ec62..41b7e1739ee0 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -173,6 +173,7 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, 
Token Tok) {
   bool ContainsSomethingElse = false;
 
   Token End;
+  End.startToken();
   End.setKind(tok::eof);
   SmallVector Stream{Tok, End};
 



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


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:122
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }

consider "Loaded compile commands..." or "Loading compile commands..." or 
"Loaded compilation database...".
People who are only dimly aware of the existence of `compile_commands.json` 
need a bit more context here.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:122
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }

sammccall wrote:
> consider "Loaded compile commands..." or "Loading compile commands..." or 
> "Loaded compilation database...".
> People who are only dimly aware of the existence of `compile_commands.json` 
> need a bit more context here.
this is significant and rare, probably OK to log rather than vlog


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73628



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-01-29 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

> This is an enabler for upcoming enhancements to indirect call promotion, for 
> example streamlined promotion guard sequences that compare against vtable 
> address instead of the target function

Can you please describe the whole approach in more detail? At the moment ICP is 
capable to do (a sort of) devirtualization is replacing indirect vtbl call with 
sequence of function address comparisons and direct calls.
Are you going to speedup this by means of comparing vtable pointers instead of 
function pointers (thus eliminating a single load per each vtbl call) or there 
is also something else in mind? If that's true, what's the next
step? Make ICP pass analyze type test intrinsics?




Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1660
+cast(CI->getArgOperand(1))->getMetadata();
 // If we found any, add them to CallSlots.
 if (!Assumes.empty()) {

This change seems to be unrelated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62300 tests passed, 0 failed 
and 837 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73300: [clang-tidy] Add library for clang-tidy main function

2020-01-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@thakis I'm sorry sorry if it was not clear. Please let me know if you still 
prefer to have separate directory for clangTidyMain to have only one target per 
CMakeLists.txt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73300



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


[PATCH] D73408: [Clang][Bundler] Add 'exclude' flag to target objects sections

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

Any additional comments?


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

https://reviews.llvm.org/D73408



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

In D72829#1846353 , @arichardson wrote:

> As this is user-facing documentation I feel like there should be a slightly 
> longer explaning what the option does.


+1 on this, otherwise LGTM. Thanks for implementing this!




Comment at: llvm/include/llvm/IR/GlobalValue.h:426
   /// Return true if this global's definition can be substituted with an
   /// *arbitrary* definition at link time.  We cannot do any IPO or inlinining
   /// across interposable call edges, since the callee can be replaced with

Minor nit: We have extended this to now determine if a definition can be 
substituted with an arbitrary definition at link time or load time. 

I would suggest changing the first `link time` to `link time or load time`, and 
changing
`since the callee can be replaced with something arbitrary at link time.` to 
`since the callee can be replaced with something arbitrary.`,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73408: [Clang][Bundler] Add 'exclude' flag to target objects sections

2020-01-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D73408



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


  1   2   >