[PATCH] D57012: Merge similar target diagnostics for interrupt attribute into one. NFC

2019-01-22 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb updated this revision to Diff 182852.
krisb added a comment.

Applied the comment.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57012

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5541,14 +5541,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 1;
 return;
   }
 
@@ -5616,14 +5616,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MIPS*/ 0 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MIPS*/ 0 << 1;
 return;
   }
 
@@ -5770,12 +5770,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_riscv_interrupt_attribute) << 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+  << /*RISC-V*/ 2 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_riscv_interrupt_attribute) << 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+  << /*RISC-V*/ 2 << 1;
 return;
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -261,22 +261,14 @@
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;
-def warn_mips_interrupt_attribute : Warning<
-   "MIPS 'interrupt' attribute only applies to functions that have "
-   "%select{no parameters|a 'void' return type}0">,
+def warn_interrupt_attribute_invalid : Warning<
+   "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to "
+   "functions that have %select{no parameters|a 'void' return type}1">,
InGroup;
 def warn_riscv_repeated_interrupt_attribute : Warning<
   "repeated RISC-V 'interrupt' attribute">, InGroup;
 def note_riscv_repeated_interrupt_attribute : Note<
   "repeated RISC-V 'interrupt' attribute is here">;
-def warn_riscv_interrupt_attribute : Warning<
-   "RISC-V 'interrupt' attribute only applies to functions that have "
-   "%select{no parameters|a 'void' return type}0">,
-   InGroup;
-def warn_msp430_interrupt_attribute : Warning<
-   "MSP430 'interrupt' attribute only applies to functions that have "
-   "%select{no parameters|a 'void' return type}0">,
-   InGroup;
 def warn_unused_parameter : Warning<"unused parameter %0">,
   InGroup, DefaultIgnore;
 def warn_unused_variable : Warning<"unused variable %0">,


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5541,14 +5541,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 1;
 return;
   }
 
@@ -5616,14 +5616,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MIPS*/ 0 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MIPS*/ 0 << 1;
 return;
   }
 
