[PATCH] D55415: Revert removal of tidy plugin support from libclang

2018-12-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.
yvvan added reviewers: bkramer, arphaman, nik.
Herald added subscribers: kadircet, jkorous, ioeric, javed.absar, ilya-biryukov.

libclang has nothing to do with clangd so I don't see why having the last one 
is the reason to remove features from libclang. Especially without reviews.


https://reviews.llvm.org/D55415

Files:
  unittests/clangd/TUSchedulerTests.cpp


Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -709,29 +709,6 @@
   TUState(TUAction::Idle, /*No action*/ "")));
 }
 
-TEST_F(TUSchedulerTests, NoTUStatusEmittedForRemovedFile) {
-  class CaptureTUStatus : public DiagnosticsConsumer {
-  public:
-void onDiagnosticsReady(PathRef File,
-std::vector Diagnostics) override {}
-
-void onFileUpdated(PathRef File, const TUStatus &Status) override {
-  // Block the worker thread until the document is removed.
-  Removed.wait();
-}
-Notification Removed;
-  } CaptureTUStatus;
-  MockFSProvider FS;
-  MockCompilationDatabase CDB;
-  ClangdServer Server(CDB, FS, CaptureTUStatus, ClangdServer::optsForTest());
-
-  Server.addDocument(testPath("foo.cpp"), "int main() {}",
- WantDiagnostics::Yes);
-  Server.removeDocument(testPath("foo.cpp"));
-  CaptureTUStatus.Removed.notify();
-  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for finishing";
-}
-
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -709,29 +709,6 @@
   TUState(TUAction::Idle, /*No action*/ "")));
 }
 
-TEST_F(TUSchedulerTests, NoTUStatusEmittedForRemovedFile) {
-  class CaptureTUStatus : public DiagnosticsConsumer {
-  public:
-void onDiagnosticsReady(PathRef File,
-std::vector Diagnostics) override {}
-
-void onFileUpdated(PathRef File, const TUStatus &Status) override {
-  // Block the worker thread until the document is removed.
-  Removed.wait();
-}
-Notification Removed;
-  } CaptureTUStatus;
-  MockFSProvider FS;
-  MockCompilationDatabase CDB;
-  ClangdServer Server(CDB, FS, CaptureTUStatus, ClangdServer::optsForTest());
-
-  Server.addDocument(testPath("foo.cpp"), "int main() {}",
- WantDiagnostics::Yes);
-  Server.removeDocument(testPath("foo.cpp"));
-  CaptureTUStatus.Removed.notify();
-  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for finishing";
-}
-
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55415: Revert removal of tidy plugin support from libclang

2018-12-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 177134.
yvvan added a comment.
Herald added a subscriber: mgorny.

I generated the wrong diff. This is the proper one.


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

https://reviews.llvm.org/D55415

Files:
  tools/libclang/CIndex.cpp
  tools/libclang/CMakeLists.txt


Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -47,6 +47,15 @@
   list(APPEND LIBS clangARCMigrate)
 endif ()
 
+if (TARGET clangTidyPlugin)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+  list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+list(APPEND LLVM_COMPILE_FLAGS 
"-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
+endif ()
+
 find_library(DL_LIBRARY_PATH dl)
 if (DL_LIBRARY_PATH)
   list(APPEND LIBS dl)
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -8938,3 +8938,16 @@
 OS << "--\n";
   }
 }
+
+#ifdef CLANG_TOOL_EXTRA_BUILD
+// This anchor is used to force the linker to link the clang-tidy plugin.
+extern volatile int ClangTidyPluginAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination =
+ClangTidyPluginAnchorSource;
+
+// This anchor is used to force the linker to link the clang-include-fixer
+// plugin.
+extern volatile int ClangIncludeFixerPluginAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ClangIncludeFixerPluginAnchorDestination =
+ClangIncludeFixerPluginAnchorSource;
+#endif


Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -47,6 +47,15 @@
   list(APPEND LIBS clangARCMigrate)
 endif ()
 
+if (TARGET clangTidyPlugin)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+  list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
+endif ()
+
 find_library(DL_LIBRARY_PATH dl)
 if (DL_LIBRARY_PATH)
   list(APPEND LIBS dl)
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -8938,3 +8938,16 @@
 OS << "--\n";
   }
 }
+
+#ifdef CLANG_TOOL_EXTRA_BUILD
+// This anchor is used to force the linker to link the clang-tidy plugin.
+extern volatile int ClangTidyPluginAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination =
+ClangTidyPluginAnchorSource;
+
+// This anchor is used to force the linker to link the clang-include-fixer
+// plugin.
+extern volatile int ClangIncludeFixerPluginAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ClangIncludeFixerPluginAnchorDestination =
+ClangIncludeFixerPluginAnchorSource;
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348569 - Fix thunks returning memptrs via sret by emitting also scalar return values directly in sret slot (PR39901)

2018-12-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Dec  7 00:17:26 2018
New Revision: 348569

URL: http://llvm.org/viewvc/llvm-project?rev=348569&view=rev
Log:
Fix thunks returning memptrs via sret by emitting also scalar return values 
directly in sret slot (PR39901)

Thunks that return member pointers via sret are broken due to using temporary
storage for the return value on the stack and then passing that pointer to a
tail call, violating the rule that a tail call can't access allocas in the
caller (see bug).

Since r90526, we put aggregate return values directly in the sret slot, but
this doesn't apply to member pointers which are considered scalar.

Unless I'm missing something subtle, we should be able to always use the sret
slot directly for indirect return values.

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

Added:
cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=348569&r1=348568&r2=348569&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Fri Dec  7 00:17:26 2018
@@ -350,8 +350,7 @@ void CodeGenFunction::EmitCallAndReturnF
   : FPT->getReturnType();
   ReturnValueSlot Slot;
   if (!ResultType->isVoidType() &&
-  CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect &&
-  !hasScalarEvaluationKind(CurFnInfo->getReturnType()))
+  CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
 Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified());
 
   // Now emit our call.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=348569&r1=348568&r2=348569&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Dec  7 00:17:26 2018
@@ -1073,9 +1073,8 @@ void CodeGenFunction::StartFunction(Glob
 // Count the implicit return.
 if (!endsWithReturn(D))
   ++NumReturnExprs;
-  } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect &&
- !hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
-// Indirect aggregate return; emit returned value directly into sret slot.
+  } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) {
+// Indirect return; emit returned value directly into sret slot.
 // This reduces code size, and affects correctness in C++.
 auto AI = CurFn->arg_begin();
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())

Added: cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp?rev=348569&view=auto
==
--- cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp Fri Dec  7 00:17:26 
2018
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple=i686 -emit-llvm -o - %s | FileCheck %s
+
+
+struct X;
+typedef void (X::*memptr)();
+
+struct A {
+  virtual memptr f();
+};
+
+struct B {
+  virtual memptr f();
+};
+
+struct C : A, B {
+  C();
+  memptr f() override __attribute__((noinline)) { return nullptr; };
+};
+
+C::C() {}
+
+// Make sure the member pointer is returned from the thunk via the return slot.
+// Because of the tail call, the return value cannot be copied into a local
+// alloca. (PR39901)
+
+// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias 
sret %agg.result, %struct.C* %this)
+// CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret %agg.result


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


[PATCH] D55371: Fix thunks returning memptrs via sret by emitting also scalar return values directly in sret slot (PR39901)

2018-12-07 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348569: Fix thunks returning memptrs via sret by emitting 
also scalar return values… (authored by hans, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55371?vs=176971&id=177135#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55371

Files:
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp


Index: cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
===
--- cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
+++ cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple=i686 -emit-llvm -o - %s | FileCheck %s
+
+
+struct X;
+typedef void (X::*memptr)();
+
+struct A {
+  virtual memptr f();
+};
+
+struct B {
+  virtual memptr f();
+};
+
+struct C : A, B {
+  C();
+  memptr f() override __attribute__((noinline)) { return nullptr; };
+};
+
+C::C() {}
+
+// Make sure the member pointer is returned from the thunk via the return slot.
+// Because of the tail call, the return value cannot be copied into a local
+// alloca. (PR39901)
+
+// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias 
sret %agg.result, %struct.C* %this)
+// CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret %agg.result
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -1073,9 +1073,8 @@
 // Count the implicit return.
 if (!endsWithReturn(D))
   ++NumReturnExprs;
-  } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect &&
- !hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
-// Indirect aggregate return; emit returned value directly into sret slot.
+  } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) {
+// Indirect return; emit returned value directly into sret slot.
 // This reduces code size, and affects correctness in C++.
 auto AI = CurFn->arg_begin();
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
Index: cfe/trunk/lib/CodeGen/CGVTables.cpp
===
--- cfe/trunk/lib/CodeGen/CGVTables.cpp
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp
@@ -350,8 +350,7 @@
   : FPT->getReturnType();
   ReturnValueSlot Slot;
   if (!ResultType->isVoidType() &&
-  CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect &&
-  !hasScalarEvaluationKind(CurFnInfo->getReturnType()))
+  CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
 Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified());
 
   // Now emit our call.


Index: cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
===
--- cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
+++ cfe/trunk/test/CodeGenCXX/thunk-returning-memptr.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple=i686 -emit-llvm -o - %s | FileCheck %s
+
+
+struct X;
+typedef void (X::*memptr)();
+
+struct A {
+  virtual memptr f();
+};
+
+struct B {
+  virtual memptr f();
+};
+
+struct C : A, B {
+  C();
+  memptr f() override __attribute__((noinline)) { return nullptr; };
+};
+
+C::C() {}
+
+// Make sure the member pointer is returned from the thunk via the return slot.
+// Because of the tail call, the return value cannot be copied into a local
+// alloca. (PR39901)
+
+// CHECK-LABEL: define linkonce_odr void @_ZThn4_N1C1fEv({ i32, i32 }* noalias sret %agg.result, %struct.C* %this)
+// CHECK: tail call void @_ZN1C1fEv({ i32, i32 }* sret %agg.result
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -1073,9 +1073,8 @@
 // Count the implicit return.
 if (!endsWithReturn(D))
   ++NumReturnExprs;
