[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-10-15 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 169783.
takuto.ikuta added a comment.

Remove unnecessary attr creation


https://reviews.llvm.org/D51340

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/CLCompatOptions.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp

Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -fno-dllexport-inlines -emit-llvm -O0 -o - |\
+// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=NOINLINE %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -emit-llvm -O0 -o - |   \
+// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=INLINE %s
+
+// Function
+
+// DEFAULT-DAG: define dso_local dllexport void @"?NormalFunction@@YAXXZ"()
+void __declspec(dllexport) NormalFunction() {}
+
+
+// DEFAULT-DAG: define weak_odr dso_local dllexport void @"?AlwaysInlineFunction@@YAXXZ"
+__forceinline void __declspec(dllexport) AlwaysInlineFunction() {}
+
+// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableExported@@YAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+__forceinline int __declspec(dllexport) AlwaysInlineWithStaticVariableExported() {
+  static int static_variable = 0;
+  ++static_variable;
+  return static_variable;
+}
+
+// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableImported@@YAHXZ@4HA" = available_externally dllimport global i32 0, align 4
+__forceinline int __declspec(dllimport) AlwaysInlineWithStaticVariableImported() {
+  static int static_variable = 0;
+  ++static_variable;
+  return static_variable;
+}
+
+int ImportedFunctionUser() {
+  return AlwaysInlineWithStaticVariableImported();
+}
+
+// Class member function
+
+// check for local static variables
+// NOINLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+
+// INLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+
+// NOINLINE-DAG: @"?static_variable@?1??InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4
+
+class __declspec(dllexport) NoTemplateExportedClass {
+ public:
+  // DEFAULT-NOT: NoTemplateExportedClass@NoTemplateExportedClass@@
+  NoTemplateExportedClass() = default;
+
+  // NOINLINE-NOT: InclassDefFunc@NoTemplateExportedClass
+  // INLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@NoTemplateExportedClass@@
+  void InclassDefFunc() {}
+
+  int f();
+
+  // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ"
+  int InclassDefFuncWithStaticVariable() {
+static int static_variable = 0;
+++static_variable;
+return static_variable;
+  }
+
+  // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@NoTemplateExportedClass@@QEAAHXZ"
+  int InclassDefFunctWithLambdaStaticVariable() {
+return ([]() { static int static_x; return ++static_x; })();
+  }
+
+  // DEFAULT-NOT: InlineOutclassDefFuncWihtoutDefinition
+  __forceinline void InlineOutclassDefFuncWihtoutDefinition();
+
+  // DEFAULT-NOT: InlineOutclassDefFunc@NoTemplateExportedClass@@
+  __forceinline void InlineOutclassDefFunc();
+
+  // DEFAULT-NOT: InlineOutclassDefFuncWithStaticVariable@NoTemplateExportedClass@@
+  __forceinline int InlineOutclassDefFuncWithStaticVariable();
+
+  // DEFAULT-DAG: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@QEAAXXZ"
+  void OutclassDefFunc();
+};
+
+void NoTemplateExportedClass::OutclassDefFunc() {}
+
+__forceinline void NoTemplateExportedClass::InlineOutclassDefFunc() {}
+
+__forceinline int NoTemplateExportedClass::InlineOutclassDefFuncWithStaticVariable() {
+  static int static_variable = 0;
+  return ++static_variable;
+}
+
+void __declspec(dllexport) NoTemplateExportedClassUser() {
+  NoTemplateExportedClass a;
+  a.InlineOutclassDefFunc();
+}
+
+template
+class __declspec(dllexport) TemplateExportedClass {
+  void InclassDefFunc() {}
+  void OutclassDefFunc();
+
+  T templateValue;
+};
+
+// DEFAULT-NOT: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@
+template void TemplateExportedClass::OutclassDefFunc() {}
+

r344583 - [mips] Group similar commands in the test case. NFC

2018-10-15 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Mon Oct 15 22:18:36 2018
New Revision: 344583

URL: http://llvm.org/viewvc/llvm-project?rev=344583=rev
Log:
[mips] Group similar commands in the test case. NFC

Modified:
cfe/trunk/test/CodeGen/target-data.c

Modified: cfe/trunk/test/CodeGen/target-data.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-data.c?rev=344583=344582=344583=diff
==
--- cfe/trunk/test/CodeGen/target-data.c (original)
+++ cfe/trunk/test/CodeGen/target-data.c Mon Oct 15 22:18:36 2018
@@ -40,31 +40,27 @@
 
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
-// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
-
 // RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
-// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
-
 // RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = 
"e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
-// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
-
 // RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 
\
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
-// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
-
 // RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+// MIPS-64EB-N32: target datalayout = 
"E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3


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


[PATCH] D50850: clang: Add triples support for MIPS r6

2018-10-15 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

Could you please rebase this patch against the trunk?




Comment at: lib/Driver/ToolChains/Linux.cpp:717
+  const StringRef MIPS64R6ELMultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa64r6el-linux-gnu",
+  "/usr/include/mipsisa64r6el-linux-gnuabi64"};

If we drop `mipsisa64r6-linux-gnu`, `mipsisa64r6el-linux-gnu` triples in the 
`getMultiarchTriple` function, why do we need these triple here?


https://reviews.llvm.org/D50850



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


[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options

2018-10-15 Thread Thiago Macieira via Phabricator via cfe-commits
thiagomacieira updated this revision to Diff 169779.
thiagomacieira added a comment.

Update detection: as of Clear Linux 25620, /usr/lib/os-relaese contains 
ID_LIKE=clear-linux-os, which allows detecting not only Clear itself, but also 
Linux distributions derived from it (Clear Linux mixes).


https://reviews.llvm.org/D53125

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains/Linux.cpp
  unittests/Driver/DistroTest.cpp

Index: unittests/Driver/DistroTest.cpp
===
--- unittests/Driver/DistroTest.cpp
+++ unittests/Driver/DistroTest.cpp
@@ -302,4 +302,28 @@
   ASSERT_FALSE(ArchLinux.IsDebian());
 }
 
+TEST(DistroTest, DetectClearLinux) {
+  vfs::InMemoryFileSystem ClearLinuxFileSystem;
+  ClearLinuxFileSystem.addFile("/usr/lib/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Clear Linux OS\"\n"
+   "VERSION=1\n"
+   "ID=clear-linux-os\n"
+   "ID_LIKE=clear-linux-os\n"
+   "VERSION_ID=25530\n"
+   "PRETTY_NAME=\"Clear Linux OS\"\n"
+   "ANSI_COLOR=\"1;35\"\n"
+   "HOME_URL=\"https://clearlinux.org\"\n;
+   "SUPPORT_URL=\"https://clearlinux.org\"\n;
+   "BUG_REPORT_URL=\"mailto:d...@lists.clearlinux.org\"\n"
+   "PRIVACY_POLICY_URL=\"http://www.intel.com/privacy\"\n;));
+
+  Distro ClearLinux{ClearLinuxFileSystem};
+  ASSERT_EQ(Distro(Distro::ClearLinux), ClearLinux);
+  ASSERT_TRUE(ClearLinux.IsClearLinux());
+  ASSERT_FALSE(ClearLinux.IsUbuntu());
+  ASSERT_FALSE(ClearLinux.IsRedhat());
+  ASSERT_FALSE(ClearLinux.IsOpenSUSE());
+  ASSERT_FALSE(ClearLinux.IsDebian());
+}
+
 } // end anonymous namespace
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -229,17 +229,20 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
+  if (Distro.IsAlpineLinux() || Distro.IsClearLinux() || Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("now");
   }
 
   if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
-  Triple.isAndroid()) {
+  Distro.IsClearLinux() || Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
 
+  if (Distro.IsClearLinux())
+ExtraOpts.push_back("--copy-dt-needed-entries");
+
   if (GCCInstallation.getParentLibPath().find("opt/rh/devtoolset") !=
   StringRef::npos)
 // With devtoolset on RHEL, we want to add a bin directory that is relative
@@ -287,7 +290,7 @@
   ExtraOpts.push_back("--build-id");
 #endif
 
-  if (IsAndroid || Distro.IsOpenSUSE())
+  if (IsAndroid || Distro.IsOpenSUSE() || Distro.IsClearLinux())
 ExtraOpts.push_back("--enable-new-dtags");
 
   // The selection of paths to try here is designed to match the patterns which
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -137,6 +137,21 @@
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
+  File = VFS.getBufferForFile("/etc/os-release");
+  if (!File)
+File = VFS.getBufferForFile("/usr/lib/os-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+Distro::DistroType Version = Distro::UnknownDistro;
+for (StringRef Line : Lines)
+  if (Version == Distro::UnknownDistro && Line.startswith("ID_LIKE="))
+Version = llvm::StringSwitch(Line.substr(7))
+  .Case("clear-linux-os", Distro::ClearLinux);
+return Version;
+  }
+
   return Distro::UnknownDistro;
 }
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -28,6 +28,7 @@
 // the first and last known member in the family, e.g. IsRedHat().
 AlpineLinux,
 ArchLinux,
+ClearLinux,
 DebianLenny,
 DebianSqueeze,
 DebianWheezy,
@@ -122,6 +123,10 @@
 return DistroVal == AlpineLinux;
   }
 
+  bool IsClearLinux() const {
+return DistroVal == ClearLinux;
+  }
+
   /// @}
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Re-applied https://reviews.llvm.org/rL344546 as 
https://reviews.llvm.org/rL344582.


https://reviews.llvm.org/D51762



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