@@ -5770,12 +5770,14 @@
   }
 
   if (hasFunctionProto(D) && getF

[PATCH] D57012: Merge similar target diagnostics for interrupt attribute into one. NFC

2019-01-22 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

@aaron.ballman Thanks! Could I ask you to commit the patch? I don't have commit 
access yet.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57012



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


[clang-tools-extra] r351788 - [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.

2019-01-22 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Jan 22 01:10:20 2019
New Revision: 351788

URL: http://llvm.org/viewvc/llvm-project?rev=351788&view=rev
Log:
[clangd] Filter out plugin related flags and move all commandline manipulations 
into OverlayCDB.

Summary:
Some projects make use of clang plugins when building, but clangd is
not aware of those plugins therefore can't work with the same compile command
arguments.

There were multiple places clangd performed commandline manipulations,
 this one also moves them all into OverlayCDB.

Reviewers: ilya-biryukov

Subscribers: klimek, sammccall, ioeric, MaskRay, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=351788&r1=351787&r2=351788&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jan 22 01:10:20 2019
@@ -289,7 +289,8 @@ void ClangdLSPServer::onInitialize(const
   if (UseDirBasedCDB)
 BaseCDB = llvm::make_unique(
 CompileCommandsDir);
-  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);
+  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags,
+  ClangdServerOpts.ResourceDir);
   Server.emplace(*CDB, FSProvider, static_cast(*this),
  ClangdServerOpts);
   applyConfiguration(Params.initializationOptions.ConfigSettings);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=351788&r1=351787&r2=351788&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Jan 22 01:10:20 2019
@@ -37,11 +37,6 @@ namespace clang {
 namespace clangd {
 namespace {
 
-std::string getStandardResourceDir() {
-  static int Dummy; // Just an address in this process.
-  return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
-}
-
 class RefactoringResultCollector final
 : public tooling::RefactoringResultConsumer {
 public:
@@ -107,8 +102,6 @@ ClangdServer::ClangdServer(const GlobalC
DiagnosticsConsumer &DiagConsumer,
const Options &Opts)
 : CDB(CDB), FSProvider(FSProvider),
-  ResourceDir(Opts.ResourceDir ? *Opts.ResourceDir
-   : getStandardResourceDir()),
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
@@ -136,7 +129,7 @@ ClangdServer::ClangdServer(const GlobalC
 AddIndex(Opts.StaticIndex);
   if (Opts.BackgroundIndex) {
 BackgroundIdx = llvm::make_unique(
-Context::current().clone(), ResourceDir, FSProvider, CDB,
+Context::current().clone(), FSProvider, CDB,
 BackgroundIndexStorage::createDiskBackedStorageFactory(),
 Opts.BackgroundIndexRebuildPeriodMs);
 AddIndex(BackgroundIdx.get());
@@ -461,10 +454,6 @@ tooling::CompileCommand ClangdServer::ge
   llvm::Optional C = CDB.getCompileCommand(File);
   if (!C) // FIXME: Suppress diagnostics? Let the user know?
 C = CDB.getFallbackCommand(File);
-
-  // Inject the resource dir.
-  // FIXME: Don't overwrite it if it's already there.
-  C->CommandLine.push_back("-resource-dir=" + ResourceDir);
   return std::move(*C);
 }
 

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=351788&r1=351787&r2=351788&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Tue Jan 22 
01:10:20 2019
@@ -8,12 +8,36 @@
 
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileS

[PATCH] D56841: [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.

2019-01-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rL351788: [clangd] Filter out plugin related flags and move 
all commandline manipulations… (authored by kadircet, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56841

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/trunk/clangd/index/Background.cpp
  clang-tools-extra/trunk/clangd/index/Background.h
  clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
  clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -64,7 +64,7 @@
 };
 
 TEST_F(OverlayCDBTest, GetCompileCommand) {
-  OverlayCDB CDB(Base.get());
+  OverlayCDB CDB(Base.get(), {}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
 Base->getCompileCommand(testPath("foo.cc")));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
@@ -84,7 +84,7 @@
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
-  OverlayCDB CDB(nullptr, {"-DA=6"});
+  OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
Index: clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
@@ -76,7 +76,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return &MSS; });
 
   tooling::CompileCommand Cmd;
@@ -113,7 +113,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return &MSS; });
 
   tooling::CompileCommand Cmd;
@@ -168,7 +168,7 @@
   // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -178,7 +178,7 @@
 
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -224,7 +224,7 @@
   Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -262,7 +262,7 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex Idx(
-  Context::empty(), "", FS, CDB, [&](llvm::StringRef) { return &MSS; },
+  Context::empty(), FS, CDB, [&](llvm::StringRef) { return &MSS; },
   /*BuildIndexPeriodMs=*/500);
 
   FS.Files[testPath("root/A.cc")] = "#include \"A.h\"";
@@ -310,7 +310,7 @@
   // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -325,7 +325,7 @@
   )cpp";
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context:

[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete

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

- Moved ParseInputs and buildCompilerInvocation into Compiler.h


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56860

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Compiler.cpp
  clangd/Compiler.h

Index: clangd/Compiler.h
===
--- clangd/Compiler.h
+++ clangd/Compiler.h
@@ -18,6 +18,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Tooling/CompilationDatabase.h"
 
 namespace clang {
 namespace clangd {
@@ -31,6 +32,17 @@
 const clang::Diagnostic &Info) override;
 };
 
+/// Information required to run clang, e.g. to parse AST or do code completion.
+struct ParseInputs {
+  tooling::CompileCommand CompileCommand;
+  IntrusiveRefCntPtr FS;
+  std::string Contents;
+};
+
+/// Builds compiler invocation that could be used to build AST or preamble.
+std::unique_ptr
+buildCompilerInvocation(const ParseInputs &Inputs);
+
 /// Creates a compiler instance, configured so that:
 ///   - Contents of the parsed file are remapped to \p MainFile.
 ///   - Preamble is overriden to use PCH passed to this function. It means the
Index: clangd/Compiler.cpp
===
--- clangd/Compiler.cpp
+++ clangd/Compiler.cpp
@@ -39,6 +39,34 @@
   IgnoreDiagnostics::log(DiagLevel, Info);
 }
 
+std::unique_ptr
+buildCompilerInvocation(const ParseInputs &Inputs) {
+  std::vector ArgStrs;
+  for (const auto &S : Inputs.CompileCommand.CommandLine)
+ArgStrs.push_back(S.c_str());
+
+  if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
+log("Couldn't set working directory when creating compiler invocation.");
+// We proceed anyway, our lit-tests rely on results for non-existing working
+// dirs.
+  }
+
+  // FIXME(ibiryukov): store diagnostics from CommandLine when we start
+  // reporting them.
+  IgnoreDiagnostics IgnoreDiagnostics;
+  llvm::IntrusiveRefCntPtr CommandLineDiagsEngine =
+  CompilerInstance::createDiagnostics(new DiagnosticOptions,
+  &IgnoreDiagnostics, false);
+  std::unique_ptr CI = createInvocationFromCommandLine(
+  ArgStrs, CommandLineDiagsEngine, Inputs.FS);
+  if (!CI)
+return nullptr;
+  // createInvocationFromCommandLine sets DisableFree.
+  CI->getFrontendOpts().DisableFree = false;
+  CI->getLangOpts()->CommentOpts.ParseAllComments = true;
+  return CI;
+}
+
 std::unique_ptr
 prepareCompilerInstance(std::unique_ptr CI,
 const PrecompiledPreamble *Preamble,
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1016,33 +1016,17 @@
   const SemaCompleteInput &Input,
   IncludeStructure *Includes = nullptr) {
   trace::Span Tracer("Sema completion");
-  std::vector ArgStrs;
-  for (const auto &S : Input.Command.CommandLine)
-ArgStrs.push_back(S.c_str());
-
-  if (Input.VFS->setCurrentWorkingDirectory(Input.Command.Directory)) {
-log("Couldn't set working directory");
-// We run parsing anyway, our lit-tests rely on results for non-existing
-// working dirs.
-  }
-
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  IgnoreDiagnostics DummyDiagsConsumer;
-  auto CI = createInvocationFromCommandLine(
-  ArgStrs,
-  CompilerInstance::createDiagnostics(new DiagnosticOptions,
-  &DummyDiagsConsumer, false),
-  VFS);
+  auto CI =
+  buildCompilerInvocation(ParseInputs{Input.Command, VFS, Input.Contents});
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;
   }
   auto &FrontendOpts = CI->getFrontendOpts();
-  FrontendOpts.DisableFree = false;
   FrontendOpts.SkipFunctionBodies = true;
-  CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
   // Setup code completion.
@@ -1072,6 +1056,7 @@
   *Offset;
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
   // the remapped buffers do not get freed.
+  IgnoreDiagnostics DummyDiagsConsumer;
   auto Clang = prepareCompilerInstance(
   std::move(CI),
   (Input.Preamble && !CompletingInPreamble) ? &Input.Preamble->Preamble
Index: clangd/ClangdUnit.h
===
--- clangd/ClangdUnit.h
+++ clangd/ClangdUnit.h
@@ -9,6 +9,7 @@
 #ifndef L

[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

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



Comment at: clangd/ClangdLSPServer.h:132
 
-  RealFileSystemProvider FSProvider;
   /// Options used for code completion

ilya-biryukov wrote:
> hokein wrote:
> > sammccall wrote:
> > > ilya-biryukov wrote:
> > > > Could we instead call `getRealFS()` when we try to initialize a 
> > > > clang-tidy options provider in `main()` and avoid changing this?
> > > > To avoid adding extra non-real-fs "modes of operation" to 
> > > > `ClangdLSPServer`. Unless you see other uses for this.
> > > We already have out-of-tree modifications to ClangdLSPServer to use 
> > > non-real FSes.
> > > Given that, I think this change is OK... though better still might be to 
> > > move it into `ClangdServer::Options`
> > Yes, this is the main reason I did this change.
> It still feels that `ClangdLSPServcer` is closely tied to real fs, so I don't 
> see how that makes things simpler. I wouldn't call the presence of 
> out-of-tree modifications a good reason to do this change, at least not 
> without tests and comments explaining why this needs to be configurable.
> 
> WRT to `ClangdServer::Options`, I believe this goes back to the previous 
> discussion we had about putting the non-data configuration parameters 
> (Index+FSProvider+CompilationsDB). I'd say put `CompilationsDB` into 
> `Options` as well if you plan to put FSProvider, they should really live 
> together (i.e. the reason we have out-of-tree modifications is closely tied 
> to our custom CDB, so it makes sense for both to stay together). 
> 
> FWIW, I still think they're FSProvider+CDB+Index should be separate 
> parameters, but that goes back to the earlier conversation we had with 
> @sammccall when the `Options` were added in the first place.
> 
> Not a big deal, just wanted to convey the intention of my original comment.
> It still feels that ClangdLSPServcer is closely tied to real fs, so I don't 
> see how that makes things simpler. I wouldn't call the presence of 
> out-of-tree modifications a good reason to do this change, at least not 
> without tests and comments explaining why this needs to be configurable.

This would simplifier our internal modification (just 1-2 line changes) -- 
ClangTidyOptionProvider needs to know FileSystem, we need a way to retrieve it 
(I believe both clangdLSPServer and ClangTidyOptionProvider should share the 
same non-real FS internally). An optional way is to add a `GetFS` method in 
ClangdLSPServer.

Anyway, I think this shouldn't block this patch, we could revisit it afterwards.




Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55256



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


[clang-tools-extra] r351792 - [clangd] Support clang-tidy configuration in clangd.

2019-01-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Jan 22 01:39:05 2019
New Revision: 351792

URL: http://llvm.org/viewvc/llvm-project?rev=351792&view=rev
Log:
[clangd] Support clang-tidy configuration in clangd.

Summary:
This patch adds some basic supports for clang-tidy configurations in clangd:
  - clangd will respect .clang-tidy configurations for each file
  - we don't aim to support all clang-tidy options in clangd, only a
small subset of condfigurations (options related to which checks will be
enabled) are supported.
  - add a `clang-tidy-checks` CLI option that can override options from
.clang-tidy file

Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, 
cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=351792&r1=351791&r2=351792&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jan 22 01:39:05 2019
@@ -720,11 +720,13 @@ void ClangdLSPServer::onSymbolInfo(const
 }
 
 ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
+ const FileSystemProvider &FSProvider,
  const clangd::CodeCompleteOptions &CCOpts,
  llvm::Optional CompileCommandsDir,
  bool UseDirBasedCDB,
  const ClangdServer::Options &Opts)
-: Transp(Transp), MsgHandler(new MessageHandler(*this)), CCOpts(CCOpts),
+: Transp(Transp), MsgHandler(new MessageHandler(*this)),
+  FSProvider(FSProvider), CCOpts(CCOpts),
   SupportedSymbolKinds(defaultSymbolKinds()),
   SupportedCompletionItemKinds(defaultCompletionItemKinds()),
   UseDirBasedCDB(UseDirBasedCDB),

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=351792&r1=351791&r2=351792&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Jan 22 01:39:05 2019
@@ -37,7 +37,8 @@ public:
   /// for compile_commands.json in all parent directories of each file.
   /// If UseDirBasedCDB is false, compile commands are not read from disk.
   // FIXME: Clean up signature around CDBs.
-  ClangdLSPServer(Transport &Transp, const clangd::CodeCompleteOptions &CCOpts,
+  ClangdLSPServer(Transport &Transp, const FileSystemProvider &FSProvider,
+  const clangd::CodeCompleteOptions &CCOpts,
   llvm::Optional CompileCommandsDir, bool UseDirBasedCDB,
   const ClangdServer::Options &Opts);
   ~ClangdLSPServer();
@@ -128,7 +129,7 @@ private:
   void call(StringRef Method, llvm::json::Value Params);
   void notify(StringRef Method, llvm::json::Value Params);
 
-  RealFileSystemProvider FSProvider;
+  const FileSystemProvider &FSProvider;
   /// Options used for code completion
   clangd::CodeCompleteOptions CCOpts;
   /// Options used for diagnostics.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=351792&r1=351791&r2=351792&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Jan 22 01:39:05 2019
@@ -105,6 +105,7 @@ ClangdServer::ClangdServer(const GlobalC
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
+  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),
   PCHs(std::make_shared()),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -140,13 +141,16 @@ ClangdServer::ClangdServer(const GlobalC
 
 voi

[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-22 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE351792: [clangd] Support clang-tidy configuration in 
clangd. (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55256?vs=182778&id=182862#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55256

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,6 +35,8 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
+  Inputs.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
+  Inputs.ClangTidyOpts.Checks = ClangTidyChecks;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -38,7 +38,8 @@
 protected:
   ParseInputs getInputs(PathRef File, std::string Contents) {
 return ParseInputs{*CDB.getCompileCommand(File),
-   buildTestFS(Files, Timestamps), std::move(Contents)};
+   buildTestFS(Files, Timestamps), std::move(Contents),
+   tidy::ClangTidyOptions::getDefaults()};
   }
 
   void updateWithCallback(TUScheduler &S, PathRef File,
Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -48,6 +48,8 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  llvm::Optional ClangTidyChecks;
+
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -363,7 +363,8 @@
   auto AST =
   ParsedAST::build(createInvocationFromCommandLine(Cmd), PreambleData,
llvm::MemoryBuffer::getMemBufferCopy(Main.code()),
-   std::make_shared(), PI.FS);
+   std::make_shared(), PI.FS,
+   tidy::ClangTidyOptions::getDefaults());
   ASSERT_TRUE(AST);
   FileIndex Index;
   Index.updateMain(MainFile, *AST);
Index: unittests/clangd/ClangdUnitTests.cpp
===
--- unittests/clangd/ClangdUnitTests.cpp
+++ unittests/clangd/ClangdUnitTests.cpp
@@ -141,6 +141,9 @@
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.HeaderFilename = "assert.h"; // Suppress "not found" error.
+  TU.ClangTidyChecks =
+  "-*, bugprone-sizeof-expression, bugprone-macro-repeated-side-effects, "
+  "modernize-deprecated-headers";
   EXPECT_THAT(
   TU.build().getDiagnostics(),
   UnorderedElementsAre(
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -105,6 +105,7 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
+  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),
   PCHs(std::make_shared()),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -140,13 +141,16 @@
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  tidy::ClangTidyOptions Options = tidy::ClangTidyOptions::getDefaults();
+  if (ClangTidyOptProvider)
+Options = ClangTidyOptProvider->getOptions(File);
   // FIXME: some build systems like Bazel will take time to preparing
   // environment to build the file, it would be nice if we could emit a
   // "PreparingBuild" status to inform users, it is non-trivial given the
   // current implementation.
-  WorkScheduler.update(File,
-   ParseInputs{getCompileCommand(File),
-   FSProvider.getFileSystem(), Contents.str()},
+  WorkScheduler.update(File, ParseInputs{getCompileCommand(File),
+ FSProvider.getFileSystem(),
+

[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete

2019-01-22 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.

Thank you!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56860



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


[PATCH] D57042: [clangd] NFC: reduce log noise from Diagnostics.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57042

Files:
  clangd/Diagnostics.cpp


Index: clangd/Diagnostics.cpp
===
--- clangd/Diagnostics.cpp
+++ clangd/Diagnostics.cpp
@@ -403,8 +403,8 @@
   if (mentionsMainFile(*LastDiag))
 Output.push_back(std::move(*LastDiag));
   else
-log("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
-LastDiag->Message);
+vlog("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
+ LastDiag->Message);
   LastDiag.reset();
 }
 


Index: clangd/Diagnostics.cpp
===
--- clangd/Diagnostics.cpp
+++ clangd/Diagnostics.cpp
@@ -403,8 +403,8 @@
   if (mentionsMainFile(*LastDiag))
 Output.push_back(std::move(*LastDiag));
   else
-log("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
-LastDiag->Message);
+vlog("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
+ LastDiag->Message);
   LastDiag.reset();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r351793 - [clangd] NFC: Use buildCompilerInvocation in CodeComplete

2019-01-22 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Jan 22 01:58:53 2019
New Revision: 351793

URL: http://llvm.org/viewvc/llvm-project?rev=351793&view=rev
Log:
[clangd] NFC: Use buildCompilerInvocation in CodeComplete

Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Compiler.cpp
clang-tools-extra/trunk/clangd/Compiler.h

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=351793&r1=351792&r2=351793&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Jan 22 01:58:53 2019
@@ -418,34 +418,6 @@ ParsedAST::ParsedAST(std::shared_ptrAction);
 }
 
-std::unique_ptr
-buildCompilerInvocation(const ParseInputs &Inputs) {
-  std::vector ArgStrs;
-  for (const auto &S : Inputs.CompileCommand.CommandLine)
-ArgStrs.push_back(S.c_str());
-
-  if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
-log("Couldn't set working directory when creating compiler invocation.");
-// We proceed anyway, our lit-tests rely on results for non-existing 
working
-// dirs.
-  }
-
-  // FIXME(ibiryukov): store diagnostics from CommandLine when we start
-  // reporting them.
-  IgnoreDiagnostics IgnoreDiagnostics;
-  llvm::IntrusiveRefCntPtr CommandLineDiagsEngine =
-  CompilerInstance::createDiagnostics(new DiagnosticOptions,
-  &IgnoreDiagnostics, false);
-  std::unique_ptr CI = createInvocationFromCommandLine(
-  ArgStrs, CommandLineDiagsEngine, Inputs.FS);
-  if (!CI)
-return nullptr;
-  // createInvocationFromCommandLine sets DisableFree.
-  CI->getFrontendOpts().DisableFree = false;
-  CI->getLangOpts()->CommentOpts.ParseAllComments = true;
-  return CI;
-}
-
 std::shared_ptr
 buildPreamble(PathRef FileName, CompilerInvocation &CI,
   std::shared_ptr OldPreamble,

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=351793&r1=351792&r2=351793&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h Tue Jan 22 01:58:53 2019
@@ -9,7 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
 
-#include "../clang-tidy/ClangTidyOptions.h"
+#include "Compiler.h"
 #include "Diagnostics.h"
 #include "FS.h"
 #include "Function.h"
@@ -60,14 +60,6 @@ struct PreambleData {
   std::unique_ptr StatCache;
 };
 
-/// Information required to run clang, e.g. to parse AST or do code completion.
-struct ParseInputs {
-  tooling::CompileCommand CompileCommand;
-  IntrusiveRefCntPtr FS;
-  std::string Contents;
-  tidy::ClangTidyOptions ClangTidyOpts;
-};
-
 /// Stores and provides access to parsed AST.
 class ParsedAST {
 public:
@@ -137,10 +129,6 @@ private:
 using PreambleParsedCallback =
 std::function)>;
 
-/// Builds compiler invocation that could be used to build AST or preamble.
-std::unique_ptr
-buildCompilerInvocation(const ParseInputs &Inputs);
-
 /// Rebuild the preamble for the new inputs unless the old one can be reused.
 /// If \p OldPreamble can be reused, it is returned unchanged.
 /// If \p OldPreamble is null, always builds the preamble.

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=351793&r1=351792&r2=351793&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Jan 22 01:58:53 2019
@@ -1016,33 +1016,17 @@ bool semaCodeComplete(std::unique_ptr ArgStrs;
-  for (const auto &S : Input.Command.CommandLine)
-ArgStrs.push_back(S.c_str());
-
-  if (Input.VFS->setCurrentWorkingDirectory(Input.Command.Directory)) {
-log("Couldn't set working directory");
-// We run parsing anyway, our lit-tests rely on results for non-existing
-// working dirs.
-  }
-
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  IgnoreDiagnostics DummyDiagsConsumer;
-  auto CI = createInvocationFromCommandLine(
-  ArgStrs,
-  CompilerInstance::createDiagnostics(new DiagnosticOptions,
-  &DummyDiagsConsumer, fals

[PATCH] D57043: [clangd] Use the shared forced-linking code.

2019-01-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov, mgorny, srhines.

Also add a missing MPI module.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57043

Files:
  clangd/CMakeLists.txt
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -572,29 +572,6 @@
 }
 
 } // namespace clangd
-namespace tidy {
-// Force the linker to link in Clang-tidy modules.
-#define LINK_TIDY_MODULE(X)
\
-  extern volatile int X##ModuleAnchorSource;   
\
-  static int LLVM_ATTRIBUTE_UNUSED X##ModuleAnchorDestination =
\
-  X##ModuleAnchorSource
-LINK_TIDY_MODULE(CERT);
-LINK_TIDY_MODULE(Abseil);
-LINK_TIDY_MODULE(Boost);
-LINK_TIDY_MODULE(Bugprone);
-LINK_TIDY_MODULE(LLVM);
-LINK_TIDY_MODULE(CppCoreGuidelines);
-LINK_TIDY_MODULE(Fuchsia);
-LINK_TIDY_MODULE(Google);
-LINK_TIDY_MODULE(Android);
-LINK_TIDY_MODULE(Misc);
-LINK_TIDY_MODULE(Modernize);
-LINK_TIDY_MODULE(Performance);
-LINK_TIDY_MODULE(Portability);
-LINK_TIDY_MODULE(Readability);
-LINK_TIDY_MODULE(ObjC);
-LINK_TIDY_MODULE(HICPP);
-LINK_TIDY_MODULE(Zircon);
-#undef LINK_TIDY_MODULE
-} // namespace tidy
 } // namespace clang
+
+#include "../clang-tidy/ClangTidyForceLinker.h"
\ No newline at end of file
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -107,6 +107,12 @@
   ${CLANGD_ATOMIC_LIB}
   )
 
+if( CLANG_ENABLE_STATIC_ANALYZER )
+  target_link_libraries(clangDaemon PRIVATE
+clangTidyMPIModule
+  )
+endif()
+
 if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -572,29 +572,6 @@
 }
 
 } // namespace clangd
-namespace tidy {
-// Force the linker to link in Clang-tidy modules.
-#define LINK_TIDY_MODULE(X)\
-  extern volatile int X##ModuleAnchorSource;   \
-  static int LLVM_ATTRIBUTE_UNUSED X##ModuleAnchorDestination =\
-  X##ModuleAnchorSource
-LINK_TIDY_MODULE(CERT);
-LINK_TIDY_MODULE(Abseil);
-LINK_TIDY_MODULE(Boost);
-LINK_TIDY_MODULE(Bugprone);
-LINK_TIDY_MODULE(LLVM);
-LINK_TIDY_MODULE(CppCoreGuidelines);
-LINK_TIDY_MODULE(Fuchsia);
-LINK_TIDY_MODULE(Google);
-LINK_TIDY_MODULE(Android);
-LINK_TIDY_MODULE(Misc);
-LINK_TIDY_MODULE(Modernize);
-LINK_TIDY_MODULE(Performance);
-LINK_TIDY_MODULE(Portability);
-LINK_TIDY_MODULE(Readability);
-LINK_TIDY_MODULE(ObjC);
-LINK_TIDY_MODULE(HICPP);
-LINK_TIDY_MODULE(Zircon);
-#undef LINK_TIDY_MODULE
-} // namespace tidy
 } // namespace clang
+
+#include "../clang-tidy/ClangTidyForceLinker.h"
\ No newline at end of file
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -107,6 +107,12 @@
   ${CLANGD_ATOMIC_LIB}
   )
 
+if( CLANG_ENABLE_STATIC_ANALYZER )
+  target_link_libraries(clangDaemon PRIVATE
+clangTidyMPIModule
+  )
+endif()
+
 if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete

2019-01-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE351793: [clangd] NFC: Use buildCompilerInvocation in 
CodeComplete (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56860?vs=182856&id=182865#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56860

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Compiler.cpp
  clangd/Compiler.h

Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -418,34 +418,6 @@
   assert(this->Action);
 }
 
-std::unique_ptr
-buildCompilerInvocation(const ParseInputs &Inputs) {
-  std::vector ArgStrs;
-  for (const auto &S : Inputs.CompileCommand.CommandLine)
-ArgStrs.push_back(S.c_str());
-
-  if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
-log("Couldn't set working directory when creating compiler invocation.");
-// We proceed anyway, our lit-tests rely on results for non-existing working
-// dirs.
-  }
-
-  // FIXME(ibiryukov): store diagnostics from CommandLine when we start
-  // reporting them.
-  IgnoreDiagnostics IgnoreDiagnostics;
-  llvm::IntrusiveRefCntPtr CommandLineDiagsEngine =
-  CompilerInstance::createDiagnostics(new DiagnosticOptions,
-  &IgnoreDiagnostics, false);
-  std::unique_ptr CI = createInvocationFromCommandLine(
-  ArgStrs, CommandLineDiagsEngine, Inputs.FS);
-  if (!CI)
-return nullptr;
-  // createInvocationFromCommandLine sets DisableFree.
-  CI->getFrontendOpts().DisableFree = false;
-  CI->getLangOpts()->CommentOpts.ParseAllComments = true;
-  return CI;
-}
-
 std::shared_ptr
 buildPreamble(PathRef FileName, CompilerInvocation &CI,
   std::shared_ptr OldPreamble,
Index: clangd/Compiler.h
===
--- clangd/Compiler.h
+++ clangd/Compiler.h
@@ -15,9 +15,11 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COMPILER_H
 
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Tooling/CompilationDatabase.h"
 
 namespace clang {
 namespace clangd {
@@ -31,6 +33,18 @@
 const clang::Diagnostic &Info) override;
 };
 
+/// Information required to run clang, e.g. to parse AST or do code completion.
+struct ParseInputs {
+  tooling::CompileCommand CompileCommand;
+  IntrusiveRefCntPtr FS;
+  std::string Contents;
+  tidy::ClangTidyOptions ClangTidyOpts;
+};
+
+/// Builds compiler invocation that could be used to build AST or preamble.
+std::unique_ptr
+buildCompilerInvocation(const ParseInputs &Inputs);
+
 /// Creates a compiler instance, configured so that:
 ///   - Contents of the parsed file are remapped to \p MainFile.
 ///   - Preamble is overriden to use PCH passed to this function. It means the
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1016,33 +1016,17 @@
   const SemaCompleteInput &Input,
   IncludeStructure *Includes = nullptr) {
   trace::Span Tracer("Sema completion");
-  std::vector ArgStrs;
-  for (const auto &S : Input.Command.CommandLine)
-ArgStrs.push_back(S.c_str());
-
-  if (Input.VFS->setCurrentWorkingDirectory(Input.Command.Directory)) {
-log("Couldn't set working directory");
-// We run parsing anyway, our lit-tests rely on results for non-existing
-// working dirs.
-  }
-
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  IgnoreDiagnostics DummyDiagsConsumer;
-  auto CI = createInvocationFromCommandLine(
-  ArgStrs,
-  CompilerInstance::createDiagnostics(new DiagnosticOptions,
-  &DummyDiagsConsumer, false),
-  VFS);
+  auto CI =
+  buildCompilerInvocation(ParseInputs{Input.Command, VFS, Input.Contents});
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;
   }
   auto &FrontendOpts = CI->getFrontendOpts();
-  FrontendOpts.DisableFree = false;
   FrontendOpts.SkipFunctionBodies = true;
-  CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
   // Setup code completion.
@@ -1072,6 +1056,7 @@
   *Offset;
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
   // the remapped buffers do not get freed.
+  IgnoreDiagnostics DummyDiagsConsumer;
   auto Clang = prepareCompilerIns

[PATCH] D53818: [ASTImporter] Changed use of Import to Import_New in ASTImporter.

2019-01-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 182866.
balazske added a comment.

- Small style corrections.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53818

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -134,25 +134,6 @@
   To->setIsUsed();
   }
 
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(SourceLocation &To, const SourceLocation &From) {
-To = Import(From);
-if (From.isValid() && To.isInvalid())
-return llvm::make_error();
-return Error::success();
-  }
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(QualType &To, const QualType &From) {
-To = Import(From);
-if (!From.isNull() && To.isNull())
-return llvm::make_error();
-return Error::success();
-  }
-
   class ASTNodeImporter : public TypeVisitor,
   public DeclVisitor,
   public StmtVisitor {
@@ -7623,13 +7604,6 @@
 
 ASTImporter::~ASTImporter() = default;
 
-Expected ASTImporter::Import_New(QualType FromT) {
-  QualType ToT = Import(FromT);
-  if (ToT.isNull() && !FromT.isNull())
-return make_error();
-  return ToT;
-}
-
 Optional ASTImporter::getFieldIndex(Decl *F) {
   assert(F && (isa(*F) || isa(*F)) &&
   "Try to get field index for non-field.");
@@ -7681,9 +7655,9 @@
   LookupTable->add(ToND);
 }
 
-QualType ASTImporter::Import(QualType FromT) {
+Expected ASTImporter::Import_New(QualType FromT) {
   if (FromT.isNull())
-return {};
+return QualType{};
 
   const Type *FromTy = FromT.getTypePtr();
 
@@ -7696,46 +7670,64 @@
   // Import the type
   ASTNodeImporter Importer(*this);
   ExpectedType ToTOrErr = Importer.Visit(FromTy);
-  if (!ToTOrErr) {
-llvm::consumeError(ToTOrErr.takeError());
-return {};
-  }
+  if (!ToTOrErr)
+return ToTOrErr.takeError();
 
   // Record the imported type.
   ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
 
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
+QualType ASTImporter::Import(QualType From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return {};
+}
 
 Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
-  TypeSourceInfo *ToTSI = Import(FromTSI);
-  if (!ToTSI && FromTSI)
-return llvm::make_error();
-  return ToTSI;
-}
-TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
 
   // FIXME: For now we just create a "trivial" type source info based
   // on the type and a single location. Implement a real version of this.
-  QualType T = Import(FromTSI->getType());
-  if (T.isNull())
-return nullptr;
+  ExpectedType TOrErr = Import_New(FromTSI->getType());
+  if (!TOrErr)
+return TOrErr.takeError();
+  ExpectedSLoc BeginLocOrErr = Import_New(FromTSI->getTypeLoc().getBeginLoc());
+  if (!BeginLocOrErr)
+return BeginLocOrErr.takeError();
 
-  return ToContext.getTrivialTypeSourceInfo(
-  T, Import(FromTSI->getTypeLoc().getBeginLoc()));
+  return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
+}
+TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
 }
 
 Expected ASTImporter::Import_New(const Attr *FromAttr) {
-  return Import(FromAttr);
-}
-Attr *ASTImporter::Import(const Attr *FromAttr) {
   Attr *ToAttr = FromAttr->clone(ToContext);
-  // NOTE: Import of SourceRange may fail.
-  ToAttr->setRange(Import(FromAttr->getRange()));
+  if (auto ToRangeOrErr = Import_New(FromAttr->getRange()))
+ToAttr->setRange(*ToRangeOrErr);
+  else
+return ToRangeOrErr.takeError();
+
   return ToAttr;
 }
+Attr *ASTImporter::Import(const Attr *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
+}
 
 Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
   auto Pos = ImportedDecls.find(FromD);
@@ -7746,12 +7738,6 @@
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {
-  Decl *ToD = Import(FromD);
-  if (!ToD && FromD)
-return llvm::make_error();
-  return ToD;
-}
-Decl *ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
 
@@ -7765,12 +7751,10 @@
 return ToD;
   }
 
-  // Import the type.
+  // Import the declaration.
   ExpectedDecl ToDOrErr = Importer.Visit(FromD);
-  if (!ToDOrErr) {
-llvm::consumeError(ToDOrErr.takeError());
-return nullptr;
-  }
+  if (!ToDOrErr)
+return ToDOrErr;
   ToD = *ToDOrErr;
 
   // Once

[PATCH] D56267: [clangd] Interfaces for writing code actions

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182870.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

- Inline Tweak::Selection::create()
- Define Tweak::id() in REGISTER_TWEAK.


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

https://reviews.llvm.org/D56267

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/tool/CMakeLists.txt
  clang-tools-extra/test/clangd/initialize-params.test

Index: clang-tools-extra/test/clangd/initialize-params.test
===
--- clang-tools-extra/test/clangd/initialize-params.test
+++ clang-tools-extra/test/clangd/initialize-params.test
@@ -25,7 +25,8 @@
 # CHECK-NEXT:  "documentSymbolProvider": true,
 # CHECK-NEXT:  "executeCommandProvider": {
 # CHECK-NEXT:"commands": [
-# CHECK-NEXT:  "clangd.applyFix"
+# CHECK-NEXT:  "clangd.applyFix",
+# CHECK-NEXT:  "clangd.applyCodeAction"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "hoverProvider": true,
Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -3,6 +3,7 @@
 
 add_clang_tool(clangd
   ClangdMain.cpp
+  $
   )
 
 set(LLVM_LINK_COMPONENTS
Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -0,0 +1,11 @@
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
+
+# A target containing all code tweaks (i.e. mini-refactorings) provided by
+# clangd.
+# Built as an object library to make sure linker does not remove global
+# constructors that register individual tweaks in a global registry.
+# To enable these tweaks in exectubales or shared libraries, add
+# $ to a list of sources, see
+# clangd/tool/CMakeLists.txt for an example.
+add_clang_library(clangDaemonTweaks OBJECT
+  )
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -0,0 +1,99 @@
+//===--- Tweak.h -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+// Tweaks are small refactoring-like actions that run over the AST and produce
+// the set of edits as a result. They are local, i.e. they should take the
+// current editor context, e.g. the cursor position and selection into account.
+// The actions are executed in two stages:
+//   - Stage 1 should check whether the action is available in a current
+// context. It should be cheap and fast to compute as it is executed for all
+// available actions on every client request, which happen quite frequently.
+//   - Stage 2 is performed after stage 1 and can be more expensive to compute.
+// It is performed when the user actually chooses the action.
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_ACTIONS_TWEAK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_ACTIONS_TWEAK_H
+
+#include "ClangdUnit.h"
+#include "Protocol.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+namespace clang {
+namespace clangd {
+
+using TweakID = llvm::StringRef;
+
+/// An interface base for small context-sensitive refactoring actions.
+/// To implement a new tweak use the following pattern in a .cpp file:
+///   class MyTweak : public Tweak {
+///   public:
+/// TweakID id() const override final; // definition provided by REGISTER_TWEAK.
+/// // implement other methods here.
+///   };
+///   REGISTER_TWEAK(MyTweak);
+class Tweak {
+public:
+  /// Input to prepare and apply tweaks.
+  struct Selection {
+/// The text of the active document.
+llvm::StringRef Code;
+/// Parsed AST of the active file.
+ParsedAST &AST;
+/// A location of the cursor in the editor.
+SourceLocation Cursor;
+// FIXME: add selection when there are checks relying on it.
+// FIXME: provide a way to get sources and ASTs for other files.
+  

[PATCH] D56267: [clangd] Interfaces for writing code actions

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



Comment at: clangd/refactor/Tweak.h:40
+  struct Selection {
+static llvm::Optional create(llvm::StringRef File,
+llvm::StringRef Code,

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > sammccall wrote:
> > > > Not convinced about this helper function.
> > > >  - much of it is just a passthrough to struct initialization. I think 
> > > > the code calling it would be clearer if it was initialising the fields 
> > > > one-by one
> > > >  - the only part that's not passthrough is already a function call with 
> > > > a clear name, calling it seems reasonable
> > > >  - I'm not sure it makes sense to have the Range -> SourceLocation 
> > > > conversion in this file, but the Tweak -> CodeAction conversion outside 
> > > > this file (and not unit-testable). There's an argument to be make to 
> > > > keep this file independent of LSP protocol structs, but I think that 
> > > > argument applies equally to this function.
> > > Expected? Passing an invalid range is always an error I guess.
> > The reason I added it is to avoid duplication between in the test code and 
> > `ClangdServer`, which are the only two clients we have.
> > I expect this to be more useful when we add a way to traverse the subset of 
> > the AST in the checks
> I understand. I think as things stand both callers would be clearer (if a 
> couple of lines longer) without this helper.
> 
> What the API should be in the future - happy to talk about that then.
I'd keep this function, here is my reasoning:

1. There are 4 usages already (2 in this patch, 2 in the tests), keeping them 
in sync means an annoying (to my taste) amount of copy-paste.
2. This function is not completely trivial, as it makes a decision on what a 
`CursorLoc` is and documents it.
3. Making changes is simpler: e.g. if we add more fields to `Tweak::Selection`, 
we'd end up changing this function (possibly its signature too) and all of its 
callers. There's almost no room for error. If we remove it, one would have to 
find and update all usages by hand and make sure they're the same.

I did update the patch to inline it, but let me know if any of this convinces 
you.




Comment at: clangd/refactor/Tweak.h:59
+  /// A unique id of the action. The convention is to
+  /// lower-case-with-dashes for the identifier.
+  virtual TweakID id() const = 0;

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > nit: one of my lessons from clang-tidy is that mapping between IDs and 
> > > implementations is annoying.
> > > Since IDs are 1:1 with classes, can we just require this to be the class 
> > > name?
> > > 
> > > (If you wanted, I think you could adapt REGISTER_TWEAK so that it goes 
> > > inside the class defn, and then it could provide the override of id() 
> > > itself)
> > That would mean no two tweaks are allowed to have the same class name. This 
> > is probably fine, but somewhat contradicts C++, which would solve it with 
> > namespaces.
> > To be fair, there's a simple trick to grep for the id to find its class, so 
> > I'd keep as is.
> > 
> > If we choose to adapt `REGISTER_TWEAK`, that would mean we force everyone 
> > to put their tweaks **only** in `.cpp` files. That creates arbitrary 
> > restrictions on how one should write a check and I'm somewhat opposed to 
> > this. But happy to reconsider if you feel strongly about this.
> I don't care about the details (e.g. whether `REGISTER_TWEAK` sets the name, 
> asserts the name, or none of the above).
> 
> I do care that we don't add a second ID for a class that's not equal to the 
> class name. This is both a bad idea from first principles and from experience 
> with clang-tidy.
> If this were ever to become a real problem, I'm happy to include the 
> namespace name in the ID.
Done, `REGISTER_TWEAK` now defines `id`.

Out of curiosity, what are the problems with clang-tidy checks that you 
mention? Finding a check by its name being hard is something that comes to 
mind. Anything else?


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

https://reviews.llvm.org/D56267



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182872.
ilya-biryukov added a comment.

- Update id of swap branches in tests
- Rebase


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

https://reviews.llvm.org/D56611

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/TweakTests.cpp

Index: clang-tools-extra/unittests/clangd/TweakTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TweakTests.cpp
@@ -0,0 +1,156 @@
+//===-- TweakTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Expr.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using llvm::Failed;
+using llvm::HasValue;
+using llvm::Succeeded;
+using ::testing::IsEmpty;
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+std::string markRange(llvm::StringRef Code, Range R) {
+  size_t Begin = llvm::cantFail(positionToOffset(Code, R.start));
+  size_t End = llvm::cantFail(positionToOffset(Code, R.end));
+  assert(Begin <= End);
+  if (Begin == End) // Mark a single point.
+return (Code.substr(0, Begin) + "^" + Code.substr(Begin)).str();
+  // Mark a range.
+  return (Code.substr(0, Begin) + "[[" + Code.substr(Begin, End - Begin) +
+  "]]" + Code.substr(End))
+  .str();
+}
+
+class TweakTest : public ::testing::Test {
+public:
+  /// Checks action is available at every point and range marked in \p Input.
+  void checkAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/true);
+  }
+
+  /// Same as checkAvailable, but checks the action is not available.
+  void checkNotAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/true);
+  }
+
+  llvm::Expected apply(TweakID ID, llvm::StringRef Input) {
+Annotations Code(Input);
+Range SelectionRng;
+if (Code.points().size() != 0) {
+  assert(Code.ranges().size() == 0 &&
+ "both a cursor point and a selection range were specified");
+  SelectionRng = Range{Code.point(), Code.point()};
+} else {
+  SelectionRng = Code.range();
+}
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+AST.getASTContext().getSourceManager(), SelectionRng.start));
+Tweak::Selection S = {Code.code(), AST, CursorLoc};
+
+auto T = prepareTweak(ID, S);
+if (!T)
+  return T.takeError();
+auto Replacements = (*T)->apply(S);
+if (!Replacements)
+  return Replacements.takeError();
+Rewriter RW(AST.getASTContext().getSourceManager(),
+AST.getASTContext().getLangOpts());
+bool Succeeded = tooling::applyAllReplacements(*Replacements, RW);
+(void)(bool) Succeeded;
+assert(Succeeded && "failed to apply replacements");
+
+std::string Result;
+llvm::raw_string_ostream OS(Result);
+RW.getRewriteBufferFor(
+  AST.getASTContext().getSourceManager().getMainFileID())
+->write(OS);
+return OS.str();
+  }
+
+private:
+  void checkAvailable(TweakID ID, llvm::StringRef Input, bool Available) {
+Annotations Code(Input);
+ASSERT_TRUE(0 < Code.points().size() || 0 < Code.ranges().size())
+<< "no points of interest specified";
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+
+auto CheckOver = [&](Range Selection) {
+  auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+  AST.getASTContext().getSourceManager(), Selection.start));
+  auto T = prepareTweak(ID, Tweak::Selection{Code.code(), AST, CursorLoc});
+  if (Available)
+EXPECT_THAT_EXPECTED(T, Failed())
+<< "code is " << markRange(Code.code(), Selection);
+  else
+EXPECT_THAT_EXPECTED(T, Succeeded())
+<< "code is " << markRange(Code.code(), Selection);
+};
+for (auto P : Code.points())
+  CheckOver(Range{P, P});
+for (auto R : Code.ranges())
+  CheckOver(R);
+  }
+};
+
+TEST_F(TweakTest, SwapIfBranches) {
+ 

[PATCH] D56610: [clangd] A code action to qualify an unqualified name

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182871.
ilya-biryukov added a comment.

- Rebase


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

https://reviews.llvm.org/D56610

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/QualifyName.cpp

Index: clang-tools-extra/clangd/refactor/tweaks/QualifyName.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/QualifyName.cpp
@@ -0,0 +1,180 @@
+//===--- QualifyName.cpp -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "AST.h"
+#include "ClangdUnit.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Fully qualifies a name under a cursor.
+/// Before:
+///   using namespace std;
+///   ^vector foo;
+/// After:
+///   std::vector foo;
+class QualifyName : public Tweak {
+public:
+  TweakID id() const override final;
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  SourceLocation InsertLoc;
+  std::string Qualifier;
+};
+
+REGISTER_TWEAK(QualifyName);
+
+struct Reference {
+  SourceLocation Begin;
+  NamedDecl *Target = nullptr;
+
+  operator bool() const { return Target != nullptr; }
+};
+
+NamedDecl *toReferencedDecl(NestedNameSpecifier *NNS) {
+  switch (NNS->getKind()) {
+  case clang::NestedNameSpecifier::Namespace:
+return NNS->getAsNamespace();
+  case clang::NestedNameSpecifier::NamespaceAlias:
+return NNS->getAsNamespaceAlias();
+  case clang::NestedNameSpecifier::TypeSpec:
+  case clang::NestedNameSpecifier::TypeSpecWithTemplate:
+return nullptr; // FIXME: handle this situation, retrieve the thing
+// referenced inside a type.
+  case clang::NestedNameSpecifier::Identifier:
+  case clang::NestedNameSpecifier::Super:
+  case clang::NestedNameSpecifier::Global: // FIXME: could return
+   // TranslationUnitDecl.
+return nullptr;
+return nullptr;
+  }
+  llvm_unreachable("unhandled NestedNameSpecifier kind.");
+}
+
+class LocateInsertLoc : public RecursiveASTVisitor {
+public:
+  LocateInsertLoc(ASTContext &Ctx, SourceLocation CursorLoc,
+  Reference &UnqualRef)
+  : Ctx(Ctx), CursorLoc(CursorLoc), UnqualRef(UnqualRef) {}
+
+  bool shouldWalkTypesOfTypeLocs() const { return false; }
+
+  // FIXME: RAT does not have VisitNestedNameSpecifierLoc. Should we add that?
+  bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+if (!RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(NNS))
+  return false;
+return VisitNestedNameSpecifierLoc(NNS);
+  }
+
+  bool VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+if (NNS.getPrefix())
+  return true; // we want only unqualified names.
+auto &SM = Ctx.getSourceManager();
+auto Rng = toHalfOpenFileRange(SM, Ctx.getLangOpts(), NNS.getSourceRange());
+if (!Rng)
+  return true;
+if (!halfOpenRangeContains(SM, *Rng, CursorLoc))
+  return true;
+auto *Target = toReferencedDecl(NNS.getNestedNameSpecifier());
+if (!Target)
+  return true; // continue traversal to recurse into types, if any.
+UnqualRef.Begin = Rng->getBegin();
+UnqualRef.Target = Target;
+return false; // we found the insertion point.
+  }
+
+  bool VisitDeclRefExpr(DeclRefExpr *E) {
+if (E->hasQualifier())
+  return true; // we want only unqualified names.
+auto &SM = Ctx.getSourceManager();
+auto Rng = toHalfOpenFileRange(SM, Ctx.getLangOpts(), E->getSourceRange());
+if (!Rng)
+  return true;
+if (!halfOpenRangeContains(SM, *Rng, CursorLoc))
+  return true;
+UnqualRef.Begin = Rng->getBegin();
+UnqualRef.Target = E->getFoundDecl();
+return false;
+  }
+
+  bool VisitTagTypeLoc(TagTypeLoc Loc) {
+auto &SM = Ctx.getSourceManager();
+auto Rng = toHalfOpenFileRange(SM, Ctx.getLangOpts(), Loc.getSourceRange());
+if (!Rng)
+  return true;
+if (!halfOpenRangeContains(SM, *Rng, CursorLoc))
+  return true;
+UnqualRef.Begin = Rng->getBegin();
+UnqualRef.Target = Loc.getDecl();
+return false;
+  }
+
+  bool VisitTypedefTypeLoc(TypedefTypeLoc Loc) {
+auto &SM = Ctx.getSourceManager();
+auto Rng = toHalfOpenFileRange(SM, Ctx.getLangOpts(), Loc.getSourceRange());
+if (!Rng)
+  return true;
+if (!halfOpenRangeCon

[PATCH] D56267: [clangd] Interfaces for writing code actions

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



Comment at: clang-tools-extra/clangd/refactor/Tweak.cpp:27
+std::vector> prepareTweaks(const Tweak::Selection &S) {
+#ifndef NDEBUG
+  {

Please note I added these assertions here.

It feels weird to traverse twice on every call to `prepareTweaks`, but that's 
the simplest option I could come up with.


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

https://reviews.llvm.org/D56267



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


Re: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-22 Thread Chandler Carruth via cfe-commits
On Sat, Jan 19, 2019 at 2:18 AM Johannes Doerfert via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jdoerfert
> Date: Fri Jan 18 21:36:54 2019
> New Revision: 351629
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351629&view=rev
> Log:
> Emit !callback metadata and introduce the callback attribute
>
>   With commit r351627, LLVM gained the ability to apply (existing) IPO
>   optimizations on indirections through callbacks, or transitive calls.
>   The general idea is that we use an abstraction to hide the middle man
>   and represent the callback call in the context of the initial caller.
>   It is described in more detail in the commit message of the LLVM patch
>   r351627, the llvm::AbstractCallSite class description, and the
>   language reference section on callback-metadata.
>
>   This commit enables clang to emit !callback metadata that is
>   understood by LLVM. It does so in three different cases:
> 1) For known broker functions declarations that are directly
>generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel.
> 2) For known broker functions that are identified by their name and
>source location through the builtin detection, e.g.,
>pthread_create from the POSIX thread API.
> 3) For user annotated functions that carry the "callback(callee, ...)"
>attribute. The attribute has to include the name, or index, of
>the callback callee and how the passed arguments can be
>identified (as many as the callback callee has). See the callback
>attribute documentation for detailed information.
>
> Differential Revision: https://reviews.llvm.org/D55483
>
> Added:
> cfe/trunk/test/CodeGen/attr-callback.c
> cfe/trunk/test/CodeGen/callback_annotated.c
> cfe/trunk/test/CodeGen/callback_openmp.c
> cfe/trunk/test/CodeGen/callback_pthread_create.c
> cfe/trunk/test/CodeGenCXX/attr-callback.cpp
> cfe/trunk/test/Sema/attr-callback-broken.c
> cfe/trunk/test/Sema/attr-callback.c
> cfe/trunk/test/SemaCXX/attr-callback-broken.cpp
> cfe/trunk/test/SemaCXX/attr-callback.cpp
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Basic/Builtins.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/Analysis/retain-release.m
> cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
> cfe/trunk/test/OpenMP/parallel_codegen.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=351629&r1=351628&r2=351629&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jan 18 21:36:54 2019
> @@ -2003,6 +2003,9 @@ public:
>  /// No error
>  GE_None,
>
> +/// Missing a type
> +GE_Missing_type,
> +
>  /// Missing a type from 
>  GE_Missing_stdio,
>
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=351629&r1=351628&r2=351629&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Jan 18 21:36:54 2019
> @@ -190,6 +190,9 @@ class VariadicIdentifierArgument  // Like VariadicUnsignedArgument except values are ParamIdx.
>  class VariadicParamIdxArgument : Argument;
>
> +// A list of identifiers matching parameters or ParamIdx indices.
> +class VariadicParamOrParamIdxArgument : Argument;
> +
>  // Like VariadicParamIdxArgument but for a single function parameter
> index.
>  class ParamIdxArgument : Argument;
>
> @@ -1210,6 +1213,13 @@ def FormatArg : InheritableAttr {
>let Documentation = [Undocumented];
>  }
>
> +def Callback : InheritableAttr {
> +  let Spellings = [Clang<"callback">];
> +  let Args = [VariadicParamOrParamIdxArgument<"Encoding">];
> +  let Subjects = SubjectList<[Function]>;
> +  let Documentation = [CallbackDocs];
> +}
> +
>  def GNUInline : InheritableAttr {
>let Spellings = [GCC<"gnu_inline">];
>let Subjects = SubjectList<[Function]>;
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=351629&r1=351628&r2=351629&view=diff
>
> ==

[PATCH] D56612: [clangd] A code action to remove 'using namespace'

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182873.
ilya-biryukov added a comment.

- Rebase


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

https://reviews.llvm.org/D56612

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp

Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -0,0 +1,204 @@
+//===--- RemoveUsingNamespace.cpp *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "AST.h"
+#include "ClangdUnit.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
+#include "llvm/ADT/ScopeExit.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Removes the 'using namespace' under the cursor and qualifies all accesses in
+/// the current file. E.g.,
+///   using namespace std;
+///   vector foo(std::map);
+/// Would become:
+///   std::vector foo(std::map);
+class RemoveUsingNamespace : public Tweak {
+public:
+  TweakID id() const override;
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  UsingDirectiveDecl *TargetDirective = nullptr;
+};
+REGISTER_TWEAK(RemoveUsingNamespace);
+
+class FindNodeUnderCursor : public RecursiveASTVisitor {
+public:
+  FindNodeUnderCursor(SourceLocation SearchedLoc, UsingDirectiveDecl *&Result)
+  : SearchedLoc(SearchedLoc), Result(Result) {}
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
+if (D->getUsingLoc() != SearchedLoc)
+  return true;
+
+Result = D;
+return false;
+  }
+
+private:
+  SourceLocation SearchedLoc;
+  UsingDirectiveDecl *&Result;
+};
+
+class FindSameUsings : public RecursiveASTVisitor {
+public:
+  FindSameUsings(UsingDirectiveDecl &Target,
+ std::vector &Results)
+  : TargetNS(Target.getNominatedNamespace()),
+TargetCtx(Target.getDeclContext()), Results(Results) {}
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
+if (D->getNominatedNamespace() != TargetNS ||
+D->getDeclContext() != TargetCtx)
+  return true;
+
+Results.push_back(D);
+return true;
+  }
+
+private:
+  NamespaceDecl *TargetNS;
+  DeclContext *TargetCtx;
+  std::vector &Results;
+};
+
+class FindIdentsToQualify
+: public tooling::RecursiveSymbolVisitor {
+public:
+  FindIdentsToQualify(ASTContext &Ctx, NamespaceDecl &TargetNS,
+  std::vector &ResultIdents)
+  : RecursiveSymbolVisitor(Ctx.getSourceManager(), Ctx.getLangOpts()),
+Ctx(Ctx), TargetNS(TargetNS), ResultIdents(ResultIdents) {}
+
+  bool visitSymbolOccurrence(const NamedDecl *D,
+ llvm::ArrayRef NameRanges) {
+if (!D || D->getCanonicalDecl() == TargetNS.getCanonicalDecl())
+  return true;
+if (!D->getDeclName().isIdentifier() ||
+D->getDeclName().getNameKind() == DeclarationName::CXXOperatorName)
+  return true; // do not add qualifiers for non-idents, e.g. 'operator+'.
+// Check the symbol is unqualified and references something inside our
+// namespace.
+// FIXME: add a check it's unqualified.
+if (!TargetNS.InEnclosingNamespaceSetOf(D->getDeclContext()))
+  return true;
+// FIXME: handle more tricky cases, e.g. we don't need the qualifier if we
+//have the using decls for some entities, we might have qualified
+//references that need updating too.
+for (auto R : NameRanges) {
+  if (!Ctx.getSourceManager().isWrittenInMainFile(R.getBegin()))
+continue; // we can't fix refences outside our file.
+  // FIXME: this might be a conflict that we need to report.
+  ResultIdents.push_back(R.getBegin());
+}
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) {
+if (!Ctx.getSourceManager().isWrittenInMainFile(D->getLocation()) &&
+!isa(D))
+  return true; // skip decls outside main file.
+return RecursiveSymbolVisitor::TraverseDecl(D);
+  }
+
+private:
+  ASTContext &Ctx;
+  NamespaceDecl &TargetNS;
+  std::vector &ResultIdents;
+};
+
+// Produces an edit to remove 'using namespace xxx::yyy' and the trailing
+// semicolon.
+llvm::Expected
+removeUsingDirective(ASTContext &Ctx, UsingDirectiveDecl *D) {
+  auto &SrcMgr = Ctx.getSourceManager();
+  auto R =
+  Lexer::getAsCharRange

Re: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-22 Thread Chandler Carruth via cfe-commits
On Sat, Jan 19, 2019 at 2:18 AM Johannes Doerfert via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jdoerfert
> Date: Fri Jan 18 21:36:54 2019
> New Revision: 351629
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351629&view=rev
> Log:
> Emit !callback metadata and introduce the callback attribute
>
>   With commit r351627, LLVM gained the ability to apply (existing) IPO
>   optimizations on indirections through callbacks, or transitive calls.
>   The general idea is that we use an abstraction to hide the middle man
>   and represent the callback call in the context of the initial caller.
>   It is described in more detail in the commit message of the LLVM patch
>   r351627, the llvm::AbstractCallSite class description, and the
>   language reference section on callback-metadata.
>
>   This commit enables clang to emit !callback metadata that is
>   understood by LLVM. It does so in three different cases:
> 1) For known broker functions declarations that are directly
>generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel.
> 2) For known broker functions that are identified by their name and
>source location through the builtin detection, e.g.,
>pthread_create from the POSIX thread API.
> 3) For user annotated functions that carry the "callback(callee, ...)"
>attribute. The attribute has to include the name, or index, of
>the callback callee and how the passed arguments can be
>identified (as many as the callback callee has). See the callback
>attribute documentation for detailed information.
>
> Differential Revision: https://reviews.llvm.org/D55483
>
> Added:
> cfe/trunk/test/CodeGen/attr-callback.c
> cfe/trunk/test/CodeGen/callback_annotated.c
> cfe/trunk/test/CodeGen/callback_openmp.c
> cfe/trunk/test/CodeGen/callback_pthread_create.c
> cfe/trunk/test/CodeGenCXX/attr-callback.cpp
> cfe/trunk/test/Sema/attr-callback-broken.c
> cfe/trunk/test/Sema/attr-callback.c
> cfe/trunk/test/SemaCXX/attr-callback-broken.cpp
> cfe/trunk/test/SemaCXX/attr-callback.cpp
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Basic/Builtins.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/Analysis/retain-release.m
> cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
> cfe/trunk/test/OpenMP/parallel_codegen.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=351629&r1=351628&r2=351629&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jan 18 21:36:54 2019
> @@ -2003,6 +2003,9 @@ public:
>  /// No error
>  GE_None,
>
> +/// Missing a type
> +GE_Missing_type,
> +
>  /// Missing a type from 
>  GE_Missing_stdio,
>
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=351629&r1=351628&r2=351629&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Jan 18 21:36:54 2019
> @@ -190,6 +190,9 @@ class VariadicIdentifierArgument  // Like VariadicUnsignedArgument except values are ParamIdx.
>  class VariadicParamIdxArgument : Argument;
>
> +// A list of identifiers matching parameters or ParamIdx indices.
> +class VariadicParamOrParamIdxArgument : Argument;
> +
>  // Like VariadicParamIdxArgument but for a single function parameter
> index.
>  class ParamIdxArgument : Argument;
>
> @@ -1210,6 +1213,13 @@ def FormatArg : InheritableAttr {
>let Documentation = [Undocumented];
>  }
>
> +def Callback : InheritableAttr {
> +  let Spellings = [Clang<"callback">];
> +  let Args = [VariadicParamOrParamIdxArgument<"Encoding">];
> +  let Subjects = SubjectList<[Function]>;
> +  let Documentation = [CallbackDocs];
> +}
> +
>  def GNUInline : InheritableAttr {
>let Spellings = [GCC<"gnu_inline">];
>let Subjects = SubjectList<[Function]>;
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=351629&r1=351628&r2=351629&view=diff
>
> ==

[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D55850#1365437 , @ebevhan wrote:

> I'm a bit late to the party here, it was an older patch so I wasn't watching 
> this one.
>
> I get a bit miffed when address space related features get locked behind 
> langoptions that aren't strictly address spaces. I know that there are 
> currently a couple code snippets which are behind LangOptions.OpenCL, that 
> are needed for address spaces to work reasonably even when you aren't using 
> OpenCL.
>
> I guess I do understand that the only address spaces that are interesting to 
> parse here are the named qualifier ones, but it would be convenient if the 
> parsing would accept other ones as well (such as the `__attribute__` based 
> ones) and not necessarily assume that the user is using OpenCL++.
>
> EDIT: Sort of jumped the gun there... The summary even says "This patch 
> doesn't enable the feature for C++ yet but it can easily be generalized if 
> the overall flow is right." Don't mind me.


This is correct. My plan was to generalize to C++ in the next patch. As I am 
more familiar with OpenCL and many rules are already well defined, this was my 
starting point. However, I want this work to be used for C++ based 
implementations generically and not just for OpenCL. I am still struggling to 
understand the semantic of address spaces in C++ for some cases and need a 
little bit more time, but I think I should be able to upload the initial patch 
soon. I would then appreciate any help with reviewing to get it right!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55850



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-22 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Okay, sounds good! I'm not a C++ expert, but I'd be happy to look at the 
patches when they're up. Haven't done much serious testing on my end so far, 
but from what I've seen the patches so far look good!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55850



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182884.
ilya-biryukov added a comment.

- Use helper to avoid creating RewriteBuffer
- Use std::string to fix stack corruption


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

https://reviews.llvm.org/D56611

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/TweakTests.cpp

Index: clang-tools-extra/unittests/clangd/TweakTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TweakTests.cpp
@@ -0,0 +1,145 @@
+//===-- TweakTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Expr.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using llvm::Failed;
+using llvm::HasValue;
+using llvm::Succeeded;
+using ::testing::IsEmpty;
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+std::string markRange(llvm::StringRef Code, Range R) {
+  size_t Begin = llvm::cantFail(positionToOffset(Code, R.start));
+  size_t End = llvm::cantFail(positionToOffset(Code, R.end));
+  assert(Begin <= End);
+  if (Begin == End) // Mark a single point.
+return (Code.substr(0, Begin) + "^" + Code.substr(Begin)).str();
+  // Mark a range.
+  return (Code.substr(0, Begin) + "[[" + Code.substr(Begin, End - Begin) +
+  "]]" + Code.substr(End))
+  .str();
+}
+
+class TweakTest : public ::testing::Test {
+public:
+  /// Checks action is available at every point and range marked in \p Input.
+  void checkAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/true);
+  }
+
+  /// Same as checkAvailable, but checks the action is not available.
+  void checkNotAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/true);
+  }
+
+  llvm::Expected apply(TweakID ID, llvm::StringRef Input) {
+Annotations Code(Input);
+Range SelectionRng;
+if (Code.points().size() != 0) {
+  assert(Code.ranges().size() == 0 &&
+ "both a cursor point and a selection range were specified");
+  SelectionRng = Range{Code.point(), Code.point()};
+} else {
+  SelectionRng = Code.range();
+}
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+AST.getASTContext().getSourceManager(), SelectionRng.start));
+Tweak::Selection S = {Code.code(), AST, CursorLoc};
+
+auto T = prepareTweak(ID, S);
+if (!T)
+  return T.takeError();
+auto Replacements = (*T)->apply(S);
+if (!Replacements)
+  return Replacements.takeError();
+return applyAllReplacements(Code.code(), *Replacements);
+  }
+
+private:
+  void checkAvailable(TweakID ID, llvm::StringRef Input, bool Available) {
+Annotations Code(Input);
+ASSERT_TRUE(0 < Code.points().size() || 0 < Code.ranges().size())
+<< "no points of interest specified";
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+
+auto CheckOver = [&](Range Selection) {
+  auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+  AST.getASTContext().getSourceManager(), Selection.start));
+  auto T = prepareTweak(ID, Tweak::Selection{Code.code(), AST, CursorLoc});
+  if (Available)
+EXPECT_THAT_EXPECTED(T, Failed())
+<< "code is " << markRange(Code.code(), Selection);
+  else
+EXPECT_THAT_EXPECTED(T, Succeeded())
+<< "code is " << markRange(Code.code(), Selection);
+};
+for (auto P : Code.points())
+  CheckOver(Range{P, P});
+for (auto R : Code.ranges())
+  CheckOver(R);
+  }
+};
+
+TEST_F(TweakTest, SwapIfBranches) {
+  llvm::StringLiteral ID = "SwapIfBranches";
+
+  checkAvailable(ID, R"cpp(
+void test() {
+  ^i^f (true) { return 100; } else { continue; }
+}
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+void test() {
+  if ^(^true) { return 100; } else { continue; }
+}
+  )cpp");
+
+  llvm::StringLiteral Input = R"cpp(
+void test() {
+  ^if (true) { return

[PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2019-01-22 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi added a comment.

Ping. It would indeed be very helpful to have information about the kind of an 
operator :-)


Repository:
  rC Clang

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

https://reviews.llvm.org/D10833



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


[clang-tools-extra] r351809 - [clangd] Fix the `-Wtype-limits` warning, NFC

2019-01-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Jan 22 04:21:25 2019
New Revision: 351809

URL: http://llvm.org/viewvc/llvm-project?rev=351809&view=rev
Log:
[clangd] Fix the `-Wtype-limits` warning, NFC

The assertion is always true, and triggers a compiler warning, so remove it.

Modified:
clang-tools-extra/trunk/clangd/index/Merge.cpp

Modified: clang-tools-extra/trunk/clangd/index/Merge.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Merge.cpp?rev=351809&r1=351808&r2=351809&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Merge.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Merge.cpp Tue Jan 22 04:21:25 2019
@@ -102,7 +102,6 @@ void MergedIndex::refs(const RefsRequest
 Callback(O);
 --Remaining;
   });
-  assert(Remaining >= 0);
   if (Remaining == 0)
 return;
   // We return less than Req.Limit if static index returns more refs for dirty


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


[PATCH] D57043: [clangd] Use the shared forced-linking code.

2019-01-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CMakeLists.txt:110
 
+if( CLANG_ENABLE_STATIC_ANALYZER )
+  target_link_libraries(clangDaemon PRIVATE

clangd doesn't support the static analyzer.
Fundamentally I don't know how to enforce the partial-traversal (needed for 
performance).


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57043



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


[PATCH] D57047: [clangd] Fix broken build after r351793.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: kadircet, sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57047

Files:
  clangd/CodeComplete.cpp


Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -18,6 +18,7 @@
 
//===--===//
 
 #include "CodeComplete.h"
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "AST.h"
 #include "ClangdUnit.h"
 #include "CodeCompletionStrings.h"
@@ -1019,8 +1020,9 @@
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  auto CI =
-  buildCompilerInvocation(ParseInputs{Input.Command, VFS, Input.Contents});
+  auto CI = buildCompilerInvocation(
+  ParseInputs{Input.Command, VFS, Input.Contents,
+  tidy::ClangTidyOptions::getDefaults()});
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;


Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -18,6 +18,7 @@
 //===--===//
 
 #include "CodeComplete.h"
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "AST.h"
 #include "ClangdUnit.h"
 #include "CodeCompletionStrings.h"
@@ -1019,8 +1020,9 @@
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  auto CI =
-  buildCompilerInvocation(ParseInputs{Input.Command, VFS, Input.Contents});
+  auto CI = buildCompilerInvocation(
+  ParseInputs{Input.Command, VFS, Input.Contents,
+  tidy::ClangTidyOptions::getDefaults()});
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r351812 - [clangd] Fix the broken buildbot.

2019-01-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Jan 22 04:55:15 2019
New Revision: 351812

URL: http://llvm.org/viewvc/llvm-project?rev=351812&view=rev
Log:
[clangd] Fix the broken buildbot.

Modified:
clang-tools-extra/trunk/clangd/tool/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/CMakeLists.txt?rev=351812&r1=351811&r2=351812&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/tool/CMakeLists.txt Tue Jan 22 04:55:15 2019
@@ -17,6 +17,7 @@ endif()
 target_link_libraries(clangd
   PRIVATE
   clangBasic
+  clangTidy
   clangDaemon
   clangFormat
   clangFrontend


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


[clang-tools-extra] r351813 - [clangd] NFC: reduce log noise from Diagnostics.

2019-01-22 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Jan 22 04:55:27 2019
New Revision: 351813

URL: http://llvm.org/viewvc/llvm-project?rev=351813&view=rev
Log:
[clangd] NFC: reduce log noise from Diagnostics.

Reviewers: sammccall

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

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

Modified:
clang-tools-extra/trunk/clangd/Diagnostics.cpp

Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=351813&r1=351812&r2=351813&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Tue Jan 22 04:55:27 2019
@@ -403,8 +403,8 @@ void StoreDiags::flushLastDiag() {
   if (mentionsMainFile(*LastDiag))
 Output.push_back(std::move(*LastDiag));
   else
-log("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
-LastDiag->Message);
+vlog("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
+ LastDiag->Message);
   LastDiag.reset();
 }
 


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


[PATCH] D57042: [clangd] NFC: reduce log noise from Diagnostics.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351813: [clangd] NFC: reduce log noise from Diagnostics. 
(authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57042

Files:
  clang-tools-extra/trunk/clangd/Diagnostics.cpp


Index: clang-tools-extra/trunk/clangd/Diagnostics.cpp
===
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp
@@ -403,8 +403,8 @@
   if (mentionsMainFile(*LastDiag))
 Output.push_back(std::move(*LastDiag));
   else
-log("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
-LastDiag->Message);
+vlog("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
+ LastDiag->Message);
   LastDiag.reset();
 }
 


Index: clang-tools-extra/trunk/clangd/Diagnostics.cpp
===
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp
@@ -403,8 +403,8 @@
   if (mentionsMainFile(*LastDiag))
 Output.push_back(std::move(*LastDiag));
   else
-log("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
-LastDiag->Message);
+vlog("Dropped diagnostic outside main file: {0}: {1}", LastDiag->File,
+ LastDiag->Message);
   LastDiag.reset();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r351814 - [clang-tidy] Fix whitespace in docs. NFC

2019-01-22 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Jan 22 04:59:34 2019
New Revision: 351814

URL: http://llvm.org/viewvc/llvm-project?rev=351814&view=rev
Log:
[clang-tidy] Fix whitespace in docs. NFC

Actually, just testing commits via monorepo ;)

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=351814&r1=351813&r2=351814&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Tue Jan 22 04:59:34 2019
@@ -260,21 +260,20 @@ An overview of all the command-line opti
 Suppressing Undesired Diagnostics
 =
 
-:program:`clang-tidy` diagnostics are intended to call out code that does
-not adhere to a coding standard, or is otherwise problematic in some way.
-However, if it is known that the code is correct, the check-specific ways
-to silence the diagnostics could be used, if they are available (e.g.
-bugprone-use-after-move can be silenced by re-initializing the variable after 
it
-has been moved out, bugprone-string-integer-assignment can be suppressed by
-explicitly casting the integer to char, readability-implicit-bool-conversion 
can
-also be suppressed by using explicit casts, etc.). If they are not available or
-if changing the semantics of the code is not desired, the ``NOLINT`` or
-``NOLINTNEXTLINE`` comments can be used instead. For example:
+:program:`clang-tidy` diagnostics are intended to call out code that does not
+adhere to a coding standard, or is otherwise problematic in some way.  However,
+if it is known that the code is correct, the check-specific ways to silence the
+diagnostics could be used, if they are available (e.g.  bugprone-use-after-move
+can be silenced by re-initializing the variable after it has been moved out,
+bugprone-string-integer-assignment can be suppressed by explicitly casting the
+integer to ``char``, readability-implicit-bool-conversion can also be 
suppressed
+by using explicit casts, etc.). If they are not available or if changing the
+semantics of the code is not desired, the ``NOLINT`` or ``NOLINTNEXTLINE``
+comments can be used instead. For example:
 
 .. code-block:: c++
 
-  class Foo
-  {
+  class Foo {
 // Silent all the diagnostics for the line
 Foo(int param); // NOLINT
 
@@ -283,7 +282,7 @@ if changing the semantics of the code is
 
 // Silent only the specified diagnostics for the next line
 // NOLINTNEXTLINE(google-explicit-constructor, google-runtime-int)
-Foo(bool param); 
+Foo(bool param);
   };
 
 The formal syntax of ``NOLINT``/``NOLINTNEXTLINE`` is the following:
@@ -307,8 +306,8 @@ The formal syntax of ``NOLINT``/``NOLINT
 
 Note that whitespaces between ``NOLINT``/``NOLINTNEXTLINE`` and the opening
 parenthesis are not allowed (in this case the comment will be treated just as
-``NOLINT``/``NOLINTNEXTLINE``), whereas in check names list (inside
-the parenthesis) whitespaces can be used and will be ignored.
+``NOLINT``/``NOLINTNEXTLINE``), whereas in check names list (inside the
+parenthesis) whitespaces can be used and will be ignored.
 
 .. _LibTooling: http://clang.llvm.org/docs/LibTooling.html
 .. _How To Setup Tooling For LLVM: 
http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html


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


[PATCH] D57012: Merge similar target diagnostics for interrupt attribute into one. NFC

2019-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D57012#1365939 , @krisb wrote:

> @aaron.ballman Thanks! Could I ask you to commit the patch? I don't have 
> commit access yet.


Happy to do so -- just to double-check: are you aware of the recent relicensing 
of the project and intending to contribute under the new license?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57012



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


[PATCH] D56967: Thread safety analysis: Improve diagnostics for double locking

2019-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56967#1365742 , @aaronpuchert 
wrote:

> Thanks for the review! I'll commit this when I have commit access again, 
> which is waiting for my employer's approval to the relicensing.


Sounds good to me!




Comment at: lib/Sema/AnalysisBasedWarnings.cpp:1693
+ << Kind << LockName);
+OptionalNotes notes =
+LocLocked.isValid()

aaronpuchert wrote:
> I'll assume it's also `Notes` then. I tend to subconsciously forget these 
> things.
Yup, my eyes missed that one, so thank you for catching it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56967



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


Re: r351701 - Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>

2019-01-22 Thread Axel Naumann via cfe-commits
Hi,

This broke our clang builds with

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)