-  } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect &&
- !hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
-// Indirect aggregate return; emit returned value directly into sret slot.
+  } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) {
+// Indirect return; emit returned value directly into sret slot.
 // This reduces code size, and affects correctness in C++.
 auto AI = CurFn->arg_begin();
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
Index: cfe/trunk/lib/CodeGen/CGVTables.cpp
===
--- cfe/trunk/lib/CodeGen/CGVTables.cpp
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp
@@ -350,8 +350,7 @@
 

[PATCH] D55415: Revert removal of tidy plugin support from libclang

2018-12-07 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

+1 as this seems to fix the regression.


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

https://reviews.llvm.org/D55415



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


[PATCH] D55415: Revert removal of tidy plugin support from libclang

2018-12-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

We can also add an extra variable for it if you care about build time


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

https://reviews.llvm.org/D55415



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


[PATCH] D55192: [PowerPC] VSX register support for inline assembly

2018-12-07 Thread Zhang Kang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348572: [PowerPC] VSX register support for inline assembly 
(authored by ZhangKang, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55192?vs=177132&id=177141#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55192

Files:
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/PPC.h
  test/CodeGen/inline-asm-matching-ppc-vsx.c


Index: test/CodeGen/inline-asm-matching-ppc-vsx.c
===
--- test/CodeGen/inline-asm-matching-ppc-vsx.c
+++ test/CodeGen/inline-asm-matching-ppc-vsx.c
@@ -0,0 +1,20 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -target-feature +vsx \
+// RUN:   -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
+
+// This case is to test VSX register support in the clobbers list for inline 
asm.
+void testVSX (void) {
+  unsigned int a = 0;
+  unsigned int *dbell=&a;
+  int d;
+  __asm__ __volatile__ (
+"lxvw4x  %%vs32, 0, %2\n\t"
+"stxvw4x %%vs32, 0, %1"
+: "=m"(*(volatile unsigned int*)(dbell))
+: "r" (dbell), "r" (&d)
+: "vs32"
+  );
+}
+
+// CHECK: call void asm sideeffect "lxvw4x  %vs32, 0, $2\0A\09stxvw4x %vs32, 
0, $1", "=*m,r,r,~{vs32}"
Index: lib/Basic/Targets/PPC.cpp
===
--- lib/Basic/Targets/PPC.cpp
+++ lib/Basic/Targets/PPC.cpp
@@ -412,6 +412,36 @@
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+// PPC ELFABIv2 DWARF Definitoin "Table 2.26. Mappings of Common Registers".
+// vs0 ~ vs31 is mapping to 32 - 63,
+// vs32 ~ vs63 is mapping to 77 - 108. 
+const TargetInfo::AddlRegName GCCAddlRegNames[] = {
+// Table of additional register names to use in user input.
+{{"vs0"}, 32},   {{"vs1"}, 33},   {{"vs2"}, 34},   {{"vs3"}, 35}, 
+{{"vs4"}, 36},   {{"vs5"}, 37},   {{"vs6"}, 38},   {{"vs7"}, 39},
+{{"vs8"}, 40},   {{"vs9"}, 41},   {{"vs10"}, 42},  {{"vs11"}, 43},
+{{"vs12"}, 44},  {{"vs13"}, 45},  {{"vs14"}, 46},  {{"vs15"}, 47},
+{{"vs16"}, 48},  {{"vs17"}, 49},  {{"vs18"}, 50},  {{"vs19"}, 51},
+{{"vs20"}, 52},  {{"vs21"}, 53},  {{"vs22"}, 54},  {{"vs23"}, 55},
+{{"vs24"}, 56},  {{"vs25"}, 57},  {{"vs26"}, 58},  {{"vs27"}, 59},
+{{"vs28"}, 60},  {{"vs29"}, 61},  {{"vs30"}, 62},  {{"vs31"}, 63},
+{{"vs32"}, 77},  {{"vs33"}, 78},  {{"vs34"}, 79},  {{"vs35"}, 80},
+{{"vs36"}, 81},  {{"vs37"}, 82},  {{"vs38"}, 83},  {{"vs39"}, 84},
+{{"vs40"}, 85},  {{"vs41"}, 86},  {{"vs42"}, 87},  {{"vs43"}, 88},
+{{"vs44"}, 89},  {{"vs45"}, 90},  {{"vs46"}, 91},  {{"vs47"}, 92},
+{{"vs48"}, 93},  {{"vs49"}, 94},  {{"vs50"}, 95},  {{"vs51"}, 96},
+{{"vs52"}, 97},  {{"vs53"}, 98},  {{"vs54"}, 99},  {{"vs55"}, 100},
+{{"vs56"}, 101}, {{"vs57"}, 102}, {{"vs58"}, 103}, {{"vs59"}, 104},
+{{"vs60"}, 105}, {{"vs61"}, 106}, {{"vs62"}, 107}, {{"vs63"}, 108},
+};
+
+ArrayRef PPCTargetInfo::getGCCAddlRegNames() const {
+  if (ABI == "elfv2")
+return llvm::makeArrayRef(GCCAddlRegNames);
+  else 
+return TargetInfo::getGCCAddlRegNames(); 
+}
+
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
 {"generic"}, {"440"}, {"450"}, {"601"},{"602"},
 {"603"}, {"603e"},{"603ev"},   {"604"},{"604e"},
Index: lib/Basic/Targets/PPC.h
===
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -176,6 +176,8 @@
 
   ArrayRef getGCCRegAliases() const override;
 
+  ArrayRef getGCCAddlRegNames() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
 switch (*Name) {


Index: test/CodeGen/inline-asm-matching-ppc-vsx.c
===
--- test/CodeGen/inline-asm-matching-ppc-vsx.c
+++ test/CodeGen/inline-asm-matching-ppc-vsx.c
@@ -0,0 +1,20 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -target-feature +vsx \
+// RUN:   -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
+
+// This case is to test VSX register support in the clobbers list for inline asm.
+void testVSX (void) {
+  unsigned int a = 0;
+  unsigned int *dbell=&a;
+  int d;
+  __asm__ __volatile__ (
+"lxvw4x  %%vs32, 0, %2\n\t"
+"stxvw4x %%vs32, 0, %1"
+: "=m"(*(volatile unsigned int*)(dbell))
+: "r" (dbell), "r" (&d)
+: "vs32"
+  );
+}
+
+// CHECK: call void asm sideeffect "lxvw4x  %vs32, 0, $2\0A\09stxvw4x %vs32, 0, $1", "=*m,r,r,~{vs32}"
Index: lib/Basic/Targets/PPC.cpp
===
--- lib/Basic/Targets/PPC.cpp
+++ lib/Basic/Targets/PPC.cpp
@@ -412,6 +412,36 @@
   return llvm::makeArrayRef(GCCRegA

[PATCH] D55270: [Sema] Further improvements to to static_assert diagnostics.

2018-12-07 Thread Clement Courbet via Phabricator via cfe-commits
courbet marked an inline comment as done.
courbet added inline comments.



Comment at: test/PCH/cxx-static_assert.cpp:17
 
-// expected-error@12 {{static_assert failed "N is not 2!"}}
+// expected-error@12 {{static_assert failed due to requirement '1 == 2' "N is 
not 2!"}}
 T<1> t1; // expected-note {{in instantiation of template class 'T<1>' 
requested here}}

aaron.ballman wrote:
> I'm not certain how I feel about now printing the failure condition when 
> there's an explicit message provided. From what I understand, a fair amount 
> of code in the wild does `static_assert(some_condition, "some_condition")` 
> because of older language modes where the message was not optional. I worry 
> we're going to start seeing a lot of diagnostics like: `static_assert failed 
> due to requirement '1 == 2' "N == 2"`, which seems a bit low-quality. See 
> `DFAPacketizer::DFAPacketizer()` in LLVM as an example of something similar.
> 
> Given that the user entered a message, do we still want to show the 
> requirement? Do we feel the same way if the requirement is fairly large?
The issue is that `"N == 2"` is a useless error message. Actually, since the  
error message has to be a string literal, there is no way for the user to print 
a debuggable output. So I really think we should print the failed condition.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55270



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


[PATCH] D55262: [OpenCL] Fix for TBAA information of pointer after addresspacecast

2018-12-07 Thread Romanov Vlad via Phabricator via cfe-commits
romanovvlad marked an inline comment as done.
romanovvlad added a comment.

Could you merge it? I have no rights to do it.


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

https://reviews.llvm.org/D55262



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


[PATCH] D55382: Make -Wstring-plus-int warns even if when the result is not out of bounds

2018-12-07 Thread Arnaud Bienner via Phabricator via cfe-commits
ArnaudBienner added a comment.

I found the commit: [1] which links to a related discussion [2] but there isn't 
much details. I wasn't sure if there was other discussions.
I will try to build Firefox with this change, and see how it goes (just need to 
find some time to do it).
I'll keep you posted.

[1]: 
https://github.com/llvm-mirror/clang/commit/1cb2d742eb6635aeab6132ee5f0b5781d39487d7
[2]: http://comments.gmane.org/gmane.comp.compilers.clang.scm/47203


Repository:
  rC Clang

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

https://reviews.llvm.org/D55382



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


[PATCH] D55417: [clangd] Change diskbackedstorage to be atomic

2018-12-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, jfb, arphaman, jkorous, MaskRay, ioeric.

There was a chance that multiple clangd instances could try to write
same shard, in which case we would get a malformed file most likely. This patch
changes the writing mechanism to first write to a temporary file and then rename
it to fit real destination. Which is guaranteed to be atomic by POSIX.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55417

Files:
  clangd/index/BackgroundIndexStorage.cpp


Index: clangd/index/BackgroundIndexStorage.cpp
===
--- clangd/index/BackgroundIndexStorage.cpp
+++ clangd/index/BackgroundIndexStorage.cpp
@@ -9,6 +9,8 @@
 
 #include "Logger.h"
 #include "index/Background.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -70,13 +72,28 @@
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
-std::error_code EC;
-llvm::raw_fd_ostream OS(ShardPath, EC);
+// Write to a temporary file first.
+llvm::SmallString<64> TempPath;
+int FD;
+auto EC = llvm::sys::fs::createTemporaryFile("clangd", "index-shard", FD,
+ TempPath);
 if (EC)
   return llvm::errorCodeToError(EC);
+// Make sure temp file is destroyed at exit.
+auto _ =
+llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
+llvm::raw_fd_ostream OS(FD, true);
 OS << Shard;
 OS.close();
+if (OS.has_error())
+  return llvm::errorCodeToError(OS.error());
+
+// Then move to real location.
+const auto ShardPath =
+getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
+EC = llvm::sys::fs::rename(TempPath, ShardPath);
+if (EC)
+  return llvm::errorCodeToError(OS.error());
 return llvm::errorCodeToError(OS.error());
   }
 };


Index: clangd/index/BackgroundIndexStorage.cpp
===
--- clangd/index/BackgroundIndexStorage.cpp
+++ clangd/index/BackgroundIndexStorage.cpp
@@ -9,6 +9,8 @@
 
 #include "Logger.h"
 #include "index/Background.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -70,13 +72,28 @@
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
-std::error_code EC;
-llvm::raw_fd_ostream OS(ShardPath, EC);
+// Write to a temporary file first.
+llvm::SmallString<64> TempPath;
+int FD;
+auto EC = llvm::sys::fs::createTemporaryFile("clangd", "index-shard", FD,
+ TempPath);
 if (EC)
   return llvm::errorCodeToError(EC);
+// Make sure temp file is destroyed at exit.
+auto _ =
+llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
+llvm::raw_fd_ostream OS(FD, true);
 OS << Shard;
 OS.close();
+if (OS.has_error())
+  return llvm::errorCodeToError(OS.error());
+
+// Then move to real location.
+const auto ShardPath =
+getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
+EC = llvm::sys::fs::rename(TempPath, ShardPath);
+if (EC)
+  return llvm::errorCodeToError(OS.error());
 return llvm::errorCodeToError(OS.error());
   }
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55417: [clangd] Change diskbackedstorage to be atomic

2018-12-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 177146.
kadircet added a comment.

- Fix returns


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55417

Files:
  clangd/index/BackgroundIndexStorage.cpp


Index: clangd/index/BackgroundIndexStorage.cpp
===
--- clangd/index/BackgroundIndexStorage.cpp
+++ clangd/index/BackgroundIndexStorage.cpp
@@ -9,6 +9,8 @@
 
 #include "Logger.h"
 #include "index/Background.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -70,14 +72,29 @@
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
-std::error_code EC;
-llvm::raw_fd_ostream OS(ShardPath, EC);
+// Write to a temporary file first.
+llvm::SmallString<64> TempPath;
+int FD;
+auto EC = llvm::sys::fs::createTemporaryFile("clangd", "index-shard", FD,
+ TempPath);
 if (EC)
   return llvm::errorCodeToError(EC);
+// Make sure temp file is destroyed at exit.
+auto _ =
+llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
+llvm::raw_fd_ostream OS(FD, true);
 OS << Shard;
 OS.close();
-return llvm::errorCodeToError(OS.error());
+if (OS.has_error())
+  return llvm::errorCodeToError(OS.error());
+
+// Then move to real location.
+const auto ShardPath =
+getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
+EC = llvm::sys::fs::rename(TempPath, ShardPath);
+if (EC)
+  return llvm::errorCodeToError(EC);
+return llvm::ErrorSuccess();
   }
 };
 


Index: clangd/index/BackgroundIndexStorage.cpp
===
--- clangd/index/BackgroundIndexStorage.cpp
+++ clangd/index/BackgroundIndexStorage.cpp
@@ -9,6 +9,8 @@
 
 #include "Logger.h"
 #include "index/Background.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -70,14 +72,29 @@
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
-std::error_code EC;
-llvm::raw_fd_ostream OS(ShardPath, EC);
+// Write to a temporary file first.
+llvm::SmallString<64> TempPath;
+int FD;
+auto EC = llvm::sys::fs::createTemporaryFile("clangd", "index-shard", FD,
+ TempPath);
 if (EC)
   return llvm::errorCodeToError(EC);
+// Make sure temp file is destroyed at exit.
+auto _ =
+llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
+llvm::raw_fd_ostream OS(FD, true);
 OS << Shard;
 OS.close();
-return llvm::errorCodeToError(OS.error());
+if (OS.has_error())
+  return llvm::errorCodeToError(OS.error());
+
+// Then move to real location.
+const auto ShardPath =
+getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
+EC = llvm::sys::fs::rename(TempPath, ShardPath);
+if (EC)
+  return llvm::errorCodeToError(EC);
+return llvm::ErrorSuccess();
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check

2018-12-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added subscribers: astrelni, ahedberg.
hokein added a comment.
This revision is now accepted and ready to land.

The check looks good from my side, except one nit.

> I assume I've got the right reviewers here, but I've also been sending a 
> bunch of stuff your way lately, so if I'm overwhelming review capacity, 
> please let me know.

I think in long run, it would be desired to have Abseil experts participate in 
reviews of abseil-related checks (upstream clang-tidy reviewers don't have much 
knowledge about Abseil). Abseil team members (@astrelni, @ahedberg) might be 
more interested in theses checks which could accelerate the review process.




Comment at: test/clang-tidy/abseil-duration-subtraction.cpp:4
+// Mimic the implementation of absl::Duration
+namespace absl {
+

We have multiple implementations in other `abseil-duration-*` tests, I think we 
could pull them out (in `test/clang-tidy/Inputs/absl/time/time.h`).


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

https://reviews.llvm.org/D55245



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


[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check

2018-12-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please always upload all patches with the full context (`-U9`)




Comment at: clang-tidy/abseil/DurationRewriter.cpp:35
+getInverseForScale(DurationScale Scale) {
+  static const std::unordered_map>

https://llvm.org/docs/ProgrammersManual.html#other-map-like-container-options
> We never use hash_set and unordered_set because they are generally very 
> expensive (each insertion requires a malloc) and very non-portable.

Since the key is an enum, [[ 
https://llvm.org/docs/ProgrammersManual.html#llvm-adt-indexedmap-h | 
`llvm/ADT/IndexedMap.h` ]] should be a much better fit.



Comment at: clang-tidy/abseil/DurationRewriter.cpp:68
+  getInverseForScale(Scale);
+  if (const Expr *MaybeCallArg = selectFirst(
+  "e", match(callExpr(callee(functionDecl(

`if (const auto *MaybeCallArg`



Comment at: clang-tidy/abseil/DurationRewriter.cpp:68
+  getInverseForScale(Scale);
+  if (const Expr *MaybeCallArg = selectFirst(
+  "e", match(callExpr(callee(functionDecl(

lebedev.ri wrote:
> `if (const auto *MaybeCallArg`
Early return?



Comment at: clang-tidy/abseil/DurationRewriter.cpp:74
+ Node, *Result.Context))) {
+return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
+  }

So you generate fix-it, and then immediately degrade it into a string. Weird.


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

https://reviews.llvm.org/D55245



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


[PATCH] D53830: [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-12-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a subscriber: hwright.
hokein added a comment.

+ @hwright who have implemented a bunch of `absl-duration-*` checks, you might 
be interested in this as well.


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

https://reviews.llvm.org/D53830



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


[PATCH] D55417: [clangd] Change diskbackedstorage to be atomic

2018-12-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

NIT: I believe we're missing a hyphen in the change description, i.e. it should 
be `disk-backed`.




Comment at: clangd/index/BackgroundIndexStorage.cpp:76
+// Write to a temporary file first.
+llvm::SmallString<64> TempPath;
+int FD;

Maybe extract this into a helper function?
Something like
```
std::error_code writeAtomically(StringRef OutPath, 
function_ref Writer) {
 /// create temp file, open output stream.
 Writer(OS):
 /// Move the temp file into OutPath.
}
```

This would keep the `storeShard` function as readable as it is now



Comment at: clangd/index/BackgroundIndexStorage.cpp:78
+int FD;
+auto EC = llvm::sys::fs::createTemporaryFile("clangd", "index-shard", FD,
+ TempPath);

Maybe create these temporary files in the same dir? That would ensure the move 
operations do not require transferring data between physical devices.
If the output file is `/some/path/foo.bar`, we could create files named 
`/some/path/foo.bar.tmp#`



Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55417



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


[PATCH] D48589: [WIP] [CodeGen] Allow specifying Extend to CoerceAndExpand

2018-12-07 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 abandoned this revision.
rogfer01 added a comment.

Upstream 

 recently amended the ABI spec so it looks to me this is not going to be needed.


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

https://reviews.llvm.org/D48589



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


r348582 - Add a AArch64 triple to tiny codemodel test.

2018-12-07 Thread David Green via cfe-commits
Author: dmgreen
Date: Fri Dec  7 03:16:03 2018
New Revision: 348582

URL: http://llvm.org/viewvc/llvm-project?rev=348582&view=rev
Log:
Add a AArch64 triple to tiny codemodel test.

Most other targets do not support the tiny code model.


Modified:
cfe/trunk/test/CodeGen/codemodels.c

Modified: cfe/trunk/test/CodeGen/codemodels.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/codemodels.c?rev=348582&r1=348581&r2=348582&view=diff
==
--- cfe/trunk/test/CodeGen/codemodels.c (original)
+++ cfe/trunk/test/CodeGen/codemodels.c Fri Dec  7 03:16:03 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm  %s -o - | FileCheck %s 
-check-prefix=CHECK-NOMODEL
-// RUN: %clang_cc1 -emit-llvm -mcode-model tiny %s -o - | FileCheck %s 
-check-prefix=CHECK-TINY
+// RUN: %clang_cc1 -triple aarch64-unknown-none-eabi -emit-llvm -mcode-model 
tiny %s -o - | FileCheck %s -check-prefix=CHECK-TINY
 // RUN: %clang_cc1 -emit-llvm -mcode-model small %s -o - | FileCheck %s 
-check-prefix=CHECK-SMALL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -mcode-model 
kernel %s -o - | FileCheck %s -check-prefix=CHECK-KERNEL
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -mcode-model 
medium %s -o - | FileCheck %s -check-prefix=CHECK-MEDIUM


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


[clang-tools-extra] r348583 - [clang-tidy] Remove duplicated getText implementation, NFC

2018-12-07 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Dec  7 03:25:37 2018
New Revision: 348583

URL: http://llvm.org/viewvc/llvm-project?rev=348583&view=rev
Log:
[clang-tidy] Remove duplicated getText implementation, NFC

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp?rev=348583&r1=348582&r2=348583&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
Fri Dec  7 03:25:37 2018
@@ -13,6 +13,7 @@
 
 #include "RedundantStringCStrCheck.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Tooling/FixIt.h"
 
 using namespace clang::ast_matchers;
 
@@ -22,14 +23,6 @@ namespace readability {
 
 namespace {
 
-template 
-StringRef getText(const ast_matchers::MatchFinder::MatchResult &Result,
-  T const &Node) {
-  return Lexer::getSourceText(
-  CharSourceRange::getTokenRange(Node.getSourceRange()),
-  *Result.SourceManager, Result.Context->getLangOpts());
-}
-
 // Return true if expr needs to be put in parens when it is an argument of a
 // prefix unary operator, e.g. when it is a binary or ternary operator
 // syntactically.
@@ -54,10 +47,12 @@ formatDereference(const ast_matchers::Ma
   if (const auto *Op = dyn_cast(&ExprNode)) {
 if (Op->getOpcode() == UO_AddrOf) {
   // Strip leading '&'.
-  return getText(Result, *Op->getSubExpr()->IgnoreParens());
+  return tooling::fixit::getText(*Op->getSubExpr()->IgnoreParens(),
+ *Result.Context);
 }
   }
-  StringRef Text = getText(Result, ExprNode);
+  StringRef Text = tooling::fixit::getText(ExprNode, *Result.Context);
+
   if (Text.empty())
 return std::string();
   // Add leading '*'.
@@ -185,7 +180,8 @@ void RedundantStringCStrCheck::check(con
   // Replace the "call" node with the "arg" node, prefixed with '*'
   // if the call was using '->' rather than '.'.
   std::string ArgText =
-  Arrow ? formatDereference(Result, *Arg) : getText(Result, *Arg).str();
+  Arrow ? formatDereference(Result, *Arg)
+: tooling::fixit::getText(*Arg, *Result.Context).str();
   if (ArgText.empty())
 return;
 


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


[PATCH] D54592: [analyzer][CStringChecker] evaluate explicit_bzero

2018-12-07 Thread David CARLIER via Phabricator via cfe-commits
devnexen marked an inline comment as done.
devnexen added inline comments.



Comment at: test/Analysis/string.c:1405-1406
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  bzero(str + 2, 2);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{FALSE}}
+}

NoQ wrote:
> Let's also add the true statement. I.e., do we know here that the actual 
> length is 2?
I think that s the limit of this checker (even with memset that does not work).


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

https://reviews.llvm.org/D54592



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


[PATCH] D55424: [analyzer] Supply all checkers with a shouldRegister function

2018-12-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, MTC, martong.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, jfb, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.
Herald added a reviewer: teemperor.
Szelethus added a parent revision: D54437: [analyzer][NFC] Merge 
ClangCheckerRegistry to CheckerRegistry.

Introduce the boolean `ento::shouldRegister##CHECKERNAME(const LangOptions 
&LO)` function very similarly to `ento::register##CHECKERNAME`. This will force 
every checker to implement this function, but maybe it isn't that bad: I saw a 
lot of ObjC or C++ specific checkers that should probably not register 
themselves based on some `LangOptions` (mine too), but they do anyways.

A big benefit of this is that //all// registry functions now register their 
checker, once it is called, registration is guaranteed.

This patch is a part of a greater effort to reinvent checker registration, more 
info here: D54438#1315953 


Repository:
  rC Clang

https://reviews.llvm.org/D55424

Files:
  include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
  include/clang/StaticAnalyzer/Core/Checker.h
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  include/clang/StaticAnalyzer/Frontend/FrontendActions.h
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
  lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
  lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
  lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
  lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
  lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
  lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
  lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
  lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
  lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
  lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
  lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCUnusedIVa

[PATCH] D55425: [analyzer] Split unix.API up to UnixAPIMisuseChecker and UnixAPIPortabilityChecker

2018-12-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, MTC.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, jfb, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.

The actual implementation of `unix.API` features a dual-checker: two checkers 
in one, even though they don't even interact at all. Split them up, as this is 
a problem for establishing dependencies.

Since the plist files change (and that's a benefit!) this patch isn't NFC.


Repository:
  rC Clang

https://reviews.llvm.org/D55425

Files:
  lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  test/Analysis/Inputs/expected-plists/unix-fns.c.plist

Index: test/Analysis/Inputs/expected-plists/unix-fns.c.plist
===
--- test/Analysis/Inputs/expected-plists/unix-fns.c.plist
+++ test/Analysis/Inputs/expected-plists/unix-fns.c.plist
@@ -3,7 +3,7 @@
 
 
  clang_version
-clang version 8.0.0 
+clang version 8.0.0
  diagnostics
  
   
@@ -744,9 +744,9 @@
descriptionCall to 'malloc' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_context0e841458f0cb7cf161d35f9db5862dcf
+   issue_hash_content_of_line_in_context4ddbefeb3fa802a0636dc63d679bdc89
   issue_context_kindfunction
   issue_contextpr2899
   issue_hash_function_offset1
@@ -835,9 +835,9 @@
descriptionCall to 'calloc' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_contexta267ff573c7e8b959a3f886677893eb0
+   issue_hash_content_of_line_in_context9f12ad2f0a645cb7e4485fed526f536e
   issue_context_kindfunction
   issue_contexttest_calloc
   issue_hash_function_offset1
@@ -926,9 +926,9 @@
descriptionCall to 'calloc' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_context14eb72957baab3c63bac610a10e6f48b
+   issue_hash_content_of_line_in_context835b2375daee5b05ac48f24ac578de4c
   issue_context_kindfunction
   issue_contexttest_calloc2
   issue_hash_function_offset1
@@ -1017,9 +1017,9 @@
descriptionCall to 'realloc' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_context7f6f67ebe3d481aed7750005bea7e371
+   issue_hash_content_of_line_in_contextbbdabcb6c5a3783012ae34bfea2a10fb
   issue_context_kindfunction
   issue_contexttest_realloc
   issue_hash_function_offset1
@@ -1108,9 +1108,9 @@
descriptionCall to 'reallocf' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_context4941698efbd81601653dff10ef9c645b
+   issue_hash_content_of_line_in_context5d222055bbf58b08ec345f0ebfd7b9d1
   issue_context_kindfunction
   issue_contexttest_reallocf
   issue_hash_function_offset1
@@ -1199,9 +1199,9 @@
descriptionCall to 'alloca' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_contextb7ca3488e81d9d9d4b8dc545258ce97c
+   issue_hash_content_of_line_in_contextf7bdefde93c0a58ec236918fb0c3a54e
   issue_context_kindfunction
   issue_contexttest_alloca
   issue_hash_function_offset1
@@ -1290,9 +1290,9 @@
descriptionCall to 'alloca' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_context1ec52551362b070237f47f6bb6c3847d
+   issue_hash_content_of_line_in_context4247526f8da82479508f2d364c2992d5
   issue_context_kindfunction
   issue_contexttest_builtin_alloca
   issue_hash_function_offset1
@@ -1381,9 +1381,9 @@
descriptionCall to 'valloc' has an allocation size of 0 bytes
categoryUnix API
typeUndefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
-   check_nameunix.API
+   check_nameoptin.portability.UnixAPI

-   issue_hash_content_of_line_in_context675741e04c8d0071d280324e23f41d35
+   issue_hash_content_of_line_in_contexte16dfa9598fd2fafe6dc5563990c1dd3
   issue_context_kindfunction
   issue_contexttest_valloc
   issue_hash_function_offset1
@@ -3015,7 +3015,7 @@
  
  files
  
-  /clang/test/Analysis/unix-fns.c
+  /home/szelethus/Documents/analyzer_opts/clang/test

[PATCH] D55131: [CTU] Add more lit tests and better error handling

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: test/Analysis/ctu-main.c:4
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o 
%t/ctudir2/ctu-other.c.ast %S/Inputs/ctu-other.c
+// RUN: cp %S/Inputs/externalFnMap2.txt %t/ctudir2/externalFnMap.txt
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -std=c89 -analyze 
-analyzer-checker=core,debug.ExprInspection  -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%t/ctudir2 
-verify %s

Szelethus wrote:
> martong wrote:
> > Szelethus wrote:
> > > This is a question rather than anything else, why do we have both 
> > > externalFnMap2.txt and externalFnMap.txt?
> > `externalFnMap.txt` goes for `ctu-other.cpp`.
> > `externalFnMap2.txt` goes for `ctu-other.c`.
> > Perhaps we should rename them in the `Inputs` directory to include the 
> > indexed file name. E.g. `ctu-other.cpp.externalFnMap.txt`. What do you 
> > think?
> Sounds great! :)
Ok, I have renamed the ExternalFnMap files.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55131



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


[PATCH] D55131: [CTU] Add more lit tests and better error handling

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 177170.
martong marked an inline comment as done.
martong added a comment.

- Rename externalFnMap files


Repository:
  rC Clang

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

https://reviews.llvm.org/D55131

Files:
  lib/CrossTU/CrossTranslationUnit.cpp
  test/Analysis/Inputs/ctu-other.c
  test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
  test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.c
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -1,7 +1,7 @@
 // RUN: mkdir -p %T/ctudir
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
-// RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
+// RUN: cp %S/Inputs/ctu-other.cpp.externalFnMap.txt %T/ctudir/externalFnMap.txt
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
 
 #include "ctu-hdr.h"
Index: test/Analysis/ctu-main.c
===
--- /dev/null
+++ test/Analysis/ctu-main.c
@@ -0,0 +1,67 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir2
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir2/ctu-other.c.ast %S/Inputs/ctu-other.c
+// RUN: cp %S/Inputs/ctu-other.c.externalFnMap.txt %t/ctudir2/externalFnMap.txt
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -std=c89 -analyze \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir2 \
+// RUN:   -verify %s
+
+void clang_analyzer_eval(int);
+
+// Test typedef and global variable in function.
+typedef struct {
+  int a;
+  int b;
+} FooBar;
+extern FooBar fb;
+int f(int);
+void testGlobalVariable() {
+  clang_analyzer_eval(f(5) == 1); // expected-warning{{TRUE}}
+}
+
+// Test enums.
+int enumCheck(void);
+enum A { x,
+ y,
+ z };
+void testEnum() {
+  clang_analyzer_eval(x == 0);// expected-warning{{TRUE}}
+  clang_analyzer_eval(enumCheck() == 42); // expected-warning{{TRUE}}
+}
+
+// Test that asm import does not fail.
+int inlineAsm();
+int testInlineAsm() {
+  return inlineAsm();
+}
+
+// Test reporting error in a macro.
+struct S;
+int g(struct S *);
+void testMacro(void) {
+  g(0); // expected-warning@Inputs/ctu-other.c:29 {{Access to field 'a' results in a dereference of a null pointer (loaded from variable 'ctx')}}
+}
+
+// The external function prototype is incomplete.
+// warning:implicit functions are prohibited by c99
+void testImplicit() {
+  int res = identImplicit(6);   // external implicit functions are not inlined
+  clang_analyzer_eval(res == 6); // expected-warning{{TRUE}}
+}
+
+// Tests the import of functions that have a struct parameter
+// defined in its prototype.
+struct DataType {
+  int a;
+  int b;
+};
+int structInProto(struct DataType *d);
+void testStructDefInArgument() {
+  struct DataType d;
+  d.a = 1;
+  d.b = 0;
+  clang_analyzer_eval(structInProto(&d) == 0); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+}
Index: test/Analysis/Inputs/externalFnMap.txt
===
--- /dev/null
+++ test/Analysis/Inputs/externalFnMap.txt
@@ -1,15 +0,0 @@
-c:@N@chns@F@chf1#I# ctu-other.cpp.ast
-c:@N@myns@N@embed_ns@F@fens#I# ctu-other.cpp.ast
-c:@F@g#I# ctu-other.cpp.ast
-c:@S@mycls@F@fscl#I#S ctu-other.cpp.ast
-c:@S@mycls@F@fcl#I# ctu-other.cpp.ast
-c:@N@myns@S@embed_cls@F@fecl#I# ctu-other.cpp.ast
-c:@S@mycls@S@embed_cls2@F@fecl2#I# ctu-other.cpp.ast
-c:@F@f#I# ctu-other.cpp.ast
-c:@N@myns@F@fns#I# ctu-other.cpp.ast
-c:@F@h#I# ctu-other.cpp.ast
-c:@F@h_chain#I# ctu-chain.cpp.ast
-c:@N@chns@S@chcls@F@chf4#I# ctu-chain.cpp.ast
-c:@N@chns@F@chf2#I# ctu-chain.cpp.ast
-c:@F@fun_using_anon_struct#I# ctu-other.cpp.ast
-c:@F@other_macro_diag#I# ctu-other.cpp.ast
Index: test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
===
--- /dev/null
+++ test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
@@ -0,0 +1,6 @@
+c:@F@inlineAsm ctu-other.c.ast
+c:@F@g ctu-other.c.ast
+c:@F@f ctu-other.c.ast
+c:@F@enumCheck ctu-other.c.ast
+c:@F@identImplicit ctu-other.c.ast
+c:@F@structInProto ctu-other.c.ast
Index: test/Analysis/Inputs/ctu-other.c
===
--- /dev/null
+++ test/Analysis/Inputs/ctu-other.c
@@ -0,0 +1,49 @@
+// Test typedef and global variable in functi

[PATCH] D55315: [clangd] Only reduce priority of a thread for indexing.

2018-12-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/index/Background.cpp:202
 std::lock_guard Lock(QueueMu);
-Queue.push_back(std::move(T));
+if (Priority == ThreadPriority::Low) {
+  Queue.push_back(Bind(

kadircet wrote:
> ilya-biryukov wrote:
> > Since we might be interested in scheduling higher-priority tasks first 
> > anyway (not in this patch, but still), maybe store a pair of `(Task, 
> > Priority)` in the queue and call `setCurrentThreadPriority` when actually 
> > running the task?
> I believe we can introduce that later on whenever we have more than 2 
> priorities, currently we push to front for important tasks and back for the 
> low priority ones. Do you think it is not enough?
Sorry, I somehow missed that `push_front` and `push_back` are used in different 
cases, I've only noticed the callback wrapping.
I feel storing priorities in the queue produces a more straightforward code as 
priority is an important scheduling signal, so it fits in nicely there. Using a 
wrapped callback, OTOH, is a bit hard to read. But that might be a personal 
preference, up to you.

See the other comment about ordering of the tasks with normal priorities, it 
looks more important



Comment at: clangd/index/Background.cpp:212
+  std::move(T)));
+} else
+  Queue.push_front(std::move(T));

It's a bit surprising that we put the new task in front of the other tasks 
**with a normal priority**.
Do we anticipate a large number of normal priority tasks? I believe our current 
expectation is that we'll have a single normal task per open compilation 
database, right? In that case the number of pending normal tasks should be a 
single-digit number in practice. Therefore, maybe add the new task after all 
the normal tasks at the start of the queue?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55315



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


[PATCH] D54592: [analyzer][CStringChecker] evaluate explicit_bzero

2018-12-07 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 177171.

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

https://reviews.llvm.org/D54592

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/string.c

Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -1184,11 +1184,14 @@
 }
 
 //===--===
-// memset()
+// memset() / explicit_bzero() / bzero()
 //===--===
 
 void *memset(void *dest, int ch, size_t count);
 
+void bzero(void *dst, size_t count);
+void explicit_bzero(void *dest, size_t count);
+
 void *malloc(size_t size);
 void free(void *);
 
@@ -1383,6 +1386,57 @@
   clang_analyzer_eval(array[4] == 0); // expected-warning{{TRUE}}
 }
 
+void bzero1_null() {
+  char *a = NULL;
+
+  bzero(a, 10); // expected-warning{{Null pointer argument in call to memory clearance function}}
+}
+
+void bzero2_char_array_null() {
+  char str[] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  bzero(str, 2);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{TRUE}}
+}
+
+void bzero3_char_ptr_null() {
+  char *str = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  bzero(str + 2, 2);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{FALSE}}
+}
+
+void explicit_bzero1_null() {
+  char *a = NULL;
+
+  explicit_bzero(a, 10); // expected-warning{{Null pointer argument in call to memory clearance function}}
+}
+
+void explicit_bzero2_clear_mypassword() {
+  char passwd[7] = "passwd";
+
+  explicit_bzero(passwd, sizeof(passwd)); // no-warning
+
+  clang_analyzer_eval(strlen(passwd) == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(passwd[0] == '\0'); // expected-warning{{TRUE}}
+}
+
+void explicit_bzero3_out_ofbound() {
+  char *privkey = (char *)malloc(7);
+  const char newprivkey[10] = "mysafekey";
+
+  strcpy(privkey, "random");
+  explicit_bzero(privkey, sizeof(newprivkey));
+#ifndef SUPPRESS_OUT_OF_BOUND
+  // expected-warning@-2 {{Memory clearance function accesses out-of-bound array element}}
+#endif
+  clang_analyzer_eval(privkey[0] == '\0');
+#ifdef SUPPRESS_OUT_OF_BOUND
+  // expected-warning@-2 {{UNKNOWN}}
+#endif
+  free(privkey);
+}
+
 //===--===
 // FIXMEs
 //===--===
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -124,6 +124,7 @@
   void evalStdCopyBackward(CheckerContext &C, const CallExpr *CE) const;
   void evalStdCopyCommon(CheckerContext &C, const CallExpr *CE) const;
   void evalMemset(CheckerContext &C, const CallExpr *CE) const;
+  void evalBzero(CheckerContext &C, const CallExpr *CE) const;
 
   // Utility methods
   std::pair
@@ -158,7 +159,7 @@
   static bool SummarizeRegion(raw_ostream &os, ASTContext &Ctx,
   const MemRegion *MR);
 
-  static bool memsetAux(const Expr *DstBuffer, const Expr *CharE,
+  static bool memsetAux(const Expr *DstBuffer, SVal CharE,
 const Expr *Size, CheckerContext &C,
 ProgramStateRef &State);
 
@@ -1005,11 +1006,10 @@
   }
 }
 
-bool CStringChecker::memsetAux(const Expr *DstBuffer, const Expr *CharE,
+bool CStringChecker::memsetAux(const Expr *DstBuffer, SVal CharVal,
const Expr *Size, CheckerContext &C,
ProgramStateRef &State) {
   SVal MemVal = C.getSVal(DstBuffer);
-  SVal CharVal = C.getSVal(CharE);
   SVal SizeVal = C.getSVal(Size);
   const MemRegion *MR = MemVal.getAsRegion();
   if (!MR)
@@ -2184,13 +2184,59 @@
   // According to the values of the arguments, bind the value of the second
   // argument to the destination buffer and set string length, or just
   // invalidate the destination buffer.
-  if (!memsetAux(Mem, CharE, Size, C, State))
+  if (!memsetAux(Mem, C.getSVal(CharE), Size, C, State))
 return;
 
   State = State->BindExpr(CE, LCtx, MemVal);
   C.addTransition(State);
 }
 
+void CStringChecker::evalBzero(CheckerContext &C, const CallExpr *CE) const {
+  if (CE->getNumArgs() != 2)
+return;
+
+  CurrentFunctionDescription = "memory clearance function";
+
+  const Expr *Mem = CE->getArg(0);
+  const Expr *Size = CE->getArg(1);
+  SVal Zero = C.getSValBuilder().makeZeroVal(C.getASTContext().IntTy);
+
+  ProgramStateRef State = C.getState();
+  
+  // See if the size argument is zero.
+  SVal SizeVal = C.getSVal(Size);
+  QualType SizeTy = Size->getType();
+
+  ProgramStateRef StateZeroSize, StateNonZeroSize;
+  std::tie(StateZeroSize, StateNonZer

[PATCH] D55133: [CTU] Add statistics

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348584: [CTU] Add statistics (authored by martong, committed 
by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55133?vs=176655&id=177173#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55133

Files:
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp


Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -21,6 +21,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Index/USRGeneration.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
@@ -32,6 +33,15 @@
 namespace cross_tu {
 
 namespace {
+#define DEBUG_TYPE "CrossTranslationUnit"
+STATISTIC(NumGetCTUCalled, "The # of getCTUDefinition function called");
+STATISTIC(
+NumNotInOtherTU,
+"The # of getCTUDefinition called but the function is not in any other 
TU");
+STATISTIC(NumGetCTUSuccess,
+  "The # of getCTUDefinition successfully returned the "
+  "requested function's body");
+
 // FIXME: This class is will be removed after the transition to llvm::Error.
 class IndexErrorCategory : public std::error_category {
 public:
@@ -151,6 +161,7 @@
   StringRef CrossTUDir,
   StringRef IndexName) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
+  ++NumGetCTUCalled;
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
@@ -216,8 +227,10 @@
 }
 
 auto It = FunctionFileMap.find(LookupName);
-if (It == FunctionFileMap.end())
+if (It == FunctionFileMap.end()) {
+  ++NumNotInOtherTU;
   return 
llvm::make_error(index_error_code::missing_definition);
+}
 StringRef ASTFileName = It->second;
 auto ASTCacheEntry = FileASTUnitMap.find(ASTFileName);
 if (ASTCacheEntry == FileASTUnitMap.end()) {
@@ -250,6 +263,7 @@
   cast(Importer.Import(const_cast(FD)));
   assert(ToDecl->hasBody());
   assert(FD->hasBody() && "Functions already imported should have body.");
+  ++NumGetCTUSuccess;
   return ToDecl;
 }
 


Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -21,6 +21,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Index/USRGeneration.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
@@ -32,6 +33,15 @@
 namespace cross_tu {
 
 namespace {
+#define DEBUG_TYPE "CrossTranslationUnit"
+STATISTIC(NumGetCTUCalled, "The # of getCTUDefinition function called");
+STATISTIC(
+NumNotInOtherTU,
+"The # of getCTUDefinition called but the function is not in any other TU");
+STATISTIC(NumGetCTUSuccess,
+  "The # of getCTUDefinition successfully returned the "
+  "requested function's body");
+
 // FIXME: This class is will be removed after the transition to llvm::Error.
 class IndexErrorCategory : public std::error_category {
 public:
@@ -151,6 +161,7 @@
   StringRef CrossTUDir,
   StringRef IndexName) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
+  ++NumGetCTUCalled;
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
@@ -216,8 +227,10 @@
 }
 
 auto It = FunctionFileMap.find(LookupName);
-if (It == FunctionFileMap.end())
+if (It == FunctionFileMap.end()) {
+  ++NumNotInOtherTU;
   return llvm::make_error(index_error_code::missing_definition);
+}
 StringRef ASTFileName = It->second;
 auto ASTCacheEntry = FileASTUnitMap.find(ASTFileName);
 if (ASTCacheEntry == FileASTUnitMap.end()) {
@@ -250,6 +263,7 @@
   cast(Importer.Import(const_cast(FD)));
   assert(ToDecl->hasBody());
   assert(FD->hasBody() && "Functions already imported should have body.");
+  ++NumGetCTUSuccess;
   return ToDecl;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348584 - [CTU] Add statistics

2018-12-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Dec  7 03:55:22 2018
New Revision: 348584

URL: http://llvm.org/viewvc/llvm-project?rev=348584&view=rev
Log:
[CTU] Add statistics

Reviewers: xazax.hun, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

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

Modified:
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp

Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=348584&r1=348583&r2=348584&view=diff
==
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Fri Dec  7 03:55:22 2018
@@ -21,6 +21,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Index/USRGeneration.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
@@ -32,6 +33,15 @@ namespace clang {
 namespace cross_tu {
 
 namespace {
+#define DEBUG_TYPE "CrossTranslationUnit"
+STATISTIC(NumGetCTUCalled, "The # of getCTUDefinition function called");
+STATISTIC(
+NumNotInOtherTU,
+"The # of getCTUDefinition called but the function is not in any other 
TU");
+STATISTIC(NumGetCTUSuccess,
+  "The # of getCTUDefinition successfully returned the "
+  "requested function's body");
+
 // FIXME: This class is will be removed after the transition to llvm::Error.
 class IndexErrorCategory : public std::error_category {
 public:
@@ -151,6 +161,7 @@ CrossTranslationUnitContext::getCrossTUD
   StringRef CrossTUDir,
   StringRef IndexName) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
+  ++NumGetCTUCalled;
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
@@ -216,8 +227,10 @@ llvm::Expected CrossTranslati
 }
 
 auto It = FunctionFileMap.find(LookupName);
-if (It == FunctionFileMap.end())
+if (It == FunctionFileMap.end()) {
+  ++NumNotInOtherTU;
   return 
llvm::make_error(index_error_code::missing_definition);
+}
 StringRef ASTFileName = It->second;
 auto ASTCacheEntry = FileASTUnitMap.find(ASTFileName);
 if (ASTCacheEntry == FileASTUnitMap.end()) {
@@ -250,6 +263,7 @@ CrossTranslationUnitContext::importDefin
   cast(Importer.Import(const_cast(FD)));
   assert(ToDecl->hasBody());
   assert(FD->hasBody() && "Functions already imported should have body.");
+  ++NumGetCTUSuccess;
   return ToDecl;
 }
 


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


[PATCH] D48116: [libclang] Allow skipping warnings from all included files

2018-12-07 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

In D48116#1144732 , @ilya-biryukov 
wrote:

> Have you considered doing the same filtering in ASTUnit's 
> `StoredDiagnosticConsumer`? It should not be more difficult and allows to 
> avoid changing the clang's diagnostic interfaces. That's what we do in clangd.


Hmm, it's a bit strange that StoredDiagnosticConsumer should also start to 
filter things.

For filtering in StoredDiagnosticConsumer one needs to pass the new bool 
everywhere along where "bool CaptureDiagnostics" is already passed on (to end 
up in the StoredDiagnosticConsumer constructor) . Also, 
ASTUnit::CaptureDiagnostics is then not enough anymore since the new bool is 
also needed in getMainBufferWithPrecompiledPreamble(). One could also (2) 
convert  "bool CaptureDiagnostics" to an enum with enumerators like 
CaptureNothing, CaptureAll, CaptureAllWithoutNonErrorsFromIncludes to make this 
a bit less invasive.

If changing clang's diagnostic interface should be avoided, I tend to go with 
(2). Ilya?

  $ git grep "bool CaptureDiagnostics"
  include/clang/Frontend/ASTUnit.h:  bool CaptureDiagnostics = false;
  include/clang/Frontend/ASTUnit.h: ASTUnit &AST, 
bool CaptureDiagnostics,
  include/clang/Frontend/ASTUnit.h: 
IntrusiveRefCntPtr Diags, bool CaptureDiagnostics,
  include/clang/Frontend/ASTUnit.h:  bool CaptureDiagnostics = false, bool 
AllowPCHWithCompilerErrors = false,
  include/clang/Frontend/ASTUnit.h:  bool OnlyLocalDecls = false, bool 
CaptureDiagnostics = false,
  include/clang/Frontend/ASTUnit.h:  bool OnlyLocalDecls = false, bool 
CaptureDiagnostics = false,
  include/clang/Frontend/ASTUnit.h:  bool OnlyLocalDecls = false, bool 
CaptureDiagnostics = false,
  lib/Frontend/ASTUnit.cpp: ASTUnit &AST, bool 
CaptureDiagnostics,
  lib/Frontend/ASTUnit.cpp:bool CaptureDiagnostics, bool 
AllowPCHWithCompilerErrors,
  lib/Frontend/ASTUnit.cpp:bool CaptureDiagnostics, bool 
UserFilesAreVolatile) {
  lib/Frontend/ASTUnit.cpp:bool OnlyLocalDecls, bool CaptureDiagnostics,
  lib/Frontend/ASTUnit.cpp:bool OnlyLocalDecls, bool CaptureDiagnostics,
  lib/Frontend/ASTUnit.cpp:bool OnlyLocalDecls, bool CaptureDiagnostics,
  tools/libclang/Indexing.cpp:  bool CaptureDiagnostics = 
!Logger::isLoggingEnabled();


Repository:
  rC Clang

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

https://reviews.llvm.org/D48116



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


[PATCH] D55133: [CTU] Add statistics

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:171
   loadExternalAST(LookupFnName, CrossTUDir, IndexName);
-  if (!ASTUnitOrError)
+  if (!ASTUnitOrError) {
 return ASTUnitOrError.takeError();

a_sidorin wrote:
> We can omit braces here.
Ok, thanks, I changed that.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55133



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


r348572 - [PowerPC] VSX register support for inline assembly

2018-12-07 Thread Kang Zhang via cfe-commits
Author: zhangkang
Date: Fri Dec  7 00:58:12 2018
New Revision: 348572

URL: http://llvm.org/viewvc/llvm-project?rev=348572&view=rev
Log:
[PowerPC] VSX register support for inline assembly

Summary:
The patch is to add the VSX register support for inline assembly. After this 
patch, we can use VSX register in inline assembly clobber list without error.

Reviewed By: jsji,  nemanjai

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

Added:
cfe/trunk/test/CodeGen/inline-asm-matching-ppc-vsx.c
Modified:
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/PPC.h

Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=348572&r1=348571&r2=348572&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Fri Dec  7 00:58:12 2018
@@ -412,6 +412,36 @@ ArrayRef PPCTar
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+// PPC ELFABIv2 DWARF Definitoin "Table 2.26. Mappings of Common Registers".
+// vs0 ~ vs31 is mapping to 32 - 63,
+// vs32 ~ vs63 is mapping to 77 - 108. 
+const TargetInfo::AddlRegName GCCAddlRegNames[] = {
+// Table of additional register names to use in user input.
+{{"vs0"}, 32},   {{"vs1"}, 33},   {{"vs2"}, 34},   {{"vs3"}, 35}, 
+{{"vs4"}, 36},   {{"vs5"}, 37},   {{"vs6"}, 38},   {{"vs7"}, 39},
+{{"vs8"}, 40},   {{"vs9"}, 41},   {{"vs10"}, 42},  {{"vs11"}, 43},
+{{"vs12"}, 44},  {{"vs13"}, 45},  {{"vs14"}, 46},  {{"vs15"}, 47},
+{{"vs16"}, 48},  {{"vs17"}, 49},  {{"vs18"}, 50},  {{"vs19"}, 51},
+{{"vs20"}, 52},  {{"vs21"}, 53},  {{"vs22"}, 54},  {{"vs23"}, 55},
+{{"vs24"}, 56},  {{"vs25"}, 57},  {{"vs26"}, 58},  {{"vs27"}, 59},
+{{"vs28"}, 60},  {{"vs29"}, 61},  {{"vs30"}, 62},  {{"vs31"}, 63},
+{{"vs32"}, 77},  {{"vs33"}, 78},  {{"vs34"}, 79},  {{"vs35"}, 80},
+{{"vs36"}, 81},  {{"vs37"}, 82},  {{"vs38"}, 83},  {{"vs39"}, 84},
+{{"vs40"}, 85},  {{"vs41"}, 86},  {{"vs42"}, 87},  {{"vs43"}, 88},
+{{"vs44"}, 89},  {{"vs45"}, 90},  {{"vs46"}, 91},  {{"vs47"}, 92},
+{{"vs48"}, 93},  {{"vs49"}, 94},  {{"vs50"}, 95},  {{"vs51"}, 96},
+{{"vs52"}, 97},  {{"vs53"}, 98},  {{"vs54"}, 99},  {{"vs55"}, 100},
+{{"vs56"}, 101}, {{"vs57"}, 102}, {{"vs58"}, 103}, {{"vs59"}, 104},
+{{"vs60"}, 105}, {{"vs61"}, 106}, {{"vs62"}, 107}, {{"vs63"}, 108},
+};
+
+ArrayRef PPCTargetInfo::getGCCAddlRegNames() const {
+  if (ABI == "elfv2")
+return llvm::makeArrayRef(GCCAddlRegNames);
+  else 
+return TargetInfo::getGCCAddlRegNames(); 
+}
+
 static constexpr llvm::StringLiteral ValidCPUNames[] = {
 {"generic"}, {"440"}, {"450"}, {"601"},{"602"},
 {"603"}, {"603e"},{"603ev"},   {"604"},{"604e"},

Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=348572&r1=348571&r2=348572&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Fri Dec  7 00:58:12 2018
@@ -176,6 +176,8 @@ public:
 
   ArrayRef getGCCRegAliases() const override;
 
+  ArrayRef getGCCAddlRegNames() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
 switch (*Name) {

Added: cfe/trunk/test/CodeGen/inline-asm-matching-ppc-vsx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-matching-ppc-vsx.c?rev=348572&view=auto
==
--- cfe/trunk/test/CodeGen/inline-asm-matching-ppc-vsx.c (added)
+++ cfe/trunk/test/CodeGen/inline-asm-matching-ppc-vsx.c Fri Dec  7 00:58:12 
2018
@@ -0,0 +1,20 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -target-feature +vsx \
+// RUN:   -target-cpu pwr9 -emit-llvm %s -o - | FileCheck %s
+
+// This case is to test VSX register support in the clobbers list for inline 
asm.
+void testVSX (void) {
+  unsigned int a = 0;
+  unsigned int *dbell=&a;
+  int d;
+  __asm__ __volatile__ (
+"lxvw4x  %%vs32, 0, %2\n\t"
+"stxvw4x %%vs32, 0, %1"
+: "=m"(*(volatile unsigned int*)(dbell))
+: "r" (dbell), "r" (&d)
+: "vs32"
+  );
+}
+
+// CHECK: call void asm sideeffect "lxvw4x  %vs32, 0, $2\0A\09stxvw4x %vs32, 
0, $1", "=*m,r,r,~{vs32}"


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


[PATCH] D55132: [CTU] Add asserts to protect invariants

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348586: [CTU] Add asserts to protect invariants (authored by 
martong, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55132?vs=176151&id=177177#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55132

Files:
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp


Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -160,6 +160,7 @@
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
   StringRef IndexName) {
+  assert(FD && "FD is missing, bad call to this function!");
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   ++NumGetCTUCalled;
   const std::string LookupFnName = getLookupName(FD);
@@ -258,6 +259,8 @@
 
 llvm::Expected
 CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) {
+  assert(FD->hasBody() && "Functions to be imported should have body.");
+
   ASTImporter &Importer = getOrCreateASTImporter(FD->getASTContext());
   auto *ToDecl =
   cast(Importer.Import(const_cast(FD)));


Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -160,6 +160,7 @@
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
   StringRef IndexName) {
+  assert(FD && "FD is missing, bad call to this function!");
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   ++NumGetCTUCalled;
   const std::string LookupFnName = getLookupName(FD);
@@ -258,6 +259,8 @@
 
 llvm::Expected
 CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) {
+  assert(FD->hasBody() && "Functions to be imported should have body.");
+
   ASTImporter &Importer = getOrCreateASTImporter(FD->getASTContext());
   auto *ToDecl =
   cast(Importer.Import(const_cast(FD)));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348586 - [CTU] Add asserts to protect invariants

2018-12-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Dec  7 04:21:43 2018
New Revision: 348586

URL: http://llvm.org/viewvc/llvm-project?rev=348586&view=rev
Log:
[CTU] Add asserts to protect invariants

Reviewers: xazax.hun, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

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

Modified:
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp

Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=348586&r1=348585&r2=348586&view=diff
==
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Fri Dec  7 04:21:43 2018
@@ -160,6 +160,7 @@ llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
   StringRef IndexName) {
+  assert(FD && "FD is missing, bad call to this function!");
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   ++NumGetCTUCalled;
   const std::string LookupFnName = getLookupName(FD);
@@ -258,6 +259,8 @@ llvm::Expected CrossTranslati
 
 llvm::Expected
 CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) {
+  assert(FD->hasBody() && "Functions to be imported should have body.");
+
   ASTImporter &Importer = getOrCreateASTImporter(FD->getASTContext());
   auto *ToDecl =
   cast(Importer.Import(const_cast(FD)));


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


r348587 - [CTU] Eliminate race condition in CTU lit tests

2018-12-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Dec  7 04:29:02 2018
New Revision: 348587

URL: http://llvm.org/viewvc/llvm-project?rev=348587&view=rev
Log:
[CTU] Eliminate race condition in CTU lit tests

Summary:
We plan to introduce additional CTU related lit test. Since lit may run the
tests in parallel, it is not safe to use the same directory (%T) for these
tests. It is safe to use however test case specific directories (%t).

Reviewers: xazax.hun, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

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

Modified:
cfe/trunk/test/Analysis/ctu-main.cpp

Modified: cfe/trunk/test/Analysis/ctu-main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctu-main.cpp?rev=348587&r1=348586&r2=348587&view=diff
==
--- cfe/trunk/test/Analysis/ctu-main.cpp (original)
+++ cfe/trunk/test/Analysis/ctu-main.cpp Fri Dec  7 04:29:02 2018
@@ -1,8 +1,15 @@
-// RUN: mkdir -p %T/ctudir
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o 
%T/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o 
%T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
-// RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
+// RUN: cp %S/Inputs/externalFnMap.txt %t/ctudir/
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -verify %s
 
 #include "ctu-hdr.h"
 


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


[PATCH] D55129: [CTU] Eliminate race condition in CTU lit tests

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348587: [CTU] Eliminate race condition in CTU lit tests 
(authored by martong, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55129

Files:
  cfe/trunk/test/Analysis/ctu-main.cpp


Index: cfe/trunk/test/Analysis/ctu-main.cpp
===
--- cfe/trunk/test/Analysis/ctu-main.cpp
+++ cfe/trunk/test/Analysis/ctu-main.cpp
@@ -1,8 +1,15 @@
-// RUN: mkdir -p %T/ctudir
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o 
%T/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o 
%T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
-// RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
+// RUN: cp %S/Inputs/externalFnMap.txt %t/ctudir/
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -verify %s
 
 #include "ctu-hdr.h"
 


Index: cfe/trunk/test/Analysis/ctu-main.cpp
===
--- cfe/trunk/test/Analysis/ctu-main.cpp
+++ cfe/trunk/test/Analysis/ctu-main.cpp
@@ -1,8 +1,15 @@
-// RUN: mkdir -p %T/ctudir
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
-// RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
+// RUN: cp %S/Inputs/externalFnMap.txt %t/ctudir/
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -verify %s
 
 #include "ctu-hdr.h"
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348588 - Adding tests for -ast-dump; NFC.

2018-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Dec  7 04:35:15 2018
New Revision: 348588

URL: http://llvm.org/viewvc/llvm-project?rev=348588&view=rev
Log:
Adding tests for -ast-dump; NFC.

This adds tests for various statements in C.

Modified:
cfe/trunk/test/AST/ast-dump-stmt.c

Modified: cfe/trunk/test/AST/ast-dump-stmt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt.c?rev=348588&r1=348587&r2=348588&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt.c (original)
+++ cfe/trunk/test/AST/ast-dump-stmt.c Fri Dec  7 04:35:15 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c11 -ast-dump -ast-dump-filter Test %s | FileCheck 
-strict-whitespace %s
+// RUN: %clang_cc1 -std=gnu11 -ast-dump %s | FileCheck -strict-whitespace %s
 
 int TestLocation = 0;
 // CHECK:  VarDecl{{.*}}TestLocation
@@ -6,10 +6,10 @@ int TestLocation = 0;
 
 int TestIndent = 1 + (1);
 // CHECK:  VarDecl{{.*}}TestIndent
-// CHECK-NEXT: {{^}}`-BinaryOperator{{[^()]*$}}
-// CHECK-NEXT: {{^}}  |-IntegerLiteral{{.*0[^()]*$}}
-// CHECK-NEXT: {{^}}  `-ParenExpr{{.*0[^()]*$}}
-// CHECK-NEXT: {{^}}`-IntegerLiteral{{.*0[^()]*$}}
+// CHECK-NEXT: {{^}}| `-BinaryOperator{{[^()]*$}}
+// CHECK-NEXT: {{^}}|   |-IntegerLiteral{{.*0[^()]*$}}
+// CHECK-NEXT: {{^}}|   `-ParenExpr{{.*0[^()]*$}}
+// CHECK-NEXT: {{^}}| `-IntegerLiteral{{.*0[^()]*$}}
 
 void TestDeclStmt() {
   int x = 0;
@@ -126,3 +126,239 @@ void TestGenericSelectionExpressions(int
   // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 12
 }
+
+void TestLabelsAndGoto(void) {
+  // Note: case and default labels are handled by TestSwitch().
+
+label1:
+  ;
+  // CHECK: LabelStmt 0x{{[^ ]*}}  
'label1'
+  // CHECK-NEXT: NullStmt 0x{{[^ ]*}} 
+
+  goto label2;
+  // CHECK-NEXT: GotoStmt 0x{{[^ ]*}}  'label2' 
0x{{[^ ]*}}
+
+label2:
+  0;
+  // CHECK-NEXT: LabelStmt 0x{{[^ ]*}}  'label2'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 0
+
+  void *ptr = &&label1;
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl
+  // CHECK-NEXT: AddrLabelExpr 0x{{[^ ]*}}  'void *' label1 
0x{{[^ ]*}}
+
+  goto *ptr;
+  // CHECK-NEXT: IndirectGotoStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'void *' lvalue Var 0x{{[^ 
]*}} 'ptr' 'void *'
+}
+
+void TestSwitch(int i) {
+  switch (i) {
+  // CHECK: SwitchStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue ParmVar 0x{{[^ 
]*}} 'i' 'int'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  case 0:
+break;
+  // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ConstantExpr
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 0
+  // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} 
+  case 1:
+  case 2:
+break;
+  // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ConstantExpr
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 1
+  // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ConstantExpr
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 2
+  // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} 
+  default:
+break;
+  // CHECK-NEXT: DefaultStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} 
+  case 3 ... 5:
+break;
+  // CHECK-NEXT: CaseStmt 0x{{[^ ]*}}  
gnu_range
+  // CHECK-NEXT: ConstantExpr
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 3
+  // CHECK-NEXT: ConstantExpr
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 5
+  // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} 
+  }
+}
+
+void TestIf(_Bool b) {
+  if (b)
+;
+  // CHECK: IfStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  '_Bool' lvalue ParmVar 0x{{[^ 
]*}} 'b' '_Bool'
+  // CHECK-NEXT: NullStmt
+
+  if (b) {}
+  // CHECK: IfStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  '_Bool' lvalue ParmVar 0x{{[^ 
]*}} 'b' '_Bool'
+  // CHECK-NEXT: CompoundStmt
+
+  if (b)
+;
+  else
+;
+  // CHECK: IfStmt 0x{{[^ ]*}}  
has_else
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  '_Bool' lvalue ParmVar 0x{{[^ 
]*}} 'b' '_Bool'
+  // CHECK-NEXT: NullStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: NullStmt 0x{{[^ ]*}} 
+
+  if (b) {}
+  else {}
+  // CHECK: IfStmt 0x{{[^ ]*}}  
has_else
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  '_Bool' lvalue ParmVar 0x{{[^ 
]*}} 'b' '_Bool'
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
+
+  if (b)
+;
+  else if (b)
+;
+  // CHECK: IfStmt 0x{{[^ ]*}}  
has_else
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  '_Bool' lvalue ParmVar 0x{{[^ 
]*}} 'b' '_Bool'
+  // CHECK-NEXT: NullStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: IfStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  '_Bool' lvalue ParmVar 
0x{{[^ ]*}} 'b' '_Bool'
+  // 

Re: r348469 - Make test resistant to line numbers changing

2018-12-07 Thread Aaron Ballman via cfe-commits
On Thu, Dec 6, 2018 at 5:55 PM Stephen Kelly  wrote:
>
>
> On 06/12/2018 12:45, Aaron Ballman wrote:
> > On Thu, Dec 6, 2018 at 4:25 AM Stephen Kelly via cfe-commits
> >  wrote:
> >> Author: steveire
> >> Date: Thu Dec  6 01:22:12 2018
> >> New Revision: 348469
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=348469&view=rev
> >> Log:
> >> Make test resistant to line numbers changing
> > I would prefer to see the line numbers be tested rather than entirely
> > ignored (it's still important information we want to make sure is
> > correct). Can you use [[@LINE + N]] to instead make the line numbers
> > relative?
>
>
> Done with r348541.

Thank you!

~Aaron

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


Re: r348471 - Add test for ObjC generics

2018-12-07 Thread Aaron Ballman via cfe-commits
On Thu, Dec 6, 2018 at 6:29 PM Stephen Kelly  wrote:
>
>
> On 06/12/2018 12:48, Aaron Ballman wrote:
> > On Thu, Dec 6, 2018 at 4:26 AM Stephen Kelly via cfe-commits
> >  wrote:
> >> Author: steveire
> >> Date: Thu Dec  6 01:23:59 2018
> >> New Revision: 348471
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=348471&view=rev
> >> Log:
> >> Add test for ObjC generics
> >>
> >> Modified:
> >>  cfe/trunk/test/AST/ast-dump-decl.m
> >>
> >> Modified: cfe/trunk/test/AST/ast-dump-decl.m
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=348471&r1=348470&r2=348471&view=diff
> >> ==
> >> --- cfe/trunk/test/AST/ast-dump-decl.m (original)
> >> +++ cfe/trunk/test/AST/ast-dump-decl.m Thu Dec  6 01:23:59 2018
> >> @@ -81,6 +81,14 @@
> >>   // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
> >>   // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
> >>
> >> +@interface TestGenericInterface : A {
> >> +}
> >> +@end
> >> +// CHECK:  ObjCInterfaceDecl{{.*}} TestGenericInterface
> >> +// CHECK-NEXT:   -ObjCTypeParamDecl
> >> +// CHECK-NEXT:   -super ObjCInterface
> >> +// CHECK-NEXT:   -ObjCProtocol
> > It would be useful to test the line and column, identifier, and type
> > information as well as the basic AST nodes.
>
> Done in r348543.

Thank you!

~Aaron

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


[PATCH] D55393: Re-order content of template parameter dumps

2018-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.



Comment at: test/AST/ast-dump-decl.cpp:330-331
 // CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT: TemplateArgument type 'int'
 // CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+// CHECK-NEXT: TemplateArgument type 'int'
 

This looks wrong to me. You did not inherit the `TemplateTypeParmDecl` from 
above, you inherited the `TemplateArgument`. The order is important here and 
should be preserved to avoid confusion.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55393



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


[PATCH] D55417: [clangd] Change disk-backed storage to be atomic

2018-12-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 177181.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55417

Files:
  clangd/index/BackgroundIndexStorage.cpp


Index: clangd/index/BackgroundIndexStorage.cpp
===
--- clangd/index/BackgroundIndexStorage.cpp
+++ clangd/index/BackgroundIndexStorage.cpp
@@ -9,6 +9,8 @@
 
 #include "Logger.h"
 #include "index/Background.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -33,6 +35,29 @@
   return ShardRootSS.str();
 }
 
+template 
+llvm::Error writeAtomically(llvm::StringRef OutPath, WriterFunction &&Writer) {
+  // Write to a temporary file first.
+  llvm::Twine TempPath(OutPath, ".tmp.");
+  TempPath.concat(std::to_string(rand()));
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(TempPath.str(), EC);
+  if (EC)
+return llvm::errorCodeToError(EC);
+  // Make sure temp file is destroyed at exit.
+  auto _ =
+  llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
+  Writer(OS);
+  OS.close();
+  if (OS.has_error())
+return llvm::errorCodeToError(OS.error());
+  // Then move to real location.
+  EC = llvm::sys::fs::rename(TempPath, OutPath);
+  if (EC)
+return llvm::errorCodeToError(EC);
+  return llvm::ErrorSuccess();
+}
+
 // Uses disk as a storage for index shards. Creates a directory called
 // ".clangd-index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
@@ -70,14 +95,9 @@
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
-std::error_code EC;
-llvm::raw_fd_ostream OS(ShardPath, EC);
-if (EC)
-  return llvm::errorCodeToError(EC);
-OS << Shard;
-OS.close();
-return llvm::errorCodeToError(OS.error());
+return writeAtomically(
+getShardPathFromFilePath(DiskShardRoot, ShardIdentifier),
+[&Shard](llvm::raw_ostream &OS) { OS << Shard; });
   }
 };
 


Index: clangd/index/BackgroundIndexStorage.cpp
===
--- clangd/index/BackgroundIndexStorage.cpp
+++ clangd/index/BackgroundIndexStorage.cpp
@@ -9,6 +9,8 @@
 
 #include "Logger.h"
 #include "index/Background.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -33,6 +35,29 @@
   return ShardRootSS.str();
 }
 
+template 
+llvm::Error writeAtomically(llvm::StringRef OutPath, WriterFunction &&Writer) {
+  // Write to a temporary file first.
+  llvm::Twine TempPath(OutPath, ".tmp.");
+  TempPath.concat(std::to_string(rand()));
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(TempPath.str(), EC);
+  if (EC)
+return llvm::errorCodeToError(EC);
+  // Make sure temp file is destroyed at exit.
+  auto _ =
+  llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
+  Writer(OS);
+  OS.close();
+  if (OS.has_error())
+return llvm::errorCodeToError(OS.error());
+  // Then move to real location.
+  EC = llvm::sys::fs::rename(TempPath, OutPath);
+  if (EC)
+return llvm::errorCodeToError(EC);
+  return llvm::ErrorSuccess();
+}
+
 // Uses disk as a storage for index shards. Creates a directory called
 // ".clangd-index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
@@ -70,14 +95,9 @@
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
-std::error_code EC;
-llvm::raw_fd_ostream OS(ShardPath, EC);
-if (EC)
-  return llvm::errorCodeToError(EC);
-OS << Shard;
-OS.close();
-return llvm::errorCodeToError(OS.error());
+return writeAtomically(
+getShardPathFromFilePath(DiskShardRoot, ShardIdentifier),
+[&Shard](llvm::raw_ostream &OS) { OS << Shard; });
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55083: Re-arrange content in FunctionDecl dump

2018-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/AST/ast-dump-decl.cpp:217
 // CHECK-NEXT: ParmVarDecl
+// CHECK-NEXT: TemplateArgument
 // CHECK-NEXT: CompoundStmt

I find this ordering to be confusing, especially because the template argument 
information is used by the parameter declaration type.



Comment at: test/AST/ast-dump-funcs.cpp:59
   // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 f 
'void (float, int)'
+  // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ]
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:15 'float'

I don't think this belongs at the start of the function -- the parameter 
information seems far more interesting than what the method overrides.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55083



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


r348589 - [unittests] Merge the PrintedStmtCXX..Matches functions (NFC)

2018-12-07 Thread Hamza Sood via cfe-commits
Author: hamzasood
Date: Fri Dec  7 04:55:01 2018
New Revision: 348589

URL: http://llvm.org/viewvc/llvm-project?rev=348589&view=rev
Log:
[unittests] Merge the PrintedStmtCXX..Matches functions (NFC)

This was reviewed as part of https://reviews.llvm.org/D36527

Modified:
cfe/trunk/unittests/AST/StmtPrinterTest.cpp

Modified: cfe/trunk/unittests/AST/StmtPrinterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StmtPrinterTest.cpp?rev=348589&r1=348588&r2=348589&view=diff
==
--- cfe/trunk/unittests/AST/StmtPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/StmtPrinterTest.cpp Fri Dec  7 04:55:01 2018
@@ -106,64 +106,59 @@ PrintedStmtMatches(StringRef Code, const
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedStmtCXX98Matches(StringRef Code, const StatementMatcher &NodeMatch,
-StringRef ExpectedPrinted) {
-  std::vector Args;
-  Args.push_back("-std=c++98");
-  Args.push_back("-Wno-unused-value");
-  return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted);
-}
-
-::testing::AssertionResult PrintedStmtCXX98Matches(
-  StringRef Code,
-  StringRef ContainingFunction,
-  StringRef ExpectedPrinted) {
-  std::vector Args;
-  Args.push_back("-std=c++98");
-  Args.push_back("-Wno-unused-value");
-  return PrintedStmtMatches(Code,
-Args,
-functionDecl(hasName(ContainingFunction),
- 
has(compoundStmt(has(stmt().bind("id"),
-ExpectedPrinted);
+enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX2a };
+
+DeclarationMatcher FunctionBodyMatcher(StringRef ContainingFunction) {
+  return functionDecl(hasName(ContainingFunction),
+  has(compoundStmt(has(stmt().bind("id");
 }
 
+template 
 ::testing::AssertionResult
-PrintedStmtCXX11Matches(StringRef Code, const StatementMatcher &NodeMatch,
-StringRef ExpectedPrinted,
-PolicyAdjusterType PolicyAdjuster = None) {
-  std::vector Args;
-  Args.push_back("-std=c++11");
-  Args.push_back("-Wno-unused-value");
+PrintedStmtCXXMatches(StdVer Standard, StringRef Code, const T &NodeMatch,
+  StringRef ExpectedPrinted,
+  PolicyAdjusterType PolicyAdjuster = None) {
+  const char *StdOpt;
+  switch (Standard) {
+  case StdVer::CXX98: StdOpt = "-std=c++98"; break;
+  case StdVer::CXX11: StdOpt = "-std=c++11"; break;
+  case StdVer::CXX14: StdOpt = "-std=c++14"; break;
+  case StdVer::CXX17: StdOpt = "-std=c++17"; break;
+  case StdVer::CXX2a: StdOpt = "-std=c++2a"; break;
+  }
+
+  std::vector Args = {
+StdOpt,
+"-Wno-unused-value",
+  };
   return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted,
 PolicyAdjuster);
 }
 
-::testing::AssertionResult PrintedStmtMSMatches(
-  StringRef Code,
-  StringRef ContainingFunction,
-  StringRef ExpectedPrinted) {
-  std::vector Args;
-  Args.push_back("-target");
-  Args.push_back("i686-pc-win32");
-  Args.push_back("-std=c++98");
-  Args.push_back("-fms-extensions");
-  Args.push_back("-Wno-unused-value");
-  return PrintedStmtMatches(Code,
-Args,
-functionDecl(hasName(ContainingFunction),
- 
has(compoundStmt(has(stmt().bind("id"),
-ExpectedPrinted);
+template 
+::testing::AssertionResult
+PrintedStmtMSMatches(StringRef Code, const T &NodeMatch,
+ StringRef ExpectedPrinted,
+ PolicyAdjusterType PolicyAdjuster = None) {
+  std::vector Args = {
+"-std=c++98",
+"-target", "i686-pc-win32",
+"-fms-extensions",
+"-Wno-unused-value",
+  };
+  return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted,
+PolicyAdjuster);
 }
 
+template 
 ::testing::AssertionResult
-PrintedStmtObjCMatches(StringRef Code, const StatementMatcher &NodeMatch,
+PrintedStmtObjCMatches(StringRef Code, const T &NodeMatch,
StringRef ExpectedPrinted,
PolicyAdjusterType PolicyAdjuster = None) {
-  std::vector Args;
-  Args.push_back("-ObjC");
-  Args.push_back("-fobjc-runtime=macosx-10.12.0");
+  std::vector Args = {
+"-ObjC",
+"-fobjc-runtime=macosx-10.12.0",
+  };
   return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted,
 PolicyAdjuster);
 }
@@ -171,13 +166,13 @@ PrintedStmtObjCMatches(StringRef Code, c
 } // unnamed namespace
 
 TEST(StmtPrinter, TestIntegerLiteral) {

[PATCH] D55394: Re-order type param children of ObjC nodes

2018-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: ABataev, rsmith.
aaron.ballman added a comment.

I don't know enough about ObjC to feel comfortable saying whether this is a 
reasonable reordering or not, so adding some reviewers.




Comment at: test/AST/ast-dump-decl.m:90
 // CHECK-NEXT:   -ObjCProtocol {{.+}} 'P'
+// CHECK-NEXT:   -ObjCTypeParamDecl {{.+}}  col:33 T 'id':'id'
 

It seems strange to me to print out the type parameter after the superclass 
information given the source order. My understanding of the AST dumping order 
is that we try to keep the order of nodes in source order whenever possible.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55394



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


[PATCH] D55393: Re-order content of template parameter dumps

2018-12-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: test/AST/ast-dump-decl.cpp:330-331
 // CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT: TemplateArgument type 'int'
 // CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+// CHECK-NEXT: TemplateArgument type 'int'
 

aaron.ballman wrote:
> This looks wrong to me. You did not inherit the `TemplateTypeParmDecl` from 
> above, you inherited the `TemplateArgument`. The order is important here and 
> should be preserved to avoid confusion.
Should this be dumped as a child of the `TemplateArgument` then? I can add it 
as a child in `ASTDumper::dumpTemplateArgument`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55393



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


[PATCH] D55411: [clang-tidy] check for flagging using declarations not in the inner most namespace

2018-12-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Please upload the patch with full context.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55411



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


[PATCH] D55410: [clang-tidy] check for flagging using declarations in headers

2018-12-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Please upload with full context.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55410



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


[PATCH] D55409: [clang-tidy] check for using declarations not in an anonymous namespace when there exists one

2018-12-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Please upload with full context.


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

https://reviews.llvm.org/D55409



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


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

While Static Analyzer is the only client of CTU library at the moment, we might 
have more in the future. I would not use the phrase `ANALYZE` in the log 
message.  Once this is resolved the rest looks good.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55135



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


[PATCH] D55428: [Docs] Expand -fstack-protector and -fstack-protector-all info

2018-12-07 Thread Carey Williams via Phabricator via cfe-commits
carwil created this revision.
carwil added a project: clang.
Herald added a subscriber: cfe-commits.

Improve the description of these command line options by providing specific 
heuristic information, as outlined for the ssp function attribute(s) in LLVM's 
documentation.


Repository:
  rC Clang

https://reviews.llvm.org/D55428

Files:
  docs/ClangCommandLineReference.rst


Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -1870,7 +1870,7 @@
 
 .. option:: -fstack-protector, -fno-stack-protector
 
-Enable stack protectors for functions potentially vulnerable to stack smashing
+Enable stack protectors for some functions potentially vulnerable to stack 
smashing. Namely those containing a char (or 8bit integer) array or constant 
sized calls to alloca, which are of greater size than ssp-buffer-size (default: 
8 bytes). All variable sized calls to alloca are considered vulnerable
 
 .. option:: -fstack-protector-all
 
@@ -1878,7 +1878,7 @@
 
 .. option:: -fstack-protector-strong
 
-Use a strong heuristic to apply stack protectors to functions
+Uses a stronger heuristic to apply stack protectors to functions that include 
arrays of any size (and any type), as well as any calls to alloca or the taking 
of an address from a local variable
 
 .. option:: -fstack-size-section, -fno-stack-size-section
 


Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -1870,7 +1870,7 @@
 
 .. option:: -fstack-protector, -fno-stack-protector
 
-Enable stack protectors for functions potentially vulnerable to stack smashing
+Enable stack protectors for some functions potentially vulnerable to stack smashing. Namely those containing a char (or 8bit integer) array or constant sized calls to alloca, which are of greater size than ssp-buffer-size (default: 8 bytes). All variable sized calls to alloca are considered vulnerable
 
 .. option:: -fstack-protector-all
 
@@ -1878,7 +1878,7 @@
 
 .. option:: -fstack-protector-strong
 
-Use a strong heuristic to apply stack protectors to functions
+Uses a stronger heuristic to apply stack protectors to functions that include arrays of any size (and any type), as well as any calls to alloca or the taking of an address from a local variable
 
 .. option:: -fstack-size-section, -fno-stack-size-section
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55331: [CodeComplete] Fix assertion failure

2018-12-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348590: [CodeComplete] Fix assertion failure (authored by 
ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55331?vs=176836&id=177187#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55331

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeCompletion/signatures-crash.cpp


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -6429,7 +6429,12 @@
 if (Expr *E = Args[0]) {
   // Use the explicit base to restrict the lookup:
   ObjectType = E->getType();
-  ObjectClassification = E->Classify(Context);
+  // Pointers in the object arguments are implicitly dereferenced, so 
we
+  // always classify them as l-values.
+  if (!ObjectType.isNull() && ObjectType->isPointerType())
+ObjectClassification = Expr::Classification::makeSimpleLValue();
+  else
+ObjectClassification = E->Classify(Context);
 } // .. else there is an implicit base.
 FunctionArgs = Args.slice(1);
   }
Index: cfe/trunk/test/CodeCompletion/signatures-crash.cpp
===
--- cfe/trunk/test/CodeCompletion/signatures-crash.cpp
+++ cfe/trunk/test/CodeCompletion/signatures-crash.cpp
@@ -0,0 +1,15 @@
+struct map {
+  void find(int);
+  void find();
+};
+
+int main() {
+  map *m;
+  m->find(10);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:11 %s -o - | 
FileCheck %s
+  // CHECK: OVERLOAD: [#void#]find(<#int#>)
+
+  // Also check when the lhs is an explicit pr-value.
+  (m+0)->find(10);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:15 %s -o - | 
FileCheck %s
+}


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -6429,7 +6429,12 @@
 if (Expr *E = Args[0]) {
   // Use the explicit base to restrict the lookup:
   ObjectType = E->getType();
-  ObjectClassification = E->Classify(Context);
+  // Pointers in the object arguments are implicitly dereferenced, so we
+  // always classify them as l-values.
+  if (!ObjectType.isNull() && ObjectType->isPointerType())
+ObjectClassification = Expr::Classification::makeSimpleLValue();
+  else
+ObjectClassification = E->Classify(Context);
 } // .. else there is an implicit base.
 FunctionArgs = Args.slice(1);
   }
Index: cfe/trunk/test/CodeCompletion/signatures-crash.cpp
===
--- cfe/trunk/test/CodeCompletion/signatures-crash.cpp
+++ cfe/trunk/test/CodeCompletion/signatures-crash.cpp
@@ -0,0 +1,15 @@
+struct map {
+  void find(int);
+  void find();
+};
+
+int main() {
+  map *m;
+  m->find(10);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:11 %s -o - | FileCheck %s
+  // CHECK: OVERLOAD: [#void#]find(<#int#>)
+
+  // Also check when the lhs is an explicit pr-value.
+  (m+0)->find(10);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:15 %s -o - | FileCheck %s
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348590 - [CodeComplete] Fix assertion failure

2018-12-07 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Dec  7 05:17:52 2018
New Revision: 348590

URL: http://llvm.org/viewvc/llvm-project?rev=348590&view=rev
Log:
[CodeComplete] Fix assertion failure

Summary:
...that fires when running completion inside an argument of
UnresolvedMemberExpr (see the added test).

The assertion that fires is from Sema::TryObjectArgumentInitialization:

assert(FromClassification.isLValue());

This happens because Sema::AddFunctionCandidates does not account for
object types which are pointers. It ends up classifying them incorrectly.
All usages of the function outside code completion are used to run
overload resolution for operators. In those cases the object type being
passed is always a non-pointer type, so it's not surprising the function
did not expect a pointer in the object argument.

However, code completion reuses the same function and calls it with the
object argument coming from UnresolvedMemberExpr, which can be a pointer
if the member expr is an arrow ('->') access.

Extending AddFunctionCandidates to allow pointer object types does not
seem too crazy since all the functions down the call chain can properly
handle pointer object types if we properly classify the object argument
as an l-value, i.e. the classification of the implicitly dereferenced
pointer.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeCompletion/signatures-crash.cpp
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=348590&r1=348589&r2=348590&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Dec  7 05:17:52 2018
@@ -6429,7 +6429,12 @@ void Sema::AddFunctionCandidates(const U
 if (Expr *E = Args[0]) {
   // Use the explicit base to restrict the lookup:
   ObjectType = E->getType();
-  ObjectClassification = E->Classify(Context);
+  // Pointers in the object arguments are implicitly dereferenced, so 
we
+  // always classify them as l-values.
+  if (!ObjectType.isNull() && ObjectType->isPointerType())
+ObjectClassification = Expr::Classification::makeSimpleLValue();
+  else
+ObjectClassification = E->Classify(Context);
 } // .. else there is an implicit base.
 FunctionArgs = Args.slice(1);
   }

Added: cfe/trunk/test/CodeCompletion/signatures-crash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/signatures-crash.cpp?rev=348590&view=auto
==
--- cfe/trunk/test/CodeCompletion/signatures-crash.cpp (added)
+++ cfe/trunk/test/CodeCompletion/signatures-crash.cpp Fri Dec  7 05:17:52 2018
@@ -0,0 +1,15 @@
+struct map {
+  void find(int);
+  void find();
+};
+
+int main() {
+  map *m;
+  m->find(10);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:11 %s -o - | 
FileCheck %s
+  // CHECK: OVERLOAD: [#void#]find(<#int#>)
+
+  // Also check when the lhs is an explicit pr-value.
+  (m+0)->find(10);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:15 %s -o - | 
FileCheck %s
+}


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


[PATCH] D55315: [clangd] Only reduce priority of a thread for indexing.

2018-12-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/index/Background.cpp:202
 std::lock_guard Lock(QueueMu);
-Queue.push_back(std::move(T));
+if (Priority == ThreadPriority::Low) {
+  Queue.push_back(Bind(

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > Since we might be interested in scheduling higher-priority tasks first 
> > > anyway (not in this patch, but still), maybe store a pair of `(Task, 
> > > Priority)` in the queue and call `setCurrentThreadPriority` when actually 
> > > running the task?
> > I believe we can introduce that later on whenever we have more than 2 
> > priorities, currently we push to front for important tasks and back for the 
> > low priority ones. Do you think it is not enough?
> Sorry, I somehow missed that `push_front` and `push_back` are used in 
> different cases, I've only noticed the callback wrapping.
> I feel storing priorities in the queue produces a more straightforward code 
> as priority is an important scheduling signal, so it fits in nicely there. 
> Using a wrapped callback, OTOH, is a bit hard to read. But that might be a 
> personal preference, up to you.
> 
> See the other comment about ordering of the tasks with normal priorities, it 
> looks more important
The wrapped callback was rather for getting rid of unnecessary system calls, 
but since normal tasks come up rarely to queue it doesn't feel like an 
important thing. Changing it to store the priority in the queue.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55315



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


[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2018-12-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 177182.
Szelethus retitled this revision from "[analyzer][WIP] Reimplement dependencies 
between checkers" to "[analyzer] Reimplement dependencies between checkers".
Szelethus edited the summary of this revision.
Szelethus added reviewers: MTC, baloghadamsoftware.
Szelethus added a comment.
This revision is now accepted and ready to land.

- No longer splitting up `InnerPointerChecker`
- After spending a lot of more time with the checker files, and adding various 
asserts in followup patches, realize that dependencies in between checkers are 
far, //far// more common than anticipated. I find it really cool that this is 
clearly visible now from the tblgen file. Add the following new checkers:
  - `StackAddrEscapeBase`
  - `StackAddrEscapeBase`
  - `CStringModeling`
  - `DynamicMemoryModeling` (base of the `MallocChecker` family)
  - `IteratorModeling` (base of the `IteratorChecker` family)
  - `ValistBase`
  - `SecuritySyntaxChecker` (base of `bcmp`, `bcopy`, etc...)
  - `NSOrCFErrorDerefChecker` (base of `NSErrorChecker` and  `CFErrorChecker`)
  - `IvarInvalidationModeling` (base of `IvarInvalidation` checker family)
- Make sure checkers are only enabled if all of their dependencies can be 
enabled
- Put strong emphasis on preserving the order of insertions when collecting 
enabled checkers
- It is no longer possible to enable `CallAndMessageUnInitRefArg` without 
`CallAndMessageChecker`. Disabling core checkers isn't supported anyways.


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

https://reviews.llvm.org/D54438

Files:
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
  test/Analysis/NewDelete-checker-test.cpp
  utils/TableGen/ClangSACheckersEmitter.cpp

Index: utils/TableGen/ClangSACheckersEmitter.cpp
===
--- utils/TableGen/ClangSACheckersEmitter.cpp
+++ utils/TableGen/ClangSACheckersEmitter.cpp
@@ -57,6 +57,13 @@
   return std::string();
 }
 
+static void printChecker(llvm::raw_ostream &OS, const Record &R) {
+  OS << '\"';
+  OS.write_escaped(getCheckerFullName(&R)) << "\", ";
+  OS << R.getName() << ", \"";
+  OS.write_escaped(getStringValue(R, "HelpText")) << '\"';
+}
+
 namespace clang {
 void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) {
   std::vector checkers = Records.getAllDerivedDefinitions("Checker");
@@ -64,7 +71,12 @@
 
   using SortedRecords = llvm::StringMap;
 
-  OS << "\n#ifdef GET_PACKAGES\n";
+  // Emit packages.
+  //
+  // PACKAGE(PACKAGENAME)
+  //   - PACKAGENAME: The name of the package.
+  OS << "\n"
+"#ifdef GET_PACKAGES\n";
   {
 SortedRecords sortedPackages;
 for (unsigned i = 0, e = packages.size(); i != e; ++i)
@@ -79,19 +91,51 @@
   OS << ")\n";
 }
   }
-  OS << "#endif // GET_PACKAGES\n\n";
-  
-  OS << "\n#ifdef GET_CHECKERS\n";
-  for (unsigned i = 0, e = checkers.size(); i != e; ++i) {
-const Record &R = *checkers[i];
+  OS << "#endif // GET_PACKAGES\n"
+"\n";
 
-OS << "CHECKER(" << "\"";
-OS.write_escaped(getCheckerFullName(&R)) << "\", ";
-OS << R.getName() << ", ";
-OS << "\"";
-OS.write_escaped(getStringValue(R, "HelpText")) << '\"';
+  // Emit checkers.
+  //
+  // CHECKER(FULLNAME, CLASS, HELPTEXT)
+  //   - FULLNAME: The full name of the checker, including packages, e.g.:
+  //   alpha.cplusplus.UninitializedObject
+  //   - CLASS: The name of the checker, with "Checker" appended, e.g.:
+  //UninitializedObjectChecker
+  //   - HELPTEXT: The description of the checker.
+  OS << "\n"
+"#ifdef GET_CHECKERS\n"
+"\n";
+  for (const Record *checker : checkers) {
+OS << "CHECKER(";
+printChecker(OS, *checker);
 OS << ")\n";
   }
-  OS << "#endif // GET_CHECKERS\n\n";
+  OS << "\n"
+"#endif // GET_CHECKERS\n"
+"\n";
+
+  // Emit dependencies.
+  //
+  // CHECKER_DEPENDENCY(FULLNAME, DEPENDENCY)
+  //   - FULLNAME: The full name of the checker that depends on another checker.
+  //   - DEPENDENCY: The full name of the checker FULLNAME depends on.
+  OS << "\n"
+"#ifdef GET_CHECKER_DEPENDENCIES\n";
+  for (cons

[PATCH] D55315: [clangd] Only reduce priority of a thread for indexing.

2018-12-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 177188.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Move priority change logic to runner
- Change storage for tasks from deque to list, since we only pop from front but 
we might end up adding into middle.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55315

Files:
  clangd/Threading.cpp
  clangd/Threading.h
  clangd/index/Background.cpp
  clangd/index/Background.h

Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -13,6 +13,7 @@
 #include "Context.h"
 #include "FSProvider.h"
 #include "GlobalCompilationDatabase.h"
+#include "Threading.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
@@ -110,14 +111,14 @@
   // queue management
   using Task = std::function;
   void run(); // Main loop executed by Thread. Runs tasks from Queue.
-  void enqueueTask(Task T);
+  void enqueueTask(Task T, ThreadPriority Prioirty);
   void enqueueLocked(tooling::CompileCommand Cmd,
  BackgroundIndexStorage *IndexStorage);
-  std::mutex QueueMu;
+  std::mutex TasksMu;
   unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks.
-  std::condition_variable QueueCV;
+  std::condition_variable TasksCV;
   bool ShouldStop = false;
-  std::deque Queue;
+  std::list> Tasks;
   std::vector ThreadPool; // FIXME: Abstract this away.
   GlobalCompilationDatabase::CommandChanged::Subscription CommandsChanged;
 };
Index: clangd/index/Background.cpp
===
--- clangd/index/Background.cpp
+++ clangd/index/Background.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SHA1.h"
@@ -104,11 +105,6 @@
   assert(this->IndexStorageFactory && "Storage factory can not be null!");
   while (ThreadPoolSize--) {
 ThreadPool.emplace_back([this] { run(); });
-// Set priority to low, since background indexing is a long running task we
-// do not want to eat up cpu when there are any other high priority threads.
-// FIXME: In the future we might want a more general way of handling this to
-// support tasks with various priorities.
-setThreadPriority(ThreadPool.back(), ThreadPriority::Low);
   }
 }
 
@@ -120,86 +116,101 @@
 
 void BackgroundIndex::stop() {
   {
-std::lock_guard Lock(QueueMu);
+std::lock_guard Lock(TasksMu);
 ShouldStop = true;
   }
-  QueueCV.notify_all();
+  TasksCV.notify_all();
 }
 
 void BackgroundIndex::run() {
   WithContext Background(BackgroundContext.clone());
   while (true) {
 Optional Task;
+ThreadPriority Priority;
 {
-  std::unique_lock Lock(QueueMu);
-  QueueCV.wait(Lock, [&] { return ShouldStop || !Queue.empty(); });
+  std::unique_lock Lock(TasksMu);
+  TasksCV.wait(Lock, [&] { return ShouldStop || !Tasks.empty(); });
   if (ShouldStop) {
-Queue.clear();
-QueueCV.notify_all();
+Tasks.clear();
+TasksCV.notify_all();
 return;
   }
   ++NumActiveTasks;
-  Task = std::move(Queue.front());
-  Queue.pop_front();
+  std::tie(Task, Priority) = std::move(Tasks.front());
+  Tasks.pop_front();
 }
+setCurrentThreadPriority(Priority);
 (*Task)();
+setCurrentThreadPriority(ThreadPriority::Normal);
 {
-  std::unique_lock Lock(QueueMu);
+  std::unique_lock Lock(TasksMu);
   assert(NumActiveTasks > 0 && "before decrementing");
   --NumActiveTasks;
 }
-QueueCV.notify_all();
+TasksCV.notify_all();
   }
 }
 
 bool BackgroundIndex::blockUntilIdleForTest(
 llvm::Optional TimeoutSeconds) {
-  std::unique_lock Lock(QueueMu);
-  return wait(Lock, QueueCV, timeoutSeconds(TimeoutSeconds),
-  [&] { return Queue.empty() && NumActiveTasks == 0; });
+  std::unique_lock Lock(TasksMu);
+  return wait(Lock, TasksCV, timeoutSeconds(TimeoutSeconds),
+  [&] { return Tasks.empty() && NumActiveTasks == 0; });
 }
 
 void BackgroundIndex::enqueue(const std::vector &ChangedFiles) {
-  enqueueTask([this, ChangedFiles] {
-trace::Span Tracer("BackgroundIndexEnqueue");
-// We're doing this asynchronously, because we'll read shards here too.
-// FIXME: read shards here too.
-
-log("Enqueueing {0} commands for indexing", ChangedFiles.size());
-SPAN_ATTACH(Tracer, "files", int64_t(ChangedFiles.size()));
-
-// We shuffle the files because processing them in a random order should
-// quickly give us good coverage of headers in the project.
-std::vector Permutation(ChangedFiles.size());
-std::iota(Permutation.begin(), Permutation.end

[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2018-12-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 177189.
Szelethus added a comment.

- Register the checker after it's dependencies (accidentally left this change 
in the next branch). This implies that `unix.MallocChecker:Optimistic` is no 
longer a thing, and is now called ųnix.DynamicMemoryModeling:Optimistic`. This 
//could// break backward compatibility, but is also addressable, since it can 
always be converted to whatever full name `DynamicMemoryModeling` will have in 
the future. @george.karpenkov @NoQ feelings on this?
- In `test/Analysis/Inputs/expected-plists/nullability-notes.m.plist`, the name 
of the checker associated with a report changed, but this is **NOT** an issue 
raised by this patch -- simply changing the order of `analyzer-checker=ABC,CBA` 
to `CBA,ABC` will cause the same issue. Please don't mind me, but I'm not 
immediately interested in fixing this issue.


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

https://reviews.llvm.org/D54438

Files:
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
  test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/malloc-annotations.c
  utils/TableGen/ClangSACheckersEmitter.cpp

Index: utils/TableGen/ClangSACheckersEmitter.cpp
===
--- utils/TableGen/ClangSACheckersEmitter.cpp
+++ utils/TableGen/ClangSACheckersEmitter.cpp
@@ -57,6 +57,13 @@
   return std::string();
 }
 
+static void printChecker(llvm::raw_ostream &OS, const Record &R) {
+  OS << '\"';
+  OS.write_escaped(getCheckerFullName(&R)) << "\", ";
+  OS << R.getName() << ", \"";
+  OS.write_escaped(getStringValue(R, "HelpText")) << '\"';
+}
+
 namespace clang {
 void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) {
   std::vector checkers = Records.getAllDerivedDefinitions("Checker");
@@ -64,7 +71,12 @@
 
   using SortedRecords = llvm::StringMap;
 
-  OS << "\n#ifdef GET_PACKAGES\n";
+  // Emit packages.
+  //
+  // PACKAGE(PACKAGENAME)
+  //   - PACKAGENAME: The name of the package.
+  OS << "\n"
+"#ifdef GET_PACKAGES\n";
   {
 SortedRecords sortedPackages;
 for (unsigned i = 0, e = packages.size(); i != e; ++i)
@@ -79,19 +91,51 @@
   OS << ")\n";
 }
   }
-  OS << "#endif // GET_PACKAGES\n\n";
-  
-  OS << "\n#ifdef GET_CHECKERS\n";
-  for (unsigned i = 0, e = checkers.size(); i != e; ++i) {
-const Record &R = *checkers[i];
+  OS << "#endif // GET_PACKAGES\n"
+"\n";
 
-OS << "CHECKER(" << "\"";
-OS.write_escaped(getCheckerFullName(&R)) << "\", ";
-OS << R.getName() << ", ";
-OS << "\"";
-OS.write_escaped(getStringValue(R, "HelpText")) << '\"';
+  // Emit checkers.
+  //
+  // CHECKER(FULLNAME, CLASS, HELPTEXT)
+  //   - FULLNAME: The full name of the checker, including packages, e.g.:
+  //   alpha.cplusplus.UninitializedObject
+  //   - CLASS: The name of the checker, with "Checker" appended, e.g.:
+  //UninitializedObjectChecker
+  //   - HELPTEXT: The description of the checker.
+  OS << "\n"
+"#ifdef GET_CHECKERS\n"
+"\n";
+  for (const Record *checker : checkers) {
+OS << "CHECKER(";
+printChecker(OS, *checker);
 OS << ")\n";
   }
-  OS << "#endif // GET_CHECKERS\n\n";
+  OS << "\n"
+"#endif // GET_CHECKERS\n"
+"\n";
+
+  // Emit dependencies.
+  //
+  // CHECKER_DEPENDENCY(FULLNAME, DEPENDENCY)
+  //   - FULLNAME: The full name of the checker that depends on another checker.
+  //   - DEPENDENCY: The full name of the checker FULLNAME depends on.
+  OS << "\n"
+"#ifdef GET_CHECKER_DEPENDENCIES\n";
+  for (const Record *checker : checkers) {
+if (checker->isValueUnset("Dependencies"))
+  continue;
+
+for (const Record *Dependency :
+checker->getValueAsListOfDefs("Dependencies")) {
+  OS << "CHECKER_DEPENDENCY(";
+  OS << '\"';
+  OS.write_escaped(getCheckerFullName(checker)) << "\", ";
+  OS << '\"';
+  OS.write_escaped(getCheckerFullName(Dependency)) << '\"';
+  OS << ")\n";
+}
+  }
+  OS << "\n"
+"#endif // GET_CHECKER_DEPENDENCIES\n";
 }

[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2018-12-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested review of this revision.
Szelethus added a comment.

Please take a second look, this is a pretty important to get right.


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

https://reviews.llvm.org/D54438



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


[PATCH] D55393: Re-order content of template parameter dumps

2018-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/AST/ast-dump-decl.cpp:330-331
 // CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT: TemplateArgument type 'int'
 // CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+// CHECK-NEXT: TemplateArgument type 'int'
 

steveire wrote:
> aaron.ballman wrote:
> > This looks wrong to me. You did not inherit the `TemplateTypeParmDecl` from 
> > above, you inherited the `TemplateArgument`. The order is important here 
> > and should be preserved to avoid confusion.
> Should this be dumped as a child of the `TemplateArgument` then? I can add it 
> as a child in `ASTDumper::dumpTemplateArgument`.
I kind of think it should. We follow the same pattern in each place -- print 
the template argument, then print this information, so combining it seems 
reasonable to me.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55393



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


[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-12-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested review of this revision.
Szelethus added a comment.

Marking this patch as non-accepted.


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

https://reviews.llvm.org/D51866



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


[PATCH] D55424: [analyzer] Supply all checkers with a shouldRegister function

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

The checker file changes in this patch are pretty boring, here are those that 
don't always return true in `shouldRegister`:

- `CastSizeChecker`
- `GTestChecker`
- `NSAutoreleasePoolChecker`
- `ObjCAtSyncChecker`


Repository:
  rC Clang

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

https://reviews.llvm.org/D55424



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


[PATCH] D55191: [clangd] Refine the way of checking a declaration is referenced by the written code.

2018-12-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 177190.
hokein marked 4 inline comments as done.
hokein added a comment.

Update based on our offline discussion.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55191

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -1225,6 +1225,53 @@
   }
 }
 
+TEST(FindReferences, ExplicitSymbols) {
+  const char *Tests[] = {
+  R"cpp(
+  struct Foo { Foo* [self]() const; };
+  void f() {
+if (Foo* T = foo.[^self]()) {} // Foo member call expr.
+  }
+  )cpp",
+
+  R"cpp(
+  struct Foo { Foo(int); };
+  Foo f() {
+int [b];
+return [^b]; // Foo constructor expr.
+  }
+  )cpp",
+
+  R"cpp(
+  struct Foo {};
+  void g(Foo);
+  Foo [f]();
+  void call() {
+g([^f]());  // Foo constructor expr.
+  }
+  )cpp",
+
+  R"cpp(
+  void [foo](int);
+  void [foo](double);
+
+  namespace ns {
+  using ::[fo^o];
+  }
+  )cpp",
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+std::vector> ExpectedLocations;
+for (const auto &R : T.ranges())
+  ExpectedLocations.push_back(RangeIs(R));
+EXPECT_THAT(findReferences(AST, T.point()),
+ElementsAreArray(ExpectedLocations))
+<< Test;
+  }
+}
+
 TEST(FindReferences, NeedsIndex) {
   const char *Header = "int foo();";
   Annotations Main("int main() { [[f^oo]](); }");
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -139,21 +139,19 @@
   SourceLocation Loc,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
 if (Loc == SearchedLocation) {
-  // Check whether the E has an implicit AST node (e.g. ImplicitCastExpr).
-  auto hasImplicitExpr = [](const Expr *E) {
-if (!E || E->child_begin() == E->child_end())
+  auto isImplicitExpr = [](const Expr *E) {
+if (!E)
   return false;
-// Use the first child is good enough for most cases -- normally the
-// expression returned by handleDeclOccurence contains exactly one
-// child expression.
-const auto *FirstChild = *E->child_begin();
-return isa(FirstChild) ||
-   isa(FirstChild) ||
-   isa(FirstChild) ||
-   isa(FirstChild);
+// We assume that a constructor expression is implict (was inserted by
+// clang) if it has an invalid paren/brace location, since such
+// experssion is impossible to write down.
+if (const auto *CtorExpr = dyn_cast(E))
+  return CtorExpr->getNumArgs() > 0 &&
+ CtorExpr->getParenOrBraceRange().isInvalid();
+return isa(E);
   };
 
-  bool IsExplicit = !hasImplicitExpr(ASTNode.OrigE);
+  bool IsExplicit = !isImplicitExpr(ASTNode.OrigE);
   // Find and add definition declarations (for GoToDefinition).
   // We don't use parameter `D`, as Parameter `D` is the canonical
   // declaration, which is the first declaration of a redeclarable


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -1225,6 +1225,53 @@
   }
 }
 
+TEST(FindReferences, ExplicitSymbols) {
+  const char *Tests[] = {
+  R"cpp(
+  struct Foo { Foo* [self]() const; };
+  void f() {
+if (Foo* T = foo.[^self]()) {} // Foo member call expr.
+  }
+  )cpp",
+
+  R"cpp(
+  struct Foo { Foo(int); };
+  Foo f() {
+int [b];
+return [^b]; // Foo constructor expr.
+  }
+  )cpp",
+
+  R"cpp(
+  struct Foo {};
+  void g(Foo);
+  Foo [f]();
+  void call() {
+g([^f]());  // Foo constructor expr.
+  }
+  )cpp",
+
+  R"cpp(
+  void [foo](int);
+  void [foo](double);
+
+  namespace ns {
+  using ::[fo^o];
+  }
+  )cpp",
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+std::vector> ExpectedLocations;
+for (const auto &R : T.ranges())
+  ExpectedLocations.push_back(RangeIs(R));
+EXPECT_THAT(findReferences(AST, T.point()),
+ElementsAreArray(ExpectedLocations))
+<< Test;
+  }
+}
+
 TEST(FindReferences, NeedsIndex) {
   const char *Header = "int foo();";
   Annotations Main("int main() { [[f^oo]](); }");
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -139,21 +13

[PATCH] D55191: [clangd] Refine the way of checking a declaration is referenced by the written code.

2018-12-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> What are the cases we're trying to filter out? Only implicit constructor or 
> anything else?

I think implicit constructor is the only case we care about. We also looked 
through the caller implementation of `handleDeclOccurence`, it is safe to 
assume it.




Comment at: unittests/clangd/XRefsTests.cpp:1228
 
+TEST(FindReferences, ExplicitSymbols) {
+  const char *Tests[] = {

ilya-biryukov wrote:
> I'm missing what does this test actually tests.
> The absence of implicit references (I guess constructor expressions)?
This test tests the cases where symbol is being marked implicit incorrectly, 
which will result in no result in xref.



Comment at: unittests/clangd/XRefsTests.cpp:1259
+  namespace ns {
+  using [fo^o];
+  }

ilya-biryukov wrote:
> Shouldn't the `usings` always be qualified? Isn't this a compiler error?
Yes, this is a compiler error, but clang's error recovery can handle it. Fixed.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55191



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


[PATCH] D55429: [analyzer] Add CheckerManager::getChecker that asserts on non-registered checkers, assert on registering already registered checkers

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

Title says it all, this is pretty important. While this doesn't immediately 
make it impossible to register multiple checkers in a registry function, it 
does make it completely avoidable.


Repository:
  rC Clang

https://reviews.llvm.org/D55429

Files:
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/analyzer-checker-config.c
  test/Analysis/free.c
  test/Analysis/outofbound.c
  test/Analysis/undef-buffers.c

Index: test/Analysis/undef-buffers.c
===
--- test/Analysis/undef-buffers.c
+++ test/Analysis/undef-buffers.c
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,core.uninitialized -analyzer-store=region -verify -analyzer-config unix:Optimistic=true %s
+// RUN: %clang_analyze_cc1 -analyzer-store=region -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix \
+// RUN:   -analyzer-checker=core.uninitialized \
+// RUN:   -analyzer-config unix:Optimistic=true
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void free(void *);
Index: test/Analysis/outofbound.c
===
--- test/Analysis/outofbound.c
+++ test/Analysis/outofbound.c
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,unix,alpha.security.ArrayBound -analyzer-store=region -verify -analyzer-config unix:Optimistic=true %s
+// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-store=region -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix \
+// RUN:   -analyzer-checker=alpha.security.ArrayBound \
+// RUN:   -analyzer-config unix:Optimistic=true
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
Index: test/Analysis/free.c
===
--- test/Analysis/free.c
+++ test/Analysis/free.c
@@ -1,5 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify -analyzer-config unix.Malloc:Optimistic=true %s
+// RUN: %clang_analyze_cc1 -fblocks -verify %s -analyzer-store=region \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.Malloc
+//
+// RUN: %clang_analyze_cc1 -fblocks -verify %s -analyzer-store=region \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-config unix.DynamicMemoryModeling:Optimistic=true
 typedef __typeof(sizeof(int)) size_t;
 void free(void *);
 void *alloca(size_t);
Index: test/Analysis/analyzer-checker-config.c
===
--- test/Analysis/analyzer-checker-config.c
+++ test/Analysis/analyzer-checker-config.c
@@ -4,7 +4,7 @@
 // RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true 2>&1 | FileCheck %s
 // RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true 2>&1 | FileCheck %s
 // RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true 2>&1 | FileCheck %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.Malloc:Optimistic=true
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.DynamicMemoryModeling:Optimistic=true
 
 // Just to test clang is working.
 # foo
Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -196,6 +196,7 @@
 for (auto lastRelatedChecker = firstRelatedChecker+size;
  firstRelatedChecker != lastRelatedChecker; ++firstRelatedChecker) {
   if (opt.second) {
+
 if (!firstRelatedChecker->ShouldRegister(LangOpts))
   continue;
 
Index: lib/StaticAnalyzer/Checkers/ValistChec

[PATCH] D55428: [Docs] Expand -fstack-protector and -fstack-protector-all info

2018-12-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please linewrap to 80 col.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55428



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


[PATCH] D53866: [Preamble] Stop generating preamble for circular #includes

2018-12-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Basic/DiagnosticLexKinds.td:432
+def err_pp_including_mainfile_for_preamble : Error<
+  "main file cannot be included recursively for preamble">, DefaultFatal;
 def err_pp_empty_filename : Error<"empty filename">;

NIT: maybe rephrase `for preamble` to `when building a preamble`? "for 
preamble" might be a bit confusing.



Comment at: include/clang/Lex/Preprocessor.h:391
   } PreambleConditionalStack;
+  bool PreambleGenerationFailed = false;
 

nik wrote:
> ilya-biryukov wrote:
> > nik wrote:
> > > ilya-biryukov wrote:
> > > > There's a mechanism to handle preamble with errors, see 
> > > > `PreprocessorOpts::AllowPCHWithCompilerErrors`.
> > > > Maybe rely on it and avoid adding a different one?
> > > I'm not sure how to make use of AllowPCHWithCompilerErrors. It's clearly 
> > > meant as an input/readonly option - do you suggest setting that one to 
> > > "false" in case we detect the cyclic include (and later checking for 
> > > it...)? That feels a bit hacky. Have you meant something else?
> > We emit an error, so the preamble will **not** be emitted. 
> > Unless the users specify `AllowPCHWithCompilerErrors`, in which case 
> > they've signed up for this anyway.
> > 
> > I propose to **not** add the new flag at all. Would that work?
> As stated further above, no.
> 
> That's because for the libclang/c-index-test case, 
> AllowPCHWithCompilerErrors=true - see clang_parseTranslationUnit_Impl. As 
> such, the preamble will be generated/emitted as the second early return in 
> PCHGenerator::HandleTranslationUnit is never hit.
if `AllowPCHWithCompilerErrors=true` is set to true, why not simply pretend the 
include was not found? That would still generate the preamble, but users have 
the error message to see that something went wrong.

`c-index-test` produces the errors, so we can check the error is present in the 
output.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53866



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


[PATCH] D55359: [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.

2018-12-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/TUScheduler.cpp:644
+  std::unique_lock Lock(Barrier, std::try_to_lock);
+  if (Lock.owns_lock()) {
+ExecuteAction();

Maybe simplify the code a bit?
```
// Replacing these two lines:
//  emitTUStatus({TUAction::Queued, Req.Name});
//  std::lock_guard BarrierLock(Barrier);

// With:
std::unique_lock BarrierLock(Barrier, std::try_to_lock);
if (!Lock.owns_lock()) {
  emitTUStatus({TUAction::Queued, Req.Name});
  Lock.lock();
}
// Rest of the code is the same...
```

Avoids creating two locks and does not require helper lamdbas.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55359



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


[PATCH] D55431: [CodeComplete] Set preferred type to bool on conditions

2018-12-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.

Repository:
  rC Clang

https://reviews.llvm.org/D55431

Files:
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/preferred-type.cpp


Index: test/CodeCompletion/preferred-type.cpp
===
--- /dev/null
+++ test/CodeCompletion/preferred-type.cpp
@@ -0,0 +1,15 @@
+void test(bool x) {
+  if (x) {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:7 %s | FileCheck %s
+  // CHECK: PREFERRED-TYPE: _Bool
+
+  while (x) {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:10 %s | FileCheck 
%s
+
+  for (; x;) {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:10 %s | FileCheck 
%s
+
+  // FIXME(ibiryukov): the condition in do-while is parsed as expression, so we
+  // fail to detect it should be converted to bool.
+  // do {} while (x);
+}
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3522,7 +3522,7 @@
 CodeCompleter->ProcessCodeCompleteResults(*S, Context, Results, 
NumResults);
 }
 
-static enum CodeCompletionContext::Kind
+static CodeCompletionContext
 mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC) {
   switch (PCC) {
   case Sema::PCC_Namespace:
@@ -3559,8 +3559,10 @@
   return CodeCompletionContext::CCC_Expression;
 
   case Sema::PCC_Expression:
-  case Sema::PCC_Condition:
 return CodeCompletionContext::CCC_Expression;
+  case Sema::PCC_Condition:
+return CodeCompletionContext(CodeCompletionContext::CCC_Expression,
+ S.getASTContext().BoolTy);
 
   case Sema::PCC_Statement:
 return CodeCompletionContext::CCC_Statement;
Index: lib/Sema/CodeCompleteConsumer.cpp
===
--- lib/Sema/CodeCompleteConsumer.cpp
+++ lib/Sema/CodeCompleteConsumer.cpp
@@ -539,9 +539,12 @@
 unsigned NumResults) {
   std::stable_sort(Results, Results + NumResults);
 
-  StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter();
+  if (!Context.getPreferredType().isNull())
+OS << "PREFERRED-TYPE: " << Context.getPreferredType().getAsString()
+   << "\n";
 
-  // Print the results.
+  StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter();
+  // Print the completions.
   for (unsigned I = 0; I != NumResults; ++I) {
 if (!Filter.empty() && isResultFilteredOut(Filter, Results[I]))
   continue;


Index: test/CodeCompletion/preferred-type.cpp
===
--- /dev/null
+++ test/CodeCompletion/preferred-type.cpp
@@ -0,0 +1,15 @@
+void test(bool x) {
+  if (x) {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:7 %s | FileCheck %s
+  // CHECK: PREFERRED-TYPE: _Bool
+
+  while (x) {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:10 %s | FileCheck %s
+
+  for (; x;) {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:10 %s | FileCheck %s
+
+  // FIXME(ibiryukov): the condition in do-while is parsed as expression, so we
+  // fail to detect it should be converted to bool.
+  // do {} while (x);
+}
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3522,7 +3522,7 @@
 CodeCompleter->ProcessCodeCompleteResults(*S, Context, Results, NumResults);
 }
 
-static enum CodeCompletionContext::Kind
+static CodeCompletionContext
 mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC) {
   switch (PCC) {
   case Sema::PCC_Namespace:
@@ -3559,8 +3559,10 @@
   return CodeCompletionContext::CCC_Expression;
 
   case Sema::PCC_Expression:
-  case Sema::PCC_Condition:
 return CodeCompletionContext::CCC_Expression;
+  case Sema::PCC_Condition:
+return CodeCompletionContext(CodeCompletionContext::CCC_Expression,
+ S.getASTContext().BoolTy);
 
   case Sema::PCC_Statement:
 return CodeCompletionContext::CCC_Statement;
Index: lib/Sema/CodeCompleteConsumer.cpp
===
--- lib/Sema/CodeCompleteConsumer.cpp
+++ lib/Sema/CodeCompleteConsumer.cpp
@@ -539,9 +539,12 @@
 unsigned NumResults) {
   std::stable_sort(Results, Results + NumResults);
 
-  StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter();
+  if (!Context.getPreferredType().isNull())
+OS << "PREFERRED-TYPE: " << Context.getPreferredType().getAsString()
+   << "\n";
 
-  // Print the results.
+  StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter();
+  // Print the completions.
   for (unsigned I = 0; I != NumResults; ++I) {
 if (!Filter.empty() && isResultFilteredOut(Filter, Results[I]))
   continue;
_

[PATCH] D55410: [clang-tidy] check for flagging using declarations in headers

2018-12-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Would it make sense to make this a generic non-abseil check?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55410



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


[PATCH] D54672: clang-include-fixer.el: support remote files

2018-12-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54672



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


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added a comment.

> While Static Analyzer is the only client of CTU library at the moment, we 
> might have more in the future. I would not use the phrase ANALYZE in the log 
> message. Once this is resolved the rest looks good.

Ok, I removed the "ANALYZE " prefix from the log message.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55135



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


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 177204.
martong added a comment.

- Remove 'ANALYZE ' prefix from the log message


Repository:
  rC Clang

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

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,14 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%T/ctudir \
+// RUN:   -analyzer-config display-ctu-progress=true 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -21,6 +21,7 @@
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-index-name = externalFnMap.txt
+// CHECK-NEXT: display-ctu-progress = false
 // CHECK-NEXT: eagerly-assume = true
 // CHECK-NEXT: elide-constructors = true
 // CHECK-NEXT: expand-macros = false
@@ -51,4 +52,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 48
+// CHECK-NEXT: num-entries = 49
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,8 +560,8 @@
   cross_tu::CrossTranslationUnitContext &CTUCtx =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir,
-  Opts.CTUIndexName);
+  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName,
+  Opts.DisplayCTUProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected CrossTranslationUnitContext::loadExternalAST(
-StringRef LookupName, StringRef CrossTUDir, StringRef IndexName) {
+StringRef LookupName, StringRef CrossTUDir, StringRef IndexName,
+bool DisplayCTUProgress) {
   // FIXME: The current implementation only supports loading functions with
   //a lookup name from a single translation unit. If multiple
   //translation units contains functions with the same lookup name an
@@ -233,6 +235,10 @@
   ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
   Unit = LoadedUnit.get();
   FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);
+  if (DisplayCTUProgress) {
+llvm::errs() << "CTU loaded AST file: "
+ << ASTFileName << "\n";
+  }
 } else {
   Unit = ASTCacheEntry->second.get();
 }
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- inclu

[PATCH] D55410: [clang-tidy] check for flagging using declarations in headers

2018-12-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/abseil/AliasFreeHeadersCheck.cpp:22
+  // Match all using declarations in header files.
+  
Finder->addMatcher(usingDecl(isExpansionInFileMatching(".*\\.h.*")).bind("x"),
+this);

Relevant:
```
$ clang-tidy -dump-config | grep -i extension -A1
  - key: cert-dcl59-cpp.HeaderFileExtensions
value:   ',h,hh,hpp,hxx'
--
  - key: google-build-namespaces.HeaderFileExtensions
value:   h,hh,hpp,hxx,
  - key: google-global-names-in-headers.HeaderFileExtensions
value:   h,hh,hpp,hxx,
--
  - key: misc-definitions-in-headers.HeaderFileExtensions
value:   h,hh,hpp,hxx,
  - key: misc-definitions-in-headers.UseHeaderFileExtension
value:   '1'
```
The list of header suffixes should be configurable.



Comment at: clang-tidy/abseil/AliasFreeHeadersCheck.cpp:29
+  diag(MatchedDecl->getLocation(), "convenience aliases in header files are "
+"dangerous: see http://google.github.io/styleguide/cppguide.html#Aliases";);
+}

http**s**



Comment at: clang-tidy/abseil/AliasFreeHeadersCheck.h:19
+
+/// FIXME: Write a short description.
+///

Hm



Comment at: docs/clang-tidy/checks/list.rst:155
hicpp-undelegated-constructor (redirects to 
bugprone-undelegated-constructor) 
+   hicpp-uppercase-literal-suffix (redirects to 
readability-uppercase-literal-suffix) 
hicpp-use-auto (redirects to modernize-use-auto) 

Many unrelated movements.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55410



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


[PATCH] D55431: [CodeComplete] Set preferred type to bool on conditions

2018-12-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D55431



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2018-12-07 Thread Paul Hoad via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: alexfh, stephenkelly, curdeius, aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

Adds a checker to clang-tidy to warn when a non void const member function, 
taking only parameters passed by value or const reference could be marked as 
'[[nodiscard]]'


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard.cpp

Index: test/clang-tidy/modernize-use-nodiscard.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.cpp
@@ -0,0 +1,138 @@
+// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
+// RUN: -- -std=c++17 \
+
+// TODO using macros to avoid CHECK-FIXES not being able to find [[xxx]]
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
+
+class Foo
+{
+public:
+bool f1() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f1() const;
+
+bool f2(int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f2(int) const;
+
+bool f3(const int &) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
+
+bool f4(void) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f4(void) const;
+
+// negative tests
+
+void f5() const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: void f5() const;
+
+bool f6();
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool f6();
+
+bool f7(int &);
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool f7(int &);
+
+bool f8(int &) const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool f8(int &) const;
+
+bool f9(int *) const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool f9(int *) const;
+
+bool f10(const int &,int &) const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool f10(const int &,int &) const;
+
+NO_DISCARD bool f12() const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: NO_DISCARD bool f12() const;
+
+MUST_USE_RESULT bool f13() const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: MUST_USE_RESULT bool f13() const;
+   
+// TODO fix CHECK-FIXES to handle "[[" "]]"
+[[nodiscard]] bool f11() const;
+// CHECK-MESSAGES-NOT: warning:
+// _CHECK-FIXES: [[nodiscard]] bool f11() const;
+
+bool _f20() const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool _f20() const;
+
+NO_RETURN bool f21() const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: NO_RETURN bool f21() const;
+
+~Foo();
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: ~Foo();
+
+bool operator +=(int) const;
+// CHECK-MESSAGES-NOT: warning:
+// CHECK-FIXES: bool operator +=(int) const;
+   
+// extra keywords (virtual,inline,const) on return type
+
+virtual bool f14() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD virtual bool f14() const;
+
+const bool f15() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD const bool f15() const;
+
+inline const bool f16() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f16' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const bool f16() const;
+
+inline virtual const bool f17() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f17' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline virtual const bool f17() const;
+
+// inline with body
+bool f18() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f18' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f18() const {
+return true;
+}
+
+bool f19() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f19'

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2018-12-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Have you evaluated this on some major C++ projects yet?
I suspect this will have pretty low SNR.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55433



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


r348594 - [CTU] Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Dec  7 06:56:02 2018
New Revision: 348594

URL: http://llvm.org/viewvc/llvm-project?rev=348594&view=rev
Log:
[CTU] Add DisplayCTUProgress analyzer switch

Summary:
With a new switch we may be able to print to stderr if a new TU is being loaded
during CTU.  This is very important for higher level scripts (like CodeChecker)
to be able to parse this output so they can create e.g. a zip file in case of
a Clang crash which contains all the related TU files.

Reviewers: xazax.hun, Szelethus, a_sidorin, george.karpenkov

Subscribers: whisperity, baloghadamsoftware, szepet, rnkovacs, a.sidorin, 
mikhail.ramalho, donat.nagy, dkrupp,

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

Modified:
cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/ctu-main.cpp

Modified: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h?rev=348594&r1=348593&r2=348594&view=diff
==
--- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h (original)
+++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h Fri Dec  7 06:56:02 
2018
@@ -108,7 +108,7 @@ public:
   /// Note that the AST files should also be in the \p CrossTUDir.
   llvm::Expected
   getCrossTUDefinition(const FunctionDecl *FD, StringRef CrossTUDir,
-   StringRef IndexName);
+   StringRef IndexName, bool DisplayCTUProgress = false);
 
   /// This function loads a function definition from an external AST
   ///file.
@@ -124,7 +124,8 @@ public:
   /// Note that the AST files should also be in the \p CrossTUDir.
   llvm::Expected loadExternalAST(StringRef LookupName,
 StringRef CrossTUDir,
-StringRef IndexName);
+StringRef IndexName,
+bool DisplayCTUProgress = false);
 
   /// This function merges a definition from a separate AST Unit into
   ///the current one which was created by the compiler instance that

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=348594&r1=348593&r2=348594&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Fri Dec  7 
06:56:02 2018
@@ -283,6 +283,11 @@ ANALYZER_OPTION(bool, ShouldDisplayMacro
 "expanded and included in the plist output.",
 false)
 
+ANALYZER_OPTION(bool, DisplayCTUProgress, "display-ctu-progress",
+"Whether to emit verbose output about "
+"the analyzer's progress related to ctu.",
+false)
+
 
//===--===//
 // Unsinged analyzer options.
 
//===--===//

Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=348594&r1=348593&r2=348594&view=diff
==
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Fri Dec  7 06:56:02 2018
@@ -159,7 +159,8 @@ CrossTranslationUnitContext::findFunctio
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(FD && "FD is missing, bad call to this function!");
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   ++NumGetCTUCalled;
@@ -168,7 +169,7 @@ CrossTranslationUnitContext::getCrossTUD
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -205,7 +206,8 @@ void CrossTranslationUnitContext::emitCr
 }
 

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348594: [CTU] Add DisplayCTUProgress analyzer switch 
(authored by martong, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55135?vs=177204&id=177208#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55135

Files:
  cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/ctu-main.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -283,6 +283,11 @@
 "expanded and included in the plist output.",
 false)
 
+ANALYZER_OPTION(bool, DisplayCTUProgress, "display-ctu-progress",
+"Whether to emit verbose output about "
+"the analyzer's progress related to ctu.",
+false)
+
 //===--===//
 // Unsinged analyzer options.
 //===--===//
Index: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
===
--- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
+++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
@@ -108,7 +108,7 @@
   /// Note that the AST files should also be in the \p CrossTUDir.
   llvm::Expected
   getCrossTUDefinition(const FunctionDecl *FD, StringRef CrossTUDir,
-   StringRef IndexName);
+   StringRef IndexName, bool DisplayCTUProgress = false);
 
   /// This function loads a function definition from an external AST
   ///file.
@@ -124,7 +124,8 @@
   /// Note that the AST files should also be in the \p CrossTUDir.
   llvm::Expected loadExternalAST(StringRef LookupName,
 StringRef CrossTUDir,
-StringRef IndexName);
+StringRef IndexName,
+bool DisplayCTUProgress = false);
 
   /// This function merges a definition from a separate AST Unit into
   ///the current one which was created by the compiler instance that
Index: cfe/trunk/test/Analysis/analyzer-config.c
===
--- cfe/trunk/test/Analysis/analyzer-config.c
+++ cfe/trunk/test/Analysis/analyzer-config.c
@@ -21,6 +21,7 @@
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-index-name = externalFnMap.txt
+// CHECK-NEXT: display-ctu-progress = false
 // CHECK-NEXT: eagerly-assume = true
 // CHECK-NEXT: elide-constructors = true
 // CHECK-NEXT: expand-macros = false
@@ -51,4 +52,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 48
+// CHECK-NEXT: num-entries = 49
Index: cfe/trunk/test/Analysis/ctu-main.cpp
===
--- cfe/trunk/test/Analysis/ctu-main.cpp
+++ cfe/trunk/test/Analysis/ctu-main.cpp
@@ -10,6 +10,14 @@
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=%t/ctudir \
 // RUN:   -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -analyzer-config display-ctu-progress=true 2>&1 %s | FileCheck %s
+
+// CHECK: CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -159,7 +159,8 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(FD && "FD is missing, bad call to this function!");
   assert(!FD->hasBody() && "FD has a definition in cur

r348595 - Revert "Multiversioning- Ensure all MV functions are emitted."

2018-12-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Dec  7 06:56:50 2018
New Revision: 348595

URL: http://llvm.org/viewvc/llvm-project?rev=348595&view=rev
Log:
Revert "Multiversioning- Ensure all MV functions are emitted."

This reverts commit 65df29f9318ac13a633c0ce13b2b0bccf06e79ca.

AS suggested by @rsmith here: https://reviews.llvm.org/rL345839
I'm reverting this and solving the initial problem in a different way.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGen/attr-target-mv.c
cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=348595&r1=348594&r2=348595&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Dec  7 06:56:50 2018
@@ -9840,10 +9840,6 @@ bool ASTContext::DeclMustBeEmitted(const
 return true;
 
   if (const auto *FD = dyn_cast(D)) {
-// Multiversioned functions always have to be emitted, because they are 
used
-// by the resolver.
-if (FD->isMultiVersion())
-  return true;
 // Forward declarations aren't required.
 if (!FD->doesThisDeclarationHaveABody())
   return FD->doesDeclarationForceExternallyVisibleDefinition();

Modified: cfe/trunk/test/CodeGen/attr-target-mv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-mv.c?rev=348595&r1=348594&r2=348595&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-mv.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-mv.c Fri Dec  7 06:56:50 2018
@@ -86,16 +86,6 @@ void bar5() {
 // WINDOWS: call i32 @foo.sse4.2
 // WINDOWS: call i32 @foo
 
-// LINUX: define linkonce i32 @foo_inline.arch_ivybridge()
-// LINUX: ret i32 1
-// LINUX: define linkonce i32 @foo_inline()
-// LINUX: ret i32 2
-
-// WINDOWS: define linkonce_odr dso_local i32 @foo_inline.arch_ivybridge()
-// WINDOWS: ret i32 1
-// WINDOWS: define linkonce_odr dso_local i32 @foo_inline()
-// WINDOWS: ret i32 2
-
 // LINUX: define i32 @bar2()
 // LINUX: call i32 @foo_inline.ifunc()
 
@@ -130,22 +120,6 @@ void bar5() {
 // WINDOWS: call void @foo_decls.sse4.2
 // Windows: call void @foo_decls
 
-// LINUX: define linkonce void @foo_decls()
-// LINUX: define linkonce void @foo_decls.sse4.2()
-
-// WINDOWS: define linkonce_odr dso_local void @foo_decls()
-// WINDOWS: define linkonce_odr dso_local void @foo_decls.sse4.2()
-
-// LINUX: define linkonce void @foo_multi(i32 %{{[^,]+}}, double %{{[^\)]+}})
-// LINUX: define linkonce void @foo_multi.avx_sse4.2(i32 %{{[^,]+}}, double 
%{{[^\)]+}})
-// LINUX: define linkonce void @foo_multi.fma4_sse4.2(i32 %{{[^,]+}}, double 
%{{[^\)]+}})
-// LINUX: define linkonce void @foo_multi.arch_ivybridge_fma4_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
-
-// WINDOWS: define linkonce_odr dso_local void @foo_multi(i32 %{{[^,]+}}, 
double %{{[^\)]+}})
-// WINDOWS: define linkonce_odr dso_local void @foo_multi.avx_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
-// WINDOWS: define linkonce_odr dso_local void @foo_multi.fma4_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
-// WINDOWS: define linkonce_odr dso_local void 
@foo_multi.arch_ivybridge_fma4_sse4.2(i32 %{{[^,]+}}, double %{{[^\)]+}})
-
 // LINUX: define void @bar4()
 // LINUX: call void @foo_multi.ifunc(i32 1, double 5.{{[0+e]*}})
 
@@ -233,3 +207,26 @@ void bar5() {
 
 // WINDOWS: declare dso_local i32 @foo_inline.arch_sandybridge()
 
+// LINUX: define linkonce i32 @foo_inline.arch_ivybridge()
+// LINUX: ret i32 1
+// LINUX: define linkonce i32 @foo_inline()
+// LINUX: ret i32 2
+
+// WINDOWS: define linkonce_odr dso_local i32 @foo_inline.arch_ivybridge()
+// WINDOWS: ret i32 1
+// WINDOWS: define linkonce_odr dso_local i32 @foo_inline()
+// WINDOWS: ret i32 2
+
+// LINUX: define linkonce void @foo_decls()
+// LINUX: define linkonce void @foo_decls.sse4.2()
+
+// WINDOWS: define linkonce_odr dso_local void @foo_decls()
+// WINDOWS: define linkonce_odr dso_local void @foo_decls.sse4.2()
+
+// LINUX: define linkonce void @foo_multi.avx_sse4.2(i32 %{{[^,]+}}, double 
%{{[^\)]+}})
+// LINUX: define linkonce void @foo_multi.fma4_sse4.2(i32 %{{[^,]+}}, double 
%{{[^\)]+}})
+// LINUX: define linkonce void @foo_multi.arch_ivybridge_fma4_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
+
+// WINDOWS: define linkonce_odr dso_local void @foo_multi.avx_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
+// WINDOWS: define linkonce_odr dso_local void @foo_multi.fma4_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
+// WINDOWS: define linkonce_odr dso_local void 
@foo_multi.arch_ivybridge_fma4_sse4.2(i32 %{{[^,]+}}, double %{{[^\)]+}})

Modified: cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp?rev=348595&r1=348594&r2=34859

r348596 - Adding tests for -ast-dump; NFC.

2018-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Dec  7 06:57:07 2018
New Revision: 348596

URL: http://llvm.org/viewvc/llvm-project?rev=348596&view=rev
Log:
Adding tests for -ast-dump; NFC.

This adds tests for various statements in C++ that are not covered by C.

Modified:
cfe/trunk/test/AST/ast-dump-stmt.cpp

Modified: cfe/trunk/test/AST/ast-dump-stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt.cpp?rev=348596&r1=348595&r2=348596&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt.cpp Fri Dec  7 06:57:07 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -ast-dump -ast-dump-filter Test %s | 
FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -ast-dump %s | FileCheck 
-strict-whitespace %s
 
 namespace n {
 void function() {}
@@ -77,7 +77,6 @@ void TestDependentScopeMemberExpr() {
   obj.member = T();
   (&obj)->member = T();
 }
-
 // CHECK: FunctionTemplateDecl {{.*}} TestDependentScopeMemberExpr
 // CHECK: CXXDependentScopeMemberExpr {{.*}} lvalue .member
 // CHECK: CXXDependentScopeMemberExpr {{.*}} lvalue ->member
@@ -96,6 +95,179 @@ void TestUnionInitList()
 // Check-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
 // Check-NEXT:   |-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
 // Check-NEXT:   | `-IntegerLiteral {{.+}}  'int' 1
+}
+
+void TestSwitch(int i) {
+  switch (int a; i)
+;
+  // CHECK: SwitchStmt 0x{{[^ ]*}}  
has_init
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:15 a 'int'
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue ParmVar 0x{{[^ 
]*}} 'i' 'int'
+  // CHECK-NEXT: NullStmt
+}
 
+void TestIf(bool b) {
+  if (int i = 12; b)
+;
+  // CHECK: IfStmt 0x{{[^ ]*}}  
has_init
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:11 i 'int' cinit
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 12
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'bool' lvalue ParmVar 0x{{[^ 
]*}} 'b' 'bool'
+  // CHECK-NEXT: NullStmt
+
+  if constexpr (sizeof(b) == 1)
+;
+  // CHECK: IfStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}}  'bool'
+  // CHECK-NEXT: BinaryOperator
+  // CHECK-NEXT: UnaryExprOrTypeTraitExpr
+  // CHECK-NEXT: ParenExpr
+  // CHECK-NEXT: DeclRefExpr
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: IntegerLiteral
+  // CHECK-NEXT: NullStmt
+
+  if constexpr (sizeof(b) == 1)
+;
+  else
+;
+  // CHECK: IfStmt 0x{{[^ ]*}}  
has_else
+  // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}}  'bool'
+  // CHECK-NEXT: BinaryOperator
+  // CHECK-NEXT: UnaryExprOrTypeTraitExpr
+  // CHECK-NEXT: ParenExpr
+  // CHECK-NEXT: DeclRefExpr
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: IntegerLiteral
+  // CHECK-NEXT: NullStmt
+  // CHECK-NEXT: NullStmt
+}
+
+struct Container {
+  int *begin() const;
+  int *end() const;
+};
 
+void TestIteration() {
+  for (int i = 0; int j = i; ++i)
+;
+  // CHECK: ForStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:12 used i 'int' cinit
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 0
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:23 used j 'int' cinit
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue Var 0x{{[^ ]*}} 
'i' 'int'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'bool' 

+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}  'int' 
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue Var 0x{{[^ ]*}} 
'j' 'int'
+  // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}}  'int' lvalue 
prefix '++'
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue Var 0x{{[^ ]*}} 
'i' 'int'
+  // CHECK-NEXT: NullStmt
+
+  int vals[10];
+  for (int v : vals)
+;
+  // CHECK: CXXForRangeStmt 0x{{[^ ]*}} 
+  // CHECK-NEXT: <<>>
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:16 implicit used __range1 
'int (&)[10]' cinit
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int [10]' lvalue Var 0x{{[^ 
]*}} 'vals' 'int [10]'
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 implicit used __begin1 
'int *':'int *' cinit
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int [10]' lvalue Var 0x{{[^ 
]*}} '__range1' 'int (&)[10]'
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:14 implicit used 
__end1 'int *':'int *' cinit
+  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}}  'int *' '+'
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int [10]' lvalue Var 0x{{[^ 
]*}} '__range1' 'int (&)[10]'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'long long' 10
+  // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}}  'bool' '!='
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int *':'int *' lvalue Var 
0x{{[^ ]*}} 

[PATCH] D55395: Re-order content in OMPDeclareReductionDecl dump

2018-12-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D55395#1322431 , @rsmith wrote:

> In D55395#1322244 , @ABataev wrote:
>
> > This is wrong, the original implementation is correct and should not be 
> > changed.
>
>
> The original implementation looks pretty clearly wrong to me, but I think 
> this is wrong too. It looks like what was intended here was probably to label 
> the two children as "combiner" and "initializer" respectively. As-is, the 
> "combiner"  text on the `OMPDeclareReductionDecl` line means nothing at all.


Oh yes, agree. Still must be reworked.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55395



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


[PATCH] D55415: Revert removal of tidy plugin support from libclang

2018-12-07 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

I'd be interested in hearing how this is used. I added this feature as an 
experiment a while back but it simply didn't work as I envisioned it to. Some 
checks do work but the overall latency makes it unusable in an IDE setting. 
People repeatedly asked me to remove it because it slows down builds while not 
adding value.


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

https://reviews.llvm.org/D55415



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


[PATCH] D55270: [Sema] Further improvements to to static_assert diagnostics.

2018-12-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: test/PCH/cxx-static_assert.cpp:17
 
-// expected-error@12 {{static_assert failed "N is not 2!"}}
+// expected-error@12 {{static_assert failed due to requirement '1 == 2' "N is 
not 2!"}}
 T<1> t1; // expected-note {{in instantiation of template class 'T<1>' 
requested here}}

courbet wrote:
> aaron.ballman wrote:
> > I'm not certain how I feel about now printing the failure condition when 
> > there's an explicit message provided. From what I understand, a fair amount 
> > of code in the wild does `static_assert(some_condition, "some_condition")` 
> > because of older language modes where the message was not optional. I worry 
> > we're going to start seeing a lot of diagnostics like: `static_assert 
> > failed due to requirement '1 == 2' "N == 2"`, which seems a bit 
> > low-quality. See `DFAPacketizer::DFAPacketizer()` in LLVM as an example of 
> > something similar.
> > 
> > Given that the user entered a message, do we still want to show the 
> > requirement? Do we feel the same way if the requirement is fairly large?
> The issue is that `"N == 2"` is a useless error message. Actually, since the  
> error message has to be a string literal, there is no way for the user to 
> print a debuggable output. So I really think we should print the failed 
> condition.
FWIW, I also don't agree with Aaron's concern.

I do think there is a lot of code in the wild whose string literal was "phoned 
in." After all, this is why C++17 allows us to omit the string literal: to 
avoid boilerplate like this.

static_assert(some-condition, "some-condition");
static_assert(some-condition, "some-condition was not satisfied");
static_assert(some-condition, "some-condition must be satisfied");
static_assert(some-condition, "");

But should Clang go _out of its way_ to suppress such "redundant" string 
literals? First of all, such suppression would be C++14-and-earlier: if a 
C++17-native program contains a string literal, we should maybe assume it's on 
purpose. Second, it's not clear how a machine could detect "redundant" literals 
with high fidelity.

static_assert(std::is_integral, "std::is_integral");
// clearly redundant
static_assert(std::is_integral, "T must be integral");
// redundant, but unlikely to be machine-detectable as such

static_assert((DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) <= (8 * 
sizeof(DFAInput)),
"(DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) > (8 * sizeof(DFAInput))");
// redundant, but unlikely to be machine-detectable as such
// thanks to the substitution of > for <=

static_assert((DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) <= (8 * 
sizeof(DFAInput)),
"(DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) too big for DFAInput");
// redundant, but unlikely to be machine-detectable as such

In any event, I agree with @courbet that Clang should print the expansion of 
the failed condition in any case.

Also: One might argue that if the `static_assert` fits completely on one source 
line, then we could omit the string-literal from our error message because the 
string literal will be shown anyway as part of the offending source line — but 
I believe IDE-users would complain about that, so, we shouldn't do that. And 
even then, we'd still want to print the failed condition!

Checking my understanding: The `static_assert` above (taken from 
`DFAPacketizer::DFAPacketizer()` in LLVM) would be unchanged by @courbet's 
patches, because none of its subexpressions are template-dependent. Right?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55270



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


r348598 - Fix spelling of WINDOWS in a test

2018-12-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Dec  7 07:06:43 2018
New Revision: 348598

URL: http://llvm.org/viewvc/llvm-project?rev=348598&view=rev
Log:
Fix spelling of WINDOWS in a test

Change-Id: I232515655359f14308e1c5509c4b7db96d1fafcb

Modified:
cfe/trunk/test/CodeGen/attr-target-mv.c

Modified: cfe/trunk/test/CodeGen/attr-target-mv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-mv.c?rev=348598&r1=348597&r2=348598&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-mv.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-mv.c Fri Dec  7 07:06:43 2018
@@ -118,7 +118,7 @@ void bar5() {
 
 // WINDOWS: define dso_local void @foo_decls.resolver() comdat
 // WINDOWS: call void @foo_decls.sse4.2
-// Windows: call void @foo_decls
+// WINDOWS: call void @foo_decls
 
 // LINUX: define void @bar4()
 // LINUX: call void @foo_multi.ifunc(i32 1, double 5.{{[0+e]*}})


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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2018-12-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D55433#1323106 , @lebedev.ri wrote:

> Have you evaluated this on some major C++ projects yet?
>  I suspect this may have pretty low SNR.


Internally yes (on millions of lines), but you are correct high noise level, 
however resulting compiles showed a number of hard to find bugs most notably 
where empty()  function on custom container was being used when they meant 
clear(), this bug had gone undetected for 10+ years.

The idea came from guidance given in Jason Turner CppCon2018 talk, 
https://www.youtube.com/watch?v=DHOlsEd0eDE (about 14 minutes in)

"is it a logical error in your code to call this member function and discard 
the return value"... the room says yes!!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55433



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


[PATCH] D55415: Revert removal of tidy plugin support from libclang

2018-12-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

In D55415#1323120 , @bkramer wrote:

> I'd be interested in hearing how this is used. I added this feature as an 
> experiment a while back but it simply didn't work as I envisioned it to. Some 
> checks do work but the overall latency makes it unusable in an IDE setting. 
> People repeatedly asked me to remove it because it slows down builds while 
> not adding value.


We use it with Qt Creator and you can see that we make additions/fixes in 
libclang from time to time.
With tidy checks selected it is slow indeed but there's always a choice whether 
to enable checks or not. And if you have very few checks enabled it performs 
quite fine. And we are still using libclang because we already have 
infrastructure on top of it which can't be just replaced with clangd (at least 
it requires quite some time).


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

https://reviews.llvm.org/D55415



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


r348599 - Add an explicit triple to this test to prevent failures due to size_t differences.

2018-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Dec  7 07:13:51 2018
New Revision: 348599

URL: http://llvm.org/viewvc/llvm-project?rev=348599&view=rev
Log:
Add an explicit triple to this test to prevent failures due to size_t 
differences.

Modified:
cfe/trunk/test/AST/ast-dump-stmt.cpp

Modified: cfe/trunk/test/AST/ast-dump-stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt.cpp?rev=348599&r1=348598&r2=348599&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt.cpp Fri Dec  7 07:13:51 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -ast-dump %s | FileCheck 
-strict-whitespace %s
+// RUN: %clang_cc1 -std=c++2a -triple x86_64-linux-gnu -fcxx-exceptions 
-ast-dump %s | FileCheck -strict-whitespace %s
 
 namespace n {
 void function() {}
@@ -187,7 +187,7 @@ void TestIteration() {
   // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}}  'int *' '+'
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int [10]' lvalue Var 0x{{[^ 
]*}} '__range1' 'int (&)[10]'
-  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'long long' 10
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'long' 10
   // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}}  'bool' '!='
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int *':'int *' lvalue Var 
0x{{[^ ]*}} '__begin1' 'int *':'int *'
@@ -255,7 +255,7 @@ void TestIteration() {
   // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}}  'int *' '+'
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int [10]' lvalue Var 0x{{[^ 
]*}} '__range1' 'int (&)[10]'
-  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'long long' 10
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'long' 10
   // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}}  'bool' '!='
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int *':'int *' lvalue Var 
0x{{[^ ]*}} '__begin1' 'int *':'int *'


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


[PATCH] D49890: Clang-Tidy Export Problem

2018-12-07 Thread Ahmad Nouralizadeh via Phabricator via cfe-commits
TheAhmad added a comment.

Hi @alexfh,
I have attached the compilation database for `MPlayer-1.3.0`.F7659818: 
compile_commands.json 
As can be seen, the paths are relative. To answer your comments I need more 
time. I do not remember the exact details. I will prepare a test as soon as 
possible. I did not use the test infrastructure, before. Therefore, I should 
learn about it.
Regards.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D49890



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


[PATCH] D55134: [CTU] Add triple/lang mismatch handling

2018-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LG!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55134



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


[PATCH] D55085: Avoid emitting redundant or unusable directories in DIFile metadata entries

2018-12-07 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Hello @aprantl,

This change broke the test suite when building in /tmp (tmpfs) on Linux:

FAIL: Clang :: CodeGen/debug-info-abspath.c (5676 of 44360)

- TEST 'Clang :: CodeGen/debug-info-abspath.c' FAILED 

Script:
---

: 'RUN: at line 1';   /tmp/_t/bin/clang -cc1 -internal-isystem 
/tmp/_t/lib/clang/8.0.0/include -nostdsysteminc -debug-info-kind=limited 
-triple x86_64-unknown-linux-gnu
/home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c -emit-llvm -o - | 
/tmp/_t/bin/FileCheck /home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c
: 'RUN: at line 4';   cp 
/home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c 
/tmp/_t/tools/clang/test/CodeGen/Output/debug-info-abspath.c.tmp.c

: 'RUN: at line 5';   /tmp/_t/bin/clang -cc1 -internal-isystem 
/tmp/_t/lib/clang/8.0.0/include -nostdsysteminc -debug-info-kind=limited 
-triple x86_64-unknown-linux-gnu
/tmp/_t/tools/clang/test/CodeGen/Output/debug-info-abspath.c.tmp.c -emit-llvm 
-o - | /tmp/_t/bin/FileCheck 
/home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c --check-prefix=INTREE


Exit Code: 1

Command Output (stderr):


/home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c:13:16: error: 
CHECK-SAME: expected string not found in input
// CHECK-SAME: directory: "{{.+}}")

  ^

:25:81: note: scanning from here
!7 = !DIFile(filename: 
"/home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c", directory: "")

  ^

:25:83: note: possible intended match here
!7 = !DIFile(filename: 
"/home/dave/s/lc/clang/test/CodeGen/debug-info-abspath.c", directory: "")

^


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

https://reviews.llvm.org/D55085



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


[PATCH] D55270: [Sema] Further improvements to to static_assert diagnostics.

2018-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/PCH/cxx-static_assert.cpp:17
 
-// expected-error@12 {{static_assert failed "N is not 2!"}}
+// expected-error@12 {{static_assert failed due to requirement '1 == 2' "N is 
not 2!"}}
 T<1> t1; // expected-note {{in instantiation of template class 'T<1>' 
requested here}}

Quuxplusone wrote:
> courbet wrote:
> > aaron.ballman wrote:
> > > I'm not certain how I feel about now printing the failure condition when 
> > > there's an explicit message provided. From what I understand, a fair 
> > > amount of code in the wild does `static_assert(some_condition, 
> > > "some_condition")` because of older language modes where the message was 
> > > not optional. I worry we're going to start seeing a lot of diagnostics 
> > > like: `static_assert failed due to requirement '1 == 2' "N == 2"`, which 
> > > seems a bit low-quality. See `DFAPacketizer::DFAPacketizer()` in LLVM as 
> > > an example of something similar.
> > > 
> > > Given that the user entered a message, do we still want to show the 
> > > requirement? Do we feel the same way if the requirement is fairly large?
> > The issue is that `"N == 2"` is a useless error message. Actually, since 
> > the  error message has to be a string literal, there is no way for the user 
> > to print a debuggable output. So I really think we should print the failed 
> > condition.
> FWIW, I also don't agree with Aaron's concern.
> 
> I do think there is a lot of code in the wild whose string literal was 
> "phoned in." After all, this is why C++17 allows us to omit the string 
> literal: to avoid boilerplate like this.
> 
> static_assert(some-condition, "some-condition");
> static_assert(some-condition, "some-condition was not satisfied");
> static_assert(some-condition, "some-condition must be satisfied");
> static_assert(some-condition, "");
> 
> But should Clang go _out of its way_ to suppress such "redundant" string 
> literals? First of all, such suppression would be C++14-and-earlier: if a 
> C++17-native program contains a string literal, we should maybe assume it's 
> on purpose. Second, it's not clear how a machine could detect "redundant" 
> literals with high fidelity.
> 
> static_assert(std::is_integral, "std::is_integral");
> // clearly redundant
> static_assert(std::is_integral, "T must be integral");
> // redundant, but unlikely to be machine-detectable as such
> 
> static_assert((DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) <= (8 * 
> sizeof(DFAInput)),
> "(DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) > (8 * sizeof(DFAInput))");
> // redundant, but unlikely to be machine-detectable as such
> // thanks to the substitution of > for <=
> 
> static_assert((DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) <= (8 * 
> sizeof(DFAInput)),
> "(DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) too big for DFAInput");
> // redundant, but unlikely to be machine-detectable as such
> 
> In any event, I agree with @courbet that Clang should print the expansion of 
> the failed condition in any case.
> 
> Also: One might argue that if the `static_assert` fits completely on one 
> source line, then we could omit the string-literal from our error message 
> because the string literal will be shown anyway as part of the offending 
> source line — but I believe IDE-users would complain about that, so, we 
> shouldn't do that. And even then, we'd still want to print the failed 
> condition!
> 
> Checking my understanding: The `static_assert` above (taken from 
> `DFAPacketizer::DFAPacketizer()` in LLVM) would be unchanged by @courbet's 
> patches, because none of its subexpressions are template-dependent. Right?
> But should Clang go _out of its way_ to suppress such "redundant" string 
> literals? 

I wasn't suggesting it should; I was suggesting that Clang should be 
conservative and suppress printing the conditional when a message is present, 
not when they look to be redundant enough.

> if a C++17-native program contains a string literal, we should maybe assume 
> it's on purpose. 

This is the exact scenario I was envisioning.

It's a relatively weak preference, but I kind of prefer not displaying the 
conditional information in the presence of a message (at least in C++17 and 
above), especially as the conditional can be huge. I'm thinking of scenarios 
where the user does something like:
```
static_assert(condition1 && condition2 && (condition3 || condition4), "Simple 
explanation");
```
except that `condition` is replaced by `std::some_type_trait` in various 
interesting ways.



Repository:
  rC Clang

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

https://reviews.llvm.org/D55270



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


r348600 - Make CPUDispatch resolver emit dependent functions.

2018-12-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Dec  7 07:31:23 2018
New Revision: 348600

URL: http://llvm.org/viewvc/llvm-project?rev=348600&view=rev
Log:
Make CPUDispatch resolver emit dependent functions.

Inline cpu_specific versions referenced before the cpu_dispatch function
weren't properly emitted, since they hadn't been referred to.  This
patch ensures that during resolver generation that all appropriate
versions are emitted.

Change-Id: I94c3766aaf9c75ca07a0ad8258efdbb834654ff8

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/attr-target-mv.c
cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=348600&r1=348599&r2=348600&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Dec  7 07:31:23 2018
@@ -2585,11 +2585,22 @@ void CodeGenModule::emitCPUDispatchDefin
 
 llvm::Constant *Func = GetGlobalValue(MangledName);
 
-if (!Func)
+if (!Func) {
+  GlobalDecl ExistingDecl = Manglings.lookup(MangledName);
+  if (ExistingDecl.getDecl() &&
+  ExistingDecl.getDecl()->getAsFunction()->isDefined()) {
+EmitGlobalFunctionDefinition(ExistingDecl, nullptr);
+Func = GetGlobalValue(MangledName);
+  } else {
+if (!ExistingDecl.getDecl())
+  ExistingDecl = GD.getWithMultiVersionIndex(Index);
+
   Func = GetOrCreateLLVMFunction(
-  MangledName, DeclTy, GD.getWithMultiVersionIndex(Index),
+  MangledName, DeclTy, ExistingDecl,
   /*ForVTable=*/false, /*DontDefer=*/true,
   /*IsThunk=*/false, llvm::AttributeList(), ForDefinition);
+  }
+}
 
 llvm::SmallVector Features;
 Target.getCPUSpecificCPUDispatchFeatures(II->getName(), Features);

Modified: cfe/trunk/test/CodeGen/attr-target-mv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-mv.c?rev=348600&r1=348599&r2=348600&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-mv.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-mv.c Fri Dec  7 07:31:23 2018
@@ -223,10 +223,12 @@ void bar5() {
 // WINDOWS: define linkonce_odr dso_local void @foo_decls()
 // WINDOWS: define linkonce_odr dso_local void @foo_decls.sse4.2()
 
+// LINUX: define linkonce void @foo_multi(i32 %{{[^,]+}}, double %{{[^\)]+}})
 // LINUX: define linkonce void @foo_multi.avx_sse4.2(i32 %{{[^,]+}}, double 
%{{[^\)]+}})
 // LINUX: define linkonce void @foo_multi.fma4_sse4.2(i32 %{{[^,]+}}, double 
%{{[^\)]+}})
 // LINUX: define linkonce void @foo_multi.arch_ivybridge_fma4_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
 
+// WINDOWS: define linkonce_odr dso_local void @foo_multi(i32 %{{[^,]+}}, 
double %{{[^\)]+}})
 // WINDOWS: define linkonce_odr dso_local void @foo_multi.avx_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
 // WINDOWS: define linkonce_odr dso_local void @foo_multi.fma4_sse4.2(i32 
%{{[^,]+}}, double %{{[^\)]+}})
 // WINDOWS: define linkonce_odr dso_local void 
@foo_multi.arch_ivybridge_fma4_sse4.2(i32 %{{[^,]+}}, double %{{[^\)]+}})

Modified: cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp?rev=348600&r1=348599&r2=348600&view=diff
==
--- cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/attr-cpuspecific.cpp Fri Dec  7 07:31:23 2018
@@ -16,8 +16,11 @@ void foo() {
 // LINUX: define void (%struct.S*)* @_ZN1S4FuncEv.resolver
 // LINUX: ret void (%struct.S*)* @_ZN1S4FuncEv.S
 // LINUX: ret void (%struct.S*)* @_ZN1S4FuncEv.O
+// LINUX: declare void @_ZN1S4FuncEv.S
+// LINUX: define linkonce_odr void @_ZN1S4FuncEv.O
 
 // WINDOWS: define dso_local void @"?Func@S@@QEAAXXZ"(%struct.S*)
 // WINDOWS: musttail call void @"?Func@S@@QEAAXXZ.S"(%struct.S* %0)
 // WINDOWS: musttail call void @"?Func@S@@QEAAXXZ.O"(%struct.S* %0)
-
+// WINDOWS: declare dso_local void @"?Func@S@@QEAAXXZ.S"
+// WINDOWS: define linkonce_odr dso_local void @"?Func@S@@QEAAXXZ.O"


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


[PATCH] D55131: [CTU] Add more lit tests and better error handling

2018-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LG!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55131



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


[PATCH] D55437: [Index] Index declarations in lambda expression.

2018-12-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, ioeric.

This fixes clangd couldn't find references for lambda parameters.


Repository:
  rC Clang

https://reviews.llvm.org/D55437

Files:
  lib/Index/IndexBody.cpp
  test/Index/cxx11-lambdas.cpp


Index: test/Index/cxx11-lambdas.cpp
===
--- test/Index/cxx11-lambdas.cpp
+++ test/Index/cxx11-lambdas.cpp
@@ -31,3 +31,4 @@
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: 
c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: 
DeclRefExpr=localA:6:9 | loc: 8:14
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: 
c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: 
DeclRefExpr=localB:6:17 | loc: 8:23
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: 
c:cxx11-lambdas.cpp@157@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
DeclRefExpr=x:7:46 | loc: 8:32
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: 
c:cxx11-lambdas.cpp@157@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
ParmDecl=x:7:46 (Definition) | loc: 7:46
\ No newline at end of file
Index: lib/Index/IndexBody.cpp
===
--- lib/Index/IndexBody.cpp
+++ lib/Index/IndexBody.cpp
@@ -454,6 +454,11 @@
 }
 return true;
   }
+
+  bool VisitLambdaExpr(const LambdaExpr *E) {
+IndexCtx.indexTagDecl(E->getLambdaClass());
+return true;
+  }
 };
 
 } // anonymous namespace


Index: test/Index/cxx11-lambdas.cpp
===
--- test/Index/cxx11-lambdas.cpp
+++ test/Index/cxx11-lambdas.cpp
@@ -31,3 +31,4 @@
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: DeclRefExpr=localA:6:9 | loc: 8:14
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: DeclRefExpr=localB:6:17 | loc: 8:23
 // CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp@157@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: DeclRefExpr=x:7:46 | loc: 8:32
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp@157@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: ParmDecl=x:7:46 (Definition) | loc: 7:46
\ No newline at end of file
Index: lib/Index/IndexBody.cpp
===
--- lib/Index/IndexBody.cpp
+++ lib/Index/IndexBody.cpp
@@ -454,6 +454,11 @@
 }
 return true;
   }
+
+  bool VisitLambdaExpr(const LambdaExpr *E) {
+IndexCtx.indexTagDecl(E->getLambdaClass());
+return true;
+  }
 };
 
 } // anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55359: [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.

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

Address review comment.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55359

Files:
  clangd/TUScheduler.cpp
  clangd/Threading.cpp
  clangd/Threading.h
  unittests/clangd/TUSchedulerTests.cpp


Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -698,13 +698,11 @@
   EXPECT_THAT(CaptureTUStatus.AllStatus,
   ElementsAre(
   // Statuses of "Update" action.
-  TUState(TUAction::Queued, "Update"),
   TUState(TUAction::RunningAction, "Update"),
   TUState(TUAction::BuildingPreamble, "Update"),
   TUState(TUAction::BuildingFile, "Update"),
 
   // Statuses of "Definitions" action
-  TUState(TUAction::Queued, "Definitions"),
   TUState(TUAction::RunningAction, "Definitions"),
   TUState(TUAction::Idle, /*No action*/ "")));
 }
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -42,6 +42,7 @@
 public:
   Semaphore(std::size_t MaxLocks);
 
+  bool try_lock();
   void lock();
   void unlock();
 
Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -28,6 +28,15 @@
 
 Semaphore::Semaphore(std::size_t MaxLocks) : FreeSlots(MaxLocks) {}
 
+bool Semaphore::try_lock() {
+  std::unique_lock Lock(Mutex);
+  if (FreeSlots > 0) {
+--FreeSlots;
+return true;
+  }
+  return false;
+}
+
 void Semaphore::lock() {
   trace::Span Span("WaitForFreeSemaphoreSlot");
   // trace::Span can also acquire locks in ctor and dtor, we make sure it
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -634,9 +634,11 @@
 } // unlock Mutex
 
 {
-  // FIXME: only emit this status when the Barrier couldn't be acquired.
-  emitTUStatus({TUAction::Queued, Req.Name});
-  std::lock_guard BarrierLock(Barrier);
+  std::unique_lock Lock(Barrier, std::try_to_lock);
+  if (!Lock.owns_lock()) {
+emitTUStatus({TUAction::Queued, Req.Name});
+Lock.lock();
+  }
   WithContext Guard(std::move(Req.Ctx));
   trace::Span Tracer(Req.Name);
   emitTUStatus({TUAction::RunningAction, Req.Name});


Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -698,13 +698,11 @@
   EXPECT_THAT(CaptureTUStatus.AllStatus,
   ElementsAre(
   // Statuses of "Update" action.
-  TUState(TUAction::Queued, "Update"),
   TUState(TUAction::RunningAction, "Update"),
   TUState(TUAction::BuildingPreamble, "Update"),
   TUState(TUAction::BuildingFile, "Update"),
 
   // Statuses of "Definitions" action
-  TUState(TUAction::Queued, "Definitions"),
   TUState(TUAction::RunningAction, "Definitions"),
   TUState(TUAction::Idle, /*No action*/ "")));
 }
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -42,6 +42,7 @@
 public:
   Semaphore(std::size_t MaxLocks);
 
+  bool try_lock();
   void lock();
   void unlock();
 
Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -28,6 +28,15 @@
 
 Semaphore::Semaphore(std::size_t MaxLocks) : FreeSlots(MaxLocks) {}
 
+bool Semaphore::try_lock() {
+  std::unique_lock Lock(Mutex);
+  if (FreeSlots > 0) {
+--FreeSlots;
+return true;
+  }
+  return false;
+}
+
 void Semaphore::lock() {
   trace::Span Span("WaitForFreeSemaphoreSlot");
   // trace::Span can also acquire locks in ctor and dtor, we make sure it
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -634,9 +634,11 @@
 } // unlock Mutex
 
 {
-  // FIXME: only emit this status when the Barrier couldn't be acquired.
-  emitTUStatus({TUAction::Queued, Req.Name});
-  std::lock_guard BarrierLock(Barrier);
+  std::unique_lock Lock(Barrier, std::try_to_lock);
+  if (!Lock.owns_lock()) {
+emitTUStatus({TUAction::Queued, Req.Name});
+Lock.lock();
+  }
   WithContext Guard(std::move(Req.Ctx));
   trace::Span Tracer(Req.Name);

r348603 - [unittests] Add C++17 and C++2a support to the tooling tests

2018-12-07 Thread Hamza Sood via cfe-commits
Author: hamzasood
Date: Fri Dec  7 07:46:29 2018
New Revision: 348603

URL: http://llvm.org/viewvc/llvm-project?rev=348603&view=rev
Log:
[unittests] Add C++17 and C++2a support to the tooling tests

Modified:
cfe/trunk/unittests/Tooling/TestVisitor.h

Modified: cfe/trunk/unittests/Tooling/TestVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/TestVisitor.h?rev=348603&r1=348602&r2=348603&view=diff
==
--- cfe/trunk/unittests/Tooling/TestVisitor.h (original)
+++ cfe/trunk/unittests/Tooling/TestVisitor.h Fri Dec  7 07:46:29 2018
@@ -44,6 +44,8 @@ public:
 Lang_CXX98,
 Lang_CXX11,
 Lang_CXX14,
+Lang_CXX17,
+Lang_CXX2a,
 Lang_OBJC,
 Lang_OBJCXX11,
 Lang_CXX = Lang_CXX98
@@ -60,6 +62,8 @@ public:
   case Lang_CXX98: Args.push_back("-std=c++98"); break;
   case Lang_CXX11: Args.push_back("-std=c++11"); break;
   case Lang_CXX14: Args.push_back("-std=c++14"); break;
+  case Lang_CXX17: Args.push_back("-std=c++17"); break;
+  case Lang_CXX2a: Args.push_back("-std=c++2a"); break;
   case Lang_OBJC:
 Args.push_back("-ObjC");
 Args.push_back("-fobjc-runtime=macosx-10.12.0");


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


[PATCH] D55438: Assert on conflicting fixes for -fix option

2018-12-07 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka created this revision.
Herald added a subscriber: cfe-commits.

Changed the assert and corresponding warning message for conflicting fixes
to only trigger if clang-tidy is run with -fix or -fix-errors.
The Fix and FixErrors variables are now passed as parameters when creating
respective objects.

This is not a finished patch. We need input if there are a more appropriate fix 
of this problem.

Patch by: Henric Karlsson and Björn Pettersson


Repository:
  rC Clang

https://reviews.llvm.org/D55438

Files:
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  tools/extra/test/clang-tidy/clang-tidy-logicalexpr-crash.c

Index: tools/extra/test/clang-tidy/clang-tidy-logicalexpr-crash.c
===
--- /dev/null
+++ tools/extra/test/clang-tidy/clang-tidy-logicalexpr-crash.c
@@ -0,0 +1,7 @@
+// RUN: clang-tidy -checks='-*,clang-analyzer-*' %s
+
+a;
+fn1() {
+  int b = -a ?: a;
+  (b || 0) && 9;
+}
Index: tools/extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- tools/extra/clang-tidy/tool/ClangTidyMain.cpp
+++ tools/extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -426,7 +426,7 @@
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
   runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
-   EnableCheckProfile, ProfilePrefix);
+   (Fix || FixErrors), EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;
  }) != Errors.end();
Index: tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -226,7 +226,8 @@
 class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
 public:
   ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx,
-  bool RemoveIncompatibleErrors = true);
+  bool RemoveIncompatibleErrors = true,
+  bool FixResolutions = false);
 
   // FIXME: The concept of converting between FixItHints and Replacements is
   // more generic and should be pulled out into a more useful Diagnostics
@@ -252,6 +253,7 @@
 
   ClangTidyContext &Context;
   bool RemoveIncompatibleErrors;
+  bool FixResolutions;
   std::vector Errors;
   std::unique_ptr HeaderFilter;
   bool LastErrorRelatesToUserCode;
Index: tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -33,8 +33,10 @@
 public:
   ClangTidyDiagnosticRenderer(const LangOptions &LangOpts,
   DiagnosticOptions *DiagOpts,
-  ClangTidyError &Error)
-  : DiagnosticRenderer(LangOpts, DiagOpts), Error(Error) {}
+  ClangTidyError &Error,
+  bool FixResolutions)
+  : DiagnosticRenderer(LangOpts, DiagOpts), Error(Error),
+FixResolutions(FixResolutions) {}
 
 protected:
   void emitDiagnosticMessage(FullSourceLoc Loc, PresumedLoc PLoc,
@@ -81,10 +83,13 @@
   llvm::Error Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
   // FIXME: better error handling (at least, don't let other replacements be
   // applied).
-  if (Err) {
+  if (Err && FixResolutions) {
 llvm::errs() << "Fix conflicts with existing fix! "
  << llvm::toString(std::move(Err)) << "\n";
 assert(false && "Fix conflicts with existing fix!");
+  } else if (Err) {
+// Replacements wont be used for fixing anything.
+consumeError(std::move(Err));
   }
 }
   }
@@ -104,6 +109,7 @@
 
 private:
   ClangTidyError &Error;
+  bool FixResolutions;
 };
 } // end anonymous namespace
 
@@ -264,10 +270,10 @@
 }
 
 ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
-ClangTidyContext &Ctx, bool RemoveIncompatibleErrors)
+ClangTidyContext &Ctx, bool RemoveIncompatibleErrors , bool FixResolutions )
 : Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
-  LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
-  LastErrorWasIgnored(false) {}
+  FixResolutions(FixResolutions), LastErrorRelatesToUserCode(false),
+  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {}
 
 void ClangTidyDiagnosticConsumer::finalizeLastError() {
  

[PATCH] D55359: [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.

2018-12-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/TUScheduler.cpp:644
+  std::unique_lock Lock(Barrier, std::try_to_lock);
+  if (Lock.owns_lock()) {
+ExecuteAction();

ilya-biryukov wrote:
> Maybe simplify the code a bit?
> ```
> // Replacing these two lines:
> //  emitTUStatus({TUAction::Queued, Req.Name});
> //  std::lock_guard BarrierLock(Barrier);
> 
> // With:
> std::unique_lock BarrierLock(Barrier, std::try_to_lock);
> if (!Lock.owns_lock()) {
>   emitTUStatus({TUAction::Queued, Req.Name});
>   Lock.lock();
> }
> // Rest of the code is the same...
> ```
> 
> Avoids creating two locks and does not require helper lamdbas.
ah, good point.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55359



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2018-12-07 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 177221.
hamzasood added a comment.

- Committed the test framework changes separately as r348589 and  r348603.
- Correctly cleanup the lambda scope if an error in encountered while parsing 
the template parameters.
- Replaced getExplicitTemplateParameterCount with 
getExplicitTemplateParameters, which returns an ArrayRef. This simplifies the 
handling of the parameters in a few places.
- Replaced a linear search over the template parameters with a binary search.
- Added expected error cases to the template lambda usage tests to ensure that 
the static assertions are correctly instantiated.
- Added a test for templated lambdas that're used within another template; 
TreeTransform already transforms the template parameter list so no change was 
needed to make the test pass.


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

https://reviews.llvm.org/D36527

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclTemplate.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp
  test/Index/print-display-names.cpp
  test/PCH/cxx11-lambdas.mm
  test/PCH/cxx1y-lambdas.mm
  test/PCH/cxx2a-template-lambdas.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  unittests/AST/StmtPrinterTest.cpp
  unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -860,7 +860,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2";>P0428R2
-  No
+  SVN
 
 
   Concepts
Index: unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp
+++ unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp
@@ -0,0 +1,53 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+
+using namespace clang;
+
+namespace {
+
+// Matches (optional) explicit template parameters.
+class LambdaTemplateParametersVisitor
+  : public ExpectedLocationVisitor {
+public:
+  bool shouldVisitImplicitCode() const { return false; }
+
+  bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+
+  bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+
+  bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, VisitsLambdaExplicitTemplateParameters) {
+  LambdaTemplateParametersVisitor Visitor;
+  Visitor.ExpectMatch("T",  2, 15);
+  Visitor.ExpectMatch("I",  2, 24);
+  Visitor.ExpectMatch("TT", 2, 31);
+  EXPECT_TRUE(Visitor.runOver(
+  "void f() { \n"
+  "  auto l = [] class TT>(auto p) { }; \n"
+  "}",
+  LambdaTemplateParametersVisitor::Lang_CXX2a));
+}
+
+} // end anonymous namespace
Index: unittests/AST/StmtPrinterTest.cpp
===
--- unittests/AST/StmtPrinterTest.cpp
+++ unittests/AST/StmtPrinterTest.cpp
@@ -232,6 +232,43 @@
 // WRONG; Should be: (a & b).operator void *()
 }
 
+TEST(StmtPrinter, TestCXXLamda) {
+  ASSERT_TRUE(PrintedStmtCXXMatches(StdVer::CXX11,
+"void A() {"
+"  auto l = [] { };"
+"}",
+lambdaExpr(anything()).bind("id"),
+"[] {\n"
+"}"));
+
+  ASSERT_TRUE(PrintedStmtCXXMatches(StdVer::CXX11,
+"void A() {"
+"  int a = 0, b = 1;"
+"  auto l = [a,b](int c, float d) { };"
+"}",
+lambdaExpr(anything()).bind("id"),
+"[a, b](int c, float d) {\n"
+"}"));
+
+  ASSERT_TRUE(PrintedStmtCXXMatches(StdVer::CXX14,
+"void A() {"
+"  auto l = [](auto a, int b, auto c, int, auto) { };"
+"}",
+lambdaExpr(anything()).bind("id"),
+"[](auto a, int b

[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

2018-12-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne requested changes to this revision.
ldionne added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: jkorous.

1. Just to make sure I understand; this patch has nothing to do with 
https://reviews.llvm.org/D48342, they are entirely orthogonal. Is this correct?
2. Also, before this patch, the allocator's `construct` and `destroy` were 
NEVER called in C++03, but were called when available in C++11. After this 
patch, they are called when available in C++03 and in C++11. Is this correct?

If (2) is true, then I believe this patch is a worthwhile improvement in terms 
of quality-of-implementation, even though it's not mandated by the spec. People 
do have custom allocators, and this behavior change between C++03 and C++11 is 
quite subtle and surprising.




Comment at: libcxx/include/memory:1466
+template 
+struct __has_construct<_Alloc, _Pointer, _Tp, typename enable_if<
+is_same

You can just say

```
template 
struct __has_construct<_Alloc, _Pointer, _Tp, typename __void_t<
decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Pointer>(), 
_VSTD::declval<_Tp>()))
>::type> : std::true_type { };
```



Comment at: libcxx/include/memory:1482
+<
+
decltype((_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()), 
void())),
+void

Here,

```
template 
struct __has_destroy<_Alloc, _Pointer, typename __void_t<
decltype(_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()))
>::type> : std::true_type { };
```



Comment at: libcxx/include/memory:1726
+#else  // _LIBCPP_HAS_NO_VARIADICS
+template 
+_LIBCPP_INLINE_VISIBILITY

Here,

```
template ::value>::type>
static void __construct(...);
```

and then below

```
template ::value>::type>
static void __construct(...);
```

This way you don't have to call `__has_construct` at the point of call and 
`__construct` is slightly more reusable.




Comment at: 
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp:122
+  {
+typedef std::vector > C;
+typedef C::allocator_type Alloc;

These tests are specific to libc++ because C++03 does not mandate this 
behavior. Please either move them into `test/libcxx` or guard them with 
`_LIBCPP_VERSION`. I think the former is what we normally do in these cases and 
should be preferred.



Comment at: 
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp:135
+  {
+typedef std::vector > C;
+typedef C::allocator_type Alloc;

Same as above, this is libc++ specific.


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

https://reviews.llvm.org/D48753



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2018-12-07 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood marked 6 inline comments as done.
hamzasood added inline comments.



Comment at: lib/AST/DeclPrinter.cpp:107-108
 
-void printTemplateParameters(const TemplateParameterList *Params);
+void printTemplateParameters(const TemplateParameterList *Params,
+ bool OmitTemplateKW = false);
 void printTemplateArguments(const TemplateArgumentList &Args,

rsmith wrote:
> Nit: I'd prefer splitting this into two functions (one that prints 
> 'template', calls the other, then prints a space, and the other to print the 
> actual template parameters) rather than passing a boolean flag.
Do you reckon that the boolean flag is okay for `TemplateParameterList::print`? 
I've left this change for now until that has been decided.


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

https://reviews.llvm.org/D36527



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


r348605 - [CTU] Add more lit tests and better error handling

2018-12-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Dec  7 08:05:58 2018
New Revision: 348605

URL: http://llvm.org/viewvc/llvm-project?rev=348605&view=rev
Log:
[CTU] Add more lit tests and better error handling

Summary:
Adding some more CTU list tests. E.g. to check if a construct is unsupported.
We also slightly modify the handling of the return value of the `Import`
function from ASTImporter.

Reviewers: xazax.hun, balazske, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

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

Added:
cfe/trunk/test/Analysis/Inputs/ctu-other.c
cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt
  - copied, changed from r348594, 
cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
cfe/trunk/test/Analysis/ctu-main.c
Removed:
cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
Modified:
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/test/Analysis/ctu-main.cpp

Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=348605&r1=348604&r2=348605&view=diff
==
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Fri Dec  7 08:05:58 2018
@@ -269,7 +269,9 @@ CrossTranslationUnitContext::importDefin
 
   ASTImporter &Importer = getOrCreateASTImporter(FD->getASTContext());
   auto *ToDecl =
-  cast(Importer.Import(const_cast(FD)));
+  cast_or_null(Importer.Import(const_cast(FD)));
+  if (!ToDecl)
+return llvm::make_error(index_error_code::failed_import);
   assert(ToDecl->hasBody());
   assert(FD->hasBody() && "Functions already imported should have body.");
   ++NumGetCTUSuccess;

Added: cfe/trunk/test/Analysis/Inputs/ctu-other.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/ctu-other.c?rev=348605&view=auto
==
--- cfe/trunk/test/Analysis/Inputs/ctu-other.c (added)
+++ cfe/trunk/test/Analysis/Inputs/ctu-other.c Fri Dec  7 08:05:58 2018
@@ -0,0 +1,49 @@
+// Test typedef and global variable in function.
+typedef struct {
+  int a;
+  int b;
+} FooBar;
+FooBar fb;
+int f(int i) {
+  if (fb.a) {
+fb.b = i;
+  }
+  return 1;
+}
+
+// Test enums.
+enum B { x = 42,
+ l,
+ s };
+int enumCheck(void) {
+  return x;
+}
+
+// Test reporting an error in macro definition
+#define MYMACRO(ctx) \
+  ctx->a;
+struct S {
+  int a;
+};
+int g(struct S *ctx) {
+  MYMACRO(ctx);
+  return 0;
+}
+
+// Test that asm import does not fail.
+int inlineAsm() {
+  int res;
+  asm("mov $42, %0"
+  : "=r"(res));
+  return res;
+}
+
+// Implicit function.
+int identImplicit(int in) {
+  return in;
+}
+
+// ASTImporter doesn't support this construct.
+int structInProto(struct DataType {int a;int b; } * d) {
+  return 0;
+}

Added: cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt?rev=348605&view=auto
==
--- cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt (added)
+++ cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt Fri Dec  7 
08:05:58 2018
@@ -0,0 +1,6 @@
+c:@F@inlineAsm ctu-other.c.ast
+c:@F@g ctu-other.c.ast
+c:@F@f ctu-other.c.ast
+c:@F@enumCheck ctu-other.c.ast
+c:@F@identImplicit ctu-other.c.ast
+c:@F@structInProto ctu-other.c.ast

Copied: cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt (from 
r348594, cfe/trunk/test/Analysis/Inputs/externalFnMap.txt)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt?p2=cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt&p1=cfe/trunk/test/Analysis/Inputs/externalFnMap.txt&r1=348594&r2=348605&rev=348605&view=diff
==
(empty)

Removed: cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/externalFnMap.txt?rev=348604&view=auto
==
--- cfe/trunk/test/Analysis/Inputs/externalFnMap.txt (original)
+++ cfe/trunk/test/Analysis/Inputs/externalFnMap.txt (removed)
@@ -1,15 +0,0 @@
-c:@N@chns@F@chf1#I# ctu-other.cpp.ast
-c:@N@myns@N@embed_ns@F@fens#I# ctu-other.cpp.ast
-c:@F@g#I# ctu-other.cpp.ast
-c:@S@mycls@F@fscl#I#S ctu-other.cpp.ast
-c:@S@mycls@F@fcl#I# ctu-other.cpp.ast
-c:@N@myns@S@embed_cls@F@fecl#I# ctu-other.cpp.ast
-c:@S@mycls@S@embed_cls2@F@fecl2#I# ctu-other.cpp.ast
-c:@F@f#I# ctu-other.cpp.ast
-c:@N@myns@F@fns#I# ctu-other.cpp.ast
-c:@F@h#I# ctu-other.cpp.ast
-c:@F@h_chain#I# ctu-chain.cpp.ast
-c

  1   2   3   >