[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Also i should not have reverted r344546, it was completely unrelated >_<


https://reviews.llvm.org/D51762



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


[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Well, i guess something went wrong, because the job behind the link is in fact 
the first job on this buildbot that included r344535.


https://reviews.llvm.org/D51762



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


[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D51762#1266086, @NoQ wrote:

> Had to revert. Sorry! https://reviews.llvm.org/rL344580.
>
> This failure was masked by another error, so i guess it was missed.


This was supposed to be fixed by commit r344535.


https://reviews.llvm.org/D51762



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


[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Had to revert. Sorry! https://reviews.llvm.org/rL344580.

This failure was masked by another error, so i guess it was missed.


https://reviews.llvm.org/D51762



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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D45639#1243010, @ldionne wrote:

> Sorry, my comment was wrong. You're right, using new libc++ headers and 
> linking against an old `libc++.dylib` is a supported use case, and in fact 
> this is exactly what happens whenever you use new libc++ headers and link 
> against the system-provided `libc++.dylib` on macOS. However, what is _not_ 
> supported is linking against a new `libc++.dylib` and then trying to run 
> using the system's `libc++.dylib`, which may be older.
>
> If you add `-L/../lib`, will you start linking against the 
> Clang-provided `libc++.dylib`? If so, and if you run the resulting 
> application without setting the `DYLD_LIBRARY_PATH` to include the 
> Clang-provided `libc++.dylib`, your program won't run because the system 
> `libc++.dylib` may not include all symbols that the newer Clang-provided 
> `libc++.dylib` contains.


Yes, that's an issue and not something this change deals with. The way we 
handle it in our build is statically linking libc++.

> Not shipping filesystem on macOS is a design choice we're making because the 
> filesystem library is not ABI stable. Adding `-L/../lib` 
> explicitly shows that you understand you're doing something unusual (and not 
> officially supported), which is good.
> 
> I assume this does not happen on Linux because Linux distributions must 
> include `libc++fs.a` as part of their system -- is that really the case?

On Linux the driver always adds `-L/../lib` so `libc++fs.a` 
is picked up whenever you pass `-lc++fs`.

> Thanks for the good explanation -- now I understand the purpose of the patch. 
> However, I think we need a larger discussion around how libc++ is shipped to 
> users and what use cases we want to support. For example, one question I have 
> is why we're even shipping `libc++.dylib`, `libc++abi.dylib` and 
> `libunwind.dylib` in our LLVM releases for MacOS, given they are provided by 
> the system (and mixing them is a recipe for disaster). Another question is 
> whether the LLVM-provided Clang should instead always link to the 
> LLVM-provided libraries (which would require users setting the 
> `DYLD_LIBRARY_PATH` properly to avoid falling back onto the macOS-provided 
> `libc++.dylib`).
> 
> I'm quite sympathetic to your use case (and in fact we have similar use 
> cases), but I'm uncomfortable moving forward with this patch until we have a 
> better understanding of some important surrounding questions. I'd like to 
> talk with @dexonsmith about it and then maybe we can meet at the LLVM Dev 
> Meeting (if you plan to attend) with other libc++ people to flesh those 
> questions out?

I'll be at LLVM Dev Meeting and I'd be happy to meet and discuss this.


Repository:
  rC Clang

https://reviews.llvm.org/D45639



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


[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-10-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

I see, many thanks. I've cherry-picked this patch locally and played with GDB - 
it appears to work fine with it. 
I'm also interested and support this change since this would simplify the 
adoption of Fission by some build systems.
@dblaikie, @echristo - are there any particular concerns with moving this 
forward ?


https://reviews.llvm.org/D52296



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


RE: [clang-tools-extra] r344513 - [clangd] Minimal implementation of automatic static index (not enabled).

2018-10-15 Thread via cfe-commits
Hi Sam,

The test you added in this commit is timing out when run on the PS4 Windows bot:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20724/steps/test/logs/stdio

command timed out: 1200 seconds without output running ['ninja', '-j', '36', 
'check-all'], attempting to kill
FAIL: Extra Tools Unit Tests :: 
clangd/./ClangdTests.exe/BackgroundIndexTest.IndexTwoFiles (44401 of 44401)
 TEST 'Extra Tools Unit Tests :: 
clangd/./ClangdTests.exe/BackgroundIndexTest.IndexTwoFiles' FAILED 

Note: Google Test filter = BackgroundIndexTest.IndexTwoFiles

[==] Running 1 test from 1 test case.

[--] Global test environment set-up.

[--] 1 test from BackgroundIndexTest

[ RUN  ] BackgroundIndexTest.IndexTwoFiles



program finished with exit code 1
elapsedTime=1446.10

Can you take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Sam McCall via cfe-commits
> Sent: Monday, October 15, 2018 6:34
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r344513 - [clangd] Minimal implementation
> of automatic static index (not enabled).
> 
> Author: sammccall
> Date: Mon Oct 15 06:34:10 2018
> New Revision: 344513
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=344513=rev
> Log:
> [clangd] Minimal implementation of automatic static index (not
> enabled).
> 
> Summary:
> See tinyurl.com/clangd-automatic-index for design and goals.
> 
> Lots of limitations to keep this patch smallish, TODOs everywhere:
>  - no serialization to disk
>  - no changes to dynamic index, which now has a much simpler job
>  - no partitioning of symbols by file to avoid duplication of header
> symbols
>  - no reindexing of edited files
>  - only a single worker thread
>  - compilation database is slurped synchronously (doesn't scale)
>  - uses memindex, rebuilds after every file (should be dex,
> periodically)
> 
> It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering
> isn't clear (it should really be in ClangdServer, but ClangdLSPServer
> has all the CDB interactions).
> 
> Reviewers: ioeric
> 
> Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman,
> kadircet, jfb, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D53032
> 
> Added:
> clang-tools-extra/trunk/clangd/index/Background.cpp
> clang-tools-extra/trunk/clangd/index/Background.h
> clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
> Modified:
> clang-tools-extra/trunk/clangd/CMakeLists.txt
> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
> clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
> clang-tools-extra/trunk/unittests/clangd/SyncAPI.h
> 
> Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/CMakeLists.txt?rev=344513=344512=344513=d
> iff
> ===
> ===
> --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Oct 15 06:34:10
> 2018
> @@ -38,6 +38,7 @@ add_clang_library(clangDaemon
>URI.cpp
>XRefs.cpp
> 
> +  index/Background.cpp
>index/CanonicalIncludes.cpp
>index/FileIndex.cpp
>index/Index.cpp
> 
> Added: clang-tools-extra/trunk/clangd/index/Background.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/index/Background.cpp?rev=344513=auto
> ===
> ===
> --- clang-tools-extra/trunk/clangd/index/Background.cpp (added)
> +++ clang-tools-extra/trunk/clangd/index/Background.cpp Mon Oct 15
> 06:34:10 2018
> @@ -0,0 +1,191 @@
> +//===-- Background.cpp - Build an index in a background thread ---
> -===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open
> Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===-
> -===//
> +
> +#include "index/Background.h"
> +#include "ClangdUnit.h"
> +#include "Compiler.h"
> +#include "Logger.h"
> +#include "Trace.h"
> +#include "index/IndexAction.h"
> +#include "index/MemIndex.h"
> +#include "index/Serialization.h"
> +#include "llvm/Support/SHA1.h"
> +#include 
> +
> +using namespace llvm;
> +namespace clang {
> +namespace clangd {
> +
> +BackgroundIndex::BackgroundIndex(Context BackgroundContext,
> + StringRef ResourceDir,
> + const FileSystemProvider )
> +: SwapIndex(llvm::make_unique()),
> ResourceDir(ResourceDir),
> +  FSProvider(FSProvider),
> BackgroundContext(std::move(BackgroundContext)),
> +  Thread([this] { run(); }) {}
> +
> 

[PATCH] D53249: Force Hexagon to use default (hexagon-link) linker

2018-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D53249#1264900, @sidneym wrote:

> https://reviews.llvm.org/D53219 added a check for either hexagon-ld or ld.  I 
> merged that change earlier today.  I can change the test to pass -fuse-ld, 
> let me know.  Thanks,


Passing `-fuse-ld=ld` is less error prone than checking for `hexagon-link` or 
`*ld*` in case someone sets the default linker to something else, e.g. 
`link.exe` on Windows or something like `foo-link` on some new platform.


Repository:
  rC Clang

https://reviews.llvm.org/D53249



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


[PATCH] D53308: [Fixed Point Arithmetic] Fixed Point to Boolean Cast

2018-10-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: ebevhan, rjmccall, bjope.
leonardchan added a project: clang.

This patch is a part of https://reviews.llvm.org/D48456 in an attempt to split 
the casting logic up into smaller patches. This contains the code for casting 
from fixed point types to boolean types.


Repository:
  rC Clang

https://reviews.llvm.org/D53308

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.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/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Frontend/fixed_point_to_bool.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
@@ -35,7 +35,6 @@
   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}}
 
-  b = accum;   // expected-error{{conversion between fixed point and '_Bool' 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}}
Index: clang/test/Frontend/fixed_point_to_bool.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_to_bool.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s
+
+_Bool global_b = 1.0k;  // @global_b = {{*.}}global i8 1, align 1
+_Bool global_b2 = 0.0k; // @global_b2 = {{*.}}global i8 0, align 1
+
+void func() {
+  _Accum a = 0.5k;
+  unsigned _Accum ua = 0.5uk;
+  _Bool b;
+
+  // CHECK: store i8 1, i8* %b, align 1
+  // CHECK-NEXT: store i8 0, i8* %b, align 1
+  // CHECK: store i8 1, i8* %b, align 1
+  // CHECK-NEXT: store i8 0, i8* %b, align 1
+  b = 0.5k;
+  b = 0.0k;
+  b = 0.5uk;
+  b = 0.0uk;
+
+  // CHECK-NEXT: store i8 1, i8* %b, align 1
+  // CHECK-NEXT: store i8 0, i8* %b, align 1
+  // CHECK-NEXT: store i8 1, i8* %b, align 1
+  // CHECK-NEXT: store i8 0, i8* %b, align 1
+  b = (_Bool)0.5r;
+  b = (_Bool)0.0r;
+  b = (_Bool)0.5ur;
+  b = (_Bool)0.0ur;
+
+  // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0
+  // CHECK-NEXT: %frombool = zext i1 [[NOTZERO]] to i8
+  // CHECK-NEXT: store i8 %frombool, i8* %b, align 1
+  b = a;
+
+  // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %ua, align 4
+  // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0
+  // CHECK-NEXT: %frombool1 = zext i1 [[NOTZERO]] to i8
+  // CHECK-NEXT: store i8 %frombool1, i8* %b, align 1
+  b = ua;
+
+  // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0
+  // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then, label %if.end
+  if (a) {
+  }
+
+  // CHECK:  [[ACCUM:%[0-9]+]] = load i32, i32* %ua, align 4
+  // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0
+  // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then{{[0-9]+}}, label %if.end{{[0-9]+}}
+  if (ua) {
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -416,7 +416,8 @@
   case CK_ZeroToOCLQueue:
   case CK_IntToOCLSampler:
   case CK_LValueBitCast:
-  case CK_FixedPointCast: {
+  case CK_FixedPointCast:
+  case CK_FixedPointToBoolean: {
 state =
 handleLValueBitCast(state, Ex, LCtx, T, ExTy, CastE, Bldr, Pred);
 continue;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5894,10 +5894,7 @@
 case Type::STK_FixedPoint:
   return CK_FixedPointCast;
 case Type::STK_Bool:
-  Diag(Src.get()->getExprLoc(),
-   diag::err_unimplemented_conversion_with_fixed_point_type)
-  << DestTy;
-  return CK_IntegralToBoolean;
+  return CK_FixedPointToBoolean;
 case Type::STK_Integral:
 case Type::STK_Floating:
 case 

[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

There seem to be more buildbots failing even after 
https://reviews.llvm.org/rL344535, eg. 
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/50318/console

  Failing Tests (3):
  libc++ :: 
std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/literals.fail.cpp
  libc++ :: 
std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/literals.fail.cpp
  libc++ :: 
std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp


https://reviews.llvm.org/D51762



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


Re: r344356 - [OPENMP][NVPTX]Reduce memory usage in orphaned functions.

2018-10-15 Thread Alexey Bataev via cfe-commits
Hi Galina, thanks for letting me know. Committed rL344574 to fix this problem.

Best regards,
Alexey Bataev

15 окт. 2018 г., в 19:03, Galina Kistanova 
mailto:gkistan...@gmail.com>> написал(а):

Hello Alexey,

It looks like this commit broke tests on one of our builders.
This failure did not manifest, but masked by another build failures.

Please have a look?

Thanks

Galina


http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/13262
. . .
Failing Tests (10):
Clang :: OpenMP/declare_target_codegen_globalization.cpp
Clang :: OpenMP/nvptx_SPMD_codegen.cpp
Clang :: OpenMP/nvptx_data_sharing.cpp
Clang :: OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
Clang :: OpenMP/nvptx_force_full_runtime_SPMD_codegen.cpp
Clang :: OpenMP/nvptx_parallel_codegen.cpp
Clang :: OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
Clang :: OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
Clang :: OpenMP/nvptx_teams_codegen.cpp
Clang :: OpenMP/nvptx_teams_reduction_codegen.cpp

On Fri, Oct 12, 2018 at 9:06 AM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Fri Oct 12 09:04:20 2018
New Revision: 344356

URL: http://llvm.org/viewvc/llvm-project?rev=344356=rev
Log:
[OPENMP][NVPTX]Reduce memory usage in orphaned functions.

if the function has globalized variables and called in context of
target/teams/distribute regions, it does not need to globalize 32
copies of the same variables for memory coalescing, it is enough to
have just one copy, because there is parallel region.
Patch does this by adding call for `__kmpc_parallel_level` function and
checking its return value. If the code sees that the parallel level is
0, then only one variable is allocated, not 32.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=344356=344355=344356=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Oct 12 09:04:20 2018
@@ -1972,6 +1972,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
 return;
   if (const RecordDecl *GlobalizedVarsRecord = I->getSecond().GlobalRecord) {
 QualType GlobalRecTy = 
CGM.getContext().getRecordType(GlobalizedVarsRecord);
+QualType SecGlobalRecTy;

 // Recover pointer to this function's global record. The runtime will
 // handle the specifics of the allocation of the memory.
@@ -1986,11 +1987,20 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
 llvm::PointerType *GlobalRecPtrTy =
 CGF.ConvertTypeForMem(GlobalRecTy)->getPointerTo();
 llvm::Value *GlobalRecCastAddr;
+llvm::Value *IsTTD = nullptr;
 if (WithSPMDCheck ||
 getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_Unknown) {
   llvm::BasicBlock *ExitBB = CGF.createBasicBlock(".exit");
   llvm::BasicBlock *SPMDBB = CGF.createBasicBlock(".spmd");
   llvm::BasicBlock *NonSPMDBB = CGF.createBasicBlock(".non-spmd");
+  if (I->getSecond().SecondaryGlobalRecord.hasValue()) {
+llvm::Value *RTLoc = emitUpdateLocation(CGF, Loc);
+llvm::Value *ThreadID = getThreadID(CGF, Loc);
+llvm::Value *PL = CGF.EmitRuntimeCall(
+createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_parallel_level),
+{RTLoc, ThreadID});
+IsTTD = Bld.CreateIsNull(PL);
+  }
   llvm::Value *IsSPMD = Bld.CreateIsNotNull(CGF.EmitNounwindRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_is_spmd_exec_mode)));
   Bld.CreateCondBr(IsSPMD, SPMDBB, NonSPMDBB);
@@ -2003,11 +2013,28 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
   // There is no need to emit line number for unconditional branch.
   (void)ApplyDebugLocation::CreateEmpty(CGF);
   CGF.EmitBlock(NonSPMDBB);
+  llvm::Value *Size = llvm::ConstantInt::get(CGM.SizeTy, GlobalRecordSize);
+  if (const RecordDecl *SecGlobalizedVarsRecord =
+  I->getSecond().SecondaryGlobalRecord.getValueOr(nullptr)) {
+SecGlobalRecTy =
+CGM.getContext().getRecordType(SecGlobalizedVarsRecord);
+
+// Recover pointer to this function's global record. The runtime will
+// handle the specifics of the allocation of the memory.
+// Use actual memory size of the record including the padding
+// for alignment purposes.
+unsigned Alignment =
+CGM.getContext().getTypeAlignInChars(SecGlobalRecTy).getQuantity();
+unsigned GlobalRecordSize =
+CGM.getContext().getTypeSizeInChars(SecGlobalRecTy).getQuantity();
+GlobalRecordSize = llvm::alignTo(GlobalRecordSize, Alignment);
+Size 

r344574 - [OPENMP][NVPTX]Increment iterator only when it is used, NFC.

2018-10-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct 15 17:09:06 2018
New Revision: 344574

URL: http://llvm.org/viewvc/llvm-project?rev=344574=rev
Log:
[OPENMP][NVPTX]Increment iterator only when it is used, NFC.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=344574=344573=344574=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Oct 15 17:09:06 2018
@@ -2138,7 +2138,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
 CGF.EmitStoreOfScalar(ParValue, VarAddr);
 I->getSecond().MappedParams->setVarAddr(CGF, VD, VarAddr.getAddress());
   }
-  ++SecIt;
+  if (IsTTD)
+++SecIt;
 }
   }
   for (const ValueDecl *VD : I->getSecond().EscapedVariableLengthDecls) {


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


[PATCH] D44672: [CodeGen] Disable UBSan for coroutine functions

2018-10-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Oh, I'm sorry I let this languish! I'll address your comments later this week, 
@vsk. Thanks so much for the review!


Repository:
  rC Clang

https://reviews.llvm.org/D44672



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


Re: r344356 - [OPENMP][NVPTX]Reduce memory usage in orphaned functions.

2018-10-15 Thread Galina Kistanova via cfe-commits
Hello Alexey,

It looks like this commit broke tests on one of our builders.
This failure did not manifest, but masked by another build failures.

Please have a look?

Thanks

Galina


http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/13262
. . .
Failing Tests (10):
Clang :: OpenMP/declare_target_codegen_globalization.cpp
Clang :: OpenMP/nvptx_SPMD_codegen.cpp
Clang :: OpenMP/nvptx_data_sharing.cpp
Clang :: OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
Clang :: OpenMP/nvptx_force_full_runtime_SPMD_codegen.cpp
Clang :: OpenMP/nvptx_parallel_codegen.cpp
Clang :: OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
Clang ::
OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
Clang :: OpenMP/nvptx_teams_codegen.cpp
Clang :: OpenMP/nvptx_teams_reduction_codegen.cpp

On Fri, Oct 12, 2018 at 9:06 AM Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Fri Oct 12 09:04:20 2018
> New Revision: 344356
>
> URL: http://llvm.org/viewvc/llvm-project?rev=344356=rev
> Log:
> [OPENMP][NVPTX]Reduce memory usage in orphaned functions.
>
> if the function has globalized variables and called in context of
> target/teams/distribute regions, it does not need to globalize 32
> copies of the same variables for memory coalescing, it is enough to
> have just one copy, because there is parallel region.
> Patch does this by adding call for `__kmpc_parallel_level` function and
> checking its return value. If the code sees that the parallel level is
> 0, then only one variable is allocated, not 32.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
> cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=344356=344355=344356=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Oct 12 09:04:20 2018
> @@ -1972,6 +1972,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
>  return;
>if (const RecordDecl *GlobalizedVarsRecord =
> I->getSecond().GlobalRecord) {
>  QualType GlobalRecTy =
> CGM.getContext().getRecordType(GlobalizedVarsRecord);
> +QualType SecGlobalRecTy;
>
>  // Recover pointer to this function's global record. The runtime will
>  // handle the specifics of the allocation of the memory.
> @@ -1986,11 +1987,20 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
>  llvm::PointerType *GlobalRecPtrTy =
>  CGF.ConvertTypeForMem(GlobalRecTy)->getPointerTo();
>  llvm::Value *GlobalRecCastAddr;
> +llvm::Value *IsTTD = nullptr;
>  if (WithSPMDCheck ||
>  getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_Unknown) {
>llvm::BasicBlock *ExitBB = CGF.createBasicBlock(".exit");
>llvm::BasicBlock *SPMDBB = CGF.createBasicBlock(".spmd");
>llvm::BasicBlock *NonSPMDBB = CGF.createBasicBlock(".non-spmd");
> +  if (I->getSecond().SecondaryGlobalRecord.hasValue()) {
> +llvm::Value *RTLoc = emitUpdateLocation(CGF, Loc);
> +llvm::Value *ThreadID = getThreadID(CGF, Loc);
> +llvm::Value *PL = CGF.EmitRuntimeCall(
> +createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_parallel_level),
> +{RTLoc, ThreadID});
> +IsTTD = Bld.CreateIsNull(PL);
> +  }
>llvm::Value *IsSPMD =
> Bld.CreateIsNotNull(CGF.EmitNounwindRuntimeCall(
>
>  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_is_spmd_exec_mode)));
>Bld.CreateCondBr(IsSPMD, SPMDBB, NonSPMDBB);
> @@ -2003,11 +2013,28 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
>// There is no need to emit line number for unconditional branch.
>(void)ApplyDebugLocation::CreateEmpty(CGF);
>CGF.EmitBlock(NonSPMDBB);
> +  llvm::Value *Size = llvm::ConstantInt::get(CGM.SizeTy,
> GlobalRecordSize);
> +  if (const RecordDecl *SecGlobalizedVarsRecord =
> +  I->getSecond().SecondaryGlobalRecord.getValueOr(nullptr)) {
> +SecGlobalRecTy =
> +CGM.getContext().getRecordType(SecGlobalizedVarsRecord);
> +
> +// Recover pointer to this function's global record. The runtime
> will
> +// handle the specifics of the allocation of the memory.
> +// Use actual memory size of the record including the padding
> +// for alignment purposes.
> +unsigned Alignment =
> +
> CGM.getContext().getTypeAlignInChars(SecGlobalRecTy).getQuantity();
> +unsigned GlobalRecordSize =
> +
> CGM.getContext().getTypeSizeInChars(SecGlobalRecTy).getQuantity();
> +GlobalRecordSize = llvm::alignTo(GlobalRecordSize, Alignment);
> +Size = Bld.CreateSelect(
> +IsTTD, 

[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The current text looks great.


https://reviews.llvm.org/D53024



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/www/analyzer/open_projects.html:27-32
+New checkers which were contributed to the analyzer,
+but have not passed a rigorous evaluation process,
+are committed as "alpha checkers" (from "alpha version"),
+and are not enabled by default.
+
+The development of many such checkers has stalled over the years.

This is extremely important to get right. Alpha doesn't mean "i did an 
experiment, let me dump my code so that it wasn't lost, maybe others will pick 
it up and turn it into a useful checker if they figure out how". Alpha doesn't 
mean "a checker that power-users can use at their own risk when they want to 
find more bugs". Alpha doesn't mean "i think this checker is great but 
maintainers think it's bad so they keep me in alpha but i'm happy because i can 
write in my resume that i'm an llvm contributor". All of these are super 
popular misconceptions.

Alpha means "i'm working on it". That's it.

Let's re-phrase to something like: "When a new checker is being developed 
incrementally, it is committed into clang and is put into the hidden "alpha" 
package (from "alpha version"). Ideally, once all desired functionality of the 
checker is implemented, checker should be moved out of the alpha package and 
become enabled by default or recommended to opt-in into, but development of 
many alpha checkers has stalled over the years."



Comment at: clang/www/analyzer/open_projects.html:80
 
-Handle floating-point values.
-Currently, the analyzer treats all floating-point values as unknown.
-However, we already have most of the infrastructure we need to handle
-floats: RangeConstraintManager. This would involve adding a new SVal kind
-for constant floats, generalizing the constraint manager to handle floats
-and integers equally, and auditing existing code to make sure it doesn't
-make untoward assumptions.
- (Difficulty: Medium)
-
-
-Implement generalized loop execution modeling.
-Currently, the analyzer simply unrolls each loop N times. This 
-means that it will not execute any code after the loop if the loop is 
-guaranteed to execute more than N times. This results in lost 
-basic block coverage. We could continue exploring the path if we could 
-model a generic i-th iteration of a loop.
- (Difficulty: Hard)
+  Improved C++ support
+  

I guess let's add the rest of the constructors from my message above.



Comment at: clang/www/analyzer/open_projects.html:88-89
+  but potentially calling
+  constructors for their fields and base classes
+  These
+  constructors of sub-objects need to know what object they are 
constructing.

Something's wrong here.


https://reviews.llvm.org/D53024



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


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-10-15 Thread Simon Atanasyan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344570: [mips] Fix handling of GNUABIN32 environment in a 
target triple (authored by atanasyan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51464?vs=168116=169763#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c
  test/Driver/linux-ld.c

Index: test/CodeGen/mips-zero-sized-struct.c
===
--- test/CodeGen/mips-zero-sized-struct.c
+++ test/CodeGen/mips-zero-sized-struct.c
@@ -2,8 +2,12 @@
 // RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
 // RUN: %clang_cc1 -triple mips64-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32 %s
 // RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32 %s
+// RUN: %clang_cc1 -triple mips64-unknown-linux-gnuabin32 -S -emit-llvm -o - %s  | FileCheck -check-prefix=N32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnuabin32 -S -emit-llvm -o - %s  | FileCheck -check-prefix=N32 %s
 // RUN: %clang_cc1 -triple mips64-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
 // RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
+// RUN: %clang_cc1 -triple mips64-unknown-linux-gnuabi64 -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnuabi64 -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
 
 // O32: define void @fn28(%struct.T2* noalias sret %agg.result, i8 signext %arg0)
 // N32: define void @fn28(i8 signext %arg0)
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,30 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3
 // PS3: target datalayout = "E-m:e-p:32:32-i64:64-n32:64"
Index: test/CodeGen/atomics-inlining.c
===
--- 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-10-15 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the patch.


https://reviews.llvm.org/D51464



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


r344570 - [mips] Fix handling of GNUABIN32 environment in a target triple

2018-10-15 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Mon Oct 15 15:43:23 2018
New Revision: 344570

URL: http://llvm.org/viewvc/llvm-project?rev=344570=rev
Log:
[mips] Fix handling of GNUABIN32 environment in a target triple

The `GNUABIN32` environment in a target triple implies using the N32
ABI. This patch adds support for this environment and switches on N32
ABI if necessary.

Patch by Patch by YunQiang Su.

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

Modified:
cfe/trunk/lib/Basic/Targets/Mips.h
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/CodeGen/atomics-inlining.c
cfe/trunk/test/CodeGen/mips-zero-sized-struct.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
cfe/trunk/test/Driver/clang-translation.c
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/lib/Basic/Targets/Mips.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.h?rev=344570=344569=344570=diff
==
--- cfe/trunk/lib/Basic/Targets/Mips.h (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.h Mon Oct 15 15:43:23 2018
@@ -69,7 +69,12 @@ public:
 UseIndirectJumpHazard(false), FPMode(FPXX) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
-setABI(getTriple().isMIPS32() ? "o32" : "n64");
+if (Triple.isMIPS32())
+  setABI("o32");
+else if (Triple.getEnvironment() == llvm::Triple::GNUABIN32)
+  setABI("n32");
+else
+  setABI("n64");
 
 CPU = ABI == "o32" ? "mips32r2" : "mips64r2";
 

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=344570=344569=344570=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon Oct 15 15:43:23 2018
@@ -82,6 +82,9 @@ void mips::getMipsCPUAndABI(const ArgLis
 }
   }
 
+  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
+ABIName = "n32";
+
   if (ABIName.empty() &&
   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=344570=344569=344570=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Oct 15 15:43:23 2018
@@ -264,11 +264,13 @@ static const char *getLDMOption(const ll
   case llvm::Triple::mipsel:
 return "elf32ltsmip";
   case llvm::Triple::mips64:
-if (tools::mips::hasMipsAbiArg(Args, "n32"))
+if (tools::mips::hasMipsAbiArg(Args, "n32") ||
+T.getEnvironment() == llvm::Triple::GNUABIN32)
   return "elf32btsmipn32";
 return "elf64btsmip";
   case llvm::Triple::mips64el:
-if (tools::mips::hasMipsAbiArg(Args, "n32"))
+if (tools::mips::hasMipsAbiArg(Args, "n32") ||
+T.getEnvironment() == llvm::Triple::GNUABIN32)
   return "elf32ltsmipn32";
 return "elf64ltsmip";
   case llvm::Triple::systemz:
@@ -1855,6 +1857,10 @@ void Generic_GCC::GCCInstallationDetecto
   "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu",
   "mips64el-linux-gnuabi64"};
 
+  static const char *const MIPSN32LibDirs[] = {"/lib32"};
+  static const char *const MIPSN32Triples[] = {"mips64-linux-gnuabin32"};
+  static const char *const MIPSN32ELLibDirs[] = {"/lib32"};
+  static const char *const MIPSN32ELTriples[] = {"mips64el-linux-gnuabin32"};
 
   static const char *const PPCLibDirs[] = {"/lib32", "/lib"};
   static const char *const PPCTriples[] = {
@@ -2051,6 +2057,8 @@ void Generic_GCC::GCCInstallationDetecto
 TripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
 BiarchLibDirs.append(begin(MIPS64LibDirs), end(MIPS64LibDirs));
 BiarchTripleAliases.append(begin(MIPS64Triples), end(MIPS64Triples));
+BiarchLibDirs.append(begin(MIPSN32LibDirs), end(MIPSN32LibDirs));
+BiarchTripleAliases.append(begin(MIPSN32Triples), end(MIPSN32Triples));
 break;
   case llvm::Triple::mipsel:
 LibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs));
@@ -2058,18 +2066,24 @@ void Generic_GCC::GCCInstallationDetecto
 TripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
 BiarchLibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs));
 BiarchTripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples));
+BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs));
+BiarchTripleAliases.append(begin(MIPSN32ELTriples), end(MIPSN32ELTriples));
 break;
   case llvm::Triple::mips64:
 

[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

I dislike web development, but that would indeed be invaluable. I'll take a 
look.


https://reviews.llvm.org/D53024



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


[PATCH] D53274: [analyzer][NFC] Fix inconsistencies in AnalyzerOptions

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:354
 
+StringRef AnalyzerOptions::getOptionAsString(Optional ,
+ StringRef Name,

george.karpenkov wrote:
> I'm slightly confused, where is this function called?
> Same for the function above?
Its used in D53277, but this addition belongs here more.

Granted, I should've refactored this file to demonstrate why I made this 
change, but in D53277 I literally delete everything, so I didn't bother.


https://reviews.llvm.org/D53274



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@Szelethus thanks! BTW if you really want to invest into maintaining the 
website,
I think it's totally worth it to change all contents to markdown,
and then have a script to generate HTML from that.
Committers would be expected to manually run that script.
This would also solve our problem with the disappearing header.


https://reviews.llvm.org/D53024



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Thanks, this looks great!


https://reviews.llvm.org/D53024



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


[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Cheers, thanks for the review!

In https://reviews.llvm.org/D53296#1265927, @george.karpenkov wrote:

> Also, that's a lot of code for printing options. I understand it's hard to do 
> wrapping properly, but I'm not sure whether it makes sense for half of the 
> `CheckerRegistration.cpp` file to be doing option wrapping for help printing.
>  Could you look into simpler alternatives? (or if your wrapping printer is 
> indeed indispensable, maybe it should go somewhere into 
> `llvm/lib/Support/format`?)
>  I am not sure what would be a better solution here, maybe it's already 
> possible to write something much smaller using components from `lib/Support`.


Aye, the formatting looks a little ridiculous. I'm not making a good job 
selling this, but I'm somewhat surprised it even works. Thanks for the 
suggestions, I'll take a look -- I wanted to find an existing solution while 
writing this, but didn't try hard enough.


Repository:
  rC Clang

https://reviews.llvm.org/D53296



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


[PATCH] D53274: [analyzer][NFC] Fix inconsistencies in AnalyzerOptions

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

OK that makes sense to me, just let's be careful not to crash in places where 
we weren't crashing before.




Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:354
 
+StringRef AnalyzerOptions::getOptionAsString(Optional ,
+ StringRef Name,

I'm slightly confused, where is this function called?
Same for the function above?


https://reviews.llvm.org/D53274



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


[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

+1, I think this is a great addition!

BTW in theory it should be possible to go wild on compile-time programming, and 
generate the entire description string at compile time,
but it does not seem to be worth it.

Also, you seem to be missing tests (at least to verify that the code does not 
crash).

Also, that's a lot of code for printing options. I understand it's hard to do 
wrapping properly, but I'm not sure whether it makes sense for half of the 
`CheckerRegistration.cpp` file to be doing option wrapping for help printing.
Could you look into simpler alternatives? (or if your wrapping printer is 
indeed indispensable, maybe it should go somewhere into 
`llvm/lib/Support/format`?)
I am not sure what would be a better solution here, maybe it's already possible 
to write something much smaller using components from `lib/Support`.


Repository:
  rC Clang

https://reviews.llvm.org/D53296



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 169758.

https://reviews.llvm.org/D53024

Files:
  clang/www/analyzer/open_projects.html

Index: clang/www/analyzer/open_projects.html
===
--- clang/www/analyzer/open_projects.html
+++ clang/www/analyzer/open_projects.html
@@ -22,162 +22,187 @@
 to the http://lists.llvm.org/mailman/listinfo/cfe-dev>cfe-dev
 mailing list to notify other members of the community.
 
-  
-  Core Analyzer Infrastructure
-  
-Explicitly model standard library functions with BodyFarm.
-http://clang.llvm.org/doxygen/classclang_1_1BodyFarm.html;>BodyFarm 
-allows the analyzer to explicitly model functions whose definitions are 
-not available during analysis. Modeling more of the widely used functions 
-(such as the members of std::string) will improve precision of the
-analysis. 
-(Difficulty: Easy, ongoing)
-
+
+  Release checkers from "alpha"
+New checkers which were contributed to the analyzer,
+but have not passed a rigorous evaluation process,
+are committed as "alpha checkers" (from "alpha version"),
+and are not enabled by default.
+
+The development of many such checkers has stalled over the years.
+Current "alpha" checkers need a cleanup:
+checkers which have been there for a long time should either
+be improved up to a point where they can be enabled by default,
+or removed, if such an improvement is not possible.
+Most notably, these checkers could be "graduated" out of alpha
+if a consistent effort is applied:
+
+
+  alpha.security.ArrayBound and
+  alpha.security.ArrayBoundV2
+  Array bounds checking is a desired feature,
+  but having an acceptable rate of false positives might not be possible
+  without a proper
+  https://en.wikipedia.org/wiki/Widening_(computer_science)">loop widening support.
+  Additionally, it might be more promising to perform index checking based on
+  https://en.wikipedia.org/wiki/Taint_checking;>tainted index values.
+  (Difficulty: Medium)
+  
+
+  alpha.cplusplus.MisusedMovedObject
+The checker emits a warning on objects which were used after
+https://en.cppreference.com/w/cpp/utility/move;>move.
+Currently it has an overly high false positive rate due to classes
+which have a well-defined semantics for use-after-move.
+This property does not hold for STL objects, but is often the case
+for custom containers.
+  (Difficulty: Medium)
+  
+
+  alpha.unix.StreamChecker
+A SimpleStreamChecker has been presented in the Building a Checker in 24 
+Hours talk 
+(http://llvm.org/devmtg/2012-11/Zaks-Rose-Checker24Hours.pdf;>slides
+https://youtu.be/kdxlsP5QVPw;>video).
+
+This alpha checker is an attempt to write a production grade stream checker.
+However, it was found to have an unacceptably high false positive rate.
+One of the found problems was that eagerly splitting the state
+based on whether the system call may fail leads to too many reports.
+A delayed split where the implication is stored in the state
+(similarly to nullability implications in TrustNonnullChecker)
+may produce much better results.
+(Difficulty: Medium)
+  
+
+  
 
-Handle floating-point values.
-Currently, the analyzer treats all floating-point values as unknown.
-However, we already have most of the infrastructure we need to handle
-floats: RangeConstraintManager. This would involve adding a new SVal kind
-for constant floats, generalizing the constraint manager to handle floats
-and integers equally, and auditing existing code to make sure it doesn't
-make untoward assumptions.
- (Difficulty: Medium)
-
-
-Implement generalized loop execution modeling.
-Currently, the analyzer simply unrolls each loop N times. This 
-means that it will not execute any code after the loop if the loop is 
-guaranteed to execute more than N times. This results in lost 
-basic block coverage. We could continue exploring the path if we could 
-model a generic i-th iteration of a loop.
- (Difficulty: Hard)
+  Improved C++ support
+  
+Handle aggregate construction.
+  https://en.cppreference.com/w/cpp/language/aggregate_initialization;>Aggregates
+  are objects that can be brace-initialized without calling a
+  constructor (that is, https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html;>
+  CXXConstructExpr does not occur in the AST),
+  but potentially calling
+  constructors for their fields and base classes
+  These
+  constructors of sub-objects need to know what object they are constructing.
+  Moreover, if the aggregate contains
+  references, lifetime extension needs to be properly modeled.
+
+  One can start 

[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

I have tried to clean up the list.


https://reviews.llvm.org/D53024



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


[PATCH] D53248: [Driver] Support direct split DWARF emission for Fuchsia

2018-10-15 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344556: [Driver] Support direct split DWARF emission for 
Fuchsia (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53248?vs=169582=169756#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53248

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/fuchsia.c


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -133,6 +133,7 @@
   llvm-cov
   llvm-cxxfilt
   llvm-dwarfdump
+  llvm-dwp
   llvm-lib
   llvm-nm
   llvm-objcopy
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -149,3 +149,8 @@
 // CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -gsplit-dwarf -c %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
+// CHECK-SPLIT-DWARF: "-split-dwarf-file" "fuchsia.dwo"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3047,8 +3047,8 @@
 
   // -gsplit-dwarf should turn on -g and enable the backend dwarf
   // splitting and extraction.
-  // FIXME: Currently only works on Linux.
-  if (T.isOSLinux()) {
+  // FIXME: Currently only works on Linux and Fuchsia.
+  if (T.isOSLinux() || T.isOSFuchsia()) {
 if (!SplitDWARFInlining)
   CmdArgs.push_back("-fno-split-dwarf-inlining");
 
@@ -3814,7 +3814,8 @@
 
   // Add the split debug info name to the command lines here so we
   // can propagate it to the backend.
-  bool SplitDWARF = SplitDWARFArg && RawTriple.isOSLinux() &&
+  bool SplitDWARF = SplitDWARFArg &&
+(RawTriple.isOSLinux() || RawTriple.isOSFuchsia()) &&
 (isa(JA) || isa(JA) ||
  isa(JA));
   const char *SplitDWARFOut;
@@ -5759,8 +5760,9 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  const llvm::Triple  = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux()) {
+  (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
 CmdArgs.push_back(SplitDebugName(Args, Input));
   }


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -133,6 +133,7 @@
   llvm-cov
   llvm-cxxfilt
   llvm-dwarfdump
+  llvm-dwp
   llvm-lib
   llvm-nm
   llvm-objcopy
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -149,3 +149,8 @@
 // CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -gsplit-dwarf -c %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
+// CHECK-SPLIT-DWARF: "-split-dwarf-file" "fuchsia.dwo"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3047,8 +3047,8 @@
 
   // -gsplit-dwarf should turn on -g and enable the backend dwarf
   // splitting and extraction.
-  // FIXME: Currently only works on Linux.
-  if (T.isOSLinux()) {
+  // FIXME: Currently only works on Linux and Fuchsia.
+  if (T.isOSLinux() || T.isOSFuchsia()) {
 if (!SplitDWARFInlining)
   CmdArgs.push_back("-fno-split-dwarf-inlining");
 
@@ -3814,7 +3814,8 @@
 
   // Add the split debug info name to the command lines here so we
   // can propagate it to the backend.
-  bool SplitDWARF = SplitDWARFArg && RawTriple.isOSLinux() &&
+  bool SplitDWARF = SplitDWARFArg &&
+(RawTriple.isOSLinux() || RawTriple.isOSFuchsia()) &&
 (isa(JA) || isa(JA) ||
  isa(JA));
   const char *SplitDWARFOut;
@@ -5759,8 +5760,9 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  const llvm::Triple  = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux()) {
+  (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
 

r344556 - [Driver] Support direct split DWARF emission for Fuchsia

2018-10-15 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Oct 15 14:30:32 2018
New Revision: 344556

URL: http://llvm.org/viewvc/llvm-project?rev=344556=rev
Log:
[Driver] Support direct split DWARF emission for Fuchsia

This enables the driver support for direct split DWARF emission for
Fuchsia in addition to Linux.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=344556=344555=344556=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Mon Oct 15 14:30:32 2018
@@ -133,6 +133,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cov
   llvm-cxxfilt
   llvm-dwarfdump
+  llvm-dwp
   llvm-lib
   llvm-nm
   llvm-objcopy

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=344556=344555=344556=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Oct 15 14:30:32 2018
@@ -3047,8 +3047,8 @@ static void RenderDebugOptions(const Too
 
   // -gsplit-dwarf should turn on -g and enable the backend dwarf
   // splitting and extraction.
-  // FIXME: Currently only works on Linux.
-  if (T.isOSLinux()) {
+  // FIXME: Currently only works on Linux and Fuchsia.
+  if (T.isOSLinux() || T.isOSFuchsia()) {
 if (!SplitDWARFInlining)
   CmdArgs.push_back("-fno-split-dwarf-inlining");
 
@@ -3814,7 +3814,8 @@ void Clang::ConstructJob(Compilation ,
 
   // Add the split debug info name to the command lines here so we
   // can propagate it to the backend.
-  bool SplitDWARF = SplitDWARFArg && RawTriple.isOSLinux() &&
+  bool SplitDWARF = SplitDWARFArg &&
+(RawTriple.isOSLinux() || RawTriple.isOSFuchsia()) &&
 (isa(JA) || isa(JA) ||
  isa(JA));
   const char *SplitDWARFOut;
@@ -5759,8 +5760,9 @@ void ClangAs::ConstructJob(Compilation &
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  const llvm::Triple  = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux()) {
+  (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
 CmdArgs.push_back(SplitDebugName(Args, Input));
   }

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=344556=344555=344556=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Mon Oct 15 14:30:32 2018
@@ -149,3 +149,8 @@
 // CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -gsplit-dwarf -c %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
+// CHECK-SPLIT-DWARF: "-split-dwarf-file" "fuchsia.dwo"


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


[PATCH] D53084: [clang-doc] Add unit tests for YAML

2018-10-15 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich added a comment.

This just seems like a lit test in unit test form, why does this need to use 
unit tests and not lit tests?


https://reviews.llvm.org/D53084



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


[PATCH] D53083: [clang-doc] Add unit tests for merging

2018-10-15 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich accepted this revision.
jakehehrlich added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/unittests/clang-doc/MergeTest.cpp:222
+
+  Expected->DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  Expected->Loc.emplace_back(12, llvm::SmallString<16>("test.cpp"));

Use {} not () on both SmallString and Location (and any other constructors)


https://reviews.llvm.org/D53083



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


[PATCH] D53081: [clang-doc] Add unit tests for serialization

2018-10-15 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich accepted this revision.
jakehehrlich added a comment.
This revision is now accepted and ready to land.

LGTM, I'd file a bug about SmallString not taking const char* in its 
constructor and I'd also put a TODO somewhere to fix that once that's resolved.


https://reviews.llvm.org/D53081



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


[PATCH] D53081: [clang-doc] Add unit tests for serialization

2018-10-15 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 169754.
juliehockett marked an inline comment as done.

https://reviews.llvm.org/D53081

Files:
  clang-tools-extra/unittests/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
  clang-tools-extra/unittests/clang-doc/ClangDocTest.h
  clang-tools-extra/unittests/clang-doc/SerializeTest.cpp

Index: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
@@ -0,0 +1,346 @@
+//===-- clang-doc/SerializeTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Serialize.h"
+#include "ClangDocTest.h"
+#include "Representation.h"
+#include "clang/AST/Comment.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace doc {
+
+class ClangDocSerializeTestVisitor
+: public RecursiveASTVisitor {
+
+  EmittedInfoList 
+  bool Public;
+
+  comments::FullComment *getComment(const NamedDecl *D) const {
+if (RawComment *Comment =
+D->getASTContext().getRawCommentForDeclNoCache(D)) {
+  Comment->setAttached();
+  return Comment->parse(D->getASTContext(), nullptr, D);
+}
+return nullptr;
+  }
+
+public:
+  ClangDocSerializeTestVisitor(EmittedInfoList , bool Public)
+  : EmittedInfos(EmittedInfos), Public(Public) {}
+
+  bool VisitNamespaceDecl(const NamespaceDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitFunctionDecl(const FunctionDecl *D) {
+// Don't visit CXXMethodDecls twice
+if (dyn_cast(D))
+  return true;
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitCXXMethodDecl(const CXXMethodDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitRecordDecl(const RecordDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitEnumDecl(const EnumDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+};
+
+void ExtractInfosFromCode(StringRef Code, size_t NumExpectedInfos, bool Public,
+  EmittedInfoList ) {
+  auto ASTUnit = clang::tooling::buildASTFromCode(Code);
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  ClangDocSerializeTestVisitor Visitor(EmittedInfos, Public);
+  Visitor.TraverseTranslationUnitDecl(TU);
+  ASSERT_EQ(NumExpectedInfos, EmittedInfos.size());
+}
+
+void ExtractInfosFromCodeWithArgs(StringRef Code, size_t NumExpectedInfos,
+  bool Public, EmittedInfoList ,
+  std::vector ) {
+  auto ASTUnit = clang::tooling::buildASTFromCodeWithArgs(Code, Args);
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  ClangDocSerializeTestVisitor Visitor(EmittedInfos, Public);
+  Visitor.TraverseTranslationUnitDecl(TU);
+  ASSERT_EQ(NumExpectedInfos, EmittedInfos.size());
+}
+
+// Test serialization of namespace declarations.
+TEST(SerializeTest, emitNamespaceInfo) {
+  EmittedInfoList Infos;
+  ExtractInfosFromCode("namespace A { namespace B { void f() {} } }", 3,
+   /*Public=*/false, Infos);
+
+  NamespaceInfo *A = InfoAsNamespace(Infos[0].get());
+  NamespaceInfo ExpectedA(EmptySID, "A");
+  CheckNamespaceInfo(, A);
+
+  NamespaceInfo *B = InfoAsNamespace(Infos[1].get());
+  NamespaceInfo ExpectedB(EmptySID, "B");
+  ExpectedB.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+  CheckNamespaceInfo(, B);
+
+  NamespaceInfo *BWithFunction = InfoAsNamespace(Infos[2].get());
+  NamespaceInfo ExpectedBWithFunction(EmptySID);
+  FunctionInfo F;
+  F.Name = "f";
+  F.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
+  F.DefLoc = Location(0, llvm::SmallString<16>("test.cpp"));
+  F.Namespace.emplace_back(EmptySID, "B", InfoType::IT_namespace);
+  

[PATCH] D53085: [clang-doc] Add unit tests for Markdown

2018-10-15 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 169752.
juliehockett marked an inline comment as done.

https://reviews.llvm.org/D53085

Files:
  clang-tools-extra/unittests/clang-doc/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -0,0 +1,361 @@
+//===-- clang-doc/MDGeneratorTest.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangDocTest.h"
+#include "Generators.h"
+#include "Representation.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace doc {
+
+std::unique_ptr getMDGenerator() {
+  auto G = doc::findGeneratorByName("md");
+  if (!G)
+return nullptr;
+  return std::move(G.get());
+}
+
+TEST(MDGeneratorTest, emitNamespaceMD) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace",
+ InfoType::IT_namespace);
+  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
+  I.ChildFunctions.emplace_back();
+  I.ChildFunctions.back().Name = "OneFunction";
+  I.ChildEnums.emplace_back();
+  I.ChildEnums.back().Name = "OneEnum";
+
+  auto G = getMDGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected = R"raw(# namespace Namespace
+
+
+
+## Namespaces
+
+ChildNamespace
+
+
+
+## Records
+
+ChildStruct
+
+
+
+## Functions
+
+### OneFunction
+
+* OneFunction()*
+
+
+
+## Enums
+
+| enum OneEnum |
+
+--
+
+
+
+
+
+)raw";
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(MDGeneratorTest, emitRecordMD) {
+  RecordInfo I;
+  I.Name = "r";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp"));
+
+  I.Members.emplace_back("int", "X", AccessSpecifier::AS_private);
+  I.TagType = TagTypeKind::TTK_Class;
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
+  I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
+
+  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
+  I.ChildFunctions.emplace_back();
+  I.ChildFunctions.back().Name = "OneFunction";
+  I.ChildEnums.emplace_back();
+  I.ChildEnums.back().Name = "OneEnum";
+
+  auto G = getMDGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected = R"raw(# class r
+
+*Defined at line 10 of test.cpp*
+
+Inherits from F, G
+
+
+
+## Members
+
+private int X
+
+
+
+## Records
+
+ChildStruct
+
+
+
+## Functions
+
+### OneFunction
+
+* OneFunction()*
+
+
+
+## Enums
+
+| enum OneEnum |
+
+--
+
+
+
+
+
+)raw";
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(MDGeneratorTest, emitFunctionMD) {
+  FunctionInfo I;
+  I.Name = "f";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp"));
+
+  I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
+  I.Params.emplace_back("int", "P");
+  I.IsMethod = true;
+  I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
+
+  auto G = getMDGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected = R"raw(### f
+
+*void f(int P)*
+
+*Defined at line 10 of test.cpp*
+
+)raw";
+
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(MDGeneratorTest, emitEnumMD) {
+  EnumInfo I;
+  I.Name = "e";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp"));
+
+  I.Members.emplace_back("X");
+  I.Scoped = true;
+
+  auto G = getMDGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected = R"raw(| enum class e |
+
+--
+
+| X |
+
+
+*Defined at line 10 of test.cpp*
+
+)raw";
+
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(MDGeneratorTest, emitCommentMD) {
+  FunctionInfo I;
+  I.Name = "f";
+  I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  I.ReturnType = TypeInfo(EmptySID, "void", 

[PATCH] D53084: [clang-doc] Add unit tests for YAML

2018-10-15 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 169751.
juliehockett marked an inline comment as done.

https://reviews.llvm.org/D53084

Files:
  clang-tools-extra/unittests/clang-doc/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -0,0 +1,427 @@
+//===-- clang-doc/YAMLGeneratorTest.cpp
+//===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangDocTest.h"
+#include "Generators.h"
+#include "Representation.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace doc {
+
+std::unique_ptr getYAMLGenerator() {
+  auto G = doc::findGeneratorByName("yaml");
+  if (!G)
+return nullptr;
+  return std::move(G.get());
+}
+
+TEST(YAMLGeneratorTest, emitNamespaceYAML) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace",
+ InfoType::IT_namespace);
+  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
+  I.ChildFunctions.emplace_back();
+  I.ChildFunctions.back().Name = "OneFunction";
+  I.ChildEnums.emplace_back();
+  I.ChildEnums.back().Name = "OneEnum";
+
+  auto G = getYAMLGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected =
+  R"raw(---
+USR: ''
+Name:'Namespace'
+Namespace:   
+  - Type:Namespace
+Name:'A'
+ChildNamespaces: 
+  - Type:Namespace
+Name:'ChildNamespace'
+ChildRecords:
+  - Type:Record
+Name:'ChildStruct'
+ChildFunctions:  
+  - USR: ''
+Name:'OneFunction'
+ReturnType:  
+ChildEnums:  
+  - USR: ''
+Name:'OneEnum'
+...
+)raw";
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(YAMLGeneratorTest, emitRecordYAML) {
+  RecordInfo I;
+  I.Name = "r";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp"));
+
+  I.Members.emplace_back("int", "X", AccessSpecifier::AS_private);
+  I.TagType = TagTypeKind::TTK_Class;
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
+  I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
+
+  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
+  I.ChildFunctions.emplace_back();
+  I.ChildFunctions.back().Name = "OneFunction";
+  I.ChildEnums.emplace_back();
+  I.ChildEnums.back().Name = "OneEnum";
+
+  auto G = getYAMLGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected =
+  R"raw(---
+USR: ''
+Name:'r'
+Namespace:   
+  - Type:Namespace
+Name:'A'
+DefLocation: 
+  LineNumber:  10
+  Filename:'test.cpp'
+Location:
+  - LineNumber:  12
+Filename:'test.cpp'
+TagType: Class
+Members: 
+  - Type:
+  Name:'int'
+Name:'X'
+Access:  Private
+Parents: 
+  - Type:Record
+Name:'F'
+VirtualParents:  
+  - Type:Record
+Name:'G'
+ChildRecords:
+  - Type:Record
+Name:'ChildStruct'
+ChildFunctions:  
+  - USR: ''
+Name:'OneFunction'
+ReturnType:  
+ChildEnums:  
+  - USR: ''
+Name:'OneEnum'
+...
+)raw";
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(YAMLGeneratorTest, emitFunctionYAML) {
+  FunctionInfo I;
+  I.Name = "f";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp"));
+  I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp"));
+
+  I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
+  I.Params.emplace_back("int", "P");
+  I.IsMethod = true;
+  I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
+
+  

[PATCH] D53081: [clang-doc] Add unit tests for serialization

2018-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp:320
+  ExtractInfosFromCodeWithArgs(
+  "export module M;\n"
+  "int moduleFunction(int x);\n"

Can you use raw strings here (and elsewhere in this file) as well?


https://reviews.llvm.org/D53081



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


[PATCH] D53082: [clang-doc] Add unit tests for bitcode

2018-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D53082



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


[PATCH] D53210: Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE""

2018-10-15 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Nevermind, looks like flaky tests.  Will try to repro and contact msan 
maintainers.


Repository:
  rC Clang

https://reviews.llvm.org/D53210



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


[PATCH] D53081: [clang-doc] Add unit tests for serialization

2018-10-15 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 169748.
juliehockett marked 2 inline comments as done.

https://reviews.llvm.org/D53081

Files:
  clang-tools-extra/unittests/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
  clang-tools-extra/unittests/clang-doc/ClangDocTest.h
  clang-tools-extra/unittests/clang-doc/SerializeTest.cpp

Index: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
@@ -0,0 +1,349 @@
+//===-- clang-doc/SerializeTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Serialize.h"
+#include "ClangDocTest.h"
+#include "Representation.h"
+#include "clang/AST/Comment.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace doc {
+
+class ClangDocSerializeTestVisitor
+: public RecursiveASTVisitor {
+
+  EmittedInfoList 
+  bool Public;
+
+  comments::FullComment *getComment(const NamedDecl *D) const {
+if (RawComment *Comment =
+D->getASTContext().getRawCommentForDeclNoCache(D)) {
+  Comment->setAttached();
+  return Comment->parse(D->getASTContext(), nullptr, D);
+}
+return nullptr;
+  }
+
+public:
+  ClangDocSerializeTestVisitor(EmittedInfoList , bool Public)
+  : EmittedInfos(EmittedInfos), Public(Public) {}
+
+  bool VisitNamespaceDecl(const NamespaceDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/ 0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitFunctionDecl(const FunctionDecl *D) {
+// Don't visit CXXMethodDecls twice
+if (dyn_cast(D))
+  return true;
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/ 0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitCXXMethodDecl(const CXXMethodDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/ 0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitRecordDecl(const RecordDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/ 0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+
+  bool VisitEnumDecl(const EnumDecl *D) {
+auto I = serialize::emitInfo(D, getComment(D), /*Line=*/ 0,
+ /*File=*/"test.cpp", Public);
+if (I)
+  EmittedInfos.emplace_back(std::move(I));
+return true;
+  }
+};
+
+void ExtractInfosFromCode(StringRef Code, size_t NumExpectedInfos, bool Public,
+  EmittedInfoList ) {
+  auto ASTUnit = clang::tooling::buildASTFromCode(Code);
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  ClangDocSerializeTestVisitor Visitor(EmittedInfos, Public);
+  Visitor.TraverseTranslationUnitDecl(TU);
+  ASSERT_EQ(NumExpectedInfos, EmittedInfos.size());
+}
+
+void ExtractInfosFromCodeWithArgs(StringRef Code, size_t NumExpectedInfos,
+  bool Public, EmittedInfoList ,
+  std::vector ) {
+  auto ASTUnit = clang::tooling::buildASTFromCodeWithArgs(Code, Args);
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  ClangDocSerializeTestVisitor Visitor(EmittedInfos, Public);
+  Visitor.TraverseTranslationUnitDecl(TU);
+  ASSERT_EQ(NumExpectedInfos, EmittedInfos.size());
+}
+
+// Test serialization of namespace declarations.
+TEST(SerializeTest, emitNamespaceInfo) {
+  EmittedInfoList Infos;
+  ExtractInfosFromCode("namespace A { namespace B { void f() {} } }", 3,
+   /*Public=*/false, Infos);
+
+  NamespaceInfo *A = InfoAsNamespace(Infos[0].get());
+  NamespaceInfo ExpectedA(EmptySID, "A");
+  CheckNamespaceInfo(, A);
+
+  NamespaceInfo *B = InfoAsNamespace(Infos[1].get());
+  NamespaceInfo ExpectedB(EmptySID, "B");
+  ExpectedB.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+  CheckNamespaceInfo(, B);
+
+  NamespaceInfo *BWithFunction = InfoAsNamespace(Infos[2].get());
+  NamespaceInfo ExpectedBWithFunction(EmptySID);
+  FunctionInfo F;
+  F.Name = "f";
+  F.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
+  F.DefLoc = Location(0, llvm::SmallString<16>("test.cpp"));
+  F.Namespace.emplace_back(EmptySID, "B", InfoType::IT_namespace);
+  

[clang-tools-extra] r344548 - added fix

2018-10-15 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Oct 15 12:59:52 2018
New Revision: 344548

URL: http://llvm.org/viewvc/llvm-project?rev=344548=rev
Log:
added fix

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=344548=344547=344548=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Mon Oct 15 12:59:52 2018
@@ -60,6 +60,47 @@ static StringRef getValueOfValueInit(con
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+  case Type::STK_FixedPoint:
+switch (InitType->getAs()->getKind()) {
+  case BuiltinType::ShortAccum:
+  case BuiltinType::SatShortAccum:
+return "0.0hk";
+  case BuiltinType::Accum:
+  case BuiltinType::SatAccum:
+return "0.0k";
+  case BuiltinType::LongAccum:
+  case BuiltinType::SatLongAccum:
+return "0.0lk";
+  case BuiltinType::UShortAccum:
+  case BuiltinType::SatUShortAccum:
+return "0.0uhk";
+  case BuiltinType::UAccum:
+  case BuiltinType::SatUAccum:
+return "0.0uk";
+  case BuiltinType::ULongAccum:
+  case BuiltinType::SatULongAccum:
+return "0.0ulk";
+  case BuiltinType::ShortFract:
+  case BuiltinType::SatShortFract:
+return "0.0hr";
+  case BuiltinType::Fract:
+  case BuiltinType::SatFract:
+return "0.0r";
+  case BuiltinType::LongFract:
+  case BuiltinType::SatLongFract:
+return "0.0lr";
+  case BuiltinType::UShortFract:
+  case BuiltinType::SatUShortFract:
+return "0.0uhr";
+  case BuiltinType::UFract:
+  case BuiltinType::SatUFract:
+return "0.0ur";
+  case BuiltinType::ULongFract:
+  case BuiltinType::SatULongFract:
+return "0.0ulr";
+  default:
+llvm_unreachable("Unhandled fixed point BuiltinType");
+}
   }
   llvm_unreachable("Invalid scalar type kind");
 }


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


[PATCH] D53299: [Fixed Point Arithmetic] Fix for clang-tools-extra warning

2018-10-15 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE344549: [Fixed Point Arithmetic] Fix for clang-tools-extra 
warning (authored by leonardchan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53299?vs=169741=169745#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53299

Files:
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp


Index: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -60,46 +60,47 @@
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+
   case Type::STK_FixedPoint:
 switch (InitType->getAs()->getKind()) {
-  case BuiltinType::ShortAccum:
-  case BuiltinType::SatShortAccum:
-return "0.0hk";
-  case BuiltinType::Accum:
-  case BuiltinType::SatAccum:
-return "0.0k";
-  case BuiltinType::LongAccum:
-  case BuiltinType::SatLongAccum:
-return "0.0lk";
-  case BuiltinType::UShortAccum:
-  case BuiltinType::SatUShortAccum:
-return "0.0uhk";
-  case BuiltinType::UAccum:
-  case BuiltinType::SatUAccum:
-return "0.0uk";
-  case BuiltinType::ULongAccum:
-  case BuiltinType::SatULongAccum:
-return "0.0ulk";
-  case BuiltinType::ShortFract:
-  case BuiltinType::SatShortFract:
-return "0.0hr";
-  case BuiltinType::Fract:
-  case BuiltinType::SatFract:
-return "0.0r";
-  case BuiltinType::LongFract:
-  case BuiltinType::SatLongFract:
-return "0.0lr";
-  case BuiltinType::UShortFract:
-  case BuiltinType::SatUShortFract:
-return "0.0uhr";
-  case BuiltinType::UFract:
-  case BuiltinType::SatUFract:
-return "0.0ur";
-  case BuiltinType::ULongFract:
-  case BuiltinType::SatULongFract:
-return "0.0ulr";
-  default:
-llvm_unreachable("Unhandled fixed point BuiltinType");
+case BuiltinType::ShortAccum:
+case BuiltinType::SatShortAccum:
+  return "0.0hk";
+case BuiltinType::Accum:
+case BuiltinType::SatAccum:
+  return "0.0k";
+case BuiltinType::LongAccum:
+case BuiltinType::SatLongAccum:
+  return "0.0lk";
+case BuiltinType::UShortAccum:
+case BuiltinType::SatUShortAccum:
+  return "0.0uhk";
+case BuiltinType::UAccum:
+case BuiltinType::SatUAccum:
+  return "0.0uk";
+case BuiltinType::ULongAccum:
+case BuiltinType::SatULongAccum:
+  return "0.0ulk";
+case BuiltinType::ShortFract:
+case BuiltinType::SatShortFract:
+  return "0.0hr";
+case BuiltinType::Fract:
+case BuiltinType::SatFract:
+  return "0.0r";
+case BuiltinType::LongFract:
+case BuiltinType::SatLongFract:
+  return "0.0lr";
+case BuiltinType::UShortFract:
+case BuiltinType::SatUShortFract:
+  return "0.0uhr";
+case BuiltinType::UFract:
+case BuiltinType::SatUFract:
+  return "0.0ur";
+case BuiltinType::ULongFract:
+case BuiltinType::SatULongFract:
+  return "0.0ulr";
+default:
+  llvm_unreachable("Unhandled fixed point BuiltinType");
 }
   }
   llvm_unreachable("Invalid scalar type kind");


Index: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -60,46 +60,47 @@
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+
   case Type::STK_FixedPoint:
 switch (InitType->getAs()->getKind()) {
-  case BuiltinType::ShortAccum:
-  case BuiltinType::SatShortAccum:
-return "0.0hk";
-  case BuiltinType::Accum:
-  case BuiltinType::SatAccum:
-return "0.0k";
-  case BuiltinType::LongAccum:
-  case BuiltinType::SatLongAccum:
-return "0.0lk";
-  case BuiltinType::UShortAccum:
-  case BuiltinType::SatUShortAccum:
-return "0.0uhk";
-  case BuiltinType::UAccum:
-  case BuiltinType::SatUAccum:
-return "0.0uk";
-  case BuiltinType::ULongAccum:
-  case BuiltinType::SatULongAccum:
-return "0.0ulk";
-  case BuiltinType::ShortFract:
-  case BuiltinType::SatShortFract:
-return "0.0hr";
-  case BuiltinType::Fract:
-  case BuiltinType::SatFract:
-return "0.0r";
-  case BuiltinType::LongFract:
-  case BuiltinType::SatLongFract:
-return "0.0lr";
-  case BuiltinType::UShortFract:
-  case BuiltinType::SatUShortFract:
-return "0.0uhr";
-  case BuiltinType::UFract:
-  case BuiltinType::SatUFract:
-return "0.0ur";
-  case BuiltinType::ULongFract:
-  case 

[clang-tools-extra] r344549 - [Fixed Point Arithmetic] Fix for clang-tools-extra warning

2018-10-15 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Oct 15 13:00:03 2018
New Revision: 344549

URL: http://llvm.org/viewvc/llvm-project?rev=344549=rev
Log:
[Fixed Point Arithmetic] Fix for clang-tools-extra warning

Fix for warnings generated on unhandled enum value `STK_FixedPoint`.

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=344549=344548=344549=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Mon Oct 15 13:00:03 2018
@@ -60,46 +60,47 @@ static StringRef getValueOfValueInit(con
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+
   case Type::STK_FixedPoint:
 switch (InitType->getAs()->getKind()) {
-  case BuiltinType::ShortAccum:
-  case BuiltinType::SatShortAccum:
-return "0.0hk";
-  case BuiltinType::Accum:
-  case BuiltinType::SatAccum:
-return "0.0k";
-  case BuiltinType::LongAccum:
-  case BuiltinType::SatLongAccum:
-return "0.0lk";
-  case BuiltinType::UShortAccum:
-  case BuiltinType::SatUShortAccum:
-return "0.0uhk";
-  case BuiltinType::UAccum:
-  case BuiltinType::SatUAccum:
-return "0.0uk";
-  case BuiltinType::ULongAccum:
-  case BuiltinType::SatULongAccum:
-return "0.0ulk";
-  case BuiltinType::ShortFract:
-  case BuiltinType::SatShortFract:
-return "0.0hr";
-  case BuiltinType::Fract:
-  case BuiltinType::SatFract:
-return "0.0r";
-  case BuiltinType::LongFract:
-  case BuiltinType::SatLongFract:
-return "0.0lr";
-  case BuiltinType::UShortFract:
-  case BuiltinType::SatUShortFract:
-return "0.0uhr";
-  case BuiltinType::UFract:
-  case BuiltinType::SatUFract:
-return "0.0ur";
-  case BuiltinType::ULongFract:
-  case BuiltinType::SatULongFract:
-return "0.0ulr";
-  default:
-llvm_unreachable("Unhandled fixed point BuiltinType");
+case BuiltinType::ShortAccum:
+case BuiltinType::SatShortAccum:
+  return "0.0hk";
+case BuiltinType::Accum:
+case BuiltinType::SatAccum:
+  return "0.0k";
+case BuiltinType::LongAccum:
+case BuiltinType::SatLongAccum:
+  return "0.0lk";
+case BuiltinType::UShortAccum:
+case BuiltinType::SatUShortAccum:
+  return "0.0uhk";
+case BuiltinType::UAccum:
+case BuiltinType::SatUAccum:
+  return "0.0uk";
+case BuiltinType::ULongAccum:
+case BuiltinType::SatULongAccum:
+  return "0.0ulk";
+case BuiltinType::ShortFract:
+case BuiltinType::SatShortFract:
+  return "0.0hr";
+case BuiltinType::Fract:
+case BuiltinType::SatFract:
+  return "0.0r";
+case BuiltinType::LongFract:
+case BuiltinType::SatLongFract:
+  return "0.0lr";
+case BuiltinType::UShortFract:
+case BuiltinType::SatUShortFract:
+  return "0.0uhr";
+case BuiltinType::UFract:
+case BuiltinType::SatUFract:
+  return "0.0ur";
+case BuiltinType::ULongFract:
+case BuiltinType::SatULongFract:
+  return "0.0ulr";
+default:
+  llvm_unreachable("Unhandled fixed point BuiltinType");
 }
   }
   llvm_unreachable("Invalid scalar type kind");


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


[PATCH] D53299: [Fixed Point Arithmetic] Fix for clang-tools-extra warning

2018-10-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 169741.
leonardchan marked 2 inline comments as done.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53299

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp


Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -60,6 +60,48 @@
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+
+  case Type::STK_FixedPoint:
+switch (InitType->getAs()->getKind()) {
+case BuiltinType::ShortAccum:
+case BuiltinType::SatShortAccum:
+  return "0.0hk";
+case BuiltinType::Accum:
+case BuiltinType::SatAccum:
+  return "0.0k";
+case BuiltinType::LongAccum:
+case BuiltinType::SatLongAccum:
+  return "0.0lk";
+case BuiltinType::UShortAccum:
+case BuiltinType::SatUShortAccum:
+  return "0.0uhk";
+case BuiltinType::UAccum:
+case BuiltinType::SatUAccum:
+  return "0.0uk";
+case BuiltinType::ULongAccum:
+case BuiltinType::SatULongAccum:
+  return "0.0ulk";
+case BuiltinType::ShortFract:
+case BuiltinType::SatShortFract:
+  return "0.0hr";
+case BuiltinType::Fract:
+case BuiltinType::SatFract:
+  return "0.0r";
+case BuiltinType::LongFract:
+case BuiltinType::SatLongFract:
+  return "0.0lr";
+case BuiltinType::UShortFract:
+case BuiltinType::SatUShortFract:
+  return "0.0uhr";
+case BuiltinType::UFract:
+case BuiltinType::SatUFract:
+  return "0.0ur";
+case BuiltinType::ULongFract:
+case BuiltinType::SatULongFract:
+  return "0.0ulr";
+default:
+  llvm_unreachable("Unhandled fixed point BuiltinType");
+}
   }
   llvm_unreachable("Invalid scalar type kind");
 }


Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -60,6 +60,48 @@
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+
+  case Type::STK_FixedPoint:
+switch (InitType->getAs()->getKind()) {
+case BuiltinType::ShortAccum:
+case BuiltinType::SatShortAccum:
+  return "0.0hk";
+case BuiltinType::Accum:
+case BuiltinType::SatAccum:
+  return "0.0k";
+case BuiltinType::LongAccum:
+case BuiltinType::SatLongAccum:
+  return "0.0lk";
+case BuiltinType::UShortAccum:
+case BuiltinType::SatUShortAccum:
+  return "0.0uhk";
+case BuiltinType::UAccum:
+case BuiltinType::SatUAccum:
+  return "0.0uk";
+case BuiltinType::ULongAccum:
+case BuiltinType::SatULongAccum:
+  return "0.0ulk";
+case BuiltinType::ShortFract:
+case BuiltinType::SatShortFract:
+  return "0.0hr";
+case BuiltinType::Fract:
+case BuiltinType::SatFract:
+  return "0.0r";
+case BuiltinType::LongFract:
+case BuiltinType::SatLongFract:
+  return "0.0lr";
+case BuiltinType::UShortFract:
+case BuiltinType::SatUShortFract:
+  return "0.0uhr";
+case BuiltinType::UFract:
+case BuiltinType::SatUFract:
+  return "0.0ur";
+case BuiltinType::ULongFract:
+case BuiltinType::SatULongFract:
+  return "0.0ulr";
+default:
+  llvm_unreachable("Unhandled fixed point BuiltinType");
+}
   }
   llvm_unreachable("Invalid scalar type kind");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53299: [Fixed Point Arithmetic] Fix for clang-tools-extra warning

2018-10-15 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope accepted this revision.
bjope added a comment.
This revision is now accepted and ready to land.

Just some inline nit:s about whitespace.

LGTM, apart from that!




Comment at: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:63
 InitType->getAs()->getElementType());
+  case Type::STK_FixedPoint:
+switch (InitType->getAs()->getKind()) {

nit: I'd add an extra line break before this line (just to follow the earlier 
style where it seems like cases are put in different groups in this switch).



Comment at: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:65
+switch (InitType->getAs()->getKind()) {
+  case BuiltinType::ShortAccum:
+  case BuiltinType::SatShortAccum:

Indents: I think case should be aligned with the switch.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53299



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


[PATCH] D53210: Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE""

2018-10-15 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I think this is now breaking:
lld :: ELF/format-binary.test
lld :: ELF/relocatable-versioned.s


Repository:
  rC Clang

https://reviews.llvm.org/D53210



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


[PATCH] D53299: [Fixed Point Arithmetic]

2018-10-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a reviewer: bjope.
leonardchan added a project: clang-tools-extra.

Fix for warnings generated on unhandled enum value `STK_FixedPoint`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53299

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp


Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -60,6 +60,47 @@
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+  case Type::STK_FixedPoint:
+switch (InitType->getAs()->getKind()) {
+  case BuiltinType::ShortAccum:
+  case BuiltinType::SatShortAccum:
+return "0.0hk";
+  case BuiltinType::Accum:
+  case BuiltinType::SatAccum:
+return "0.0k";
+  case BuiltinType::LongAccum:
+  case BuiltinType::SatLongAccum:
+return "0.0lk";
+  case BuiltinType::UShortAccum:
+  case BuiltinType::SatUShortAccum:
+return "0.0uhk";
+  case BuiltinType::UAccum:
+  case BuiltinType::SatUAccum:
+return "0.0uk";
+  case BuiltinType::ULongAccum:
+  case BuiltinType::SatULongAccum:
+return "0.0ulk";
+  case BuiltinType::ShortFract:
+  case BuiltinType::SatShortFract:
+return "0.0hr";
+  case BuiltinType::Fract:
+  case BuiltinType::SatFract:
+return "0.0r";
+  case BuiltinType::LongFract:
+  case BuiltinType::SatLongFract:
+return "0.0lr";
+  case BuiltinType::UShortFract:
+  case BuiltinType::SatUShortFract:
+return "0.0uhr";
+  case BuiltinType::UFract:
+  case BuiltinType::SatUFract:
+return "0.0ur";
+  case BuiltinType::ULongFract:
+  case BuiltinType::SatULongFract:
+return "0.0ulr";
+  default:
+llvm_unreachable("Unhandled fixed point BuiltinType");
+}
   }
   llvm_unreachable("Invalid scalar type kind");
 }


Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -60,6 +60,47 @@
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
 InitType->getAs()->getElementType());
+  case Type::STK_FixedPoint:
+switch (InitType->getAs()->getKind()) {
+  case BuiltinType::ShortAccum:
+  case BuiltinType::SatShortAccum:
+return "0.0hk";
+  case BuiltinType::Accum:
+  case BuiltinType::SatAccum:
+return "0.0k";
+  case BuiltinType::LongAccum:
+  case BuiltinType::SatLongAccum:
+return "0.0lk";
+  case BuiltinType::UShortAccum:
+  case BuiltinType::SatUShortAccum:
+return "0.0uhk";
+  case BuiltinType::UAccum:
+  case BuiltinType::SatUAccum:
+return "0.0uk";
+  case BuiltinType::ULongAccum:
+  case BuiltinType::SatULongAccum:
+return "0.0ulk";
+  case BuiltinType::ShortFract:
+  case BuiltinType::SatShortFract:
+return "0.0hr";
+  case BuiltinType::Fract:
+  case BuiltinType::SatFract:
+return "0.0r";
+  case BuiltinType::LongFract:
+  case BuiltinType::SatLongFract:
+return "0.0lr";
+  case BuiltinType::UShortFract:
+  case BuiltinType::SatUShortFract:
+return "0.0uhr";
+  case BuiltinType::UFract:
+  case BuiltinType::SatUFract:
+return "0.0ur";
+  case BuiltinType::ULongFract:
+  case BuiltinType::SatULongFract:
+return "0.0ulr";
+  default:
+llvm_unreachable("Unhandled fixed point BuiltinType");
+}
   }
   llvm_unreachable("Invalid scalar type kind");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53295: [OpenCL] Mark load of block invoke function as invariant

2018-10-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1318
+CGM.getModule().getMDKindID("invariant.load"),
+llvm::MDNode::get(getLLVMContext(), None));
+

OpenCL blocks are still potentially function-local, right?  I don't think 
you're allowed to put `invariant.load` on something that's visibly initialized, 
even if it's visibly initialized to the same thing every time.  The problem is 
that `invariant.load` could allow the load to be hoisted above the 
initialization.

If you can solve that problem, you can make this non-OpenCL-specific.


https://reviews.llvm.org/D53295



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


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In https://reviews.llvm.org/D52840#1265615, @mgorny wrote:

> The first one seems to indicate that your `libclang.so` is broken in release 
> mode (optimization error?). The second one is correct (some of the tests test 
> for errors, and apparently don't silence the messages).


Ok, thanks for the clarification on the second point.

As to the first issue, it turned out to be more complicated.  The wrong value 
results from this call in CursorVisitor::Visit

  switch (Visitor(Cursor, Parent, ClientData)) {

This is a callback routine passed in from the caller, which in the case of the 
Python bindings means that an FFI closure is being called.

Now, due to a historical quirk in the FFI ABI, return values of integral type 
smaller than the register word size must be passed as the special "ffi_arg" 
type when using FFI (either for calls or for closures).  It seems the Python 
2.7 code that interfaces with FFI does not correctly respect this.  As a 
result, it seems that when the closure returns a 32-bit value, it is not 
properly extended and the high bits of the return register contain garbage.

But that violates our ABI, which requires extension to full register size.   
And it seems the clang code, when built with optimization, does indeed rely on 
that ABI guarantee.

So there's a bug in Python (or depending on how you want to look at it, in 
libffi -- that part of the interface has also long been under-documented 
unfortunately), which hits on our platform.  I'll see if I can do anything 
about that, but for now we'll probably want to disable those tests on SystemZ.


Repository:
  rC Clang

https://reviews.llvm.org/D52840



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


[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, MTC, rnkovacs.
Herald added subscribers: cfe-commits, donat.nagy, mikhail.ramalho, dmgreen, 
a.sidorin, mgrang, szepet, whisperity.

Title says it all, here's how it look like locally:

  OVERVIEW: Clang Static Analyzer -analyzer-config Option List
  
  USAGE: clang [CLANG_OPTIONS] -analyzer-config 

  
 clang [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, -analyzer-config 
OPTION2=VALUE, ...
  
  OPTIONS:
  
aggressive-binary-operation-simplification
  (bool) Whether SValBuilder should 
rearrange
  comparisons and additive operations of
  symbolic expressions which consist of a 
sum
  of a symbol and a concrete integer into 
the
  format where symbols are on the left-hand
  side and the integer is on the right. 
This is
  only done if both symbols and both 
concrete
  integers are signed, greater than or 
equal to
  the quarter of the minimum value of the 
type
  and less than or equal to the quarter of 
the
  maximum value of that type. A + n  B 
+ m
  becomes A - B  m - n, where A and B
  symbolic, n and m are integers.  is 
any
  of '==', '!=', '<', '<=', '>', '>=', '+' 
or
  '-'. The rearrangement also happens with 
'-'
  instead of '+' on either or both side and
  also if any or both integers are missing.
  (default: false)
  
avoid-suppressing-null-argument-paths
  (bool) Whether a bug report should not be
  suppressed if its path includes a call 
with a
  null argument, even if that call has a 
null
  return. This option has no effect when
  #shouldSuppressNullReturnPaths() is false.
  This is a counter-heuristic to avoid false
  negatives. (default: false)
  
c++-allocator-inlining(bool) Whether or not allocator call may 
be
  considered for inlining. (default: true)
  
c++-container-inlining(bool) Whether or not methods of C++
  container objects may be considered for
  inlining. (default: false)
  
c++-inlining  (string) Controls which C++ member 
functions
  will be considered for inlining. Value:
  "constructors", "destructors" (default),
  "methods".
  
c++-shared_ptr-inlining   (bool) Whether or not the destructor of 
C++
  'shared_ptr' may be considered for 
inlining.
  This covers std::shared_ptr,
  std::tr1::shared_ptr, and 
boost::shared_ptr,
  and indeed any destructor named
  '~shared_ptr'. (default: false)
  
c++-stdlib-inlining   (bool) Whether or not C++ standard library
  functions may be considered for inlining.
  (default: true)
  
c++-temp-dtor-inlining(bool) Whether C++ temporary destructors
  should be inlined during analysis. If
  temporary destructors are disabled in the 
CFG
  via the 'cfg-temporary-dtors' option,
  temporary destructors would not be inlined
  anyway. (default: true)
  
c++-template-inlining (bool) Whether or not templated functions 
may
  be considered for inlining.
  
cfg-conditional-static-initializers
  (bool) Whether 'static' initializers 
should
  be in conditional logic in the CFG. 
(default:
  true)
  
cfg-implicit-dtors(bool) Whether or not implicit destructors
  for C++ objects should be included in the
   

[PATCH] D53274: [analyzer][NFC] Fix inconsistencies in AnalyzerOptions

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

In https://reviews.llvm.org/D53274#1265625, @george.karpenkov wrote:

> I'm not sure why you could get away with removing those llvm_unreachable 
> cases?


Because I got a warning for using `default` when every enum value was handled 
in the switch. Since whether the flag is set or not can be retrieved via 
`llvm::Optional::hasValue()`, I removed the `.*NotSet` flags. The future 
maintainer who adds a new value will get a warning for not handling it anyways.

In https://reviews.llvm.org/D53274#1265618, @george.karpenkov wrote:

> > The main motivation behind here is to emit warnings if an invalid
>
> I'm totally with you here, but IIRC (@NoQ might want to correct me here),
>  the design decision was made specifically to ignore incorrect options, so 
> that e.g. old versions of Xcode used with old projects would still work.


I intend to emit a warning, but go on with the analysis. That's fair I believe?


https://reviews.llvm.org/D53274



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


[PATCH] D53277: [analyzer][NFC] Collect all -analyzer-config options in a .def file

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 169731.
Szelethus retitled this revision from "[analyzer][NFC][WIP] Collect all 
-analyzer-config options in a .def file" to "[analyzer][NFC] Collect all 
-analyzer-config options in a .def file".
Szelethus edited the summary of this revision.
Szelethus added a comment.

Added descriptions.


https://reviews.llvm.org/D53277

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -56,17 +56,17 @@
 static std::unique_ptr generateWorkList(AnalyzerOptions ,
   SubEngine ) {
   switch (Opts.getExplorationStrategy()) {
-case AnalyzerOptions::ExplorationStrategyKind::DFS:
+case ExplorationStrategyKind::DFS:
   return WorkList::makeDFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFS:
+case ExplorationStrategyKind::BFS:
   return WorkList::makeBFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFSBlockDFSContents:
+case ExplorationStrategyKind::BFSBlockDFSContents:
   return WorkList::makeBFSBlockDFSContents();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirst:
+case ExplorationStrategyKind::UnexploredFirst:
   return WorkList::makeUnexploredFirst();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstQueue:
+case ExplorationStrategyKind::UnexploredFirstQueue:
   return WorkList::makeUnexploredFirstPriorityQueue();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstLocationQueue:
+case ExplorationStrategyKind::UnexploredFirstLocationQueue:
   return WorkList::makeUnexploredFirstPriorityLocationQueue();
   }
 }
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -49,7 +49,7 @@
   return Result;
 }
 
-AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
+UserModeKind AnalyzerOptions::getUserMode() {
   if (!UserMode.hasValue()) {
 StringRef ModeStr = getOptionAsString("mode", "deep");
 UserMode = llvm::StringSwitch>(ModeStr)
@@ -61,7 +61,7 @@
   return UserMode.getValue();
 }
 
-AnalyzerOptions::ExplorationStrategyKind
+ExplorationStrategyKind
 AnalyzerOptions::getExplorationStrategy() {
   if (!ExplorationStrategy.hasValue()) {
 StringRef StratStr = getOptionAsString("exploration_strategy",
@@ -182,137 +182,6 @@
   return V.getValue();
 }
 
-bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
-  return getBooleanOption(IncludeTemporaryDtorsInCFG,
-  "cfg-temporary-dtors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeImplicitDtorsInCFG() {
-  return getBooleanOption(IncludeImplicitDtorsInCFG,
-  "cfg-implicit-dtors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeLifetimeInCFG() {
-  return getBooleanOption(IncludeLifetimeInCFG, "cfg-lifetime",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::includeLoopExitInCFG() {
-  return getBooleanOption(IncludeLoopExitInCFG, "cfg-loopexit",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::includeRichConstructorsInCFG() {
-  return getBooleanOption(IncludeRichConstructorsInCFG,
-  "cfg-rich-constructors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeScopesInCFG() {
-  return getBooleanOption(IncludeScopesInCFG,
-  "cfg-scopes",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::mayInlineCXXStandardLibrary() {
-  return getBooleanOption(InlineCXXStandardLibrary,
-  "c++-stdlib-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineTemplateFunctions() {
-  return getBooleanOption(InlineTemplateFunctions,
-  "c++-template-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineCXXAllocator() {
-  return getBooleanOption(InlineCXXAllocator,
-  "c++-allocator-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineCXXContainerMethods() {
-  return getBooleanOption(InlineCXXContainerMethods,
-  "c++-container-inlining",
-  /*Default=*/false);
-}
-
-bool AnalyzerOptions::mayInlineCXXSharedPtrDtor() {
-  return getBooleanOption(InlineCXXSharedPtrDtor,
-  "c++-shared_ptr-inlining",
-  

[PATCH] D52784: [ARM][AArch64] Pass through endianness flags to the GNU assembler and linker

2018-10-15 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for this patch.  With it I was able to link+boot a BE aarch64 Linux 
kernel (and a LE aarch64 Linux kernel).




Comment at: lib/Driver/ToolChains/Gnu.cpp:268
   case llvm::Triple::thumbeb:
-return "armelfb_linux_eabi";
+return (isArmBigEndian(T, Args)) ? "armelfb_linux_eabi"
+ : "armelf_linux_eabi";

probably don't need the parens around `isArmBigEndian(...)`.


https://reviews.llvm.org/D52784



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


[PATCH] D53295: [OpenCL] Mark load of block invoke function as invariant

2018-10-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, Anastasia.

  OpenCL v2.0 s6.12.5:
Block variable declarations are implicitly qualified with const.
  Therefore all block variables must be initialized at declaration time and
  may not be reassigned.
  
  As such, load of block invoke function can be marked as invariant. This is
  to facilitate lowering of indirect function calls resulted from it to
  direct function calls since OpenCL does not require supporting of function
  pointer.


https://reviews.llvm.org/D53295

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenOpenCL/blocks.cl


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -98,6 +98,19 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}} @blockInLoopCondition
+// COMMON: %[[INV:.*]] = getelementptr {{.*}}%block.literal, i32 0, i32 2
+// COMMON: load {{.*}}%[[INV]]{{.*}}, !invariant.load
+void blockInLoopCondition(int* res, int tid, int multiplier) {
+  int (^kernelBlock)(int) = ^(int num) {
+return num * multiplier;
+  };
+  res[tid] = 39;
+  for(int i=0; i(Func)->setMetadata(
+CGM.getModule().getMDKindID("invariant.load"),
+llvm::MDNode::get(getLLVMContext(), None));
+
   const FunctionType *FuncTy = FnType->castAs();
   const CGFunctionInfo  =
 CGM.getTypes().arrangeBlockFunctionCall(Args, FuncTy);


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -98,6 +98,19 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}} @blockInLoopCondition
+// COMMON: %[[INV:.*]] = getelementptr {{.*}}%block.literal, i32 0, i32 2
+// COMMON: load {{.*}}%[[INV]]{{.*}}, !invariant.load
+void blockInLoopCondition(int* res, int tid, int multiplier) {
+  int (^kernelBlock)(int) = ^(int num) {
+return num * multiplier;
+  };
+  res[tid] = 39;
+  for(int i=0; i(Func)->setMetadata(
+CGM.getModule().getMDKindID("invariant.load"),
+llvm::MDNode::get(getLLVMContext(), None));
+
   const FunctionType *FuncTy = FnType->castAs();
   const CGFunctionInfo  =
 CGM.getTypes().arrangeBlockFunctionCall(Args, FuncTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52957: [analyzer] Teach CallEvent about C++17 aligned new.

2018-10-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Whoops, almost forgot to doxygen-ize comments. Landed in 
https://reviews.llvm.org/rC344540.


Repository:
  rL LLVM

https://reviews.llvm.org/D52957



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


r344540 - [analyzer] Add doxygen comments for the new CXXAllocatorCall APIs.

2018-10-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 15 11:01:34 2018
New Revision: 344540

URL: http://llvm.org/viewvc/llvm-project?rev=344540=rev
Log:
[analyzer] Add doxygen comments for the new CXXAllocatorCall APIs.

Forgot to squeeze this into r344539.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=344540=344539=344540=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Mon 
Oct 15 11:01:34 2018
@@ -921,11 +921,9 @@ public:
 return getOriginExpr()->getOperatorNew();
   }
 
-  // Size and maybe implicit alignment in C++17. Instead of size, the AST
-  // contains the construct-expression. Alignment is always hidden.
-  // We pretend that argument 0 is size and argument 1 is alignment (if passed
-  // implicitly) and the rest are placement args. This makes sure that the
-  // number of arguments is always the same as the number of parameters.
+  /// Number of non-placement arguments to the call. It is equal to 2 for
+  /// C++17 aligned operator new() calls that have alignment implicitly
+  /// passed as the second argument, and to 1 for other operator new() calls.
   unsigned getNumImplicitArgs() const {
 return getOriginExpr()->passAlignment() ? 2 : 1;
   }
@@ -941,6 +939,10 @@ public:
 return getOriginExpr()->getPlacementArg(Index - getNumImplicitArgs());
   }
 
+  /// Number of placement arguments to the operator new() call. For example,
+  /// standard std::nothrow operator new and standard placement new both have
+  /// 1 implicit argument (size) and 1 placement argument, while regular
+  /// operator new() has 1 implicit argument and 0 placement arguments.
   const Expr *getPlacementArgExpr(unsigned Index) const {
 return getOriginExpr()->getPlacementArg(Index);
   }


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


r344539 - [analyzer] Teach CallEvent about C++17 aligned operator new().

2018-10-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 15 10:53:18 2018
New Revision: 344539

URL: http://llvm.org/viewvc/llvm-project?rev=344539=rev
Log:
[analyzer] Teach CallEvent about C++17 aligned operator new().

In C++17, when class C has large alignment value, a special case of
overload resolution rule kicks in for expression new C that causes the aligned
version of operator new() to be called. The aligned new has two arguments:
size and alignment. However, the new-expression has only one "argument":
the construct-expression for C(). This causes a false positive in
core.CallAndMessage's check for matching number of arguments and number
of parameters.

Update CXXAllocatorCall, which is a CallEvent sub-class for operator new calls
within new-expressions, so that the number of arguments always matched
the number of parameters.

rdar://problem/44738501

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

Added:
cfe/trunk/test/Analysis/new-aligned.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=344539=344538=344539=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Mon 
Oct 15 10:53:18 2018
@@ -921,15 +921,28 @@ public:
 return getOriginExpr()->getOperatorNew();
   }
 
+  // Size and maybe implicit alignment in C++17. Instead of size, the AST
+  // contains the construct-expression. Alignment is always hidden.
+  // We pretend that argument 0 is size and argument 1 is alignment (if passed
+  // implicitly) and the rest are placement args. This makes sure that the
+  // number of arguments is always the same as the number of parameters.
+  unsigned getNumImplicitArgs() const {
+return getOriginExpr()->passAlignment() ? 2 : 1;
+  }
+
   unsigned getNumArgs() const override {
-return getOriginExpr()->getNumPlacementArgs() + 1;
+return getOriginExpr()->getNumPlacementArgs() + getNumImplicitArgs();
   }
 
   const Expr *getArgExpr(unsigned Index) const override {
 // The first argument of an allocator call is the size of the allocation.
-if (Index == 0)
+if (Index < getNumImplicitArgs())
   return nullptr;
-return getOriginExpr()->getPlacementArg(Index - 1);
+return getOriginExpr()->getPlacementArg(Index - getNumImplicitArgs());
+  }
+
+  const Expr *getPlacementArgExpr(unsigned Index) const {
+return getOriginExpr()->getPlacementArg(Index);
   }
 
   Kind getKind() const override { return CE_CXXAllocator; }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=344539=344538=344539=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Mon Oct 15 10:53:18 2018
@@ -503,10 +503,14 @@ static void addParameterValuesToBindings
 const ParmVarDecl *ParamDecl = *I;
 assert(ParamDecl && "Formal parameter has no decl?");
 
+// TODO: Support allocator calls.
 if (Call.getKind() != CE_CXXAllocator)
   if (Call.isArgumentConstructedDirectly(Idx))
 continue;
 
+// TODO: Allocators should receive the correct size and possibly alignment,
+// determined in compile-time but not represented as arg-expressions,
+// which makes getArgSVal() fail and return UnknownVal.
 SVal ArgVal = Call.getArgSVal(Idx);
 if (!ArgVal.isUnknown()) {
   Loc ParamLoc = SVB.makeLoc(MRMgr.getVarRegion(ParamDecl, CalleeCtx));

Added: cfe/trunk/test/Analysis/new-aligned.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/new-aligned.cpp?rev=344539=auto
==
--- cfe/trunk/test/Analysis/new-aligned.cpp (added)
+++ cfe/trunk/test/Analysis/new-aligned.cpp Mon Oct 15 10:53:18 2018
@@ -0,0 +1,14 @@
+//RUN: %clang_analyze_cc1 -std=c++17 -analyze -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+// Notice the weird alignment.
+struct alignas(1024) S {};
+
+void foo() {
+  // Operator new() here is the C++17 aligned new that takes two arguments:
+  // size and alignment. Size is passed implicitly as usual, and alignment
+  // is passed implicitly in a similar manner.
+  S *s = new S; // no-warning
+  delete s;
+}


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


[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options

2018-10-15 Thread Thiago Macieira via Phabricator via cfe-commits
thiagomacieira marked an inline comment as done.
thiagomacieira added inline comments.



Comment at: lib/Driver/Distro.cpp:148
+for (StringRef Line : Lines)
+  if (Version == Distro::UnknownDistro && Line.startswith("ID="))
+Version = llvm::StringSwitch(Line.substr(3))

I'm changing this so we can detect Clear-derived distributions.


https://reviews.llvm.org/D53125



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


[PATCH] D52957: [analyzer] Teach CallEvent about C++17 aligned new.

2018-10-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344539: [analyzer] Teach CallEvent about C++17 aligned 
operator new(). (authored by dergachev, committed by ).
Herald added subscribers: llvm-commits, donat.nagy.

Changed prior to commit:
  https://reviews.llvm.org/D52957?vs=168556=169726#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52957

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/test/Analysis/new-aligned.cpp


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -921,15 +921,28 @@
 return getOriginExpr()->getOperatorNew();
   }
 
+  // Size and maybe implicit alignment in C++17. Instead of size, the AST
+  // contains the construct-expression. Alignment is always hidden.
+  // We pretend that argument 0 is size and argument 1 is alignment (if passed
+  // implicitly) and the rest are placement args. This makes sure that the
+  // number of arguments is always the same as the number of parameters.
+  unsigned getNumImplicitArgs() const {
+return getOriginExpr()->passAlignment() ? 2 : 1;
+  }
+
   unsigned getNumArgs() const override {
-return getOriginExpr()->getNumPlacementArgs() + 1;
+return getOriginExpr()->getNumPlacementArgs() + getNumImplicitArgs();
   }
 
   const Expr *getArgExpr(unsigned Index) const override {
 // The first argument of an allocator call is the size of the allocation.
-if (Index == 0)
+if (Index < getNumImplicitArgs())
   return nullptr;
-return getOriginExpr()->getPlacementArg(Index - 1);
+return getOriginExpr()->getPlacementArg(Index - getNumImplicitArgs());
+  }
+
+  const Expr *getPlacementArgExpr(unsigned Index) const {
+return getOriginExpr()->getPlacementArg(Index);
   }
 
   Kind getKind() const override { return CE_CXXAllocator; }
Index: cfe/trunk/test/Analysis/new-aligned.cpp
===
--- cfe/trunk/test/Analysis/new-aligned.cpp
+++ cfe/trunk/test/Analysis/new-aligned.cpp
@@ -0,0 +1,14 @@
+//RUN: %clang_analyze_cc1 -std=c++17 -analyze -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+// Notice the weird alignment.
+struct alignas(1024) S {};
+
+void foo() {
+  // Operator new() here is the C++17 aligned new that takes two arguments:
+  // size and alignment. Size is passed implicitly as usual, and alignment
+  // is passed implicitly in a similar manner.
+  S *s = new S; // no-warning
+  delete s;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -503,10 +503,14 @@
 const ParmVarDecl *ParamDecl = *I;
 assert(ParamDecl && "Formal parameter has no decl?");
 
+// TODO: Support allocator calls.
 if (Call.getKind() != CE_CXXAllocator)
   if (Call.isArgumentConstructedDirectly(Idx))
 continue;
 
+// TODO: Allocators should receive the correct size and possibly alignment,
+// determined in compile-time but not represented as arg-expressions,
+// which makes getArgSVal() fail and return UnknownVal.
 SVal ArgVal = Call.getArgSVal(Idx);
 if (!ArgVal.isUnknown()) {
   Loc ParamLoc = SVB.makeLoc(MRMgr.getVarRegion(ParamDecl, CalleeCtx));


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -921,15 +921,28 @@
 return getOriginExpr()->getOperatorNew();
   }
 
+  // Size and maybe implicit alignment in C++17. Instead of size, the AST
+  // contains the construct-expression. Alignment is always hidden.
+  // We pretend that argument 0 is size and argument 1 is alignment (if passed
+  // implicitly) and the rest are placement args. This makes sure that the
+  // number of arguments is always the same as the number of parameters.
+  unsigned getNumImplicitArgs() const {
+return getOriginExpr()->passAlignment() ? 2 : 1;
+  }
+
   unsigned getNumArgs() const override {
-return getOriginExpr()->getNumPlacementArgs() + 1;
+return getOriginExpr()->getNumPlacementArgs() + getNumImplicitArgs();
   }
 
   const Expr *getArgExpr(unsigned Index) const override {
 // The first argument of an allocator call is the size of the allocation.
-if (Index == 0)
+if (Index < getNumImplicitArgs())
   return nullptr;
-return getOriginExpr()->getPlacementArg(Index - 1);
+return 

r344538 - [analyzer] NFC: RetainCountChecker: Don't dump() symbols into program point tags.

2018-10-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 15 10:47:56 2018
New Revision: 344538

URL: http://llvm.org/viewvc/llvm-project?rev=344538=rev
Log:
[analyzer] NFC: RetainCountChecker: Don't dump() symbols into program point 
tags.

We don't need a separate node for every symbol, because whenever the first
symbol leaks, a bug is emitted, the analysis is sinked, and the checker
callback immediately returns due to State variable turning into null,
so we never get to see the second leaking symbol.

Additionally, we are no longer able to break normal analysis while experimenting
with debug dumps.

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.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=344538=344537=344538=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Mon Oct 15 10:47:56 2018
@@ -1314,19 +1314,6 @@ void RetainCountChecker::checkEndFunctio
   processLeaks(state, Leaked, Ctx, Pred);
 }
 
-const ProgramPointTag *
-RetainCountChecker::getDeadSymbolTag(SymbolRef sym) const {
-  const CheckerProgramPointTag * = DeadSymbolTags[sym];
-  if (!tag) {
-SmallString<64> buf;
-llvm::raw_svector_ostream out(buf);
-out << "Dead Symbol : ";
-sym->dumpToStream(out);
-tag = new CheckerProgramPointTag(this, out.str());
-  }
-  return tag;
-}
-
 void RetainCountChecker::checkDeadSymbols(SymbolReaper ,
   CheckerContext ) const {
   ExplodedNode *Pred = C.getPredecessor();
@@ -1342,8 +1329,8 @@ void RetainCountChecker::checkDeadSymbol
 if (const RefVal *T = B.lookup(Sym)){
   // Use the symbol as the tag.
   // FIXME: This might not be as unique as we would like.
-  const ProgramPointTag *Tag = getDeadSymbolTag(Sym);
-  state = handleAutoreleaseCounts(state, Pred, Tag, C, Sym, *T);
+  static CheckerProgramPointTag Tag(this, "DeadSymbolAutorelease");
+  state = handleAutoreleaseCounts(state, Pred, , C, Sym, *T);
   if (!state)
 return;
 


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


[PATCH] D52804: [analyzer] NFC: RetainCountChecker: Avoid dumping symbols during normal operation.

2018-10-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344538: [analyzer] NFC: RetainCountChecker: Dont 
dump() symbols into program point… (authored by dergachev, committed by ).
Herald added a subscriber: donat.nagy.

Repository:
  rC Clang

https://reviews.llvm.org/D52804

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp


Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -1314,19 +1314,6 @@
   processLeaks(state, Leaked, Ctx, Pred);
 }
 
-const ProgramPointTag *
-RetainCountChecker::getDeadSymbolTag(SymbolRef sym) const {
-  const CheckerProgramPointTag * = DeadSymbolTags[sym];
-  if (!tag) {
-SmallString<64> buf;
-llvm::raw_svector_ostream out(buf);
-out << "Dead Symbol : ";
-sym->dumpToStream(out);
-tag = new CheckerProgramPointTag(this, out.str());
-  }
-  return tag;
-}
-
 void RetainCountChecker::checkDeadSymbols(SymbolReaper ,
   CheckerContext ) const {
   ExplodedNode *Pred = C.getPredecessor();
@@ -1342,8 +1329,8 @@
 if (const RefVal *T = B.lookup(Sym)){
   // Use the symbol as the tag.
   // FIXME: This might not be as unique as we would like.
-  const ProgramPointTag *Tag = getDeadSymbolTag(Sym);
-  state = handleAutoreleaseCounts(state, Pred, Tag, C, Sym, *T);
+  static CheckerProgramPointTag Tag(this, "DeadSymbolAutorelease");
+  state = handleAutoreleaseCounts(state, Pred, , C, Sym, *T);
   if (!state)
 return;
 


Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -1314,19 +1314,6 @@
   processLeaks(state, Leaked, Ctx, Pred);
 }
 
-const ProgramPointTag *
-RetainCountChecker::getDeadSymbolTag(SymbolRef sym) const {
-  const CheckerProgramPointTag * = DeadSymbolTags[sym];
-  if (!tag) {
-SmallString<64> buf;
-llvm::raw_svector_ostream out(buf);
-out << "Dead Symbol : ";
-sym->dumpToStream(out);
-tag = new CheckerProgramPointTag(this, out.str());
-  }
-  return tag;
-}
-
 void RetainCountChecker::checkDeadSymbols(SymbolReaper ,
   CheckerContext ) const {
   ExplodedNode *Pred = C.getPredecessor();
@@ -1342,8 +1329,8 @@
 if (const RefVal *T = B.lookup(Sym)){
   // Use the symbol as the tag.
   // FIXME: This might not be as unique as we would like.
-  const ProgramPointTag *Tag = getDeadSymbolTag(Sym);
-  state = handleAutoreleaseCounts(state, Pred, Tag, C, Sym, *T);
+  static CheckerProgramPointTag Tag(this, "DeadSymbolAutorelease");
+  state = handleAutoreleaseCounts(state, Pred, , C, Sym, *T);
   if (!state)
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53274: [analyzer][NFC] Fix inconsistencies in AnalyzerOptions

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

I'm not sure why you could get away with removing those llvm_unreachable cases?




Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:373
-  default:
-llvm_unreachable("Invalid mode.");
   case UMK_Shallow:

Why?



Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:418
-  default:
-llvm_unreachable("Invalid mode.");
   case UMK_Shallow:

Why?



Comment at: lib/StaticAnalyzer/Core/CoreEngine.cpp:72
-default:
-  llvm_unreachable("Unexpected case");
   }

Why?


https://reviews.llvm.org/D53274



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


[PATCH] D53239: [python] [tests] Disable python binding tests when building with LLVM_USE_SANITIZER=Address

2018-10-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344537: [python] [tests] Disable python binding tests under 
LLVM_USE_SANITIZER=Address (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53239?vs=169535=169724#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53239

Files:
  cfe/trunk/bindings/python/tests/CMakeLists.txt


Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -7,9 +7,24 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
+# Check if we are building with ASan
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if (LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(LLVM_USE_ASAN FALSE)
+else()
+  set(LLVM_USE_ASAN TRUE)
+endif()
+
 # Tests fail on Windows, and need someone knowledgeable to fix.
 # It's not clear whether it's a test or a valid binding problem.
-if(NOT WIN32)
+#
+# Do not try to run if libclang was built with ASan because
+# the sanitizer library will likely be loaded too late to perform
+# interception and will then fail.
+# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
+# portable so its easier just to not run the tests when building
+# with ASan.
+if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()


Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -7,9 +7,24 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
+# Check if we are building with ASan
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if (LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(LLVM_USE_ASAN FALSE)
+else()
+  set(LLVM_USE_ASAN TRUE)
+endif()
+
 # Tests fail on Windows, and need someone knowledgeable to fix.
 # It's not clear whether it's a test or a valid binding problem.
-if(NOT WIN32)
+#
+# Do not try to run if libclang was built with ASan because
+# the sanitizer library will likely be loaded too late to perform
+# interception and will then fail.
+# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
+# portable so its easier just to not run the tests when building
+# with ASan.
+if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r344537 - [python] [tests] Disable python binding tests under LLVM_USE_SANITIZER=Address

2018-10-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 15 10:43:23 2018
New Revision: 344537

URL: http://llvm.org/viewvc/llvm-project?rev=344537=rev
Log:
[python] [tests] Disable python binding tests under LLVM_USE_SANITIZER=Address

They don't work yet.

Patch by Dan Liew!

rdar://problem/45242886

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

Modified:
cfe/trunk/bindings/python/tests/CMakeLists.txt

Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344537=344536=344537=diff
==
--- cfe/trunk/bindings/python/tests/CMakeLists.txt (original)
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt Mon Oct 15 10:43:23 2018
@@ -7,9 +7,24 @@ add_custom_target(check-clang-python
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
+# Check if we are building with ASan
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if (LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(LLVM_USE_ASAN FALSE)
+else()
+  set(LLVM_USE_ASAN TRUE)
+endif()
+
 # Tests fail on Windows, and need someone knowledgeable to fix.
 # It's not clear whether it's a test or a valid binding problem.
-if(NOT WIN32)
+#
+# Do not try to run if libclang was built with ASan because
+# the sanitizer library will likely be loaded too late to perform
+# interception and will then fail.
+# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
+# portable so its easier just to not run the tests when building
+# with ASan.
+if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()


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


[PATCH] D53274: [analyzer][NFC] Fix inconsistencies in AnalyzerOptions

2018-10-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> The main motivation behind here is to emit warnings if an invalid

I'm totally with you here, but IIRC (@NoQ might want to correct me here),
the design decision was made specifically to ignore incorrect options, so that 
e.g. old versions of Xcode used with old projects would still work.


https://reviews.llvm.org/D53274



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


[PATCH] D53210: Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE""

2018-10-15 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344536: Revert 344389 Revert r344375 [Driver] 
check for exit code from SIGPIPE (authored by nickdesaulniers, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53210?vs=169474=169723#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53210

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -81,6 +81,7 @@
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
+#include  // EX_IOERR
 #endif
 
 using namespace clang::driver;
@@ -1388,20 +1389,30 @@
 
   // Otherwise, remove result files and print extra information about abnormal
   // failures.
+  int Res = 0;
   for (const auto  : FailingCommands) {
-int Res = CmdPair.first;
+int CommandRes = CmdPair.first;
 const Command *FailingCommand = CmdPair.second;
 
 // Remove result files if we're not saving temps.
 if (!isSaveTempsEnabled()) {
   const JobAction *JA = cast(>getSource());
   C.CleanupFileMap(C.getResultFiles(), JA, true);
 
   // Failure result files are valid unless we crashed.
-  if (Res < 0)
+  if (CommandRes < 0)
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+#if LLVM_ON_UNIX
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (CommandRes == EX_IOERR) {
+  Res = CommandRes;
+  continue;
+}
+#endif
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
@@ -1411,17 +1422,17 @@
 // diagnostics, so always print the diagnostic there.
 const Tool  = FailingCommand->getCreator();
 
-if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) {
+if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) 
{
   // FIXME: See FIXME above regarding result code interpretation.
-  if (Res < 0)
+  if (CommandRes < 0)
 Diag(clang::diag::err_drv_command_signalled)
 << FailingTool.getShortName();
   else
-Diag(clang::diag::err_drv_command_failed) << FailingTool.getShortName()
-  << Res;
+Diag(clang::diag::err_drv_command_failed)
+<< FailingTool.getShortName() << CommandRes;
 }
   }
-  return 0;
+  return Res;
 }
 
 void Driver::PrintHelp(bool ShowHidden) const {


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -81,6 +81,7 @@
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
+#include  // EX_IOERR
 #endif
 
 using namespace clang::driver;
@@ -1388,20 +1389,30 @@
 
   // Otherwise, remove result files and print extra information about abnormal
   // failures.
+  int Res = 0;
   for (const auto  : FailingCommands) {
-int Res = CmdPair.first;
+int CommandRes = CmdPair.first;
 const Command *FailingCommand = CmdPair.second;
 
 // Remove result files if we're not saving temps.
 if (!isSaveTempsEnabled()) {
   const JobAction *JA = cast(>getSource());
   C.CleanupFileMap(C.getResultFiles(), JA, true);
 
   // Failure result files are valid unless we crashed.
-  if (Res < 0)
+  if (CommandRes < 0)
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+#if LLVM_ON_UNIX
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (CommandRes == EX_IOERR) {
+  Res = CommandRes;
+  continue;
+}
+#endif
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
@@ -1411,17 +1422,17 @@
 // diagnostics, so always print the diagnostic there.
 const Tool  = FailingCommand->getCreator();
 
-if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) {
+if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) {
   // FIXME: See FIXME above regarding result code interpretation.
-  if (Res < 0)
+  if (CommandRes < 0)
 Diag(clang::diag::err_drv_command_signalled)
 << FailingTool.getShortName();
   else
-Diag(clang::diag::err_drv_command_failed) << FailingTool.getShortName()
-  << Res;
+Diag(clang::diag::err_drv_command_failed)
+<< FailingTool.getShortName() << CommandRes;
 }
   }
-  return 0;
+  return Res;
 }
 
 void Driver::PrintHelp(bool ShowHidden) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r344536 - Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE""

2018-10-15 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Mon Oct 15 10:39:00 2018
New Revision: 344536

URL: http://llvm.org/viewvc/llvm-project?rev=344536=rev
Log:
Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE""

Summary:
Add preprocessor guards for UNIX.

This reverts commit r344389.

Reviewers: rnk, majnemer, jfb

Reviewed By: rnk

Subscribers: cfe-commits, pirama, srhines

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=344536=344535=344536=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Oct 15 10:39:00 2018
@@ -81,6 +81,7 @@
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
+#include  // EX_IOERR
 #endif
 
 using namespace clang::driver;
@@ -1388,8 +1389,9 @@ int Driver::ExecuteCompilation(
 
   // Otherwise, remove result files and print extra information about abnormal
   // failures.
+  int Res = 0;
   for (const auto  : FailingCommands) {
-int Res = CmdPair.first;
+int CommandRes = CmdPair.first;
 const Command *FailingCommand = CmdPair.second;
 
 // Remove result files if we're not saving temps.
@@ -1398,10 +1400,19 @@ int Driver::ExecuteCompilation(
   C.CleanupFileMap(C.getResultFiles(), JA, true);
 
   // Failure result files are valid unless we crashed.
-  if (Res < 0)
+  if (CommandRes < 0)
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+#if LLVM_ON_UNIX
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (CommandRes == EX_IOERR) {
+  Res = CommandRes;
+  continue;
+}
+#endif
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
@@ -1411,17 +1422,17 @@ int Driver::ExecuteCompilation(
 // diagnostics, so always print the diagnostic there.
 const Tool  = FailingCommand->getCreator();
 
-if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) {
+if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) 
{
   // FIXME: See FIXME above regarding result code interpretation.
-  if (Res < 0)
+  if (CommandRes < 0)
 Diag(clang::diag::err_drv_command_signalled)
 << FailingTool.getShortName();
   else
-Diag(clang::diag::err_drv_command_failed) << FailingTool.getShortName()
-  << Res;
+Diag(clang::diag::err_drv_command_failed)
+<< FailingTool.getShortName() << CommandRes;
 }
   }
-  return 0;
+  return Res;
 }
 
 void Driver::PrintHelp(bool ShowHidden) const {


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


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

The first one seems to indicate that your `libclang.so` is broken in release 
mode (optimization error?). The second one is correct (some of the tests test 
for errors, and apparently don't silence the messages).


Repository:
  rC Clang

https://reviews.llvm.org/D52840



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


[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls

2018-10-15 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Can you add a test case please?


Repository:
  rC Clang

https://reviews.llvm.org/D53200



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


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

This causes check-all to abort for me on SystemZ in Release mode (and never 
actually run the lit tests):

  [40/365] cd /home/uweigand/llvm/llvm-head/tools/clang/bindings/python && 
/usr/bin/cmake -E...BRARY_PATH=/home/uweigand/llvm/build/llvm-head/lib 
/usr/bin/python2.7 -m unittest discover
  FAILED: tools/clang/bindings/python/tests/CMakeFiles/check-clang-python 
  cd /home/uweigand/llvm/llvm-head/tools/clang/bindings/python && 
/usr/bin/cmake -E env 
CLANG_LIBRARY_PATH=/home/uweigand/llvm/build/llvm-head/lib /usr/bin/python2.7 
-m unittest discover
  Invalid CXChildVisitResult!
  UNREACHABLE executed at 
/home/uweigand/llvm/llvm-head/tools/clang/tools/libclang/CIndex.cpp:233!
  Child aborted

When running in Debug mode I see instead:

  [165/536] cd /home/uweigand/llvm/llvm-head/tools/clang/bindings/python && 
/usr/bin/cmake -...PATH=/home/uweigand/llvm/build/llvm-head-debug/lib 
/usr/bin/python2.7 -m unittest discover
  ..LIBCLANG 
TOOLING ERROR: fixed-compilation-database: Error while opening fixed database: 
No such file or directory
  json-compilation-database: Error while opening JSON database: No such file or 
directory
  
  ..
  --
  Ran 120 tests in 8.522s
  
  OK

which apparently doesn't count as failure, but still doesn't look quite right 
to me.

Is this some environment setup problem, or does this expose a real bug?  It's 
certainly not good that running the remaining tests is completely aborted in 
Release mode ...


Repository:
  rC Clang

https://reviews.llvm.org/D52840



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


[clang-tools-extra] r344533 - [clangd] Revert include path change in Dexp. NFC

2018-10-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Oct 15 09:47:45 2018
New Revision: 344533

URL: http://llvm.org/viewvc/llvm-project?rev=344533=rev
Log:
[clangd] Revert include path change in Dexp. NFC

Modified:
clang-tools-extra/trunk/clangd/index/dex/dexp/CMakeLists.txt
clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/CMakeLists.txt?rev=344533=344532=344533=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/dexp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/CMakeLists.txt Mon Oct 15 
09:47:45 2018
@@ -1,5 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../)
 
 set(LLVM_LINK_COMPONENTS

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp?rev=344533=344532=344533=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp Mon Oct 15 09:47:45 
2018
@@ -12,9 +12,9 @@
 //
 
//===--===//
 
-#include "Dex.h"
-#include "Serialization.h"
 #include "SourceCode.h"
+#include "index/Serialization.h"
+#include "index/dex/Dex.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"


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


[PATCH] D53220: Remove possibility to change compile database path at runtime

2018-10-15 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.

I think it'd be a good idea to separate out the on-initialization vs 
dynamically-changing parameters more - I think they should probably be disjoint 
in fact.

But we can discuss/implement that separately from this patch - the change 
itself is really nice.




Comment at: clangd/ClangdLSPServer.cpp:433
 
 reparseOpenedFiles();
   }

sammccall wrote:
> This isn't needed, the compilation database can only be set during 
> initialization.
It's still here... maybe forgot to upload a new diff?
(Just to be clear: I meant `reparseOpenFiles` doesn't need to be called, as 
there are none.)



Comment at: clangd/ClangdLSPServer.h:90
   void reparseOpenedFiles();
+  void applyConfiguration(const ClangdInitializationOptions );
   void applyConfiguration(const ClangdConfigurationParamsChange );

simark wrote:
> sammccall wrote:
> > Prefer a different name for this function - an overload set should have 
> > similar semantics and these are quite different (pseudo-constructor vs 
> > mutation allowed at any time).
> Ok, I'll think about a better name.
(In fact, this could also live directly in `onInitialize`, I think?)



Comment at: clangd/Protocol.h:422
+struct ClangdInitializationOptions : public ClangdConfigurationParamsChange {
+  llvm::Optional compilationDatabasePath;
+};

simark wrote:
> sammccall wrote:
> > Can we just move this to InitializeParams as a clangd extension?
> > Doing tricks with inheritance here makes the protocol harder to understand.
> > Can we just move this to InitializeParams as a clangd extension?
> 
> Do you mean move it in the JSON, so it looks like this on the wire?
> 
> ```
> {
>   "method": "initialize",
>   "params": {
> "compilationDatabasePath": "",
> ...
>   }
> }
> ```
> 
> instead of 
> 
> ```
> {
>   "method": "initialize",
>   "params": {
> "initializationOptions": {
>   "compilationDatabasePath": ""
> },
> ...
>   }
> }
> ```
> 
> ?
> 
> I think `initializationOptions` is a good place for this to be, I wouldn't 
> change that..  If you don't like the inheritance, we can just get rid of it 
> in our code and have two separate versions of the deserializing code.  We 
> designed it so `didChangeConfiguration` and the initialization options would 
> share the same structure, but it doesn't have to stay that way.
> Do you mean move it in the JSON, so it looks like this on the wire?

Well, since you asked... :-) I'm not going to push hard for it (this patch is 
certainly a win already), but I do think that would be much clearer.

The current protocol has `InitializeParams` and `ClangdInitializationOptions`, 
and it's not clear semantically what the distinction between them is.

With hindsight, I think something like this would be easier to follow:
```
// Clangd options that may be set at startup.
struct InitializeParams {
  // Clangd extension: override the path used to load the CDB.
  Optional compilationDatabasePath;
  // Provides initial configuration as if by workspace/updateConfiguration.
  Optional initialConfiguration;
}
// Clangd options that may be set dynamically at runtime.
struct ClangdConfigurationParamsChange { ... }
```
though even here, the benefit from being able to inline the initial 
configuration into the initalize message is unclear to me. The implementation 
has to support dynamic updates in any case, so why not make use of that?

> We designed it so didChangeConfiguration and the initialization options would 
> share the same structure

This makes sense, but if they're diverging, I'm not sure that keeping them 
*mostly* the same brings more benefits than confusion.

--

That said, if you prefer to keep the JSON as it is, that's fine. (If we grow 
more extensions, we may want to reorganize in future though?)
My main concern is the use of inheritance here, and how it provides a default 
(configuration-change options can be provided at startup) that doesn't seem 
obviously correct and is hard to opt out of.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53220



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:64
+
+  // Fix the definition.
+  llvm::Optional Loc = findConstToRemove(Def, Result);

JonasToth wrote:
> ymandel wrote:
> > JonasToth wrote:
> > > ymandel wrote:
> > > > JonasToth wrote:
> > > > > I feel that this comment doesn't add value. Could you please either 
> > > > > make it more expressive or remove it?
> > > > Agreed. I merged the comment below into this one, so one comment 
> > > > describes the rest of the control flow in this block.
> > > Did I tell you the "only one diagnostic in-flight" thing? :D
> > > I told you wrong stuff as you already figured out in the code. Please 
> > > adjust this comment and the additional scope is not necessary too.
> > But, I think you are *correct* in this assertion.  When I tried multiple 
> > in-flight diagnostics, it failed with error:
> > 
> > clang-tidy: 
> > /usr/local/google/home/yitzhakm/Projects/llvm/llvm/tools/clang/include/clang/Basic/Diagnostic.h:1297:
> >  clang::DiagnosticBuilder 
> > clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int): 
> > Assertion `CurDiagID == std::numeric_limits::max() && "Multiple 
> > diagnostics in flight at once!"' failed.
> > 
> > Am I doing something wrong?
> > 
> > 
> Then let me revert what I said and claim the first thing again :D 
> 
> I think, the issue is, that you have the `auto Diag = diag()` object not 
> destroyed before the next one is created. So temporarily storing the 
> locations for the problematic transformations might be necessary to close the 
> scope of the `Diag` first and then emit the notes.
> 
> It would be a good idea, to make a function that returns you a list of FixIts 
> and the list of problematic transformations.
> Having these 2 lists (best is probably `llvm::SmallVector`, see 
> https://llvm.org/docs/ProgrammersManual.html#dss-smallvector) simplifies 
> creating the diagnostics a lot.
> Then you have 2 scopes for emitting, one scope for the actual warning and 
> replacement and the second scope for emitting the fail-notes.
> 
> These 2 scopes could even be methods (necessary to access `diag()`).
Sounds good. Here's a stab at this restructuring:
https://reviews.llvm.org/differential/diff/169718/

Doesn't seem worth factoring the actual diag() calls into methods, but let me 
know what you think.

I'll go ahead with other changes as well, just wanted to get this out there...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-10-15 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344530: [Fixed Point Arithmetic] FixedPointCast (authored by 
leonardchan, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50616?vs=169714=169716#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50616

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

Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -2066,7 +2066,8 @@
 STK_Integral,
 STK_Floating,
 STK_IntegralComplex,
-STK_FloatingComplex
+STK_FloatingComplex,
+STK_FixedPoint
   };
 
   /// Given that this is a scalar type, classify it.
Index: cfe/trunk/include/clang/AST/OperationKinds.def
===
--- cfe/trunk/include/clang/AST/OperationKinds.def
+++ cfe/trunk/include/clang/AST/OperationKinds.def
@@ -197,6 +197,10 @@
 ///float f = i;
 CAST_OPERATION(IntegralToFloating)
 
+/// CK_FixedPointCast - Fixed point to fixed point.
+///(_Accum) 0.5r
+CAST_OPERATION(FixedPointCast)
+
 /// CK_FloatingToIntegral - Floating point to integral.  Rounds
 /// towards zero, discarding any fractional component.
 ///(int) f
Index: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
@@ -172,6 +172,8 @@
   "this value is too large for this fixed point type">;
 def err_fixed_point_not_enabled : Error<"compile with "
   "'-ffixed-point' to enable fixed point types">;
+def err_unimplemented_conversion_with_fixed_point_type : Error<
+  "conversion between fixed point and %0 is not yet supported">;
 
 // SEH
 def err_seh_expected_handler : Error<
Index: cfe/trunk/test/Frontend/fixed_point_conversions.c
===
--- cfe/trunk/test/Frontend/fixed_point_conversions.c
+++ cfe/trunk/test/Frontend/fixed_point_conversions.c
@@ -0,0 +1,283 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s -check-prefix=SAME
+
+void TestFixedPointCastSameType() {
+  _Accum a = 2.5k;
+  _Accum a2 = a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a2, align 4
+
+  a2 = (_Accum)a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a2, align 4
+}
+
+void TestFixedPointCastDown() {
+  long _Accum la = 2.5lk;
+  _Accum a = la;
+  // DEFAULT:  [[LACCUM:%[0-9]+]] = load i64, i64* %la, align 8
+  // DEFAULT-NEXT: [[ACCUM_AS_I64:%[0-9]+]] = ashr i64 [[LACCUM]], 16
+  // DEFAULT-NEXT: [[ACCUM:%[0-9]+]] = trunc i64 [[ACCUM_AS_I64]] to i32
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a, align 4
+
+  a = (_Accum)la;
+  // DEFAULT:  [[LACCUM:%[0-9]+]] = load i64, i64* %la, align 8
+  // DEFAULT-NEXT: [[ACCUM_AS_I64:%[0-9]+]] = ashr i64 [[LACCUM]], 16
+  // DEFAULT-NEXT: [[ACCUM:%[0-9]+]] = trunc i64 [[ACCUM_AS_I64]] to i32
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a, align 4
+
+  short _Accum sa = a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: [[SACCUM_AS_I32:%[0-9]+]] = ashr i32 [[ACCUM]], 8
+  // DEFAULT-NEXT: [[SACCUM:%[0-9]+]] = trunc i32 [[SACCUM_AS_I32]] to i16
+  // DEFAULT-NEXT: store i16 [[SACCUM]], i16* %sa, align 2
+
+  sa = (short _Accum)a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: [[SACCUM_AS_I32:%[0-9]+]] = ashr i32 [[ACCUM]], 8
+  // DEFAULT-NEXT: [[SACCUM:%[0-9]+]] = trunc i32 [[SACCUM_AS_I32]] to i16
+  // DEFAULT-NEXT: store i16 [[SACCUM]], i16* %sa, align 2
+}
+
+void TestFixedPointCastUp() {
+  short _Accum sa = 2.5hk;
+  _Accum a = sa;
+  // DEFAULT:  [[SACCUM:%[0-9]+]] = load i16, i16* %sa, align 2
+  // DEFAULT-NEXT: [[SACCUM_BUFF:%[0-9]+]] = sext i16 [[SACCUM]] to i32
+  // DEFAULT-NEXT: [[ACCUM:%[0-9]+]] = shl i32 

[PATCH] D51762: First part of the calendar stuff

2018-10-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.

After discussions with @EricWF, I landed a modified version as revision 344529.


https://reviews.llvm.org/D51762



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


r344530 - [Fixed Point Arithmetic] FixedPointCast

2018-10-15 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Oct 15 09:07:02 2018
New Revision: 344530

URL: http://llvm.org/viewvc/llvm-project?rev=344530=rev
Log:
[Fixed Point Arithmetic] FixedPointCast

This patch is a part of https://reviews.llvm.org/D48456 in an attempt to
split them up. This contains the code for casting between fixed point types
and other fixed point types.

The method for converting between fixed point types is based off the convert()
method in APFixedPoint.

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

Added:
cfe/trunk/test/Frontend/fixed_point_conversions.c
cfe/trunk/test/Frontend/fixed_point_unknown_conversions.c
Modified:
cfe/trunk/include/clang/AST/OperationKinds.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp

Modified: cfe/trunk/include/clang/AST/OperationKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=344530=344529=344530=diff
==
--- cfe/trunk/include/clang/AST/OperationKinds.def (original)
+++ cfe/trunk/include/clang/AST/OperationKinds.def Mon Oct 15 09:07:02 2018
@@ -197,6 +197,10 @@ CAST_OPERATION(IntegralToBoolean)
 ///float f = i;
 CAST_OPERATION(IntegralToFloating)
 
+/// CK_FixedPointCast - Fixed point to fixed point.
+///(_Accum) 0.5r
+CAST_OPERATION(FixedPointCast)
+
 /// CK_FloatingToIntegral - Floating point to integral.  Rounds
 /// towards zero, discarding any fractional component.
 ///(int) f

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=344530=344529=344530=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Oct 15 09:07:02 2018
@@ -2066,7 +2066,8 @@ public:
 STK_Integral,
 STK_Floating,
 STK_IntegralComplex,
-STK_FloatingComplex
+STK_FloatingComplex,
+STK_FixedPoint
   };
 
   /// Given that this is a scalar type, classify it.

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=344530=344529=344530=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Mon Oct 15 09:07:02 
2018
@@ -172,6 +172,8 @@ def err_too_large_for_fixed_point : Erro
   "this value is too large for this fixed point type">;
 def err_fixed_point_not_enabled : Error<"compile with "
   "'-ffixed-point' to enable fixed point types">;
+def err_unimplemented_conversion_with_fixed_point_type : Error<
+  "conversion between fixed point and %0 is not yet supported">;
 
 // SEH
 def err_seh_expected_handler : Error<

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=344530=344529=344530=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Oct 15 09:07:02 2018
@@ -1644,6 +1644,7 @@ bool CastExpr::CastConsistency() const {
   case CK_ZeroToOCLEvent:
   case CK_ZeroToOCLQueue:
   case CK_IntToOCLSampler:
+  case CK_FixedPointCast:
 assert(!getType()->isBooleanType() && "unheralded conversion to bool");
 goto CheckNoBasePath;
 

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=344530=344529=344530=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Oct 15 09:07:02 2018
@@ -9556,6 +9556,7 @@ bool IntExprEvaluator::VisitCastExpr(con
   case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
+  case CK_FixedPointCast:
 llvm_unreachable("invalid cast kind for integral value");
 
   case CK_BitCast:
@@ -10090,6 +10091,7 @@ bool ComplexExprEvaluator::VisitCastExpr
   case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
+  case CK_FixedPointCast:
 llvm_unreachable("invalid cast kind for complex value");
 
   case CK_LValueToRValue:

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 

[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-10-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 169714.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

https://reviews.llvm.org/D50616

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

Index: test/Frontend/fixed_point_unknown_conversions.c
===
--- /dev/null
+++ test/Frontend/fixed_point_unknown_conversions.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+void func() {
+  _Bool b;
+  char c;
+  int i;
+  float f;
+  double d;
+  double _Complex dc;
+  int _Complex ic;
+  struct S {
+int i;
+  } s;
+  enum E {
+A
+  } e;
+  int *ptr;
+  typedef int int_t;
+  int_t i2;
+
+  _Accum accum;
+  _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}}
+
+  b = accum;   // expected-error{{conversion between fixed point and '_Bool' 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: test/Frontend/fixed_point_conversions.c
===
--- /dev/null
+++ test/Frontend/fixed_point_conversions.c
@@ -0,0 +1,283 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s -check-prefix=SAME
+
+void TestFixedPointCastSameType() {
+  _Accum a = 2.5k;
+  _Accum a2 = a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a2, align 4
+
+  a2 = (_Accum)a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a2, align 4
+}
+
+void TestFixedPointCastDown() {
+  long _Accum la = 2.5lk;
+  _Accum a = la;
+  // DEFAULT:  [[LACCUM:%[0-9]+]] = load i64, i64* %la, align 8
+  // DEFAULT-NEXT: [[ACCUM_AS_I64:%[0-9]+]] = ashr i64 [[LACCUM]], 16
+  // DEFAULT-NEXT: [[ACCUM:%[0-9]+]] = trunc i64 [[ACCUM_AS_I64]] to i32
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a, align 4
+
+  a = (_Accum)la;
+  // DEFAULT:  [[LACCUM:%[0-9]+]] = load i64, i64* %la, align 8
+  

[PATCH] D53220: Remove possibility to change compile database path at runtime

2018-10-15 Thread Simon Marchi via Phabricator via cfe-commits
simark marked an inline comment as done.
simark added inline comments.



Comment at: clangd/ClangdLSPServer.h:90
   void reparseOpenedFiles();
+  void applyConfiguration(const ClangdInitializationOptions );
   void applyConfiguration(const ClangdConfigurationParamsChange );

sammccall wrote:
> Prefer a different name for this function - an overload set should have 
> similar semantics and these are quite different (pseudo-constructor vs 
> mutation allowed at any time).
Ok, I'll think about a better name.



Comment at: clangd/Protocol.h:422
+struct ClangdInitializationOptions : public ClangdConfigurationParamsChange {
+  llvm::Optional compilationDatabasePath;
+};

sammccall wrote:
> Can we just move this to InitializeParams as a clangd extension?
> Doing tricks with inheritance here makes the protocol harder to understand.
> Can we just move this to InitializeParams as a clangd extension?

Do you mean move it in the JSON, so it looks like this on the wire?

```
{
  "method": "initialize",
  "params": {
"compilationDatabasePath": "",
...
  }
}
```

instead of 

```
{
  "method": "initialize",
  "params": {
"initializationOptions": {
  "compilationDatabasePath": ""
},
...
  }
}
```

?

I think `initializationOptions` is a good place for this to be, I wouldn't 
change that..  If you don't like the inheritance, we can just get rid of it in 
our code and have two separate versions of the deserializing code.  We designed 
it so `didChangeConfiguration` and the initialization options would share the 
same structure, but it doesn't have to stay that way.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53220



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


[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.

2018-10-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

For reference, @jkorous has a WIP in https://reviews.llvm.org/D53290.
It's scope is a superset, and I think everything in common is basically the 
same (they were both based on a common prototype).
Jan is out at the moment, so I think it makes sense to move ahead with this 
piece - it's progress, and the smaller scope makes landing the change easier.

I just realized though there are no JSONTransport unit tests in this patch, 
I'll add those.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53286



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


[PATCH] D53293: add riscv32e to the clang

2018-10-15 Thread Daliang Xu via Phabricator via cfe-commits
xudaliang.pku created this revision.
xudaliang.pku added a reviewer: asb.
Herald added subscribers: cfe-commits, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, mgrang, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.

1. add optioins -march=rv32e
2. add ilp32e


Repository:
  rC Clang

https://reviews.llvm.org/D53293

Files:
  lib/Basic/Targets.cpp
  lib/Basic/Targets/RISCV.cpp
  lib/Basic/Targets/RISCV.h
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/Arch/RISCV.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp

Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -191,7 +191,8 @@
   Triple.getEnvironment() == llvm::Triple::GNUX32)
 return "libx32";
 
-  if (Triple.getArch() == llvm::Triple::riscv32)
+  if (Triple.getArch() == llvm::Triple::riscv32 ||
+  Triple.getArch() == llvm::Triple::riscv32e)
 return "lib32";
 
   return Triple.isArch32Bit() ? "lib" : "lib64";
@@ -254,8 +255,9 @@
   const bool IsAndroid = Triple.isAndroid();
   const bool IsMips = Triple.isMIPS();
   const bool IsHexagon = Arch == llvm::Triple::hexagon;
-  const bool IsRISCV =
-  Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64;
+  const bool IsRISCV = Arch == llvm::Triple::riscv32 ||
+   Arch == llvm::Triple::riscv64 ||
+   Triple.getArch() == llvm::Triple::riscv32e;
 
   if (IsMips && !SysRoot.empty())
 ExtraOpts.push_back("--sysroot=" + SysRoot);
@@ -574,6 +576,8 @@
 Loader =
 (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
 break;
+  // not sure whether riscv32e use riscv32-ld,
+  case llvm::Triple::riscv32e:
   case llvm::Triple::riscv32: {
 StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
 LibDir = "lib";
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -252,6 +252,8 @@
 return "elf64lppc";
   case llvm::Triple::riscv32:
 return "elf32lriscv";
+  case llvm::Triple::riscv32e:
+return "elf32lriscv";
   case llvm::Triple::riscv64:
 return "elf64lriscv";
   case llvm::Triple::sparc:
@@ -607,6 +609,7 @@
 break;
   }
   case llvm::Triple::riscv32:
+  case llvm::Triple::riscv32e:
   case llvm::Triple::riscv64: {
 StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple());
 CmdArgs.push_back("-mabi");
@@ -842,7 +845,8 @@
 }
 
 static bool isRISCV(llvm::Triple::ArchType Arch) {
-  return Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64;
+  return Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64 ||
+ Arch == llvm::Triple::riscv32e;
 }
 
 static Multilib makeMultilib(StringRef commonSuffix) {
@@ -1396,6 +1400,8 @@
 
   FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS());
   Multilib Ilp32 = makeMultilib("lib32/ilp32").flag("+m32").flag("+mabi=ilp32");
+  Multilib Ilp32e =
+  makeMultilib("lib32/ilp32e").flag("+m32").flag("+mabi=ilp32e");
   Multilib Ilp32f =
   makeMultilib("lib32/ilp32f").flag("+m32").flag("+mabi=ilp32f");
   Multilib Ilp32d =
@@ -1405,16 +1411,19 @@
   Multilib Lp64d = makeMultilib("lib64/lp64d").flag("+m64").flag("+mabi=lp64d");
   MultilibSet RISCVMultilibs =
   MultilibSet()
-  .Either({Ilp32, Ilp32f, Ilp32d, Lp64, Lp64f, Lp64d})
+  .Either({Ilp32, Ilp32e, Ilp32f, Ilp32d, Lp64, Lp64f, Lp64d})
   .FilterOut(NonExistent);
 
   Multilib::flags_list Flags;
   bool IsRV64 = TargetTriple.getArch() == llvm::Triple::riscv64;
+  bool IsRV32E = TargetTriple.getArch() == llvm::Triple::riscv32e;
   StringRef ABIName = tools::riscv::getRISCVABI(Args, TargetTriple);
 
   addMultilibFlag(!IsRV64, "m32", Flags);
+  addMultilibFlag(IsRV32E, "m32", Flags);
   addMultilibFlag(IsRV64, "m64", Flags);
   addMultilibFlag(ABIName == "ilp32", "mabi=ilp32", Flags);
+  addMultilibFlag(ABIName == "ilp32e", "mabi=ilp32e", Flags);
   addMultilibFlag(ABIName == "ilp32f", "mabi=ilp32f", Flags);
   addMultilibFlag(ABIName == "ilp32d", "mabi=ilp32d", Flags);
   addMultilibFlag(ABIName == "lp64", "mabi=lp64", Flags);
@@ -2401,6 +2410,7 @@
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
   case llvm::Triple::riscv32:
+  case llvm::Triple::riscv32e:
   case llvm::Triple::riscv64:
   case llvm::Triple::systemz:
   case llvm::Triple::mips:
@@ -2549,7 +2559,8 @@
!getTriple().hasEnvironment()) ||
   getTriple().getOS() == llvm::Triple::Solaris ||
   getTriple().getArch() == llvm::Triple::riscv32 ||
-  getTriple().getArch() == llvm::Triple::riscv64;
+  getTriple().getArch() == llvm::Triple::riscv64 ||
+  getTriple().getArch() == llvm::Triple::riscv32e;
 
   if 

[PATCH] D53084: [clang-doc] Add unit tests for YAML

2018-10-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp:45
+  assert(!Err);
+  std::string Expected =
+  "---\n"

Nit: use raw strings here as well, the same here below.


https://reviews.llvm.org/D53084



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


[PATCH] D53292: [clangd] Add createIndex in dexp

2018-10-15 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE344521: [clangd] Add createIndex in dexp (authored by 
hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53292?vs=169712=169713#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53292

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -31,9 +31,9 @@
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@
  llvm::make_unique},
 };
 
+std::unique_ptr openIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = openIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to open the index.\n";
 return -1;
   }
 


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -31,9 +31,9 @@
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@
  llvm::make_unique},
 };
 
+std::unique_ptr openIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = openIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to open the index.\n";
 return -1;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r344521 - [clangd] Add createIndex in dexp

2018-10-15 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Oct 15 08:12:40 2018
New Revision: 344521

URL: http://llvm.org/viewvc/llvm-project?rev=344521=rev
Log:
[clangd] Add createIndex in dexp

Summary:
This would allow easily injecting our internal customization.

Also updates the stale "symbol-collection-file" flag.

Reviewers: sammccall

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

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp?rev=344521=344520=344521=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp Mon Oct 15 08:12:40 
2018
@@ -31,9 +31,9 @@ using namespace llvm;
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@ struct {
  llvm::make_unique},
 };
 
+std::unique_ptr openIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@ int main(int argc, const char *argv[]) {
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = openIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to open the index.\n";
 return -1;
   }
 


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


[PATCH] D53292: [clangd] Add createIndex in dexp

2018-10-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 169712.
hokein marked 2 inline comments as done.
hokein added a comment.

createIndex => openIndex


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53292

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -31,9 +31,9 @@
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@
  llvm::make_unique},
 };
 
+std::unique_ptr openIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = openIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to open the index.\n";
 return -1;
   }
 


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -31,9 +31,9 @@
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@
  llvm::make_unique},
 };
 
+std::unique_ptr openIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = openIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to open the index.\n";
 return -1;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53292: [clangd] Add createIndex in dexp

2018-10-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/index/dex/dexp/Dexp.cpp:256
 
+std::unique_ptr createIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);

createIndex seems a slightly odd name for this (as if writing new files or 
adding new data somehow): openIndex or so?



Comment at: clangd/index/dex/dexp/Dexp.cpp:273
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to create an index.\n";
 return -1;

"to open the index"?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53292



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


[clang-tools-extra] r344520 - [clangd] Use SyncAPI in more places in tests. NFC

2018-10-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Oct 15 08:04:03 2018
New Revision: 344520

URL: http://llvm.org/viewvc/llvm-project?rev=344520=rev
Log:
[clangd] Use SyncAPI in more places in tests. NFC

Modified:
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=344520=344519=344520=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Oct 15 08:04:03 2018
@@ -286,6 +286,7 @@ class SymbolSlab {
 public:
   using const_iterator = std::vector::const_iterator;
   using iterator = const_iterator;
+  using value_type = Symbol;
 
   SymbolSlab() = default;
 
@@ -294,6 +295,7 @@ public:
   const_iterator find(const SymbolID ) const;
 
   size_t size() const { return Symbols.size(); }
+  bool empty() const { return Symbols.empty(); }
   // Estimates the total memory usage.
   size_t bytes() const {
 return sizeof(*this) + Arena.getTotalMemory() +
@@ -389,6 +391,7 @@ public:
   const_iterator begin() const { return Refs.begin(); }
   const_iterator end() const { return Refs.end(); }
   size_t size() const { return Refs.size(); }
+  bool empty() const { return Refs.empty(); }
 
   size_t bytes() const {
 return sizeof(*this) + Arena.getTotalMemory() +

Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=344520=344519=344520=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Mon Oct 15 
08:04:03 2018
@@ -7,12 +7,12 @@
 //
 
//===--===//
 
-#include "Annotations.h"
 #include "AST.h"
+#include "Annotations.h"
 #include "ClangdUnit.h"
+#include "SyncAPI.h"
 #include "TestFS.h"
 #include "TestTU.h"
-#include "gmock/gmock.h"
 #include "index/FileIndex.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
@@ -20,11 +20,14 @@
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 using testing::_;
 using testing::AllOf;
+using testing::Contains;
 using testing::ElementsAre;
+using testing::IsEmpty;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -35,6 +38,8 @@ MATCHER_P(RefRange, Range, "") {
   Range.end.character);
 }
 MATCHER_P(FileURI, F, "") { return arg.Location.FileURI == F; }
+MATCHER_P(DeclURI, U, "") { return arg.CanonicalDeclaration.FileURI == U; }
+MATCHER_P(QName, N, "") { return (arg.Scope + arg.Name).str() == N; }
 
 namespace clang {
 namespace clangd {
@@ -67,15 +72,6 @@ std::unique_ptr refSlab(const S
   return llvm::make_unique(std::move(Slab).build());
 }
 
-std::vector getSymbolNames(const SymbolIndex ,
-std::string Query = "") {
-  FuzzyFindRequest Req;
-  Req.Query = Query;
-  std::vector Names;
-  I.fuzzyFind(Req, [&](const Symbol ) { Names.push_back(S.Name); });
-  return Names;
-}
-
 RefSlab getRefs(const SymbolIndex , SymbolID ID) {
   RefsRequest Req;
   Req.IDs = {ID};
@@ -86,11 +82,11 @@ RefSlab getRefs(const SymbolIndex , Sy
 
 TEST(FileSymbolsTest, UpdateAndGet) {
   FileSymbols FS;
-  EXPECT_THAT(getSymbolNames(*FS.buildMemIndex()), UnorderedElementsAre());
+  EXPECT_THAT(runFuzzyFind(*FS.buildMemIndex(), ""), IsEmpty());
 
   FS.update("f1", numSlab(1, 3), refSlab(SymbolID("1"), "f1.cc"));
-  EXPECT_THAT(getSymbolNames(*FS.buildMemIndex()),
-  UnorderedElementsAre("1", "2", "3"));
+  EXPECT_THAT(runFuzzyFind(*FS.buildMemIndex(), ""),
+  UnorderedElementsAre(QName("1"), QName("2"), QName("3")));
   EXPECT_THAT(getRefs(*FS.buildMemIndex(), SymbolID("1")),
   RefsAre({FileURI("f1.cc")}));
 }
@@ -99,8 +95,9 @@ TEST(FileSymbolsTest, Overlap) {
   FileSymbols FS;
   FS.update("f1", numSlab(1, 3), nullptr);
   FS.update("f2", numSlab(3, 5), nullptr);
-  EXPECT_THAT(getSymbolNames(*FS.buildMemIndex()),
-  UnorderedElementsAre("1", "2", "3", "4", "5"));
+  EXPECT_THAT(runFuzzyFind(*FS.buildMemIndex(), ""),
+  UnorderedElementsAre(QName("1"), QName("2"), QName("3"),
+   QName("4"), QName("5")));
 }
 
 TEST(FileSymbolsTest, SnapshotAliveAfterRemove) {
@@ -110,27 +107,20 @@ TEST(FileSymbolsTest, SnapshotAliveAfter
   FS.update("f1", numSlab(1, 3), refSlab(ID, "f1.cc"));
 
   auto Symbols = FS.buildMemIndex();
-  EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", 

[PATCH] D53292: [clangd] Add createIndex in dexp

2018-10-15 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 would allow easily injecting our internal customization.

Also updates the stale "symbol-collection-file" flag.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53292

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -31,9 +31,9 @@
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@
  llvm::make_unique},
 };
 
+std::unique_ptr createIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = createIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to create an index.\n";
 return -1;
   }
 


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -31,9 +31,9 @@
 namespace {
 
 llvm::cl::opt
-SymbolCollection("symbol-collection-file",
- llvm::cl::desc("Path to the file with symbol collection"),
- llvm::cl::Positional, llvm::cl::Required);
+IndexPath("index-path",
+  llvm::cl::desc("Path to the index"),
+  llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@
  llvm::make_unique},
 };
 
+std::unique_ptr createIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@
 
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
-Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-  /*UseDex=*/true);
+Index = createIndex(IndexPath);
   });
 
   if (!Index) {
-llvm::outs()
-<< "ERROR: Please provide a valid path to symbol collection file.\n";
+llvm::outs() << "Failed to create an index.\n";
 return -1;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53288: [clangd] Optionally use dex for the preamble parts of the dynamic index.

2018-10-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clangd/ClangdServer.h:79
+/// Use a heavier and faster in-memory index implementation.
+/// FIXME: we should make this true if it isn't too slow!.
+bool HeavyweightDynamicSymbolIndex = false;

"too slow" seems confusing, dex is faster, I think here it means too slow to 
build?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53288



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


[PATCH] D53290: [WIP] clangd Transport layer

2018-10-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, jfb, arphaman, dexonsmith, 
MaskRay, ioeric, ilya-biryukov, mgorny.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53290

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/Transport.cpp
  clangd/Transport.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -315,13 +315,20 @@
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
 
+  // TODO
+  std::unique_ptr TransportLayer = newJSONTransport(stdin, llvm::outs(), InputStyle);
+  if (!TransportLayer.get()) {
+  // TODO
+  return 42;
+  }
+
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(
-  Out, CCOpts, CompileCommandsDirPath,
+  *TransportLayer.get(), CCOpts, CompileCommandsDirPath,
   /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
   constexpr int NoShutdownRequestErrorCode = 1;
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
-  return LSPServer.run(stdin, InputStyle) ? 0 : NoShutdownRequestErrorCode;
+  return LSPServer.run() ? 0 : NoShutdownRequestErrorCode;
 }
Index: clangd/Transport.h
===
--- /dev/null
+++ clangd/Transport.h
@@ -0,0 +1,94 @@
+//===--- Transport.h - sending and receiving LSP messages ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// The language server protocol is usually implemented by writing messages as
+// JSON-RPC over the stdin/stdout of a subprocess. However other communications
+// mechanisms are possible, such as XPC on mac (see xpc/ directory).
+//
+// The Transport interface allows the mechanism to be replaced, and the JSONRPC
+// Transport is the standard implementation.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace clangd {
+
+// A transport is responsible for maintaining the connection to a client
+// application, and reading/writing structured messages to it.
+//
+// Transports have limited thread safety requirements:
+//  - messages will not be sent concurrently
+//  - messages MAY be sent while loop() is reading, or its callback is active
+class Transport {
+public:
+  Transport() : shouldTerminateLoop(false) { }
+  virtual ~Transport() = default;
+
+  // Called by Clangd to send messages to the client.
+  // (Because JSON and XPC are so similar, these are concrete and delegate to
+  // sendMessage. We could change this to support more diverse transports).
+  void notifyClient(llvm::StringRef Method, llvm::json::Value Params);
+  void callClient(llvm::StringRef Method, llvm::json::Value Params,
+llvm::json::Value ID);
+  void replyToClient(llvm::json::Value ID, llvm::Expected Result);
+
+  // Implemented by Clangd to handle incoming messages. (See loop() below).
+  class MessageHandler {
+  public:
+// TODO was originally abstract
+virtual ~MessageHandler() {}
+virtual bool notifyServer(llvm::StringRef Method, llvm::json::Value ) = 0;
+virtual bool callServer(llvm::StringRef Method, llvm::json::Value Params,
+  llvm::json::Value ID) = 0;
+virtual bool replyToServer(llvm::json::Value ID,
+   llvm::Expected Result) = 0;
+  };
+  // Called by Clangd to receive messages from the client.
+  // The transport should in turn invoke the handler to process messages.
+  // If handler returns true, the transport should immedately return success.
+  // Otherwise, it returns an error when the transport becomes unusable.
+  // (Because JSON and XPC are so similar, they share handleMessage()).
+  virtual bool loop(MessageHandler &) = 0;
+
+  std::atomic shouldTerminateLoop;
+
+protected:
+  // Common implementation for notify(), call(), and reply().
+  virtual void sendMessage(llvm::json::Value) = 0;
+  // Delegates to notify(), call(), and reply().
+  bool handleMessage(llvm::json::Value, MessageHandler&);
+};
+
+// Controls the way JSON-RPC messages are encoded (both input and output).
+enum 

[PATCH] D53274: [analyzer][NFC] Fix inconsistencies in AnalyzerOptions

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 169703.

https://reviews.llvm.org/D53274

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -68,8 +68,6 @@
   return WorkList::makeUnexploredFirstPriorityQueue();
 case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstLocationQueue:
   return WorkList::makeUnexploredFirstPriorityLocationQueue();
-default:
-  llvm_unreachable("Unexpected case");
   }
 }
 
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -50,27 +50,24 @@
 }
 
 AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
-  if (UserMode == UMK_NotSet) {
-StringRef ModeStr =
-Config.insert(std::make_pair("mode", "deep")).first->second;
-UserMode = llvm::StringSwitch(ModeStr)
+  if (!UserMode.hasValue()) {
+StringRef ModeStr = getOptionAsString("mode", "deep");
+UserMode = llvm::StringSwitch>(ModeStr)
   .Case("shallow", UMK_Shallow)
   .Case("deep", UMK_Deep)
-  .Default(UMK_NotSet);
-assert(UserMode != UMK_NotSet && "User mode is invalid.");
+  .Default(None);
+assert(UserMode.getValue() && "User mode is invalid.");
   }
-  return UserMode;
+  return UserMode.getValue();
 }
 
 AnalyzerOptions::ExplorationStrategyKind
 AnalyzerOptions::getExplorationStrategy() {
-  if (ExplorationStrategy == ExplorationStrategyKind::NotSet) {
-StringRef StratStr =
-Config
-.insert(std::make_pair("exploration_strategy", "unexplored_first_queue"))
-.first->second;
+  if (!ExplorationStrategy.hasValue()) {
+StringRef StratStr = getOptionAsString("exploration_strategy",
+   "unexplored_first_queue");
 ExplorationStrategy =
-llvm::StringSwitch(StratStr)
+llvm::StringSwitch>(StratStr)
 .Case("dfs", ExplorationStrategyKind::DFS)
 .Case("bfs", ExplorationStrategyKind::BFS)
 .Case("unexplored_first",
@@ -81,15 +78,15 @@
   ExplorationStrategyKind::UnexploredFirstLocationQueue)
 .Case("bfs_block_dfs_contents",
   ExplorationStrategyKind::BFSBlockDFSContents)
-.Default(ExplorationStrategyKind::NotSet);
-assert(ExplorationStrategy != ExplorationStrategyKind::NotSet &&
+.Default(None);
+assert(ExplorationStrategy.hasValue() &&
"User mode is invalid.");
   }
-  return ExplorationStrategy;
+  return ExplorationStrategy.getValue();
 }
 
 IPAKind AnalyzerOptions::getIPAMode() {
-  if (IPAMode == IPAK_NotSet) {
+  if (!IPAMode.hasValue()) {
 // Use the User Mode to set the default IPA value.
 // Note, we have to add the string to the Config map for the ConfigDumper
 // checker to function properly.
@@ -102,53 +99,41 @@
 assert(DefaultIPA);
 
 // Lookup the ipa configuration option, use the default from User Mode.
-StringRef ModeStr =
-Config.insert(std::make_pair("ipa", DefaultIPA)).first->second;
-IPAKind IPAConfig = llvm::StringSwitch(ModeStr)
+StringRef ModeStr = getOptionAsString("ipa", DefaultIPA);
+IPAMode = llvm::StringSwitch>(ModeStr)
 .Case("none", IPAK_None)
 .Case("basic-inlining", IPAK_BasicInlining)
 .Case("inlining", IPAK_Inlining)
 .Case("dynamic", IPAK_DynamicDispatch)
 .Case("dynamic-bifurcate", IPAK_DynamicDispatchBifurcate)
-.Default(IPAK_NotSet);
-assert(IPAConfig != IPAK_NotSet && "IPA Mode is invalid.");
-
-// Set the member variable.
-IPAMode = IPAConfig;
+.Default(None);
+assert(IPAMode.hasValue() && "IPA Mode is invalid.");
   }
 
-  return IPAMode;
+  return IPAMode.getValue();
 }
 
 bool
 AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) {
   if (getIPAMode() < IPAK_Inlining)
 return false;
 
   if (!CXXMemberInliningMode) {
-static const char *ModeKey = "c++-inlining";
-
-StringRef ModeStr =
-Config.insert(std::make_pair(ModeKey, "destructors")).first->second;
+StringRef ModeStr = getOptionAsString("c++-inlining", "destructors");
 
-CXXInlineableMemberKind  =
-  const_cast(CXXMemberInliningMode);
-
-MutableMode = llvm::StringSwitch(ModeStr)
+CXXMemberInliningMode =
+  llvm::StringSwitch>(ModeStr)
   .Case("constructors", CIMK_Constructors)
   .Case("destructors", CIMK_Destructors)
-  .Case("none", CIMK_None)
   .Case("methods", CIMK_MemberFunctions)
-  .Default(CXXInlineableMemberKind());
+  .Case("none", CIMK_None)
+  

[PATCH] D53288: [clangd] Optionally use dex for the preamble parts of the dynamic index.

2018-10-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.

Reuse the old -use-dex-index experiment flag for this.

To avoid breaking the tests, make Dex deduplicate symbols, addressing an old 
FIXME.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53288

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/index/Background.cpp
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  clangd/index/dex/Dex.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/DexTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TestTU.cpp

Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -50,7 +50,8 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = llvm::make_unique();
+  auto Idx = llvm::make_unique(
+  /*URISchemes=*/std::vector{}, /*UseDex=*/true);
   Idx->updatePreamble(Filename, AST.getASTContext(), AST.getPreprocessorPtr());
   Idx->updateMain(Filename, AST);
   return std::move(Idx);
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -86,35 +86,37 @@
 
 TEST(FileSymbolsTest, UpdateAndGet) {
   FileSymbols FS;
-  EXPECT_THAT(getSymbolNames(*FS.buildMemIndex()), UnorderedElementsAre());
+  EXPECT_THAT(getSymbolNames(*FS.buildIndex(IndexType::Light)),
+  UnorderedElementsAre());
 
   FS.update("f1", numSlab(1, 3), refSlab(SymbolID("1"), "f1.cc"));
-  EXPECT_THAT(getSymbolNames(*FS.buildMemIndex()),
+  EXPECT_THAT(getSymbolNames(*FS.buildIndex(IndexType::Light)),
   UnorderedElementsAre("1", "2", "3"));
-  EXPECT_THAT(getRefs(*FS.buildMemIndex(), SymbolID("1")),
+  EXPECT_THAT(getRefs(*FS.buildIndex(IndexType::Light), SymbolID("1")),
   RefsAre({FileURI("f1.cc")}));
 }
 
 TEST(FileSymbolsTest, Overlap) {
   FileSymbols FS;
   FS.update("f1", numSlab(1, 3), nullptr);
   FS.update("f2", numSlab(3, 5), nullptr);
-  EXPECT_THAT(getSymbolNames(*FS.buildMemIndex()),
-  UnorderedElementsAre("1", "2", "3", "4", "5"));
+  for (auto Type : {IndexType::Light, IndexType::Heavy})
+EXPECT_THAT(getSymbolNames(*FS.buildIndex(Type)),
+UnorderedElementsAre("1", "2", "3", "4", "5"));
 }
 
 TEST(FileSymbolsTest, SnapshotAliveAfterRemove) {
   FileSymbols FS;
 
   SymbolID ID("1");
   FS.update("f1", numSlab(1, 3), refSlab(ID, "f1.cc"));
 
-  auto Symbols = FS.buildMemIndex();
+  auto Symbols = FS.buildIndex(IndexType::Light);
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
   EXPECT_THAT(getRefs(*Symbols, ID), RefsAre({FileURI("f1.cc")}));
 
   FS.update("f1", nullptr, nullptr);
-  auto Empty = FS.buildMemIndex();
+  auto Empty = FS.buildIndex(IndexType::Light);
   EXPECT_THAT(getSymbolNames(*Empty), UnorderedElementsAre());
   EXPECT_THAT(getRefs(*Empty, ID), ElementsAre());
 
Index: unittests/clangd/DexTests.cpp
===
--- unittests/clangd/DexTests.cpp
+++ unittests/clangd/DexTests.cpp
@@ -492,19 +492,13 @@
"other::A"));
 }
 
-// FIXME(kbobyrev): This test is different for Dex and MemIndex: while
-// MemIndex manages response deduplication, Dex simply returns all matched
-// symbols which means there might be equivalent symbols in the response.
-// Before drop-in replacement of MemIndex with Dex happens, FileIndex
-// should handle deduplication instead.
 TEST(DexTest, DexDeduplicate) {
   std::vector Symbols = {symbol("1"), symbol("2"), symbol("3"),
  symbol("2") /* duplicate */};
   FuzzyFindRequest Req;
   Req.Query = "2";
   Dex I(Symbols, RefSlab(), URISchemes);
-  EXPECT_FALSE(Req.Limit);
-  EXPECT_THAT(match(I, Req), ElementsAre("2", "2"));
+  EXPECT_THAT(match(I, Req), ElementsAre("2"));
 }
 
 TEST(DexTest, DexLimitedNumMatches) {
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -29,11 +29,11 @@
 using namespace clang;
 using namespace clang::clangd;
 
-// FIXME: remove this option when Dex is stable enough.
+// FIXME: remove this option when Dex is cheap enough.
 static llvm::cl::opt
 UseDex("use-dex-index",
-   llvm::cl::desc("Use experimental Dex static index."),
-   llvm::cl::init(true), llvm::cl::Hidden);
+   llvm::cl::desc("Use experimental Dex dynamic index."),
+   llvm::cl::init(false), llvm::cl::Hidden);
 
 static llvm::cl::opt CompileCommandsDir(
 "compile-commands-dir",
@@ -286,14 +286,15 @@
   if (!ResourceDir.empty())
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = 

[PATCH] D53277: [analyzer][NFC][WIP] Collect all -analyzer-config options in a .def file

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 169697.

https://reviews.llvm.org/D53277

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -56,17 +56,17 @@
 static std::unique_ptr generateWorkList(AnalyzerOptions ,
   SubEngine ) {
   switch (Opts.getExplorationStrategy()) {
-case AnalyzerOptions::ExplorationStrategyKind::DFS:
+case ExplorationStrategyKind::DFS:
   return WorkList::makeDFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFS:
+case ExplorationStrategyKind::BFS:
   return WorkList::makeBFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFSBlockDFSContents:
+case ExplorationStrategyKind::BFSBlockDFSContents:
   return WorkList::makeBFSBlockDFSContents();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirst:
+case ExplorationStrategyKind::UnexploredFirst:
   return WorkList::makeUnexploredFirst();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstQueue:
+case ExplorationStrategyKind::UnexploredFirstQueue:
   return WorkList::makeUnexploredFirstPriorityQueue();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstLocationQueue:
+case ExplorationStrategyKind::UnexploredFirstLocationQueue:
   return WorkList::makeUnexploredFirstPriorityLocationQueue();
   }
 }
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -49,7 +49,7 @@
   return Result;
 }
 
-AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
+UserModeKind AnalyzerOptions::getUserMode() {
   if (!UserMode.hasValue()) {
 StringRef ModeStr = getOptionAsString("mode", "deep");
 UserMode = llvm::StringSwitch>(ModeStr)
@@ -61,7 +61,7 @@
   return UserMode.getValue();
 }
 
-AnalyzerOptions::ExplorationStrategyKind
+ExplorationStrategyKind
 AnalyzerOptions::getExplorationStrategy() {
   if (!ExplorationStrategy.hasValue()) {
 StringRef StratStr = getOptionAsString("exploration_strategy",
@@ -182,137 +182,6 @@
   return V.getValue();
 }
 
-bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
-  return getBooleanOption(IncludeTemporaryDtorsInCFG,
-  "cfg-temporary-dtors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeImplicitDtorsInCFG() {
-  return getBooleanOption(IncludeImplicitDtorsInCFG,
-  "cfg-implicit-dtors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeLifetimeInCFG() {
-  return getBooleanOption(IncludeLifetimeInCFG, "cfg-lifetime",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::includeLoopExitInCFG() {
-  return getBooleanOption(IncludeLoopExitInCFG, "cfg-loopexit",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::includeRichConstructorsInCFG() {
-  return getBooleanOption(IncludeRichConstructorsInCFG,
-  "cfg-rich-constructors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeScopesInCFG() {
-  return getBooleanOption(IncludeScopesInCFG,
-  "cfg-scopes",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::mayInlineCXXStandardLibrary() {
-  return getBooleanOption(InlineCXXStandardLibrary,
-  "c++-stdlib-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineTemplateFunctions() {
-  return getBooleanOption(InlineTemplateFunctions,
-  "c++-template-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineCXXAllocator() {
-  return getBooleanOption(InlineCXXAllocator,
-  "c++-allocator-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineCXXContainerMethods() {
-  return getBooleanOption(InlineCXXContainerMethods,
-  "c++-container-inlining",
-  /*Default=*/false);
-}
-
-bool AnalyzerOptions::mayInlineCXXSharedPtrDtor() {
-  return getBooleanOption(InlineCXXSharedPtrDtor,
-  "c++-shared_ptr-inlining",
-  /*Default=*/false);
-}
-
-bool AnalyzerOptions::mayInlineCXXTemporaryDtors() {
-  return getBooleanOption(InlineCXXTemporaryDtors,
-  "c++-temp-dtor-inlining",
-  /*Default=*/true);
-}
-
-bool 

[PATCH] D53277: [analyzer][NFC][WIP] Collect all -analyzer-config options in a .def file

2018-10-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 169696.

https://reviews.llvm.org/D53277

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -56,17 +56,17 @@
 static std::unique_ptr generateWorkList(AnalyzerOptions ,
   SubEngine ) {
   switch (Opts.getExplorationStrategy()) {
-case AnalyzerOptions::ExplorationStrategyKind::DFS:
+case ExplorationStrategyKind::DFS:
   return WorkList::makeDFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFS:
+case ExplorationStrategyKind::BFS:
   return WorkList::makeBFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFSBlockDFSContents:
+case ExplorationStrategyKind::BFSBlockDFSContents:
   return WorkList::makeBFSBlockDFSContents();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirst:
+case ExplorationStrategyKind::UnexploredFirst:
   return WorkList::makeUnexploredFirst();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstQueue:
+case ExplorationStrategyKind::UnexploredFirstQueue:
   return WorkList::makeUnexploredFirstPriorityQueue();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstLocationQueue:
+case ExplorationStrategyKind::UnexploredFirstLocationQueue:
   return WorkList::makeUnexploredFirstPriorityLocationQueue();
   }
 }
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -49,7 +49,7 @@
   return Result;
 }
 
-AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
+UserModeKind AnalyzerOptions::getUserMode() {
   if (!UserMode.hasValue()) {
 StringRef ModeStr = getOptionAsString("mode", "deep");
 UserMode = llvm::StringSwitch>(ModeStr)
@@ -61,7 +61,7 @@
   return UserMode.getValue();
 }
 
-AnalyzerOptions::ExplorationStrategyKind
+ExplorationStrategyKind
 AnalyzerOptions::getExplorationStrategy() {
   if (!ExplorationStrategy.hasValue()) {
 StringRef StratStr = getOptionAsString("exploration_strategy",
@@ -182,137 +182,6 @@
   return V.getValue();
 }
 
-bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
-  return getBooleanOption(IncludeTemporaryDtorsInCFG,
-  "cfg-temporary-dtors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeImplicitDtorsInCFG() {
-  return getBooleanOption(IncludeImplicitDtorsInCFG,
-  "cfg-implicit-dtors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeLifetimeInCFG() {
-  return getBooleanOption(IncludeLifetimeInCFG, "cfg-lifetime",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::includeLoopExitInCFG() {
-  return getBooleanOption(IncludeLoopExitInCFG, "cfg-loopexit",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::includeRichConstructorsInCFG() {
-  return getBooleanOption(IncludeRichConstructorsInCFG,
-  "cfg-rich-constructors",
-  /* Default = */ true);
-}
-
-bool AnalyzerOptions::includeScopesInCFG() {
-  return getBooleanOption(IncludeScopesInCFG,
-  "cfg-scopes",
-  /* Default = */ false);
-}
-
-bool AnalyzerOptions::mayInlineCXXStandardLibrary() {
-  return getBooleanOption(InlineCXXStandardLibrary,
-  "c++-stdlib-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineTemplateFunctions() {
-  return getBooleanOption(InlineTemplateFunctions,
-  "c++-template-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineCXXAllocator() {
-  return getBooleanOption(InlineCXXAllocator,
-  "c++-allocator-inlining",
-  /*Default=*/true);
-}
-
-bool AnalyzerOptions::mayInlineCXXContainerMethods() {
-  return getBooleanOption(InlineCXXContainerMethods,
-  "c++-container-inlining",
-  /*Default=*/false);
-}
-
-bool AnalyzerOptions::mayInlineCXXSharedPtrDtor() {
-  return getBooleanOption(InlineCXXSharedPtrDtor,
-  "c++-shared_ptr-inlining",
-  /*Default=*/false);
-}
-
-bool AnalyzerOptions::mayInlineCXXTemporaryDtors() {
-  return getBooleanOption(InlineCXXTemporaryDtors,
-  "c++-temp-dtor-inlining",
-  /*Default=*/true);
-}
-
-bool 

[PATCH] D53032: [clangd] Minimal implementation of automatic static index, behind a flag.

2018-10-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE344513: [clangd] Minimal implementation of automatic 
static index (not enabled). (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53032?vs=169694=169695#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53032

Files:
  clangd/CMakeLists.txt
  clangd/index/Background.cpp
  clangd/index/Background.h
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -17,7 +17,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
 
 #include "ClangdServer.h"
-#include 
+#include "index/Index.h"
 
 namespace clang {
 namespace clangd {
@@ -50,6 +50,9 @@
 llvm::Expected>
 runDocumentSymbols(ClangdServer , PathRef File);
 
+SymbolSlab runFuzzyFind(const SymbolIndex , StringRef Query);
+SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest );
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -10,6 +10,7 @@
 
 add_extra_unittest(ClangdTests
   Annotations.cpp
+  BackgroundIndexTests.cpp
   CancellationTests.cpp
   ClangdTests.cpp
   ClangdUnitTests.cpp
Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -0,0 +1,37 @@
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "index/Background.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using testing::UnorderedElementsAre;
+
+namespace clang {
+namespace clangd {
+
+MATCHER_P(Named, N, "") { return arg.Name == N; }
+
+TEST(BackgroundIndexTest, IndexTwoFiles) {
+  MockFSProvider FS;
+  // a.h yields different symbols when included by A.cc vs B.cc.
+  // Currently we store symbols for each TU, so we get both.
+  FS.Files[testPath("root/A.h")] = "void a_h(); void NAME(){}";
+  FS.Files[testPath("root/A.cc")] = "#include \"A.h\"";
+  FS.Files[testPath("root/B.cc")] = "#define NAME bar\n#include \"A.h\"";
+  BackgroundIndex Idx(Context::empty(), "", FS);
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", "-DNAME=foo", testPath("root/A.cc")};
+  Idx.enqueue(testPath("root"), Cmd);
+  Cmd.CommandLine.back() = Cmd.Filename = testPath("root/B.cc");
+  Idx.enqueue(testPath("root"), Cmd);
+
+  Idx.blockUntilIdleForTest();
+  EXPECT_THAT(runFuzzyFind(Idx, ""),
+  UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar")));
+}
+
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -125,5 +125,17 @@
   return std::move(*Result);
 }
 
+SymbolSlab runFuzzyFind(const SymbolIndex , StringRef Query) {
+  FuzzyFindRequest Req;
+  Req.Query = Query;
+  return runFuzzyFind(Index, Req);
+}
+
+SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest ) {
+  SymbolSlab::Builder Builder;
+  Index.fuzzyFind(Req, [&](const Symbol ) { Builder.insert(Sym); });
+  return std::move(Builder).build();
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -0,0 +1,79 @@
+//===--- Background.h - Build an index in a background thread *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H
+
+#include "Context.h"
+#include "FSProvider.h"
+#include "index/FileIndex.h"
+#include "index/Index.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/Support/SHA1.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+// Builds an in-memory index by by running the static indexer action over
+// all commands in a compilation database. Indexing happens in the background.
+// FIXME: it should also persist its state on disk for fast start.
+// FIXME: it should watch for changes to files on disk.
+class BackgroundIndex : public SwapIndex {
+public:
+  // FIXME: resource-dir injection should be hoisted somewhere common.
+  BackgroundIndex(Context 

[clang-tools-extra] r344513 - [clangd] Minimal implementation of automatic static index (not enabled).

2018-10-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Oct 15 06:34:10 2018
New Revision: 344513

URL: http://llvm.org/viewvc/llvm-project?rev=344513=rev
Log:
[clangd] Minimal implementation of automatic static index (not enabled).

Summary:
See tinyurl.com/clangd-automatic-index for design and goals.

Lots of limitations to keep this patch smallish, TODOs everywhere:
 - no serialization to disk
 - no changes to dynamic index, which now has a much simpler job
 - no partitioning of symbols by file to avoid duplication of header symbols
 - no reindexing of edited files
 - only a single worker thread
 - compilation database is slurped synchronously (doesn't scale)
 - uses memindex, rebuilds after every file (should be dex, periodically)

It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering
isn't clear (it should really be in ClangdServer, but ClangdLSPServer
has all the CDB interactions).

Reviewers: ioeric

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

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

Added:
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
clang-tools-extra/trunk/unittests/clangd/SyncAPI.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=344513=344512=344513=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Oct 15 06:34:10 2018
@@ -38,6 +38,7 @@ add_clang_library(clangDaemon
   URI.cpp
   XRefs.cpp
 
+  index/Background.cpp
   index/CanonicalIncludes.cpp
   index/FileIndex.cpp
   index/Index.cpp

Added: clang-tools-extra/trunk/clangd/index/Background.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=344513=auto
==
--- clang-tools-extra/trunk/clangd/index/Background.cpp (added)
+++ clang-tools-extra/trunk/clangd/index/Background.cpp Mon Oct 15 06:34:10 2018
@@ -0,0 +1,191 @@
+//===-- Background.cpp - Build an index in a background thread 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "index/Background.h"
+#include "ClangdUnit.h"
+#include "Compiler.h"
+#include "Logger.h"
+#include "Trace.h"
+#include "index/IndexAction.h"
+#include "index/MemIndex.h"
+#include "index/Serialization.h"
+#include "llvm/Support/SHA1.h"
+#include 
+
+using namespace llvm;
+namespace clang {
+namespace clangd {
+
+BackgroundIndex::BackgroundIndex(Context BackgroundContext,
+ StringRef ResourceDir,
+ const FileSystemProvider )
+: SwapIndex(llvm::make_unique()), ResourceDir(ResourceDir),
+  FSProvider(FSProvider), BackgroundContext(std::move(BackgroundContext)),
+  Thread([this] { run(); }) {}
+
+BackgroundIndex::~BackgroundIndex() {
+  stop();
+  Thread.join();
+}
+
+void BackgroundIndex::stop() {
+  {
+std::lock_guard Lock(QueueMu);
+ShouldStop = true;
+  }
+  QueueCV.notify_all();
+}
+
+void BackgroundIndex::run() {
+  WithContext Background(std::move(BackgroundContext));
+  while (true) {
+llvm::Optional Task;
+{
+  std::unique_lock Lock(QueueMu);
+  QueueCV.wait(Lock, [&] { return ShouldStop || !Queue.empty(); });
+  if (ShouldStop) {
+Queue.clear();
+QueueCV.notify_all();
+return;
+  }
+  ++NumActiveTasks;
+  Task = std::move(Queue.front());
+  Queue.pop_front();
+}
+(*Task)();
+{
+  std::unique_lock Lock(QueueMu);
+  assert(NumActiveTasks > 0 && "before decrementing");
+  --NumActiveTasks;
+}
+QueueCV.notify_all();
+  }
+}
+
+void BackgroundIndex::blockUntilIdleForTest() {
+  std::unique_lock Lock(QueueMu);
+  QueueCV.wait(Lock, [&] { return Queue.empty() && NumActiveTasks == 0; });
+}
+
+void BackgroundIndex::enqueue(StringRef Directory,
+  tooling::CompileCommand Cmd) {
+  std::lock_guard Lock(QueueMu);
+  enqueueLocked(std::move(Cmd));
+}
+
+void BackgroundIndex::enqueueAll(StringRef Directory,
+ const tooling::CompilationDatabase ) {
+  trace::Span Tracer("BackgroundIndexEnqueueCDB");
+  // FIXME: this function may be slow. Perhaps enqueue a task to re-read the 
CDB
+  // from disk and enqueue the commands 

  1   2   >