on CentOS Linux release 7.6.1810 (Core),

[ 23%] Building CXX object
tools/clang/lib/Basic/CMakeFiles/clangBasic.dir/Module.cpp.o

In file included from include/llvm/ADT/StringMap.h:20:0,
 from include/llvm/Support/Host.h:16,
 from include/llvm/ADT/Hashing.h:48,
 from include/llvm/ADT/ArrayRef.h:12,
 from include/llvm/ADT/DenseMapInfo.h:16,
 from include/llvm/ADT/DenseMap.h:16,
 from tools/clang/include/clang/Basic/FileManager.h:19,
 from tools/clang/include/clang/Basic/Module.h:18,
 from tools/clang/lib/Basic/Module.cpp:14:
include/llvm/Support/PointerLikeTypeTraits.h: In instantiation of
‘struct llvm::PointerLikeTypeTraits’:
/usr/include/c++/4.8.2/type_traits:1087:41:   required by substitution
of ‘template static decltype
(((declval<_Tp1>)()=(declval<_Up1>)(), std::__sfinae_types::__one()))
std::__is_assignable_helper<_Tp, _Up>::__test(int) [with _Tp1 = _Tp1;
_Up1 = _Up1; _Tp =
llvm::detail::trivial_helper >&; _Up = const
llvm::detail::trivial_helper >&] [with _Tp1 =
llvm::detail::trivial_helper >&; _Up1 = const
llvm::detail::trivial_helper >&]’
/usr/include/c++/4.8.2/type_traits:1094:50:   required from ‘constexpr
const bool
std::__is_assignable_helper >&, const
llvm::detail::trivial_helper >&>::value’
/usr/include/c++/4.8.2/type_traits:1099:12:   required from ‘struct
std::is_assignable >&, const
llvm::detail::trivial_helper >&>’
/usr/include/c++/4.8.2/type_traits:1112:12:   required from ‘struct
std::__is_copy_assignable_impl >, false>’
/usr/include/c++/4.8.2/type_traits:1118:12:   required from ‘struct
std::is_copy_assignable > >’
include/llvm/Support/type_traits.h:142:25:   required from ‘constexpr
const bool
llvm::is_trivially_copyable >::has_trivial_copy_assign’
include/llvm/Support/type_traits.h:163:32:   required from ‘constexpr
const bool
llvm::is_trivially_copyable >::value’
include/llvm/ADT/SmallVector.h:321:7:   required from ‘class
llvm::SmallVectorImpl >’
include/llvm/ADT/SmallVector.h:845:7:   required from ‘class
llvm::SmallVector, 2u>’
tools/clang/include/clang/Basic/Module.h:290:30:   required from here
include/llvm/Support/PointerLikeTypeTraits.h:59:8: error: invalid
application of ‘__alignof__’ to incomplete type ‘clang::Module’
   enum { NumLowBitsAvailable = detail::ConstantLog2::value };
^

FYI in case you wonder:

$ ls -l /usr/include/c++/
total 8
drwxr-xr-x. 12 root root 4096 Dec 11 03:24 4.8.2
lrwxrwxrwx.  1 root root5 Dec 11 03:24 4.8.5 -> 4.8.2


Are we outside the "allowed" range for GCC versions?

Cheers, Axel.

On 1/20/19 10:19 PM, Serge Guelton via cfe-commits wrote:
> Author: serge_sans_paille
> Date: Sun Jan 20 13:19:56 2019
> New Revision: 351701
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=351701&view=rev
> Log:
> Replace llvm::isPodLike<...>  by llvm::is_trivially_copyable<...>
> 
> As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization 
> for
> isPodLike> did not match the expectation of
> std::is_trivially_copyable which makes the memcpy optimization invalid.
> 
> This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable.
> Unfortunately std::is_trivially_copyable is not portable across compiler / STL
> versions. So a portable version is provided too.
> 
> Note that the following specialization were invalid:
> 
> std::pair
> llvm::Optional
> 
> Tests have been added to assert that former specialization are respected by 
> the
> standard usage of llvm::is_trivially_copyable, and that when a decent version
> of std::is_trivially_copyable is available, llvm::is_trivially_copyable is
> compared to std::is_trivially_copyable.
> 
> As of this patch, llvm::Optional is no longer considered trivially copyable,
> even if T is. This is to be fixed in a later patch, as it has impact on a
> long-running bug (see r347004)
> 
> Note that GCC warns about this UB, but this got silented by 
> https://reviews.llvm.org/D50296.
> 
> Differential Revision: https://reviews.llvm.org/D54472
> 
> 
> Modified:
> cfe/trunk/include/clang/AST/BaseSubobject.h
> cfe/trunk/include/clang/AST/CharUnits.h
> cfe/trunk/include/clang/AST/DeclAccessPair.h
> cfe/trunk/include/clang/AST/DeclarationName.h
> cfe/trunk/include/clang/AST/ExprObjC.h
> cfe/trunk/include/clang/AST/GlobalDecl.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/Analysis/ProgramPoint.h
> cfe/trunk/include/clang/Basic/IdentifierTable.h
> cfe/trunk/include/clang/Basic/SourceLocation.h
> cfe/trunk/include/clang/Lex/Token.h
> cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
> cfe/trunk/include/clang/Sema/Ownership.h
> cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
> cfe/trunk/lib/AST/VTableBuilder.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/t

[PATCH] D56429: fix python3 compability issue

2019-01-22 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@roxma: do you want me to commit this on your behalf?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56429



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


[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A drop-by comment.




Comment at: clangd/IncludeFixer.cpp:66
+  vlog("Trying to fix include for incomplete type {0}", IncompleteType);
+  FuzzyFindRequest Req;
+  Req.AnyScope = false;

sammccall wrote:
> limit?
Why do we use fuzzyFind and not `lookup` here?
Are there cases when we can't construct `SymbolID` for the `TagDecl`?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56903



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


[clang-tools-extra] r351818 - Fix "missing field 'ClangTidyOpts' initializer" warning. NFCI.

2019-01-22 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jan 22 05:35:16 2019
New Revision: 351818

URL: http://llvm.org/viewvc/llvm-project?rev=351818&view=rev
Log:
Fix "missing field 'ClangTidyOpts' initializer" warning. NFCI.

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=351818&r1=351817&r2=351818&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Jan 22 05:35:16 2019
@@ -1019,8 +1019,9 @@ bool semaCodeComplete(std::unique_ptr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  auto CI =
-  buildCompilerInvocation(ParseInputs{Input.Command, VFS, Input.Contents});
+  auto CI = buildCompilerInvocation(
+  ParseInputs{Input.Command, VFS, Input.Contents,
+  tidy::ClangTidyOptions::getDefaults()});
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;


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


[PATCH] D56429: fix python3 compability issue

2019-01-22 Thread rox via Phabricator via cfe-commits
roxma added a comment.

Yes please.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56429



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


[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I have found some other minor things in the tests.




Comment at: unittests/AST/ASTImporterTest.cpp:2275
+  auto DFDef = cxxMethodDecl(
+  hasName("f"), hasParent(cxxRecordDecl(hasName("B"))), isDefinition());
+  auto FDefAll = cxxMethodDecl(hasName("f"), isDefinition());

I think the parent should have `hasName("D")` here. Seems like a copy paste 
error.



Comment at: unittests/AST/ASTImporterTest.cpp:2282
+auto *FromD = FirstDeclMatcher().match(FromTU, DP);
+ImportedD = Import(FromD, Lang_CXX);
+  }

`ImportedD` seems to be unused. (And in the next test case too.)



Comment at: unittests/AST/ASTImporterTest.cpp:2400
+
+  // Check that the redecl chain is intact.
+  EXPECT_EQ(ToBFOutOfClass->getPreviousDecl(), ToBFInClass);

Could we check the redecl chain of `D::f()` too?


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

https://reviews.llvm.org/D56936



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


[PATCH] D57032: [SemaCXX] Param diagnostic matches overload logic

2019-01-22 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:5092
 // The parameter types are identical
-if (Context.hasSameType(DefParamTy, DeclParamTy))
+if (Context.hasSameType(DefParamTy.getUnqualifiedType(),
+DeclParamTy.getUnqualifiedType()))

I see this is what `Sema::FunctionParamTypesAreEqual` does, but maybe both 
places should use `hasSameUnqualifiedType`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57032



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182900.
ilya-biryukov added a comment.

- Use a helper to avoid creating RewriteBuffer


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

https://reviews.llvm.org/D56611

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/TweakTests.cpp

Index: clang-tools-extra/unittests/clangd/TweakTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TweakTests.cpp
@@ -0,0 +1,145 @@
+//===-- TweakTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Expr.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using llvm::Failed;
+using llvm::HasValue;
+using llvm::Succeeded;
+using ::testing::IsEmpty;
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+std::string markRange(llvm::StringRef Code, Range R) {
+  size_t Begin = llvm::cantFail(positionToOffset(Code, R.start));
+  size_t End = llvm::cantFail(positionToOffset(Code, R.end));
+  assert(Begin <= End);
+  if (Begin == End) // Mark a single point.
+return (Code.substr(0, Begin) + "^" + Code.substr(Begin)).str();
+  // Mark a range.
+  return (Code.substr(0, Begin) + "[[" + Code.substr(Begin, End - Begin) +
+  "]]" + Code.substr(End))
+  .str();
+}
+
+class TweakTest : public ::testing::Test {
+public:
+  /// Checks action is available at every point and range marked in \p Input.
+  void checkAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/true);
+  }
+
+  /// Same as checkAvailable, but checks the action is not available.
+  void checkNotAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/false);
+  }
+
+  llvm::Expected apply(TweakID ID, llvm::StringRef Input) {
+Annotations Code(Input);
+Range SelectionRng;
+if (Code.points().size() != 0) {
+  assert(Code.ranges().size() == 0 &&
+ "both a cursor point and a selection range were specified");
+  SelectionRng = Range{Code.point(), Code.point()};
+} else {
+  SelectionRng = Code.range();
+}
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+AST.getASTContext().getSourceManager(), SelectionRng.start));
+Tweak::Selection S = {Code.code(), AST, CursorLoc};
+
+auto T = prepareTweak(ID, S);
+if (!T)
+  return T.takeError();
+auto Replacements = (*T)->apply(S);
+if (!Replacements)
+  return Replacements.takeError();
+return applyAllReplacements(Code.code(), *Replacements);
+  }
+
+private:
+  void checkAvailable(TweakID ID, llvm::StringRef Input, bool Available) {
+Annotations Code(Input);
+ASSERT_TRUE(0 < Code.points().size() || 0 < Code.ranges().size())
+<< "no points of interest specified";
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+
+auto CheckOver = [&](Range Selection) {
+  auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+  AST.getASTContext().getSourceManager(), Selection.start));
+  auto T = prepareTweak(ID, Tweak::Selection{Code.code(), AST, CursorLoc});
+  if (Available)
+EXPECT_THAT_EXPECTED(T, Succeeded())
+<< "code is " << markRange(Code.code(), Selection);
+  else
+EXPECT_THAT_EXPECTED(T, Failed())
+<< "code is " << markRange(Code.code(), Selection);
+};
+for (auto P : Code.points())
+  CheckOver(Range{P, P});
+for (auto R : Code.ranges())
+  CheckOver(R);
+  }
+};
+
+TEST_F(TweakTest, SwapIfBranches) {
+  llvm::StringLiteral ID = "SwapIfBranches";
+
+  checkAvailable(ID, R"cpp(
+void test() {
+  ^i^f (true) { return 100; } else { continue; }
+}
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+void test() {
+  if ^(^true) { return 100; } else { continue; }
+}
+  )cpp");
+
+  llvm::StringLiteral Input = R"cpp(
+void test() {
+  ^if (true) { return 100; } else { continue; }
+}
+  )c

[PATCH] D57047: [clangd] Fix broken build after r351793.

2019-01-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, but hokein might know better whether to push the default options or the 
one in ClangdServerOpts


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57047



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


[PATCH] D57047: [clangd] Fix broken build after r351793.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In D57047#1366265 , @kadircet wrote:

> LGTM, but hokein might know better whether to push the default options or the 
> one in ClangdServerOpts


I'm going to land this now to unbreak build. Feel free to comment or do further 
refactoring if the default is not the best thing to pass here. Currently, this 
doesn't seem to matter as it's not used in CodeCompletion.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57047



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


[PATCH] D57047: [clangd] Fix broken build after r351793.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric abandoned this revision.
ioeric added a comment.

nvm, Simon beat me to it ;)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57047



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D55850#1366094 , @ebevhan wrote:

> Okay, sounds good! I'm not a C++ expert, but I'd be happy to look at the 
> patches when they're up. Haven't done much serious testing on my end so far, 
> but from what I've seen the patches so far look good!


Cool! Thanks a lot for your feedback btw. Let me know if you discover any 
issues/bugs! I do need to improve testing at some point soon as I am sure there 
are still a lot of uncaught corner cases.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55850



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


[clang-tools-extra] r351826 - [clangd] Followup fix of rL351818

2019-01-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Jan 22 06:48:04 2019
New Revision: 351826

URL: http://llvm.org/viewvc/llvm-project?rev=351826&view=rev
Log:
[clangd] Followup fix of rL351818

ClangTidyOptions::getDefaults is not free, it will initialize all
clang-tidy modules to get check-specific options, and we don't use this
information in CodeComplete, so using an empty one (constructed by
default constructor) is sufficient.

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=351826&r1=351825&r2=351826&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Jan 22 06:48:04 2019
@@ -1019,9 +1019,11 @@ bool semaCodeComplete(std::unique_ptr VFS = Input.VFS;
   if (Input.Preamble && Input.Preamble->StatCache)
 VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
-  auto CI = buildCompilerInvocation(
-  ParseInputs{Input.Command, VFS, Input.Contents,
-  tidy::ClangTidyOptions::getDefaults()});
+  ParseInputs PInput;
+  PInput.CompileCommand = Input.Command;
+  PInput.FS = VFS;
+  PInput.Contents = Input.Contents;
+  auto CI = buildCompilerInvocation(PInput);
   if (!CI) {
 elog("Couldn't create CompilerInvocation");
 return false;


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


[PATCH] D57047: [clangd] Fix broken build after r351793.

2019-01-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I think it is safe to use the empty one (constructed by the default 
constructor) here -- since `getDefaults` is not free, and we don't need the 
configurations in codeComplete, fixed in rL351826 
.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57047



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


[PATCH] D56984: [libunwind] Silence warnings about unused parameters

2019-01-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM, but would it make sense to have a macro like 
`_LIBUNWIND_MAYBE_UNUSED(var)` instead?


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D56984



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 182910.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Fix a typo in a comment: isValidRange -> isValidFileRange
- Make action available under 'else' keywords and conditions
- Move the logic of creating replacements to apply
- Use llvm::isa instead of dyn_cast_or_null


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

https://reviews.llvm.org/D56611

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/TweakTests.cpp

Index: clang-tools-extra/unittests/clangd/TweakTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TweakTests.cpp
@@ -0,0 +1,145 @@
+//===-- TweakTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Expr.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using llvm::Failed;
+using llvm::HasValue;
+using llvm::Succeeded;
+using ::testing::IsEmpty;
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+std::string markRange(llvm::StringRef Code, Range R) {
+  size_t Begin = llvm::cantFail(positionToOffset(Code, R.start));
+  size_t End = llvm::cantFail(positionToOffset(Code, R.end));
+  assert(Begin <= End);
+  if (Begin == End) // Mark a single point.
+return (Code.substr(0, Begin) + "^" + Code.substr(Begin)).str();
+  // Mark a range.
+  return (Code.substr(0, Begin) + "[[" + Code.substr(Begin, End - Begin) +
+  "]]" + Code.substr(End))
+  .str();
+}
+
+class TweakTest : public ::testing::Test {
+public:
+  /// Checks action is available at every point and range marked in \p Input.
+  void checkAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/true);
+  }
+
+  /// Same as checkAvailable, but checks the action is not available.
+  void checkNotAvailable(TweakID ID, llvm::StringRef Input) {
+return checkAvailable(ID, Input, /*Available=*/false);
+  }
+
+  llvm::Expected apply(TweakID ID, llvm::StringRef Input) {
+Annotations Code(Input);
+Range SelectionRng;
+if (Code.points().size() != 0) {
+  assert(Code.ranges().size() == 0 &&
+ "both a cursor point and a selection range were specified");
+  SelectionRng = Range{Code.point(), Code.point()};
+} else {
+  SelectionRng = Code.range();
+}
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+AST.getASTContext().getSourceManager(), SelectionRng.start));
+Tweak::Selection S = {Code.code(), AST, CursorLoc};
+
+auto T = prepareTweak(ID, S);
+if (!T)
+  return T.takeError();
+auto Replacements = (*T)->apply(S);
+if (!Replacements)
+  return Replacements.takeError();
+return applyAllReplacements(Code.code(), *Replacements);
+  }
+
+private:
+  void checkAvailable(TweakID ID, llvm::StringRef Input, bool Available) {
+Annotations Code(Input);
+ASSERT_TRUE(0 < Code.points().size() || 0 < Code.ranges().size())
+<< "no points of interest specified";
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Code.code();
+
+ParsedAST AST = TU.build();
+
+auto CheckOver = [&](Range Selection) {
+  auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+  AST.getASTContext().getSourceManager(), Selection.start));
+  auto T = prepareTweak(ID, Tweak::Selection{Code.code(), AST, CursorLoc});
+  if (Available)
+EXPECT_THAT_EXPECTED(T, Succeeded())
+<< "code is " << markRange(Code.code(), Selection);
+  else
+EXPECT_THAT_EXPECTED(T, Failed())
+<< "code is " << markRange(Code.code(), Selection);
+};
+for (auto P : Code.points())
+  CheckOver(Range{P, P});
+for (auto R : Code.ranges())
+  CheckOver(R);
+  }
+};
+
+TEST_F(TweakTest, SwapIfBranches) {
+  llvm::StringLiteral ID = "SwapIfBranches";
+
+  checkAvailable(ID, R"cpp(
+void test() {
+  ^i^f^^(^t^r^u^e^) { return 100; } ^e^l^s^e^ { continue; }
+}
+  )cpp");
+
+  checkNotAvailabl

[PATCH] D56849: [ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.

2019-01-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Thanks for tidying up the docs. LG with one nit.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:5018
+/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")
+///   matches "x.m", but not "m"; however,
+/// memberExpr(hasObjectExpression(hasType(pointsTo(

nit: Let's use backquotes here instead of double quotes. Same three lines below.


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

https://reviews.llvm.org/D56849



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

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



Comment at: clangd/refactor/tweaks/SwapIfBranches.cpp:34
+/// After:
+///   if (foo) { continue; } else { return 10; }
+class SwapIfBranches : public Tweak {

sammccall wrote:
> The before/after is useful, we should probably have it for all tweaks if 
> possible.
> It'd also be useful to notate where the cursor can be to trigger the action. 
> Partly because it forces us to consider this!
> 
> e.g. (not sure if this actually matches the logic you want, just an example)
> ```
> Before:
>   if (foo) { return 10; } else { continue; }
>   ^^   ^
> After:
>   ...
> ```
LG, updated the comment and ranges per suggestion.
I still not sure if the action should span the whole condition, but going with 
the suggested ranges anyway. We can tweak them later if the resulting ranges 
turn out to be problematic.

However, note that I excluded `{` and `}` from available ranges, but only 
because I'm lazy and this requires declaring some more local vars, etc.



Comment at: clangd/refactor/tweaks/SwapIfBranches.cpp:46
+private:
+  tooling::Replacements Result;
+};

sammccall wrote:
> I think prepare() should just verify:
>  - cursor is in the right place
>  - else statement exists and isn't an else if
>  - both branches are compound statements (for now)
>  - (maybe) relevant locations (if keyword, else keyword, braces) are not 
> macro expansions
> and then record the relevant source locations (or just the IfStmt*)
> 
> We may be able to get away with doing all the work in `prepare()`, but it's 
> not a good model for future tweaks. (And it is at least somewhat wasteful on 
> a hot path).
Done.
The only reason I thought applying replacements was a sensible idea is because 
it would fail in some weird macro cases (only when resulting ranges overlap, 
though). And it seemed better to avoid showing the action rather than showing 
it and failing later.



Comment at: clangd/refactor/tweaks/SwapIfBranches.cpp:50
+
+class FindIfUnderCursor : public RecursiveASTVisitor {
+public:

sammccall wrote:
> (Mostly this is food for thought for later - we shouldn't try to solve 
> everything in this patch)
> 
> Two efficiency problems here:
>  - doing one traversal per tweak is wasteful (when we have >1 tweaks, but 
> worth at least *thinking* about)
>  - traversing the entire AST rather than just the nodes over the cursor is 
> bad news (though "over the cursor" may not be trivial to define)
> 
> Idea for how to "framework" this problem away:
> Add `vector SelectedNodes` to the inputs, the idea being that 
> this is the stack from the narrowest `Expr` under the cursor to the 
> `TranslationUnitDecl` at the top.
> This can be produced by a RecursiveASTVisitor (that either traverses the 
> whole AST, or just the bits under the cursor if that's simple enough).
> Tweaks would iterate over the nodes from narrowest to broadest, deciding 
> whether to select this node for processing, continue iterating, or bail out.
> 
> Matching in checks are then pretty easy to write, we haven't removed too much 
> flexibility in flow control, and it's pretty hard to write a slow check.
> 
> There are some complications:
>  - we need access to parents somehow (e.g. consider the case of adding NS 
> qualifiers, we want to match on names but then traverse up to the containing 
> declrefexpr to get the nested namespace loc)
>  - the interesting nodes may be a tree rather than a stack, because nodes 
> overlap in the source. We could store a postorder traversal... but this makes 
> e.g. "bail out when you hit a functiondecl" harder - you probably want to 
> bail out of the current branch only.
>  - things get complicated when we think about macros - depending on the 
> semantics we want, it may be hard for the framework to prune parts of the 
> tree that aren't under the cursor withouth traversing the whole AST.
I mostly agree, however I still wonder whether that would be inefficient in 
some cases. E.g. consider a corner if the input selection from LSP contains the 
whole file? I see two options there: (1) putting all nodes of a file into 
`vector`, (2) putting only the top-level `TranslationUnitDecl` 
there.

It seems easy to end up with (1) to make the interface useful, however we 
probably prefer (2) because otherwise we're back into the worst-case scenario, 
i.e. "every  tweak traverses all the nodes"

> we need access to parents somehow (e.g. consider the case of adding NS 
> qualifiers, we want to match on names but then traverse up to the containing 
> declrefexpr to get the nested namespace loc)

I wonder if it's possible to instead write the checks so that they only look at 
the children of the nodes in a vector? My bet is that almost all of the checks 
only need to look one or two levels down, so this shouldn't turn into 
inefficiency.


[PATCH] D56540: [clangd] Clean the cache of file statuses on vscode-clangd when clangd crashes.

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

LGTM




Comment at: clangd/clients/clangd-vscode/src/extension.ts:127
+(fileStatus) => { status.onFileUpdated(fileStatus); });
+} else if (newState == vscodelc.State.Stopped) {
+// Clear all cached statuses when clangd crashes.

This looks scary, if we end up doing that in too many places, the code would 
become completely unreadable.

Have no idea how to make it better, but a very general observation is that we'd 
be better off with dropping all the state we have when clangd crashes and 
starting from scratch, rather than trying to keep old components and bring them 
into a sensible state when crashes happen.

No need to do anything right now, just something to keep in mind for the future.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56540



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


[PATCH] D56539: [clangd] Drop documentation in static index if symbols are not indexed for completion.

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

Just realized I missed this review, sorry about that.
LGTM with a nit.




Comment at: clangd/index/FileIndex.cpp:51
 CollectorOpts.RefFilter = RefKind::All;
-  }else {
+CollectorOpts.StoreAllDocumentation = false;
+  } else {

NIT: maybe mention the rationale here in a comment? Something like `// comments 
for main file can always be obtained from sema, do not store them in the index.`


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56539



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


[PATCH] D57055: [RISCV] Mark TLS as supported

2019-01-22 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill created this revision.
lewis-revill added a reviewer: asb.
Herald added subscribers: cfe-commits, jocewei, PkmX, rkruppe, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.

Inform Clang that TLS is implemented by LLVM for RISC-V


Repository:
  rC Clang

https://reviews.llvm.org/D57055

Files:
  lib/Basic/Targets/RISCV.h


Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -36,7 +36,7 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
+TLSSupported = true;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();


Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -36,7 +36,7 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
+TLSSupported = true;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57055: [RISCV] Mark TLS as supported

2019-01-22 Thread James Clarke via Phabricator via cfe-commits
jrtc27 requested changes to this revision.
jrtc27 added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Basic/Targets/RISCV.h:39
 HasD(false), HasC(false) {
-TLSSupported = false;
+TLSSupported = true;
 LongDoubleWidth = 128;

With the exception of `SystemZTargetInfo`, all CPU target info classes rely on 
the base already initialising it to `true` by default, so you can just delete 
this line.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57055



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


[PATCH] D57057: [clangd] Log clang-tidy configuration, NFC

2019-01-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.

This is used for debugging purpose.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57057

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -265,6 +265,8 @@
   llvm::Optional CTContext;
   {
 trace::Span Tracer("ClangTidyInit");
+vlog("ClangTidy configuration for file {0}: {1}", MainInput.getFile(),
+ tidy::configurationAsText(ClangTidyOpts));
 tidy::ClangTidyCheckFactories CTFactories;
 for (const auto &E : tidy::ClangTidyModuleRegistry::entries())
   E.instantiate()->addCheckFactories(CTFactories);


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -265,6 +265,8 @@
   llvm::Optional CTContext;
   {
 trace::Span Tracer("ClangTidyInit");
+vlog("ClangTidy configuration for file {0}: {1}", MainInput.getFile(),
+ tidy::configurationAsText(ClangTidyOpts));
 tidy::ClangTidyCheckFactories CTFactories;
 for (const auto &E : tidy::ClangTidyModuleRegistry::entries())
   E.instantiate()->addCheckFactories(CTFactories);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56849: [ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.

2019-01-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 182918.
ymandel marked an inline comment as done.
ymandel added a comment.

Use backticks instead of quotes for quoted code.


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

https://reviews.llvm.org/D56849

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h

Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2887,14 +2887,22 @@
  InnerMatcher.matches(*UnderlyingDecl, Finder, Builder);
 }
 
-/// Matches on the implicit object argument of a member call expression.
+/// Matches on the implicit object argument of a member call expression, after
+/// stripping off any parentheses or implicit casts.
 ///
-/// Example matches y.x()
-///   (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))
+/// Given
 /// \code
-///   class Y { public: void x(); };
-///   void z() { Y y; y.x(); }
+///   class Y { public: void m(); };
+///   Y g();
+///   class X : public Y {};
+///   void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
 /// \endcode
+/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")
+///   matches `y.m()` and `(g()).m()`.
+/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")
+///   matches `x.m()`.
+/// cxxMemberCallExpr(on(callExpr()))
+///   matches `(g()).m()`.
 ///
 /// FIXME: Overload to allow directly matching types?
 AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher,
@@ -3254,6 +3262,23 @@
   .matches(Node, Finder, Builder);
 }
 
+/// Matches on the implicit object argument of a member call expression. Unlike
+/// `on`, matches the argument directly without stripping away anything.
+///
+/// Given
+/// \code
+///   class Y { public: void m(); };
+///   Y g();
+///   class X : public Y { void g(); };
+///   void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
+/// \endcode
+/// cxxMemberCallExpr(onImplicitObjectArgument(hasType(
+/// cxxRecordDecl(hasName("Y")
+///   matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
+/// cxxMemberCallExpr(on(callExpr()))
+///   does not match `(g()).m()`, because the parens are not ignored.
+///
+/// FIXME: Overload to allow directly matching types?
 AST_MATCHER_P(CXXMemberCallExpr, onImplicitObjectArgument,
   internal::Matcher, InnerMatcher) {
   const Expr *ExprNode = Node.getImplicitObjectArgument();
@@ -3261,8 +3286,22 @@
   InnerMatcher.matches(*ExprNode, Finder, Builder));
 }
 
-/// Matches if the expression's type either matches the specified
-/// matcher, or is a pointer to a type that matches the InnerMatcher.
+/// Matches if the type of the expression's implicit object argument either
+/// matches the InnerMatcher, or is a pointer to a type that matches the
+/// InnerMatcher.
+///
+/// Given
+/// \code
+///   class Y { public: void m(); };
+///   class X : public Y { void g(); };
+///   void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); }
+/// \endcode
+/// cxxMemberCallExpr(thisPointerType(hasDeclaration(
+/// cxxRecordDecl(hasName("Y")
+///   matches `y.m()`, `p->m()` and `x.m()`.
+/// cxxMemberCallExpr(thisPointerType(hasDeclaration(
+/// cxxRecordDecl(hasName("X")
+///   matches `x.g()`.
 AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,
internal::Matcher, InnerMatcher, 0) {
   return onImplicitObjectArgument(
@@ -4964,18 +5003,22 @@
   return InnerMatcher.matches(*Node.getMemberDecl(), Finder, Builder);
 }
 
-/// Matches a member expression where the object expression is
-/// matched by a given matcher.
+/// Matches a member expression where the object expression is matched by a
+/// given matcher. Implicit object expressions are included; that is, it matches
+/// use of implicit `this`.
 ///
 /// Given
 /// \code
-///   struct X { int m; };
-///   void f(X x) { x.m; m; }
+///   struct X {
+/// int m;
+/// int f(X x) { x.m; return m; }
+///   };
 /// \endcode
-/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))
-///   matches "x.m" and "m"
-/// with hasObjectExpression(...)
-///   matching "x" and the implicit object expression of "m" which has type X*.
+/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")
+///   matches `x.m`, but not `m`; however,
+/// memberExpr(hasObjectExpression(hasType(pointsTo(
+//  cxxRecordDecl(hasName("X"))
+///   matches `m` (aka. `this->m`), but not `x.m`.
 AST_POLYMORPHIC_MATCHER_P(
 hasObjectExpression,
 AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -4810,16 +4810,20 @@
 
 
 Matcher

[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-01-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 182919.
ymandel marked an inline comment as done.
ymandel added a comment.

Remove unnecessary expectation.


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

https://reviews.llvm.org/D56850

Files:
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -470,6 +470,96 @@
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(Snippet2, MatchesX));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(Matcher, HasObjectExpr) {
+  auto M = memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return x.m; }
+};
+  )cc",
+  M));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return m; }
+};
+  )cc",
+  M));
+}
+
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
   StatementMatcher ArgumentY =
 declRefExpr(to(varDecl(hasName("y".bind("arg");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57055: [RISCV] Mark TLS as supported

2019-01-22 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 182920.
lewis-revill added a comment.

Rely on default value rather than explicitly marking `TLSSupported` as true.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57055

Files:
  lib/Basic/Targets/RISCV.h


Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -36,7 +36,6 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();


Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -36,7 +36,6 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D56916#1365357 , @ilya-biryukov 
wrote:

> Good point, @aaron.ballman! @dgoldman, could you please add a test case?


Unfortunately I can't get ninja check-clangd to build:

  
/Users/davg/dev/llvm/source/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:54:27:
 error: no matching member function for call to 'getThisType'
  ActualMemberDecl->getThisType(ActualMemberDecl->getASTContext())
  ~~^~~
  
/Users/davg/dev/llvm/source/llvm/tools/clang/include/clang/AST/DeclCXX.h:2182:12:
 note: candidate function not viable: requires 0 arguments, but 1 was provided
QualType getThisType() const;
 ^
  
/Users/davg/dev/llvm/source/llvm/tools/clang/include/clang/AST/DeclCXX.h:2184:19:
 note: candidate function not viable: requires 2 arguments, but 1 was provided
static QualType getThisType(const FunctionProtoType *FPT,
^
  1 error generated.
  [1230/1512] Building CXX object 
tools/clang/tools/extra/clang-tidy/cert/CMakeFiles/clangTidyCERTModule.dir/CERTTidyModule.cpp.o
  ninja: build stopped: subcommand failed.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916



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


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 182921.
dgoldman marked an inline comment as done.
dgoldman added a comment.

- use auto


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916

Files:
  clangd/index/SymbolCollector.cpp


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -369,19 +369,25 @@
   if (!ID)
 return true;
 
-  const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
+  // FIXME: ObjCPropertyDecl are not properly indexed here:
+  // - ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  auto *OriginalDecl = dyn_cast(ASTNode.OrigD);
+  if (!OriginalDecl)
+return true;
+
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
 BasicSymbol = addDeclaration(*ND, std::move(*ID));
-  else if (isPreferredDeclaration(OriginalDecl, Roles))
+  else if (isPreferredDeclaration(*OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID));
+BasicSymbol = addDeclaration(*OriginalDecl, std::move(*ID));
 
   if (Roles & static_cast(index::SymbolRole::Definition))
-addDefinition(OriginalDecl, *BasicSymbol);
+addDefinition(*OriginalDecl, *BasicSymbol);
   return true;
 }
 


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -369,19 +369,25 @@
   if (!ID)
 return true;
 
-  const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
+  // FIXME: ObjCPropertyDecl are not properly indexed here:
+  // - ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  auto *OriginalDecl = dyn_cast(ASTNode.OrigD);
+  if (!OriginalDecl)
+return true;
+
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
 BasicSymbol = addDeclaration(*ND, std::move(*ID));
-  else if (isPreferredDeclaration(OriginalDecl, Roles))
+  else if (isPreferredDeclaration(*OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID));
+BasicSymbol = addDeclaration(*OriginalDecl, std::move(*ID));
 
   if (Roles & static_cast(index::SymbolRole::Definition))
-addDefinition(OriginalDecl, *BasicSymbol);
+addDefinition(*OriginalDecl, *BasicSymbol);
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In D56903#1365487 , @sammccall wrote:

> This looks pretty good! My main concern is latency (and variability of 
> latency) in practice.
> Particularly:
>
> - we should avoid paying for fuzzyfind and fetching hundreds of results when 
> we want exact-match
> - limit the damage in degenerate cases: should we limit to e.g. 5 index 
> queries per TU?
>
>   Actually, now that I think about it - if we can see a forward declaration, 
> can't we do a lookup() instead of a fuzzyFind? Is the problem that this 
> doesn't generalize to the no-declaration case (where it looks like a typo)?


I switched to use lookup requests for incomplete type diagnostics. And yes, the 
typo errors need to use FuzzyFind or lookup by names as no USR is available.

> If we had an operation that looked like lookup() but worked by qname, would 
> we design the feature the same way?
>  In particular, would we want to batch the requests to the index (lookup 
> takes a set of IDs)? This would affect the code structure a bit. But it would 
> make the feature cost basically O(1) instead of O(errs)...

As chatted offline, we decided to leave the batching optimization as a TODO in 
this patch. See inline comment for more detailed response regarding performance.




Comment at: clangd/ClangdUnit.h:91
+IntrusiveRefCntPtr VFS,
+const SymbolIndex *Index);
 

sammccall wrote:
> Index is a reasonable (if surprising) param here, but I think we need to 
> explicitly enable the include-fixing behavior. Even the very minimal 
> hard-coded list of clang-tidy checks caused issues :-( And this is going to 
> result in new network RPCs in some configs.
> 
> I'd suggest keeping the Index param, and wrapping the "use include fixer?" 
> policy along with the clang-tidy options in D55256 as some sort of 
> "diagnostic options" struct. (Though be wary of name clash with the one in 
> Diagnostics.h, sigh).
How about `ParseOptions`?



Comment at: clangd/IncludeFixer.cpp:39
+   const clang::Diagnostic &Info) const {
+  if (isIncompleteTypeDiag(Info.getID())) {
+// Incomplete type diagnostics should have a QualType argument for the

sammccall wrote:
> can you add a trace to this function so we know what the impact on latency is?
Added a tracer in `fixInCompleteType` to avoid noise from unsupported 
diagnostics.



Comment at: clangd/IncludeFixer.cpp:66
+  vlog("Trying to fix include for incomplete type {0}", IncompleteType);
+  FuzzyFindRequest Req;
+  Req.AnyScope = false;

ilya-biryukov wrote:
> sammccall wrote:
> > limit?
> Why do we use fuzzyFind and not `lookup` here?
> Are there cases when we can't construct `SymbolID` for the `TagDecl`?
Switched to use lookup. The typo diagnostics (i.e. undefined symbol) can't use 
lookup as there is no declaration, but we can definitely use lookup for 
incomplete types in this patch.



Comment at: clangd/IncludeFixer.cpp:74
+  llvm::Optional Matched;
+  Index.fuzzyFind(Req, [&](const Symbol &Sym) {
+// FIXME: support multiple matched symbols.

sammccall wrote:
> so issuing a bunch of fuzzy finds in sequence is clearly not ideal from a 
> performance standpoint.
> Any ideas on what we might do better, or how we can limit the worst case?
> (not sure we need to do any better in this patch, but might be worth comments)
As you suggested, batching requests from all diagnostics would definitely help. 
SymbolIndex already supports batch lookup by IDs, but we would need to extend 
SymbolIndex to support lookup by Names for the typo errors that we are handling 
in D57021. In order to batch index requests from all diagnostics, the existing 
logic around handling and storing diagnostics might also need refactoring. I 
added a TODO for this. We can revisit if the performance turned out to be a big 
problem.

Another thing we could do is adding cache for index results. For example, for 
the code copy-paste case, one incomplete/undefined symbol can cause multiple 
errors. Caching should save us some unnecessary index queries.

For this patch, I added a limit on the number of index requests in IncludeFixer 
(5 for now), which would prevent us from sending too many index requests when 
building AST.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56903



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


[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 182922.
ioeric marked 15 inline comments as done.
ioeric added a comment.

- Address review comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56903

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Compiler.h
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DiagnosticsTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestIndex.cpp
  unittests/clangd/TestIndex.h
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -49,6 +49,8 @@
   std::vector ExtraArgs;
 
   llvm::Optional ClangTidyChecks;
+  // Index to use when building AST.
+  const SymbolIndex *ExternalIndex = nullptr;
 
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,8 +35,11 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
-  Inputs.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
-  Inputs.ClangTidyOpts.Checks = ClangTidyChecks;
+  Inputs.Opts = ParseOptions();
+  Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
+  Inputs.Index = ExternalIndex;
+  if (Inputs.Index)
+Inputs.Opts.EnableIncludeFixer = true;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TestIndex.h
===
--- unittests/clangd/TestIndex.h
+++ unittests/clangd/TestIndex.h
@@ -18,6 +18,19 @@
 // Creates Symbol instance and sets SymbolID to given QualifiedName.
 Symbol symbol(llvm::StringRef QName);
 
+// Helpers to produce fake index symbols with proper SymbolID.
+// USRFormat is a regex replacement string for the unqualified part of the USR.
+Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
+   llvm::StringRef USRFormat);
+// Creats a function symbol assuming no function arg.
+Symbol func(llvm::StringRef Name);
+// Creates a class symbol.
+Symbol cls(llvm::StringRef Name);
+// Creates a variable symbol.
+Symbol var(llvm::StringRef Name);
+// Creates a namespace symbol.
+Symbol ns(llvm::StringRef Name);
+
 // Create a slab of symbols with the given qualified names as IDs and names.
 SymbolSlab generateSymbols(std::vector QualifiedNames);
 
Index: unittests/clangd/TestIndex.cpp
===
--- unittests/clangd/TestIndex.cpp
+++ unittests/clangd/TestIndex.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include "TestIndex.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/Support/Regex.h"
 
 namespace clang {
 namespace clangd {
@@ -25,6 +27,58 @@
   return Sym;
 }
 
+static std::string replace(llvm::StringRef Haystack, llvm::StringRef Needle,
+   llvm::StringRef Repl) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  std::pair Split;
+  for (Split = Haystack.split(Needle); !Split.second.empty();
+   Split = Split.first.split(Needle))
+OS << Split.first << Repl;
+  Result += Split.first;
+  OS.flush();
+  return Result;
+}
+
+// Helpers to produce fake index symbols for memIndex() or completions().
+// USRFormat is a regex replacement string for the unqualified part of the USR.
+Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
+   llvm::StringRef USRFormat) {
+  Symbol Sym;
+  std::string USR = "c:"; // We synthesize a few simple cases of USRs by hand!
+  size_t Pos = QName.rfind("::");
+  if (Pos == llvm::StringRef::npos) {
+Sym.Name = QName;
+Sym.Scope = "";
+  } else {
+Sym.Name = QName.substr(Pos + 2);
+Sym.Scope = QName.substr(0, Pos + 2);
+USR += "@N@" + replace(QName.substr(0, Pos), "::", "@N@"); // ns:: -> @N@ns
+  }
+  USR += llvm::Regex("^.*$").sub(USRFormat, Sym.Name); // e.g. func -> @F@func#
+  Sym.ID = SymbolID(USR);
+  Sym.SymInfo.Kind = Kind;
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.Origin = SymbolOrigin::Static;
+  return Sym;
+}
+
+Symbol func(llvm::StringRef Name) { // Assumes the function has no args.

[PATCH] D57021: [clangd] Suggest adding missing includes for typos (like include-fixer).

2019-01-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 182925.
ioeric added a comment.

- Rebase on D56903 


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57021

Files:
  clangd/ClangdUnit.cpp
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -30,6 +30,11 @@
   return Field(&Diag::Fixes, ElementsAre(FixMatcher));
 }
 
+testing::Matcher WithFix(testing::Matcher FixMatcher1,
+   testing::Matcher FixMatcher2) {
+  return Field(&Diag::Fixes, UnorderedElementsAre(FixMatcher1, FixMatcher2));
+}
+
 testing::Matcher WithNote(testing::Matcher NoteMatcher) {
   return Field(&Diag::Notes, ElementsAre(NoteMatcher));
 }
@@ -280,6 +285,25 @@
   Pair(EqualToLSPDiag(NoteInMainLSP), IsEmpty(;
 }
 
+struct SymbolWithHeader {
+  std::string QName;
+  std::string DeclaringFile;
+  std::string IncludeHeader;
+};
+
+std::unique_ptr
+buildIndexWithSymbol(llvm::ArrayRef Syms) {
+  SymbolSlab::Builder Slab;
+  for (const auto &S : Syms) {
+Symbol Sym = cls(S.QName);
+Sym.Flags |= Symbol::IndexedForCodeCompletion;
+Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Slab.insert(Sym);
+  }
+  return MemIndex::build(std::move(Slab).build(), RefSlab());
+}
+
 TEST(IncludeFixerTest, IncompleteType) {
   Annotations Test(R"cpp(
 $insert[[]]namespace ns {
@@ -292,14 +316,8 @@
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
-  Symbol Sym = cls("ns::X");
-  Sym.Flags |= Symbol::IndexedForCodeCompletion;
-  Sym.CanonicalDeclaration.FileURI = "unittest:///x.h";
-  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
-
-  SymbolSlab::Builder Slab;
-  Slab.insert(Sym);
-  auto Index = MemIndex::build(std::move(Slab).build(), RefSlab());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
 
   EXPECT_THAT(
@@ -314,6 +332,64 @@
 "Add include \"x.h\" for symbol ns::X");
 }
 
+TEST(IncludeFixerTest, Typo) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+void bar() {
+  ns::$qualified[[X]] x; // ns:: is valid.
+  ::$global[[Global]] glob;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""},
+   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unqualified"), "unknown type name 'X'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("qualified"),
+ "no type named 'X' in namespace 'ns'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("global"),
+ "no type named 'Global' in the global namespace"),
+WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
+"Add include \"global.h\" for symbol Global");
+}
+
+TEST(IncludeFixerTest, MultipleMatchedSymbols) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace na {
+namespace nb {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"na::X", "unittest:///a.h", "\"a.h\""},
+   SymbolWithHeader{"na::nb::X", "unittest:///b.h", "\"b.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("unqualified"), "unknown type name 'X'"),
+  WithFix(Fix(Test.range("insert"), "#include \"a.h\"\n",
+  "Add include \"a.h\" for symbol na::X"),
+  Fix(Test.range("insert"), "#include \"b.h\"\n",
+  "Add include \"b.h\" for symbol na::nb::X");
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/IncludeFixer.h
===
--- clangd/IncludeFixer.h
+++ clangd/IncludeFixer.h
@@ -14,6 +14,13 @@
 #include "index/Index.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "c

[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> Unfortunately I can't get ninja check-clangd to build:

Looks like `clang-tools-extra` uses an old revision. Rebasing after rL350916 
 should do the trick.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916



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


[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Shafik,
I have realized what's the problem with the `ctu-main` test. When we import the 
body and set the new body to the existing FunctionDecl then the parameters are 
still the old parameters so the new body does not refer to the formal 
parameters! This way the analyzer legally thinks that the parameter is not used 
inside the function because there is no DeclRef to that :(
This could be solved only if we merge *every* parts precisely, including the 
parameters, body, noexcept specifier, etc. But this would be a huge work.

Also, the test in `ctu-main` contains ODR violations. E.g, below `fcl` is first 
just a protoype, then it is defined in-class in the second TU.

  // ctu-main.cpp
  class mycls {
  public:
int fcl(int x);
//...
  
  // ctu-other.cpp
   class mycls {
   public:
int fcl(int x) {
  return x + 5;
}
//...

In the second TU it should be defined out-of-class.

So my suggestion is to

1. use out-of-class definition of functions in `ctu-other.cpp`. Since I tried 
it already i have the diff for the lit tests, attached.F7837319: 
lit_tests.patch 
2. skip the case when there is a definition in the 'from' context and let it do 
the redecl chain.

For 2) I was thinking about this:

  if (FoundByLookup) {
if (auto *MD = dyn_cast(FoundByLookup)) {
  if (D->getLexicalDeclContext() == D->getDeclContext()) {
if (!D->doesThisDeclarationHaveABody())
  return cast(const_cast(FoundByLookup));
else {
  // Let's continue and build up the redecl chain in this case.
  // FIXME Merge the functions into one decl.
}
  }
}
  }

Later, we must implement the case when we have to merge the definition into the 
prototype properly, but that should be definitely another patch. 
Actually, this case comes up mostly with class template specializations , 
because different specializations may have a function prototype in one TU, but 
a definition for that in another TU (see e.g. the test 
`MergeFieldDeclsOfClassTemplateSpecialization`).




Comment at: lib/AST/ASTImporter.cpp:3042
 
+  if (FoundByLookup) {
+if (auto *MD = dyn_cast(FoundByLookup)) {

It is not trivial why we add this block to the code, so I think a comment would 
be really appreciated here.
I was thinking about something like this:
```
+  // We do not allow more than one in-class prototype of a function.  This is
+  // because AST clients like VTableBuilder asserts on this.  VTableBuilder
+  // assumes that only one function can override a function. Building a redecl
+  // chain would result there are more than one function which override the
+  // base function (even if they are part of the same redecl chain inside the
+  // derived class.)
```


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

https://reviews.llvm.org/D56936



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


[PATCH] D57060: [NFC][Clang] Add driver tests for sb and predres

2019-01-22 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
dnsampaio added a reviewer: pbarrio.
Herald added subscribers: cfe-commits, javed.absar.

Add tests that arguments for enabling/disabling sb and predres are correctly 
being or not passed by the driver.


Repository:
  rC Clang

https://reviews.llvm.org/D57060

Files:
  test/Driver/aarch64-predres.c
  test/Driver/arm-sb.c


Index: test/Driver/arm-sb.c
===
--- /dev/null
+++ test/Driver/arm-sb.c
@@ -0,0 +1,14 @@
+// RUN: %clang -### -target arm-none-none-eabi -march=armv8a+sb %s 2>&1 | 
FileCheck %s
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+sb %s 2>&1 | 
FileCheck %s
+// CHECK: "-target-feature" "+sb"
+// CHECK-NOT: "-target-feature" "-sb"
+
+// RUN: %clang -### -target arm-none-none-eabi -march=armv8.5a+nosb %s 2>&1 | 
FileCheck %s --check-prefix=NOSB
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+nosb %s 
2>&1 | FileCheck %s --check-prefix=NOSB
+// NOSB: "-target-feature" "-sb"
+// NOSB-NOT: "-target-feature" "+sb"
+
+// RUN: %clang -### -target arm-none-none-eabi %s 2>&1 | FileCheck %s 
--check-prefix=ABSENT
+// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s 
--check-prefix=ABSENT
+// ABSENT-NOT: "-target-feature" "+sb"
+// ABSENT-NOT: "-target-feature" "-sb"
Index: test/Driver/aarch64-predres.c
===
--- /dev/null
+++ test/Driver/aarch64-predres.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+predres 
%s 2>&1 | FileCheck %s
+// CHECK: "-target-feature" "+predres"
+// CHECK-NOT: "-target-feature" "-predres"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+nopredres 
%s 2>&1 | FileCheck %s --check-prefix=NOPR
+// NOPR: "-target-feature" "-predres"
+// NOPR-NOT: "-target-feature" "+predres"
+
+// RUN: %clang -### -target aarch64-none-none-eabi   
%s 2>&1 | FileCheck %s --check-prefix=ABSENT
+// ABSENT-NOT: "-target-feature" "+predres"
+// ABSENT-NOT: "-target-feature" "-predres"


Index: test/Driver/arm-sb.c
===
--- /dev/null
+++ test/Driver/arm-sb.c
@@ -0,0 +1,14 @@
+// RUN: %clang -### -target arm-none-none-eabi -march=armv8a+sb %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+sb %s 2>&1 | FileCheck %s
+// CHECK: "-target-feature" "+sb"
+// CHECK-NOT: "-target-feature" "-sb"
+
+// RUN: %clang -### -target arm-none-none-eabi -march=armv8.5a+nosb %s 2>&1 | FileCheck %s --check-prefix=NOSB
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+nosb %s 2>&1 | FileCheck %s --check-prefix=NOSB
+// NOSB: "-target-feature" "-sb"
+// NOSB-NOT: "-target-feature" "+sb"
+
+// RUN: %clang -### -target arm-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENT
+// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENT
+// ABSENT-NOT: "-target-feature" "+sb"
+// ABSENT-NOT: "-target-feature" "-sb"
Index: test/Driver/aarch64-predres.c
===
--- /dev/null
+++ test/Driver/aarch64-predres.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+predres %s 2>&1 | FileCheck %s
+// CHECK: "-target-feature" "+predres"
+// CHECK-NOT: "-target-feature" "-predres"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+nopredres %s 2>&1 | FileCheck %s --check-prefix=NOPR
+// NOPR: "-target-feature" "-predres"
+// NOPR-NOT: "-target-feature" "+predres"
+
+// RUN: %clang -### -target aarch64-none-none-eabi   %s 2>&1 | FileCheck %s --check-prefix=ABSENT
+// ABSENT-NOT: "-target-feature" "+predres"
+// ABSENT-NOT: "-target-feature" "-predres"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:3046
+if (!D->doesThisDeclarationHaveABody())
+  return cast(const_cast(FoundByLookup));
+else {

balazske wrote:
> The `cast` should not be needed here (and is not done at the other 
> return places). The `const_cast` can be omitted too (`FoundByLookup` is not 
> const now).
We must also register the decl into the map of imported decls as we do in all 
the other cases.
```
return Importer.MapImported(D, FoundByLookup);
```


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

https://reviews.llvm.org/D56936



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


[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-01-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 182933.
ymandel marked 3 inline comments as done.
ymandel added a comment.

Extended test of `hasObjectExpression`.


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

https://reviews.llvm.org/D56850

Files:
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -470,6 +470,100 @@
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(Snippet2, MatchesX));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(Matcher, HasObjectExpr) {
+  auto Snippet1 = R"cc(
+struct X {
+  int m;
+  int f(X x) { return x.m; }
+};
+  )cc";
+  auto Snippet2 = R"cc(
+struct X {
+  int m;
+  int f(X x) { return m; }
+};
+  )cc";
+  auto MatchesX =
+  memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(Snippet1, MatchesX));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  auto MatchesXPointer = memberExpr(
+  hasObjectExpression(hasType(pointsTo(cxxRecordDecl(hasName("X"));
+  EXPECT_TRUE(notMatches(Snippet1, MatchesXPointer));
+  EXPECT_TRUE(matches(Snippet2, MatchesXPointer));
+}
+
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
   StatementMatcher ArgumentY =
 declRefExpr(to(varDecl(hasName("y".bind("arg");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-01-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:558
+  int m;
+  int f(X x) { return m; }
+};

steveire wrote:
> Are we missing a matcher that would reach the type of X in this case? 
> `hasImplicitObjectExpression`, or something equivalent?
Good question. The reason we're not reaching `X` in this case is that we're 
distinguishing between `T` and `T*` (like `thisPointerType` does). That's 
separate from the difference between `on` and `onImplicitObjectArgument`.  So, 
I think we'll at least want a matcher that elides this difference, e.g.
`hasObjectType`.

I'm less inclined to add matchers that distinguish the written from the coerced 
member expression (one variant each for the expression and type matchers) given 
that I think this issue comes up far less for member expressions that don't 
involve calls. I'm just afraid that the proliferation of matchers might confuse 
beginners.

Note that I extended the test to include the hasPointerType() case (especially 
since it's now mentioned in the comments).


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

https://reviews.llvm.org/D56850



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


[PATCH] D56651: [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl

2019-01-22 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

The updated version looks good to me! Thank you!


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

https://reviews.llvm.org/D56651



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


r351841 - ReleaseNotes: remove openmp notes from r351580

2019-01-22 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Jan 22 09:01:39 2019
New Revision: 351841

URL: http://llvm.org/viewvc/llvm-project?rev=351841&view=rev
Log:
ReleaseNotes: remove openmp notes from r351580

They were for the 8.0 branch, and have been committed there in r351839.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351841&r1=351840&r2=351841&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Jan 22 09:01:39 2019
@@ -133,36 +133,7 @@ ABI Changes in Clang
 OpenMP Support in Clang
 --
 
-- OpenMP 5.0 features
-
-  - Support relational-op != (not-equal) as one of the canonical forms of 
random
-access iterator.
-  - Added support for mapping of the lambdas in target regions.
-  - Added parsing/sema analysis for the requires directive.
-  - Support nested declare target directives.
-  - Make the `this` pointer implicitly mapped as `map(this[:1])`.
-  - Added the `close` *map-type-modifier*.
-
-- Various bugfixes and improvements.
-
-New features supported for Cuda devices:
-
-- Added support for the reductions across the teams.
-
-- Extended number of constructs that can be executed in SPMD mode.
-
-- Fixed support for lastprivate/reduction variables in SPMD constructs.
-
-- New collapse clause scheme to avoid expensive remainder operations.
-
-- New default schedule for distribute and parallel constructs.
-
-- Simplified code generation for distribute and parallel in SPMD mode.
-
-- Flag (``-fopenmp_optimistic_collapse``) for user to limit collapsed
-  loop counter width when safe to do so.
-
-- General performance improvement.
+- ...
 
 CUDA Support in Clang
 -


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


Re: r351580 - [OPENMP][DOCS] Release notes/OpenMP support updates, NFC.

2019-01-22 Thread Hans Wennborg via cfe-commits
Thanks, I've merged it to 8.0 in r351839.

Since the release notes are for 8.0 and not trunk, I've removed the
change from trunk in r351841.

On Fri, Jan 18, 2019 at 12:05 PM Kelvin Li  wrote:
>
> Hi Hans,
>
> I am not sure if it is the proper way to request the change committed
> to the release_80 branch.  Please let me know if I need to do
> something else.
>
> Thanks,
> Kelvin
>
> -- Forwarded message -
> From: Kelvin Li via cfe-commits 
> Date: Fri, Jan 18, 2019 at 3:01 PM
> Subject: r351580 - [OPENMP][DOCS] Release notes/OpenMP support updates, NFC.
> To: 
>
>
> Author: kli
> Date: Fri Jan 18 11:57:37 2019
> New Revision: 351580
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351580&view=rev
> Log:
> [OPENMP][DOCS] Release notes/OpenMP support updates, NFC.
>
> Differential Revision: https://reviews.llvm.org/D56733
>
> Modified:
> cfe/trunk/docs/OpenMPSupport.rst
> cfe/trunk/docs/ReleaseNotes.rst
>
> Modified: cfe/trunk/docs/OpenMPSupport.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=351580&r1=351579&r2=351580&view=diff
> ==
> --- cfe/trunk/docs/OpenMPSupport.rst (original)
> +++ cfe/trunk/docs/OpenMPSupport.rst Fri Jan 18 11:57:37 2019
> @@ -17,60 +17,50 @@
>  OpenMP Support
>  ==
>
> -Clang fully supports OpenMP 4.5. Clang supports offloading to X86_64, 
> AArch64,
> -PPC64[LE] and has `basic support for Cuda devices`_.
> -
> -Standalone directives
> -=
> -
> -* #pragma omp [for] simd: :good:`Complete`.
> -
> -* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
> -  analysis + generation of special attributes for X86 target, but still
> -  missing the LLVM pass for vectorization.
> -
> -* #pragma omp taskloop [simd]: :good:`Complete`.
> -
> -* #pragma omp target [enter|exit] data: :good:`Complete`.
> -
> -* #pragma omp target update: :good:`Complete`.
> -
> -* #pragma omp target: :good:`Complete`.
> +Clang supports the following OpenMP 5.0 features
>
> -* #pragma omp declare target: :good:`Complete`.
> +* The `reduction`-based clauses in the `task` and `target`-based directives.
>
> -* #pragma omp teams: :good:`Complete`.
> +* Support relational-op != (not-equal) as one of the canonical forms of 
> random
> +  access iterator.
>
> -* #pragma omp distribute [simd]: :good:`Complete`.
> +* Support for mapping of the lambdas in target regions.
>
> -* #pragma omp distribute parallel for [simd]: :good:`Complete`.
> +* Parsing/sema analysis for the requires directive.
>
> -Combined directives
> -===
> +* Nested declare target directives.
>
> -* #pragma omp parallel for simd: :good:`Complete`.
> +* Make the `this` pointer implicitly mapped as `map(this[:1])`.
>
> -* #pragma omp target parallel: :good:`Complete`.
> +* The `close` *map-type-modifier*.
>
> -* #pragma omp target parallel for [simd]: :good:`Complete`.
> -
> -* #pragma omp target simd: :good:`Complete`.
> -
> -* #pragma omp target teams: :good:`Complete`.
> -
> -* #pragma omp teams distribute [simd]: :good:`Complete`.
> -
> -* #pragma omp target teams distribute [simd]: :good:`Complete`.
> -
> -* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
> -
> -* #pragma omp target teams distribute parallel for [simd]: :good:`Complete`.
> +Clang fully supports OpenMP 4.5. Clang supports offloading to X86_64, 
> AArch64,
> +PPC64[LE] and has `basic support for Cuda devices`_.
>
> -Clang does not support any constructs/updates from OpenMP 5.0 except
> -for `reduction`-based clauses in the `task` and `target`-based directives.
> +* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
> +  analysis + generation of special attributes for X86 target, but still
> +  missing the LLVM pass for vectorization.
>
>  In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools
> -Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux,
> Windows, and mac OS.
> +Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux,
> Windows, and macOS.
> +
> +General improvements
> +
> +- New collapse clause scheme to avoid expensive remainder operations.
> +  Compute loop index variables after collapsing a loop nest via the
> +  collapse clause by replacing the expensive remainder operation with
> +  multiplications and additions.
> +
> +- The default schedules for the `distribute` and `for` constructs in a
> +  parallel region and in SPMD mode have changed to ensure coalesced
> +  accesses. For the `distribute` construct, a static schedule is used
> +  with a chunk size equal to the number of threads per team (default
> +  value of threads or as specified by the `thread_limit` clause if
> +  present). For the `for` construct, the schedule is static with chunk
> +  size of one.
> +
> +- Simplified SPMD code generation for `distribute parallel for` when
> +  the new default schedules are

[PATCH] D56723: [CodeComplete] Propagate preferred types through parser in more cases

2019-01-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for the suggestion, this should definitely work! I did struggle to 
figure out a way to do this without annotating every path with `enterUnknown` 
and failed.
I'll try playing around with your idea, my initial plan is to store preferred 
type alongside the current token as a member of the `Parser` class and update 
it when advancing to next token, when the parser backtracks and in the places 
where we care about propagating the types.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56723



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


Re: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-22 Thread Doerfert, Johannes Rudolf via cfe-commits
On 01/22, Chandler Carruth wrote:
> On Sat, Jan 19, 2019 at 2:18 AM Johannes Doerfert via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > Author: jdoerfert
> > Date: Fri Jan 18 21:36:54 2019
> > New Revision: 351629
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=351629&view=rev
> > Log:
> > Emit !callback metadata and introduce the callback attribute
> >
> >   With commit r351627, LLVM gained the ability to apply (existing) IPO
> >   optimizations on indirections through callbacks, or transitive calls.
> >   The general idea is that we use an abstraction to hide the middle man
> >   and represent the callback call in the context of the initial caller.
> >   It is described in more detail in the commit message of the LLVM patch
> >   r351627, the llvm::AbstractCallSite class description, and the
> >   language reference section on callback-metadata.
> >
> >   This commit enables clang to emit !callback metadata that is
> >   understood by LLVM. It does so in three different cases:
> > 1) For known broker functions declarations that are directly
> >generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel.
> > 2) For known broker functions that are identified by their name and
> >source location through the builtin detection, e.g.,
> >pthread_create from the POSIX thread API.
> > 3) For user annotated functions that carry the "callback(callee, ...)"
> >attribute. The attribute has to include the name, or index, of
> >the callback callee and how the passed arguments can be
> >identified (as many as the callback callee has). See the callback
> >attribute documentation for detailed information.
> >
> > Differential Revision: https://reviews.llvm.org/D55483
> >
> > ==
> > --- cfe/trunk/test/CodeGen/callback_pthread_create.c (added)
> > +++ cfe/trunk/test/CodeGen/callback_pthread_create.c Fri Jan 18 21:36:54
> > 2019
> > @@ -0,0 +1,32 @@
> > +// RUN: %clang -O1 %s -S -c -emit-llvm -o - | FileCheck %s
> > +// RUN: %clang -O1 %s -S -c -emit-llvm -o - | opt -ipconstprop -S |
> > FileCheck --check-prefix=IPCP %s
> > +
> > +// CHECK: declare !callback ![[cid:[0-9]+]] dso_local i32 @pthread_create
> > +// CHECK: ![[cid]] = !{![[cidb:[0-9]+]]}
> > +// CHECK: ![[cidb]] = !{i64 2, i64 3, i1 false}
> > +
> > +#include 
> 
> 
> Another thing I notecide is that this code assumes the system has
> `pthread.h` -- what about systems without it? I mean, you can disable the
> test, but it seems bad to lose test coverage just because of that.
 
So far, I disabled the test with a later addition which makes sure this
test is only run under Linux. I'm unsure why we loose coverage because
of that?

> I would much prefer that you provide your own stub `pthread.h` in the
> Inputs/... tree of the test suite and use that to test this in a portable
> way.

I do not completely follow but I'm open to improving the test. Basically
I have to make sure the builtin recognition will trigger on the header
file and the contained declaration. If we can somehow do this in a
portable way I'm all for it. Is that how we test other builtin gnu extensions?

Cheers,
  Johannes


> > +
> > +const int GlobalVar = 0;
> > +
> > +static void *callee0(void *payload) {
> > +// IPCP:  define internal i8* @callee0
> > +// IPCP-NEXT:   entry:
> > +// IPCP-NEXT: ret i8* null
> > +  return payload;
> > +}
> > +
> > +static void *callee1(void *payload) {
> > +// IPCP:  define internal i8* @callee1
> > +// IPCP-NEXT:   entry:
> > +// IPCP-NEXT: ret i8* bitcast (i32* @GlobalVar to i8*)
> > +  return payload;
> > +}
> > +
> > +void foo() {
> > +  pthread_t MyFirstThread;
> > +  pthread_create(&MyFirstThread, NULL, callee0, NULL);
> > +
> > +  pthread_t MySecondThread;
> > +  pthread_create(&MySecondThread, NULL, callee1, (void *)&GlobalVar);
> > +}
> >
> > Added: cfe/trunk/test/CodeGenCXX/attr-callback.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-callback.cpp?rev=351629&view=auto


signature.asc
Description: PGP signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55447: [Sema] Fix Modified Type in address_space AttributedType

2019-01-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

@rsmith Any comments on this patch before submitting?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55447



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


Re: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-22 Thread Doerfert, Johannes Rudolf via cfe-commits
On 01/22, Chandler Carruth wrote:
> On Sat, Jan 19, 2019 at 2:18 AM Johannes Doerfert via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > Author: jdoerfert
> > Date: Fri Jan 18 21:36:54 2019
> > New Revision: 351629
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=351629&view=rev
> > Log:
> > Emit !callback metadata and introduce the callback attribute
> >
> >   With commit r351627, LLVM gained the ability to apply (existing) IPO
> >   optimizations on indirections through callbacks, or transitive calls.
> >   The general idea is that we use an abstraction to hide the middle man
> >   and represent the callback call in the context of the initial caller.
> >   It is described in more detail in the commit message of the LLVM patch
> >   r351627, the llvm::AbstractCallSite class description, and the
> >   language reference section on callback-metadata.
> >
> >   This commit enables clang to emit !callback metadata that is
> >   understood by LLVM. It does so in three different cases:
> > 1) For known broker functions declarations that are directly
> >generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel.
> > 2) For known broker functions that are identified by their name and
> >source location through the builtin detection, e.g.,
> >pthread_create from the POSIX thread API.
> > 3) For user annotated functions that carry the "callback(callee, ...)"
> >attribute. The attribute has to include the name, or index, of
> >the callback callee and how the passed arguments can be
> >identified (as many as the callback callee has). See the callback
> >attribute documentation for detailed information.
> >
> > Differential Revision: https://reviews.llvm.org/D55483
> >
> > Added: cfe/trunk/test/Sema/attr-callback-broken.c
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-callback-broken.c?rev=351629&view=auto
> >
> > ==
> > --- cfe/trunk/test/Sema/attr-callback-broken.c (added)
> > +++ cfe/trunk/test/Sema/attr-callback-broken.c Fri Jan 18 21:36:54 2019
> > @@ -0,0 +1,75 @@
> > +// RUN: %clang_cc1 %s -verify -fsyntax-only
> > +
> > +__attribute__((callback())) void no_callee(void (*callback)(void)); //
> > expected-error {{'callback' attribute specifies no callback callee}}
> > +
> > +__attribute__((callback(1, 1))) void too_many_args_1(void
> > (*callback)(void)) {}  // expected-error {{'callback' attribute takes
> > one argument}}
> > +__attribute__((callback(1, -1))) void too_many_args_2(double
> > (*callback)(void)); // expected-error {{'callback' attribute takes one
> > argument}}
> > +__attribute__((callback(1, 2, 2))) void too_many_args_3(void
> > (*callback)(int), int); // expected-error {{'callback' attribute requires
> > exactly 2 arguments}}
> > +
> > +__attribute__((callback(1, 2))) void too_few_args_1(void (*callback)(int,
> > int), int); // expected-error {{'callback' attribute takes one argument}}
> > +__attribute__((callback(1))) void too_few_args_2(int (*callback)(int));
> >  // expected-error {{'callback' attribute takes no arguments}}
> > +__attribute__((callback(1, -1))) void too_few_args_3(void
> > (*callback)(int, int)) {}   // expected-error {{'callback' attribute takes
> > one argument}}
> > +
> > +__attribute__((callback(-1))) void oob_args_1(void (*callback)(void));
> >  // expected-error {{'callback' attribute specifies invalid callback
> > callee}}
> > +__attribute__((callback(2))) void oob_args_2(int *(*callback)(void)) {}
> >   // expected-error {{'callback' attribute parameter 1 is out of
> > bounds}}
> > +__attribute__((callback(1, 3))) void oob_args_3(short (*callback)(int),
> > int);  // expected-error {{'callback' attribute parameter 2 is out of
> > bounds}}
> > +__attribute__((callback(-2, 2))) void oob_args_4(void *(*callback)(int),
> > int); // expected-error {{'callback' attribute parameter 1 is out of
> > bounds}}
> > +__attribute__((callback(1, -2))) void oob_args_5(void *(*callback)(int),
> > int); // expected-error {{'callback' attribute parameter 2 is out of
> > bounds}}
> > +__attribute__((callback(1, 2))) void oob_args_6(void *(*callback)(int),
> > ...);  // expected-error {{'callback' attribute parameter 2 is out of
> > bounds}}
> > +
> > +__attribute__((callback(1))) __attribute__((callback(1))) void
> > multiple_cb_1(void (*callback)(void));   //
> > expected-error {{multiple 'callback' attributes specified}}
> > +__attribute__((callback(1))) __attribute__((callback(2))) void
> > multiple_cb_2(void (*callback1)(void), void (*callback2)(void)); //
> > expected-error {{multiple 'callback' attributes specified}}
> > +
> > +#ifdef HAS_THIS
> > +__attribute__((callback(0))) void oob_args_0(void (*callback)(void)); //
> > expected-error {{'callback' attribute specifies invalid callback callee}}
> > +#else
> > +__attribute__((callback(0))) v

r351849 - [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl

2019-01-22 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Tue Jan 22 09:59:45 2019
New Revision: 351849

URL: http://llvm.org/viewvc/llvm-project?rev=351849&view=rev
Log:
[ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl

Summary:
Shafik found out that importing a CXXConstructorDecl will create a translation 
unit that
causes Clang's CodeGen to crash. The reason for that is that we don't copy the 
OperatorDelete
from the CXXConstructorDecl when importing. This patch fixes it and adds a test 
case for that.

Reviewers: shafik, martong, a_sidorin, a.sidorin

Reviewed By: martong, a_sidorin

Subscribers: rnkovacs, cfe-commits

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

Added:
cfe/trunk/test/Import/destructor/
cfe/trunk/test/Import/destructor/Inputs/
cfe/trunk/test/Import/destructor/Inputs/F.cpp
cfe/trunk/test/Import/destructor/test.cpp
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=351849&r1=351848&r2=351849&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jan 22 09:59:45 2019
@@ -3091,12 +3091,28 @@ ExpectedDecl ASTNodeImporter::VisitFunct
 FromConstructor->isExplicit(),
 D->isInlineSpecified(), D->isImplicit(), D->isConstexpr()))
   return ToFunction;
-  } else if (isa(D)) {
+  } else if (CXXDestructorDecl *FromDtor = dyn_cast(D)) {
+
+auto Imp =
+importSeq(const_cast(FromDtor->getOperatorDelete()),
+  FromDtor->getOperatorDeleteThisArg());
+
+if (!Imp)
+  return Imp.takeError();
+
+FunctionDecl *ToOperatorDelete;
+Expr *ToThisArg;
+std::tie(ToOperatorDelete, ToThisArg) = *Imp;
+
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
 ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(),
 D->isImplicit()))
   return ToFunction;
+
+CXXDestructorDecl *ToDtor = cast(ToFunction);
+
+ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg);
   } else if (CXXConversionDecl *FromConversion =
  dyn_cast(D)) {
 if (GetImportedOrCreateDecl(

Added: cfe/trunk/test/Import/destructor/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/destructor/Inputs/F.cpp?rev=351849&view=auto
==
--- cfe/trunk/test/Import/destructor/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/destructor/Inputs/F.cpp Tue Jan 22 09:59:45 2019
@@ -0,0 +1,3 @@
+struct B {
+  virtual ~B() {}
+};

Added: cfe/trunk/test/Import/destructor/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/destructor/test.cpp?rev=351849&view=auto
==
--- cfe/trunk/test/Import/destructor/test.cpp (added)
+++ cfe/trunk/test/Import/destructor/test.cpp Tue Jan 22 09:59:45 2019
@@ -0,0 +1,10 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s
+
+// Triggers the deserialization of B's destructor.
+B b1;
+
+// CHECK: CXXDestructorDecl
+
+// CHECK-NEXT: ~B 'void () noexcept' virtual
+// CHECK-SAME: 'void () noexcept'
+// CHECK-SAME: virtual


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


[PATCH] D56651: [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl

2019-01-22 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351849: [ASTImporter] Fix importing OperatorDelete from 
CXXConstructorDecl (authored by teemperor, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D56651

Files:
  lib/AST/ASTImporter.cpp
  test/Import/destructor/Inputs/F.cpp
  test/Import/destructor/test.cpp


Index: test/Import/destructor/Inputs/F.cpp
===
--- test/Import/destructor/Inputs/F.cpp
+++ test/Import/destructor/Inputs/F.cpp
@@ -0,0 +1,3 @@
+struct B {
+  virtual ~B() {}
+};
Index: test/Import/destructor/test.cpp
===
--- test/Import/destructor/test.cpp
+++ test/Import/destructor/test.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s
+
+// Triggers the deserialization of B's destructor.
+B b1;
+
+// CHECK: CXXDestructorDecl
+
+// CHECK-NEXT: ~B 'void () noexcept' virtual
+// CHECK-SAME: 'void () noexcept'
+// CHECK-SAME: virtual
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -3091,12 +3091,28 @@
 FromConstructor->isExplicit(),
 D->isInlineSpecified(), D->isImplicit(), D->isConstexpr()))
   return ToFunction;
-  } else if (isa(D)) {
+  } else if (CXXDestructorDecl *FromDtor = dyn_cast(D)) {
+
+auto Imp =
+importSeq(const_cast(FromDtor->getOperatorDelete()),
+  FromDtor->getOperatorDeleteThisArg());
+
+if (!Imp)
+  return Imp.takeError();
+
+FunctionDecl *ToOperatorDelete;
+Expr *ToThisArg;
+std::tie(ToOperatorDelete, ToThisArg) = *Imp;
+
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
 ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(),
 D->isImplicit()))
   return ToFunction;
+
+CXXDestructorDecl *ToDtor = cast(ToFunction);
+
+ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg);
   } else if (CXXConversionDecl *FromConversion =
  dyn_cast(D)) {
 if (GetImportedOrCreateDecl(


Index: test/Import/destructor/Inputs/F.cpp
===
--- test/Import/destructor/Inputs/F.cpp
+++ test/Import/destructor/Inputs/F.cpp
@@ -0,0 +1,3 @@
+struct B {
+  virtual ~B() {}
+};
Index: test/Import/destructor/test.cpp
===
--- test/Import/destructor/test.cpp
+++ test/Import/destructor/test.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s
+
+// Triggers the deserialization of B's destructor.
+B b1;
+
+// CHECK: CXXDestructorDecl
+
+// CHECK-NEXT: ~B 'void () noexcept' virtual
+// CHECK-SAME: 'void () noexcept'
+// CHECK-SAME: virtual
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -3091,12 +3091,28 @@
 FromConstructor->isExplicit(),
 D->isInlineSpecified(), D->isImplicit(), D->isConstexpr()))
   return ToFunction;
-  } else if (isa(D)) {
+  } else if (CXXDestructorDecl *FromDtor = dyn_cast(D)) {
+
+auto Imp =
+importSeq(const_cast(FromDtor->getOperatorDelete()),
+  FromDtor->getOperatorDeleteThisArg());
+
+if (!Imp)
+  return Imp.takeError();
+
+FunctionDecl *ToOperatorDelete;
+Expr *ToThisArg;
+std::tie(ToOperatorDelete, ToThisArg) = *Imp;
+
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), cast(DC),
 ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(),
 D->isImplicit()))
   return ToFunction;
+
+CXXDestructorDecl *ToDtor = cast(ToFunction);
+
+ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg);
   } else if (CXXConversionDecl *FromConversion =
  dyn_cast(D)) {
 if (GetImportedOrCreateDecl(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57004: [docs] Add release notes for notable things I've contributed since last release

2019-01-22 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added inline comments.
This revision is now accepted and ready to land.



Comment at: docs/ReleaseNotes.rst:190
+- For MinGW, clang now produces vtables and RTTI for dllexported classes
+  without key functions.
+

mstorsjo wrote:
> This comment doesn't really say much for the casual reader, perhaps it should 
> just be left out and regarded as general assorted bugfixes? Although the fix 
> (D55698) is a notable step towards matching GCC better for MinGW, and fixes 
> an actual issue (building Qt in debug mode).
I think keeping it in is fine. If you want you could of course expand with 
mentioning the Qt part of your comment and maybe link to a bug entry if 
applicable.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57004



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


[PATCH] D57004: [docs] Add release notes for notable things I've contributed since last release

2019-01-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: docs/ReleaseNotes.rst:190
+- For MinGW, clang now produces vtables and RTTI for dllexported classes
+  without key functions.
+

hans wrote:
> mstorsjo wrote:
> > This comment doesn't really say much for the casual reader, perhaps it 
> > should just be left out and regarded as general assorted bugfixes? Although 
> > the fix (D55698) is a notable step towards matching GCC better for MinGW, 
> > and fixes an actual issue (building Qt in debug mode).
> I think keeping it in is fine. If you want you could of course expand with 
> mentioning the Qt part of your comment and maybe link to a bug entry if 
> applicable.
I agree, I think the info about Qt is the kind of newsworthy thing users will 
want to know and will understand.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57004



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


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 182942.
dgoldman added a comment.
Herald added a subscriber: jfb.

- FIXME and dyn_cast
- use auto
- Add test


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -437,6 +437,23 @@
   QName("MyProtocol"), QName("MyProtocol::someMethodName3:")));
 }
 
+TEST_F(SymbolCollectorTest, ObjCPropertyImpl) {
+  const std::string Header = R"(
+@interface Container
+@property(nonatomic) int magic;
+@end
+
+@implementation Container
+@end
+  )";
+  TestFileName = testPath("test.m");
+  runSymbolCollector(Header, /*Main=*/"", {"-xobjective-c++"});
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  QName("Container"), QName("Container::magic"),
+  QName("Container::_magic")));
+}
+
 TEST_F(SymbolCollectorTest, Locations) {
   Annotations Header(R"cpp(
 // Declared in header, defined in main.
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -347,19 +347,25 @@
   if (!ID)
 return true;
 
-  const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
+  // FIXME: ObjCPropertyDecl are not properly indexed here:
+  // - ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  auto *OriginalDecl = dyn_cast(ASTNode.OrigD);
+  if (!OriginalDecl)
+return true;
+
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
 BasicSymbol = addDeclaration(*ND, std::move(*ID), IsMainFileOnly);
-  else if (isPreferredDeclaration(OriginalDecl, Roles))
+  else if (isPreferredDeclaration(*OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID), IsMainFileOnly);
+BasicSymbol = addDeclaration(*OriginalDecl, std::move(*ID), 
IsMainFileOnly);
 
   if (Roles & static_cast(index::SymbolRole::Definition))
-addDefinition(OriginalDecl, *BasicSymbol);
+addDefinition(*OriginalDecl, *BasicSymbol);
   return true;
 }
 


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -437,6 +437,23 @@
   QName("MyProtocol"), QName("MyProtocol::someMethodName3:")));
 }
 
+TEST_F(SymbolCollectorTest, ObjCPropertyImpl) {
+  const std::string Header = R"(
+@interface Container
+@property(nonatomic) int magic;
+@end
+
+@implementation Container
+@end
+  )";
+  TestFileName = testPath("test.m");
+  runSymbolCollector(Header, /*Main=*/"", {"-xobjective-c++"});
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  QName("Container"), QName("Container::magic"),
+  QName("Container::_magic")));
+}
+
 TEST_F(SymbolCollectorTest, Locations) {
   Annotations Header(R"cpp(
 // Declared in header, defined in main.
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -347,19 +347,25 @@
   if (!ID)
 return true;
 
-  const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
+  // FIXME: ObjCPropertyDecl are not properly indexed here:
+  // - ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  auto *OriginalDecl = dyn_cast(ASTNode.OrigD);
+  if (!OriginalDecl)
+return true;
+
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
 BasicSymbol = addDeclaration(*ND, std::move(*ID), IsMainFileOnly);
-  else if (isPreferredDeclaration(OriginalDecl, Roles))
+  else if (isPreferredDeclaration(*OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID), IsMainFileOnly);
+BasicSymbol = addDeclaration(*OriginalDecl, std::move(*ID), IsMainFile

[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D56916#1366456 , @ilya-biryukov 
wrote:

> > Unfortunately I can't get ninja check-clangd to build:
>
> Looks like `clang-tools-extra` uses an old revision. Rebasing after rL350916 
>  should do the trick.


Thanks, looks like my update script was skipping over that repo. Test case 
implemented. As I don't have commit access, can you land this for me?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916



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


[PATCH] D56946: [Documentation] Use HTTPS whenever possible in Clang

2019-01-22 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Seems like a good change to me.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56946



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


[PATCH] D55676: [Modules] Fix decl order for DeclsInPrototype

2019-01-22 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping


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

https://reviews.llvm.org/D55676



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


Re: [clang-tools-extra] r351788 - [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.

2019-01-22 Thread Hans Wennborg via cfe-commits
This has been merged to the 8.0 branch in r351860. Please  let me know
if there are any follow-ups so they can be merged too.

Thanks,
Hans

On Tue, Jan 22, 2019 at 1:10 AM Kadir Cetinkaya via cfe-commits
 wrote:
>
> Author: kadircet
> Date: Tue Jan 22 01:10:20 2019
> New Revision: 351788
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351788&view=rev
> Log:
> [clangd] Filter out plugin related flags and move all commandline 
> manipulations into OverlayCDB.
>
> Summary:
> Some projects make use of clang plugins when building, but clangd is
> not aware of those plugins therefore can't work with the same compile command
> arguments.
>
> There were multiple places clangd performed commandline manipulations,
>  this one also moves them all into OverlayCDB.
>
> Reviewers: ilya-biryukov
>
> Subscribers: klimek, sammccall, ioeric, MaskRay, jkorous, arphaman, 
> cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D56841
>
> Modified:
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
> clang-tools-extra/trunk/clangd/index/Background.cpp
> clang-tools-extra/trunk/clangd/index/Background.h
> clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> 
> clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=351788&r1=351787&r2=351788&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jan 22 01:10:20 
> 2019
> @@ -289,7 +289,8 @@ void ClangdLSPServer::onInitialize(const
>if (UseDirBasedCDB)
>  BaseCDB = llvm::make_unique(
>  CompileCommandsDir);
> -  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);
> +  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags,
> +  ClangdServerOpts.ResourceDir);
>Server.emplace(*CDB, FSProvider, static_cast(*this),
>   ClangdServerOpts);
>applyConfiguration(Params.initializationOptions.ConfigSettings);
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=351788&r1=351787&r2=351788&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Jan 22 01:10:20 2019
> @@ -37,11 +37,6 @@ namespace clang {
>  namespace clangd {
>  namespace {
>
> -std::string getStandardResourceDir() {
> -  static int Dummy; // Just an address in this process.
> -  return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
> -}
> -
>  class RefactoringResultCollector final
>  : public tooling::RefactoringResultConsumer {
>  public:
> @@ -107,8 +102,6 @@ ClangdServer::ClangdServer(const GlobalC
> DiagnosticsConsumer &DiagConsumer,
> const Options &Opts)
>  : CDB(CDB), FSProvider(FSProvider),
> -  ResourceDir(Opts.ResourceDir ? *Opts.ResourceDir
> -   : getStandardResourceDir()),
>DynamicIdx(Opts.BuildDynamicSymbolIndex
>   ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
>   : nullptr),
> @@ -136,7 +129,7 @@ ClangdServer::ClangdServer(const GlobalC
>  AddIndex(Opts.StaticIndex);
>if (Opts.BackgroundIndex) {
>  BackgroundIdx = llvm::make_unique(
> -Context::current().clone(), ResourceDir, FSProvider, CDB,
> +Context::current().clone(), FSProvider, CDB,
>  BackgroundIndexStorage::createDiskBackedStorageFactory(),
>  Opts.BackgroundIndexRebuildPeriodMs);
>  AddIndex(BackgroundIdx.get());
> @@ -461,10 +454,6 @@ tooling::CompileCommand ClangdServer::ge
>llvm::Optional C = CDB.getCompileCommand(File);
>if (!C) // FIXME: Suppress diagnostics? Let the user know?
>  C = CDB.getFallbackCommand(File);
> -
> -  // Inject the resource dir.
> -  // FIXME: Don't overwrite it if it's already there.
> -  C->CommandLine.push_back("-resource-dir=" + ResourceDir);
>return std::move(*C);
>  }
>
>
> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=351788&r1=351787&r2=351788&view=diff
> ==
> --- clang-tools-extra/trunk/clangd

[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-01-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 182945.
leonardchan marked 6 inline comments as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D56900

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Frontend/fixed_point_conversions.c
  clang/test/Frontend/fixed_point_errors.c
  clang/test/Frontend/fixed_point_unknown_conversions.c

Index: clang/test/Frontend/fixed_point_unknown_conversions.c
===
--- clang/test/Frontend/fixed_point_unknown_conversions.c
+++ clang/test/Frontend/fixed_point_unknown_conversions.c
@@ -22,28 +22,19 @@
   _Fract fract = accum; // ok
   _Accum *accum_ptr;
 
-  accum = b;   // expected-error{{conversion between fixed point and '_Bool' is not yet supported}}
-  accum = i;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
-  accum = i;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
   accum = f;   // expected-error{{conversion between fixed point and 'float' is not yet supported}}
   accum = d;   // expected-error{{conversion between fixed point and 'double' is not yet supported}}
   accum = dc;  // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}}
   accum = ic;  // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}}
   accum = s;   // expected-error{{assigning to '_Accum' from incompatible type 'struct S'}}
-  accum = e;   // expected-error{{conversion between fixed point and 'enum E' is not yet supported}}
   accum = ptr; // expected-error{{assigning to '_Accum' from incompatible type 'int *'}}
   accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}}
-  accum = i2;  // expected-error{{conversion between fixed point and 'int_t' (aka 'int') is not yet supported}}
 
-  c = accum;   // expected-error{{conversion between fixed point and 'char' is not yet supported}}
-  i = accum;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
   f = accum;   // expected-error{{conversion between fixed point and 'float' is not yet supported}}
   d = accum;   // expected-error{{conversion between fixed point and 'double' is not yet supported}}
   dc = accum;  // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}}
   ic = accum;  // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}}
   s = accum;   // expected-error{{assigning to 'struct S' from incompatible type '_Accum'}}
-  e = accum;   // expected-error{{conversion between fixed point and 'enum E' is not yet supported}}
   ptr = accum; // expected-error{{assigning to 'int *' from incompatible type '_Accum'}}
   ptr = accum_ptr; // expected-warning{{incompatible pointer types assigning to 'int *' from '_Accum *'}}
-  i2 = accum;  // expected-error{{conversion between fixed point and 'int' is not yet supported}}
 }
Index: clang/test/Frontend/fixed_point_errors.c
===
--- clang/test/Frontend/fixed_point_errors.c
+++ clang/test/Frontend/fixed_point_errors.c
@@ -233,8 +233,20 @@
  // expected-warning@-1{{type specifier missing, defaults to 'int'}}
 }
 
+// Ok conversions
+int i_const = -2.5hk;
+_Sat short _Accum sat_sa_const2 = 256.0k;
+_Sat unsigned short _Accum sat_usa_const = -1.0hk;
+short _Accum sa_const3 = 2;
+short _Accum sa_const4 = -2;
+
 // Overflow
 short _Accum sa_const = 256.0k;   // expected-warning{{implicit conversion from 256.0 cannot fit within the range of values for 'short _Accum'}}
 short _Fract sf_const = 1.0hk;// expected-warning{{implicit conversion from 1.0 cannot fit within the range of values for 'short _Fract'}}
 unsigned _Accum ua_const = -1.0k; // expected-warning{{implicit conversion from -1.0 cannot fit within the range of values for 'unsigned _Accum'}}
 short _Accum sa_const2 = 128.0k + 128.0k; // expected-warning{{implicit conversion from 256.0 cannot fit within the range of values for 'short _Accum'}}
+short s_const = 65536.0lk;// expected-warning{{implicit conversion from 65536.0 cannot fit within the range of values for 'short'}}
+unsigned u_const = -2.5hk;// expected-warning{{implicit conversion f

[clang-tools-extra] r351862 - [Documentation] Use HTTPS whenever possible.

2019-01-22 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Jan 22 11:19:48 2019
New Revision: 351862

URL: http://llvm.org/viewvc/llvm-project?rev=351862&view=rev
Log:
[Documentation] Use HTTPS whenever possible.

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

Modified:
clang-tools-extra/trunk/docs/clang-doc.rst
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/docs/clang-tidy.rst
clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/portability-simd-intrinsics.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-magic-numbers.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/docs/clangd.rst
clang-tools-extra/trunk/docs/include-fixer.rst
clang-tools-extra/trunk/docs/modularize.rst
clang-tools-extra/trunk/docs/pp-trace.rst

Modified: clang-tools-extra/trunk/docs/clang-doc.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-doc.rst?rev=351862&r1=351861&r2=351862&view=diff
==
--- clang-tools-extra/trunk/docs/clang-doc.rst (original)
+++ clang-tools-extra/trunk/docs/clang-doc.rst Tue Jan 22 11:19:48 2019
@@ -20,10 +20,10 @@ Use
 =
 
 :program:`clang-doc` is a `LibTooling
-`_-based tool, and so requires a
+`_-based tool, and so requires a
 compile command database for your project (for an example of how to do this 
 see `How To Setup Tooling For LLVM
-`_).
+`_).
 
 The tool can be used on a single file or multiple files as defined in 
 the compile commands database:

Modified: clang-tools-extra/trunk/docs/clang-rename.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=351862&r1=351861&r2=351862&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Tue Jan 22 11:19:48 2019
@@ -24,10 +24,10 @@ Using Clang-Rename
 ==
 
 :program:`clang-rename` is a `LibTooling
-`_-based tool, and it's easier to
+`_-based tool, and it's easier to
 work with if you set up a compile command database for your project (for an
 example of how to do this see `How To Setup Tooling For LLVM
-`_). You can also
+`_). You can also
 specify compilation options on the command line after `--`:
 
 .. code-block:: console
@@ -140,7 +140,7 @@ Vim Integration
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
 `clang-rename/tool/clang-rename.py
-`_.
+`_.
 
 Please note that **you have to save all buffers, in which the replacement will
 happen before running the tool**.
@@ -157,7 +157,7 @@ Emacs Integration
 You can also use :program:`clang-rename` while using Emacs! To set up
 :program:`clang-rename` integration for Emacs see
 `clang-rename/tool/clang-rename.el
-`_.
+`_.
 
 Once installed, you can point your cursor to symbols you want to rename, press
 `M-X`, type `clang-rename` and new desired name.

Modified: clang-tools-extra/trunk/docs/clang-tidy.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy.rst?rev=351862&r1=351861&r2=351862&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy.rst Tue Jan 22 11:19:48 2019
@@ -3,4 +3,4 @@
 .. meta::
:http-equiv=refresh: 0;URL='clang-tidy/'
 
-clang-

[PATCH] D56926: [Documentation] Use HTTPS whenever possible in clang-tools-extra

2019-01-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE351862: [Documentation] Use HTTPS whenever possible. 
(authored by eugenezelenko, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56926?vs=182590&id=182947#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56926

Files:
  docs/clang-doc.rst
  docs/clang-rename.rst
  docs/clang-tidy.rst
  docs/clang-tidy/Integrations.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
  docs/clang-tidy/checks/llvm-include-order.rst
  docs/clang-tidy/checks/llvm-namespace-comment.rst
  docs/clang-tidy/checks/modernize-pass-by-value.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  docs/clang-tidy/checks/portability-simd-intrinsics.rst
  docs/clang-tidy/checks/readability-else-after-return.rst
  docs/clang-tidy/checks/readability-magic-numbers.rst
  docs/clang-tidy/index.rst
  docs/clangd.rst
  docs/include-fixer.rst
  docs/modularize.rst
  docs/pp-trace.rst

Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -32,7 +32,7 @@
 ``compile_commands.json`` as generated by CMake does not include header files,
 so only implementation files can be handled by tools.
 
-.. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
+.. _How To Setup Tooling For LLVM: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
 Creating a Symbol Index From a Compilation Database
 ---
Index: docs/clang-tidy.rst
===
--- docs/clang-tidy.rst
+++ docs/clang-tidy.rst
@@ -3,4 +3,4 @@
 .. meta::
:http-equiv=refresh: 0;URL='clang-tidy/'
 
-clang-tidy documentation has moved here: http://clang.llvm.org/extra/clang-tidy/
+clang-tidy documentation has moved here: https://clang.llvm.org/extra/clang-tidy/
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -24,10 +24,10 @@
 ==
 
 :program:`clang-rename` is a `LibTooling
-`_-based tool, and it's easier to
+`_-based tool, and it's easier to
 work with if you set up a compile command database for your project (for an
 example of how to do this see `How To Setup Tooling For LLVM
-`_). You can also
+`_). You can also
 specify compilation options on the command line after `--`:
 
 .. code-block:: console
@@ -140,7 +140,7 @@
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
 `clang-rename/tool/clang-rename.py
-`_.
+`_.
 
 Please note that **you have to save all buffers, in which the replacement will
 happen before running the tool**.
@@ -157,7 +157,7 @@
 You can also use :program:`clang-rename` while using Emacs! To set up
 :program:`clang-rename` integration for Emacs see
 `clang-rename/tool/clang-rename.el
-`_.
+`_.
 
 Once installed, you can point your cursor to symbols you want to rename, press
 `M-X`, type `clang-rename` and new desired name.
Index: docs/clangd.rst
===
--- docs/clangd.rst
+++ docs/clangd.rst
@@ -31,7 +31,7 @@
 ==
 
 Packages are available for debian-based distributions, see the `LLVM packages
-page `_. :program:`Clangd` is included in the
+page `_. :program:`Clangd` is included in the
 `clang-tools` package.
 However, it is a good idea to check your distribution's packaging system first
 as it might already be available.
@@ -147,14 +147,14 @@
 ==
 
 A good place for interested contributors is the `Clangd developer mailing list
-`_. For discussions with the
+`_. For discussions with the
 broader community on topics not only related to Clangd, use
 `Clang developer mailing list
-`_.
+`_.
 If you're also interested in contributing patches

[PATCH] D55400: [analyzer] Move out tracking retain count for OSObjects into a separate checker

2019-01-22 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> Deal with the consequences of this, and just correct all plist files to now 
> refer to the new base checker.

What does it mean?

> Each time a report is emitted from these checkers, create a ProgramPointTag, 
> and "manually" make sure the emitted checker name doesn't change.

I'm not sure what do you propose exactly, but sounds pretty bad.

> Rename osx.cocoa.RetainCount to something else. This one is clearly 
> nonsensical, but let's put it here for the sake of completeness.

I don't think we can rename the old checker, as older Xcode versions have 
"osx.cocoa.RetainCount" hardcoded in them.

TBH I'm not really sold on the way we "bundle" multiple checkers (from the 
tablegen) into a single class.
For one, that means options don't work at all, and essentially the checker name 
is defined by the class which was registered by the tablegen first (which 
should not even be visible, and should be an internal implementation detail).
Do you have better proposals on how, conceptually, grouped checkers should be 
organized?

Essentially, we have a single checker class with two checks, which should be 
toggle-able orthogonally from each other.
For legacy reasons, we can't quite get rid of `osx.cocoa.RetainCount` (but even 
if we could, what then?)


Repository:
  rC Clang

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

https://reviews.llvm.org/D55400



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


[PATCH] D55676: [Modules] Fix decl order for DeclsInPrototype

2019-01-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseDecl.cpp:6237
+llvm::sort(SortedDecls, [](const Decl *L, const Decl *R) {
+  return L->getID() < R->getID();
+});

I would prefer that we use `getID` only for debug dumping purposes. Can we 
change `Scope::DeclsInContext` to be a `SetVector` instead? (How much does that 
cost us memory-wise?)


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

https://reviews.llvm.org/D55676



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I'll just add that we've been trying to not put things behind OpenCL guards as 
much as possible.  Most of the remaining OpenCL checks are for OpenCL-specific 
logic like inferring the default address space, and yeah, we could probably 
make that a target option or something.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55850



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


r351864 - [analyzer] Model another special-case kind of cast for OSObject RetainCountChecker

2019-01-22 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jan 22 11:50:47 2019
New Revision: 351864

URL: http://llvm.org/viewvc/llvm-project?rev=351864&view=rev
Log:
[analyzer] Model another special-case kind of cast for OSObject 
RetainCountChecker

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/os_object_base.h
cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=351864&r1=351863&r2=351864&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Tue Jan 
22 11:50:47 2019
@@ -677,6 +677,9 @@ public:
 // Function returns the first argument.
 Identity,
 
+// Function returns "this" argument.
+IdentityThis,
+
 // Function either returns zero, or the input parameter.
 IdentityOrZero
   };

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=351864&r1=351863&r2=351864&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Tue Jan 22 11:50:47 2019
@@ -849,7 +849,6 @@ void RetainCountChecker::processNonLeakE
 
//===--===//
 
 bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const 
{
-  // Get the callee. We're only interested in simple C functions.
   ProgramStateRef state = C.getState();
   const FunctionDecl *FD = C.getCalleeDecl(CE);
   if (!FD)
@@ -874,18 +873,27 @@ bool RetainCountChecker::evalCall(const
 
   // Bind the return value.
   if (BSmr == BehaviorSummary::Identity ||
-  BSmr == BehaviorSummary::IdentityOrZero) {
-SVal RetVal = state->getSVal(CE->getArg(0), LCtx);
+  BSmr == BehaviorSummary::IdentityOrZero ||
+  BSmr == BehaviorSummary::IdentityThis) {
+
+const Expr *BindReturnTo =
+(BSmr == BehaviorSummary::IdentityThis)
+? cast(CE)->getImplicitObjectArgument()
+: CE->getArg(0);
+SVal RetVal = state->getSVal(BindReturnTo, LCtx);
 
 // If the receiver is unknown or the function has
 // 'rc_ownership_trusted_implementation' annotate attribute, conjure a
 // return value.
+// FIXME: this branch is very strange.
 if (RetVal.isUnknown() ||
 (hasTrustedImplementationAnnotation && !ResultTy.isNull())) {
   SValBuilder &SVB = C.getSValBuilder();
   RetVal =
   SVB.conjureSymbolVal(nullptr, CE, LCtx, ResultTy, C.blockCount());
 }
+
+// Bind the value.
 state = state->BindExpr(CE, LCtx, RetVal, /*Invalidate=*/false);
 
 if (BSmr == BehaviorSummary::IdentityOrZero) {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=351864&r1=351863&r2=351864&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Tue Jan 22 
11:50:47 2019
@@ -152,6 +152,10 @@ static bool isOSObjectDynamicCast(String
   return S == "safeMetaCast";
 }
 
+static bool isOSObjectThisCast(StringRef S) {
+  return S == "metaCast";
+}
+
 static bool isOSIteratorSubclass(const Decl *D) {
   return isSubclass(D, "OSIterator");
 }
@@ -219,13 +223,13 @@ RetainSummaryManager::getSummaryForOSObj
 const CXXRecordDecl *PD = RetTy->getPointeeType()->getAsCXXRecordDecl();
 if (PD && isOSObjectSubclass(PD)) {
   if (const IdentifierInfo *II = FD->getIdentifier()) {
-if (isOSObjectDynamicCast(II->getName()))
+StringRef FuncName = II->getName();
+if (isOSObjectDynamicCast(FuncName) || isOSObjectThisCast(FuncName))
   return getDefaultSummary();
 
 // All objects returned with functions *not* starting with
 // get, or iterators, are returned at +1.
-if ((!II->getName().startswith("get") &&
- !II->getName().startswith("Get")) ||
+if ((!FuncName.startswith("get") && !FuncName.startswith("Get")) ||
 isOSIteratorSubclass(PD)) {
   return getOSSummaryCreate

r351865 - [analyzer] Insert notes in RetainCountChecker where our dynamic cast modeling assumes 'null' output

2019-01-22 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jan 22 11:51:00 2019
New Revision: 351865

URL: http://llvm.org/viewvc/llvm-project?rev=351865&view=rev
Log:
[analyzer] Insert notes in RetainCountChecker where our dynamic cast modeling 
assumes 'null' output

rdar://47397214

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=351865&r1=351864&r2=351865&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Tue Jan 22 11:51:00 2019
@@ -575,7 +575,6 @@ void RetainCountChecker::checkSummary(co
 
   // Helper tag for providing diagnostics: indicate whether dealloc was sent
   // at this location.
-  static CheckerProgramPointTag DeallocSentTag(this, DeallocTagDescription);
   bool DeallocSent = false;
 
   for (unsigned idx = 0, e = CallOrMsg.getNumArgs(); idx != e; ++idx) {
@@ -903,8 +902,7 @@ bool RetainCountChecker::evalCall(const
   // Assume that output is zero on the other branch.
   NullOutputState = NullOutputState->BindExpr(
   CE, LCtx, C.getSValBuilder().makeNull(), /*Invalidate=*/false);
-
-  C.addTransition(NullOutputState);
+  C.addTransition(NullOutputState, &CastFailTag);
 
   // And on the original branch assume that both input and
   // output are non-zero.

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h?rev=351865&r1=351864&r2=351865&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
Tue Jan 22 11:51:00 2019
@@ -260,9 +260,11 @@ class RetainCountChecker
   RefCountBug leakWithinFunction{this, RefCountBug::LeakWithinFunction};
   RefCountBug leakAtReturn{this, RefCountBug::LeakAtReturn};
 
+  CheckerProgramPointTag DeallocSentTag{this, "DeallocSent"};
+  CheckerProgramPointTag CastFailTag{this, "DynamicCastFail"};
+
   mutable std::unique_ptr Summaries;
 public:
-  static constexpr const char *DeallocTagDescription = "DeallocSent";
 
   /// Track Objective-C and CoreFoundation objects.
   bool TrackObjCAndCFObjects = false;
@@ -361,6 +363,14 @@ public:
  CheckerContext &Ctx,
  ExplodedNode *Pred = nullptr) const;
 
+  const CheckerProgramPointTag &getDeallocSentTag() const {
+return DeallocSentTag;
+  }
+
+  const CheckerProgramPointTag &getCastFailTag() const {
+return CastFailTag;
+  }
+
 private:
   /// Perform the necessary checks and state adjustments at the end of the
   /// function.

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp?rev=351865&r1=351864&r2=351865&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 (original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 Tue Jan 22 11:51:00 2019
@@ -66,7 +66,7 @@ StringRef RefCountBug::getDescription()
 RefCountBug::RefCountBug(const CheckerBase *Checker, RefCountBugType BT)
 : BugType(Checker, bugTypeToName(BT), categories::MemoryRefCount,
   /*SupressOnSink=*/BT == LeakWithinFunction || BT == 
LeakAtReturn),
-  BT(BT) {}
+  BT(BT), Checker(Checker) {}
 
 static bool isNumericLiteralExpression(const Expr *E) {
   // FIXME: This set of cases was copied from SemaExprObjC.
@@ -423,6 +423,8 @@ RefCountReportVisitor::VisitNode(const E
   BugReporterContext &BRC, BugReport &BR) {
 
   const auto &BT = static_cast(BR.getBugType());
+  const auto *Checker =
+  static_cast(BT.getChecker());
 
   bool IsFreeUnowned = BT.getBugType() == RefCountBug::FreeNotOwned ||
BT.getBugType() == RefCountBug::DeallocNotOwned;
@@ -509,8 +511,12 @@ RefCountRepo

[PATCH] D57062: [analyzer] Re-enable the "System is over constrained" assertion on optimized builds.

2019-01-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, george.karpenkov, 
rnkovacs, mikhail.ramalho, Szelethus, baloghadamsoftware.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.

This assertion was only enabled in Debug+Asserts, not on Release+Asserts, 
because it's expensive. Indeed, enabling it on Release+Asserts builds seems to 
cause varied slowdown, up to roughly ~5%. However, i think it's worth it, 
because this assertion is very important because it's very fundamental: when it 
crashes, it means that we've investigated a path that was already //obviously// 
infeasible, i.e. we could have refuted the path much earlier if we simply 
looked closer at it with existing solvers.
So, because, testing on large codebases is pretty much always done in 
Release+Asserts mode, it kinda scares me that we're missing out on such an 
important test while doing our ultimate real-world testing.

The slowdown is at most a constant factor - like, it roughly doubles the cost 
of every assume() operation, so it won't cause more than 2x slowdown, and in 
practice assume() isn't showing up in our profiles too much, so the ~5% number 
is relatively reliable.
Of course, the behavior of Clang we actually release (i.e., built without 
asserts) isn't really affected.


Repository:
  rC Clang

https://reviews.llvm.org/D57062

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h


Index: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -94,13 +94,7 @@
 // If StTrue is infeasible, asserting the falseness of Cond is unnecessary
 // because the existing constraints already establish this.
 if (!StTrue) {
-#ifndef __OPTIMIZE__
-  // This check is expensive and should be disabled even in Release+Asserts
-  // builds.
-  // FIXME: __OPTIMIZE__ is a GNU extension that Clang implements but MSVC
-  // does not. Is there a good equivalent there?
   assert(assume(State, Cond, false) && "System is over constrained.");
-#endif
   return ProgramStatePair((ProgramStateRef)nullptr, State);
 }
 


Index: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -94,13 +94,7 @@
 // If StTrue is infeasible, asserting the falseness of Cond is unnecessary
 // because the existing constraints already establish this.
 if (!StTrue) {
-#ifndef __OPTIMIZE__
-  // This check is expensive and should be disabled even in Release+Asserts
-  // builds.
-  // FIXME: __OPTIMIZE__ is a GNU extension that Clang implements but MSVC
-  // does not. Is there a good equivalent there?
   assert(assume(State, Cond, false) && "System is over constrained.");
-#endif
   return ProgramStatePair((ProgramStateRef)nullptr, State);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56935: [NewPM] Add support for new-PM plugins to clang

2019-01-22 Thread Philip Pfaffe via Phabricator via cfe-commits
philip.pfaffe added a comment.

This generally looks sane. What will happen on windows though? Will it silently 
fail?




Comment at: clang/include/clang/Basic/CodeGenOptions.h:292
+  /// List of dynamic shared object files to be loaded as pass plugins.
+  std::vector PassPlugins;
+

This  should be SmallVector.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56935



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


[clang-tools-extra] r351867 - [doc] Replace 'class' with 'struct' for 'public' by default

2019-01-22 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Tue Jan 22 12:27:02 2019
New Revision: 351867

URL: http://llvm.org/viewvc/llvm-project?rev=351867&view=rev
Log:
[doc] Replace 'class' with 'struct' for 'public' by default

Make sample syntax correct.


Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst?rev=351867&r1=351866&r2=351867&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst 
Tue Jan 22 12:27:02 2019
@@ -8,15 +8,15 @@ to overridden parent's virtual methods.
 
 .. code-block:: c++
 
-  class A {
+  struct A {
 int virtual foo() {...}
   };
 
-  class B: public A {
+  struct B: public A {
 int foo() override {...}
   };
 
-  class C: public B {
+  struct C: public B {
 int foo() override { A::foo(); }
   // 
   // warning: qualified name A::foo refers to a member overridden in subclass; 
did you mean 'B'?  [bugprone-parent-virtual-call]


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


[PATCH] D57004: [docs] Add release notes for notable things I've contributed since last release

2019-01-22 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351872: [docs] Add release notes for notable things 
I've contributed since last release (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57004?vs=182754&id=182961#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57004

Files:
  cfe/branches/release_80/docs/ReleaseNotes.rst


Index: cfe/branches/release_80/docs/ReleaseNotes.rst
===
--- cfe/branches/release_80/docs/ReleaseNotes.rst
+++ cfe/branches/release_80/docs/ReleaseNotes.rst
@@ -136,6 +136,9 @@
   instrumenting for gcov-based profiling.
   See the :doc:`UsersManual` for details.
 
+- When using a custom stack alignment, the ``stackrealign`` attribute is now
+  implicitly set on the main function.
+
 - ...
 
 Deprecated Compiler Flags
@@ -179,6 +182,15 @@
   `dllexport` and `dllimport` attributes not apply to inline member functions.
   This can significantly reduce compile and link times. See the `User's Manual
   `_ for more info.
+
+- For MinGW, ``-municode`` now correctly defines ``UNICODE`` during
+  preprocessing.
+
+- For MinGW, clang now produces vtables and RTTI for dllexported classes
+  without key functions. This fixes building Qt in debug mode.
+
+- Allow using Address Sanitizer and Undefined Behaviour Sanitizer on MinGW.
+
 - ...
 
 


Index: cfe/branches/release_80/docs/ReleaseNotes.rst
===
--- cfe/branches/release_80/docs/ReleaseNotes.rst
+++ cfe/branches/release_80/docs/ReleaseNotes.rst
@@ -136,6 +136,9 @@
   instrumenting for gcov-based profiling.
   See the :doc:`UsersManual` for details.
 
+- When using a custom stack alignment, the ``stackrealign`` attribute is now
+  implicitly set on the main function.
+
 - ...
 
 Deprecated Compiler Flags
@@ -179,6 +182,15 @@
   `dllexport` and `dllimport` attributes not apply to inline member functions.
   This can significantly reduce compile and link times. See the `User's Manual
   `_ for more info.
+
+- For MinGW, ``-municode`` now correctly defines ``UNICODE`` during
+  preprocessing.
+
+- For MinGW, clang now produces vtables and RTTI for dllexported classes
+  without key functions. This fixes building Qt in debug mode.
+
+- Allow using Address Sanitizer and Undefined Behaviour Sanitizer on MinGW.
+
 - ...
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >