[clang-tools-extra] r342445 - [pp-trace] Remove unused using directives

2018-09-17 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Mon Sep 17 23:57:58 2018
New Revision: 342445

URL: http://llvm.org/viewvc/llvm-project?rev=342445&view=rev
Log:
[pp-trace] Remove unused using directives

Modified:
clang-tools-extra/trunk/pp-trace/PPTrace.cpp

Modified: clang-tools-extra/trunk/pp-trace/PPTrace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPTrace.cpp?rev=342445&r1=342444&r2=342445&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPTrace.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPTrace.cpp Mon Sep 17 23:57:58 2018
@@ -73,11 +73,8 @@
 #include 
 
 using namespace clang;
-using namespace clang::driver;
-using namespace clang::driver::options;
 using namespace clang::tooling;
 using namespace llvm;
-using namespace llvm::opt;
 
 // Options:
 


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


[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision.
shuaiwang added reviewers: JonasToth, aaron.ballman.
Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, a.sidorin, 
szepet, xazax.hun.
Herald added a reviewer: george.karpenkov.

We handle pointee mutation for native pointers & pointer-like types
(loosely defined as having an `operator*` returning non-const reference)

This diff alone just implemented the cases where pointee of an `Exp` is
*directly* mutated (e.g. invoking non-const member function.)

The most trivial class of casts is handled as well for easier unit
testing, `findPointeeCastMutation` is not done yet.

Planned future work:

- `findPointeeDerefMutation`: `Exp` is first dereferenced, and then mutated.
- `findPointee{Member,Array}Mutation`: member (or array element) of pointee is 
accessed and then mutated.
- `findPointeeArithmeticMutation`: handling pointer arithmetic
- `findPointeeAssignmentMutation`: pointer is assigned to another var and then 
mutated.


Repository:
  rC Clang

https://reviews.llvm.org/D52219

Files:
  include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -40,16 +40,34 @@
 bool isMutated(const SmallVectorImpl &Results, ASTUnit *AST) {
   const auto *const S = selectFirst("stmt", Results);
   const auto *const E = selectFirst("expr", Results);
+  assert(E);
   return ExprMutationAnalyzer(*S, AST->getASTContext()).isMutated(E);
 }
 
+bool isPointeeMutated(const SmallVectorImpl &Results,
+  ASTUnit *AST) {
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);
+  assert(E);
+  return ExprMutationAnalyzer(*S, AST->getASTContext()).isPointeeMutated(E);
+}
+
 SmallVector
 mutatedBy(const SmallVectorImpl &Results, ASTUnit *AST) {
+  const Stmt *(ExprMutationAnalyzer::*MutationFinder)(const Expr *) =
+  &ExprMutationAnalyzer::findMutation;
+  const Stmt *(ExprMutationAnalyzer::*PointeeMutationFinder)(const Expr *) =
+  &ExprMutationAnalyzer::findPointeeMutation;
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
-const Stmt *By = Analyzer.findMutation(E);
+auto Finder = MutationFinder;
+if (const auto *DRE = dyn_cast(E)) {
+  if (DRE->getNameInfo().getAsString()[0] == 'p')
+Finder = PointeeMutationFinder;
+}
+const Stmt *By = (Analyzer.*Finder)(E);
 std::string buffer;
 llvm::raw_string_ostream stream(buffer);
 By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
@@ -88,10 +106,14 @@
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
-  const auto AST = tooling::buildASTFromCode("void f() { int x; x; }");
-  const auto Results =
+  auto AST = tooling::buildASTFromCode("void f() { int x; x; }");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode("void f() { const int x = 0; x; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
 class AssignmentTest : public ::testing::TestWithParam {};
@@ -124,42 +146,104 @@
 Values("++x", "--x", "x++", "x--"), );
 
 TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) {
-  const auto AST = tooling::buildASTFromCode(
+  auto AST = tooling::buildASTFromCode(
   "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+  EXPECT_FALSE(isPointeeMutated(Results, AST.get()));
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+
+  AST = tooling::buildASTFromCode(
+  "void f() { struct Foo { void mf(); }; Foo *p; p->mf(); }");
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_TRUE(isPointeeMutated(Results, AST.get()));
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("p->mf()"));
 }
 
 TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
   auto AST = tooling::buildASTFromCodeWithArgs(
   "struct X { template  void mf(); };"
-  "template  void f() { X x; x.mf(); }",
+  "template  void f() { X x; x.mf(); }"
+  "template  void g() { X *p; p->mf(); }",
   {"-fno-delayed-template-parsing"});
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXP

[PATCH] D51910: [Modules] Add platform feature to requires clause

2018-09-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Basic/Module.cpp:81
+  // 2, Environment
+  // 3. Platform-Environment
+  if (Platform == Feature || Target.getTriple().getOSName() == Feature ||

Comment is out of date.


https://reviews.llvm.org/D51910



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


[PATCH] D52218: Warn on self-initializations

2018-09-17 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu created this revision.

Improve some diagnostics around self-initialization.  The uninitialized checker 
does not warn on self-initialization, but does warn later if the variable is 
used.  GCC also has a -Winit-self which will enable a -Wuninitialized warning 
for self-initialized.  -Winit-self is active in -Wall

There's also the matter of the variable being const.  GCC -Wuninitialized will 
warn on a const self-initialized with or without -Winit-self.

This patch will make it so that const self-initialization is always warned on 
under -Wuninitialized.  Since Clang does not use warning flags to control other 
warnings, -Winit-self will be a new warning group for non-const 
self-initialized.  -Winit-self will also be in -Wall via -Wmost.

  // GCC - warn with -Wuninitialized and -Winit-self
  // Clang - no warning
  // Clang with patch - warn with -Winit-self
  void f1() {
int x = x;
  }
  
  // GCC - warn with -Wuninitialized
  // Clang - no warning
  // Clang with patch - warn with -Wuninitialized
  void f2() {
const int x = x;
  }




https://reviews.llvm.org/D52218

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/uninitialized.cpp

Index: test/SemaCXX/uninitialized.cpp
===
--- test/SemaCXX/uninitialized.cpp
+++ test/SemaCXX/uninitialized.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -std=c++1z -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wno-unused -std=c++1z -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wno-unused -Wno-init-self -std=c++1z -verify %s
 
 // definitions for std::move
 namespace std {
@@ -1432,7 +1433,7 @@
 void array_capture(bool b) {
   const char fname[] = "array_capture";
   if (b) {
-int unused; // expected-warning {{unused variable}}
+int unused;
   } else {
 [fname]{};
   }
@@ -1447,3 +1448,15 @@
 
   switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
 }
+
+namespace const_self_init {
+const int a = a;  // no-warning for global
+
+void const_init() {
+  const int a = a; // expected-warning {{variable 'a' is uninitialized when used within its own initialization}}
+
+  const int b = b; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}}
+  int c = b;
+}
+
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1,6 +1,19 @@
 Init = Result.getAs();
   }
 
+  if (!VDecl->getType().isConstQualified()) {
+if (auto *SubExpr = dyn_cast(Init->IgnoreParens())) {
+  if (SubExpr->getCastKind() == CK_LValueToRValue) {
+if (auto *DRE = dyn_cast(SubExpr->getSubExpr())) {
+  if (DRE->getDecl() == VDecl) {
+Diag(VDecl->getLocation(), diag::warn_uninit_self_init)
+<< VDecl << VDecl->getSourceRange() << DRE->getSourceRange();
+  }
+}
+  }
+}
+  }
+
   // Check for self-references within variable initializers.
   // Variables declared within a function/method body (except for references)
   // are handled by a dataflow analysis.
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -977,7 +977,8 @@
 // uninitialized. Proven code paths which access 'x' in
 // an uninitialized state after this will still warn.
 if (const Expr *Initializer = VD->getInit()) {
-  if (!alwaysReportSelfInit && DRE == Initializer->IgnoreParenImpCasts())
+  if (!VD->getType().isConstQualified() && !alwaysReportSelfInit &&
+  DRE == Initializer->IgnoreParenImpCasts())
 return false;
 
   ContainsReference CR(S.Context, DRE);
@@ -1518,10 +1519,17 @@
   UsesVec *vec = V.getPointer();
   bool hasSelfInit = V.getInt();
 
-  // Specially handle the case where we have uses of an uninitialized
-  // variable, but the root cause is an idiomatic self-init.  We want
-  // to report the diagnostic at the self-init since that is the root cause.
-  if (!vec->empty() && hasSelfInit && hasAlwaysUninitializedUse(vec))
+  if (hasSelfInit && vd->getType().isConstQualified()) {
+// Handle "const int a = a;"
+DiagnoseUninitializedUse(S, vd,
+ UninitUse(vd->getInit()->IgnoreParenCasts(),
+   /* isAlwaysUninit */ true),
+ /* alwaysReportSelfInit */ true);
+  } else if (!vec->empty() && hasSelfInit && hasAlwaysUninitializedUse(vec))
+// Specially handle the case where we have uses of an uninitialized
+ 

[PATCH] D51910: [Modules] Add platform feature to requires clause

2018-09-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 165861.
bruno added a comment.

Update patch after review.


https://reviews.llvm.org/D51910

Files:
  docs/Modules.rst
  lib/Basic/Module.cpp
  test/Modules/target-platform-features.m

Index: test/Modules/target-platform-features.m
===
--- /dev/null
+++ test/Modules/target-platform-features.m
@@ -0,0 +1,79 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/InputsA
+
+// RUN: echo "module RequiresMacOS {"   >> %t/InputsA/module.map
+// RUN: echo "  requires macos" >> %t/InputsA/module.map
+// RUN: echo "}">> %t/InputsA/module.map
+// RUN: echo "module RequiresNotiOS {"  >> %t/InputsA/module.map
+// RUN: echo "  requires !ios"  >> %t/InputsA/module.map
+// RUN: echo "}">> %t/InputsA/module.map
+// RUN: echo "module RequiresMain {">> %t/InputsA/module.map
+// RUN: echo "  module SubRequiresNotiOS {" >> %t/InputsA/module.map
+// RUN: echo "requires !ios">> %t/InputsA/module.map
+// RUN: echo "  }"  >> %t/InputsA/module.map
+// RUN: echo "}">> %t/InputsA/module.map
+
+// RUN: %clang_cc1 -triple=x86_64-apple-macosx10.6 -DENABLE_DARWIN -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x objective-c -I%t/InputsA -verify %s 
+// expected-no-diagnostics
+
+// RUN: not %clang_cc1 -triple=arm64-apple-ios -DENABLE_DARWIN -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x objective-c -I%t/InputsA %s  2> %t/notios
+// RUN: FileCheck %s -check-prefix=CHECK-IOS < %t/notios
+#ifdef ENABLE_DARWIN
+// CHECK-IOS: module 'RequiresMacOS' requires feature 'macos'
+@import RequiresMacOS;
+// CHECK-IOS: module 'RequiresNotiOS' is incompatible with feature 'ios'
+@import RequiresNotiOS;
+// We should never get errors for submodules that don't match
+// CHECK-IOS-NOT: module 'RequiresMain'
+@import RequiresMain;
+#endif
+
+// RUN: mkdir %t/InputsB
+// RUN: echo "module RequiresiOSSim {" >> %t/InputsB/module.map
+// RUN: echo "  requires iossimulator"  >> %t/InputsB/module.map
+// RUN: echo "}">> %t/InputsB/module.map
+// RUN: %clang_cc1 -triple=x86_64-apple-iossimulator -DENABLE_IOSSIM -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x objective-c -I%t/InputsB %s  -verify
+// RUN: %clang_cc1 -triple=x86_64-apple-ios-simulator -DENABLE_IOSSIM -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x objective-c -I%t/InputsB %s  -verify
+
+#ifdef ENABLE_IOSSIM
+@import RequiresiOSSim;
+#endif
+
+// RUN: mkdir %t/InputsC
+// RUN: echo "module RequiresLinuxEABIA {"  >> %t/InputsC/module.map
+// RUN: echo "  requires linux, gnueabi">> %t/InputsC/module.map
+// RUN: echo "}">> %t/InputsC/module.map
+// RUN: echo "module RequiresLinuxEABIB {"  >> %t/InputsC/module.map
+// RUN: echo "  requires gnueabi"   >> %t/InputsC/module.map
+// RUN: echo "}">> %t/InputsC/module.map
+// RUN: echo "module RequiresLinuxEABIC {"  >> %t/InputsC/module.map
+// RUN: echo "  requires linux" >> %t/InputsC/module.map
+// RUN: echo "}">> %t/InputsC/module.map
+// RUN: %clang_cc1 -triple=armv8r-none-linux-gnueabi -DENABLE_LINUXEABI -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x objective-c -I%t/InputsC %s -verify
+
+#ifdef ENABLE_LINUXEABI
+@import RequiresLinuxEABIA;
+@import RequiresLinuxEABIB;
+@import RequiresLinuxEABIC;
+#endif
+
+// RUN: mkdir %t/InputsD
+// RUN: echo "module RequiresWinMSVCA {"  >> %t/InputsD/module.map
+// RUN: echo "  requires windows" >> %t/InputsD/module.map
+// RUN: echo "}"  >> %t/InputsD/module.map
+// RUN: echo "module RequiresWinMSVCB {"  >> %t/InputsD/module.map
+// RUN: echo "  requires windows, msvc"   >> %t/InputsD/module.map
+// RUN: echo "}"  >> %t/InputsD/module.map
+// RUN: echo "module RequiresWinMSVCC {"  >> %t/InputsD/module.map
+// RUN: echo "  requires msvc">> %t/InputsD/module.map
+// RUN: echo "}"  >> %t/InputsD/module.map
+// RUN: %clang_cc1 -triple=thumbv7-unknown-windows-msvc -DENABLE_WINMSVC -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x objective-c -I%t/InputsD %s  -verify
+
+#ifdef ENABLE_WINMSVC
+@import RequiresWinMSVCA;
+@import RequiresWinMSVCB;
+@import RequiresWinMSVCC;
+#endif
Index: lib/Basic/Module.cpp
===
--- lib/Basic/Module.cpp
+++ lib/Basic/Module.cpp
@@ -71,6 +71,40 @@
   }
 }
 
+static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) {
+  StringRef Platform = Target.getPlatformName();
+  StringRef Env = Target.getTriple().getEnvironmentName();
+
+  // Attempt to match 

[PATCH] D52189: [analyzer] Fix a crash regression on casting opaque symbolic pointers from unrelated base classes to derived classes.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 165854.
NoQ added a comment.

Add a defensive check that prevents more crashes if the source type is not a 
class at all.


https://reviews.llvm.org/D52189

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.cpp


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -70,5 +70,35 @@
   clang_analyzer_eval(c->x); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(c->y); // expected-warning{{TRUE}}
 }
+} // namespace base_to_derived_double_inheritance
+
+namespace base_to_derived_opaque_class {
+class NotInt {
+public:
+  operator int() { return !x; } // no-crash
+  int x;
+};
+
+typedef struct Opaque *OpaqueRef;
+typedef void *VeryOpaqueRef;
+
+class Transparent {
+public:
+  int getNotInt() { return NI; }
+  NotInt NI;
+};
+
+class SubTransparent : public Transparent {};
+
+SubTransparent *castToDerived(Transparent *TRef) {
+  return (SubTransparent *)TRef;
 }
 
+void foo(OpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+
+void foo(VeryOpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+} // namespace base_to_derived_opaque_class
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -375,8 +375,18 @@
 MR = Uncasted;
   }
 
+  // If we're casting a symbolic base pointer to a derived class, use
+  // CXXDerivedObjectRegion to represent the cast. If it's a pointer to an
+  // unrelated type, it must be a weird reinterpret_cast and we have to
+  // be fine with ElementRegion. TODO: Should we instead make
+  // Derived{TargetClass, Element{SourceClass, SR}}?
   if (const auto *SR = dyn_cast(MR)) {
-return loc::MemRegionVal(MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+QualType T = SR->getSymbol()->getType();
+const CXXRecordDecl *SourceClass = T->getPointeeCXXRecordDecl();
+if (TargetClass && SourceClass && TargetClass->isDerivedFrom(SourceClass))
+  return loc::MemRegionVal(
+  MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+return loc::MemRegionVal(GetElementZeroRegion(SR, TargetType));
   }
 
   // We failed if the region we ended up with has perfect type info.


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -70,5 +70,35 @@
   clang_analyzer_eval(c->x); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(c->y); // expected-warning{{TRUE}}
 }
+} // namespace base_to_derived_double_inheritance
+
+namespace base_to_derived_opaque_class {
+class NotInt {
+public:
+  operator int() { return !x; } // no-crash
+  int x;
+};
+
+typedef struct Opaque *OpaqueRef;
+typedef void *VeryOpaqueRef;
+
+class Transparent {
+public:
+  int getNotInt() { return NI; }
+  NotInt NI;
+};
+
+class SubTransparent : public Transparent {};
+
+SubTransparent *castToDerived(Transparent *TRef) {
+  return (SubTransparent *)TRef;
 }
 
+void foo(OpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+
+void foo(VeryOpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+} // namespace base_to_derived_opaque_class
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -375,8 +375,18 @@
 MR = Uncasted;
   }
 
+  // If we're casting a symbolic base pointer to a derived class, use
+  // CXXDerivedObjectRegion to represent the cast. If it's a pointer to an
+  // unrelated type, it must be a weird reinterpret_cast and we have to
+  // be fine with ElementRegion. TODO: Should we instead make
+  // Derived{TargetClass, Element{SourceClass, SR}}?
   if (const auto *SR = dyn_cast(MR)) {
-return loc::MemRegionVal(MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+QualType T = SR->getSymbol()->getType();
+const CXXRecordDecl *SourceClass = T->getPointeeCXXRecordDecl();
+if (TargetClass && SourceClass && TargetClass->isDerivedFrom(SourceClass))
+  return loc::MemRegionVal(
+  MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+return loc::MemRegionVal(GetElementZeroRegion(SR, TargetType));
   }
 
   // We failed if the region we ended up with has perfect type info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52200: Thread safety analysis: Handle ObjCIvarRefExpr in SExprBuilder::translate

2018-09-17 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley, lukasza.
Herald added a subscriber: cfe-commits.

This imitates the code for MemberExpr. I hope it is right, for I have
absolutely no understanding of ObjC++.

Fixes 38896.


Repository:
  rC Clang

https://reviews.llvm.org/D52200

Files:
  include/clang/Analysis/Analyses/ThreadSafetyCommon.h
  lib/Analysis/ThreadSafetyCommon.cpp
  test/SemaObjCXX/warn-thread-safety-analysis.mm


Index: test/SemaObjCXX/warn-thread-safety-analysis.mm
===
--- /dev/null
+++ test/SemaObjCXX/warn-thread-safety-analysis.mm
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta 
-Wno-objc-root-class %s
+
+class __attribute__((lockable)) Lock {
+public:
+  void Acquire() __attribute__((exclusive_lock_function())) {}
+  void Release() __attribute__((unlock_function())) {}
+};
+
+class __attribute__((scoped_lockable)) AutoLock {
+public:
+  AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock)))
+  : lock_(lock) {
+lock.Acquire();
+  }
+  ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
+
+private:
+  Lock &lock_;
+};
+
+@interface MyInterface {
+@private
+  Lock lock_;
+  int value_;
+}
+
+- (void)incrementValue;
+- (void)decrementValue;
+
+@end
+
+@implementation MyInterface
+
+- (void)incrementValue {
+  AutoLock lock(lock_);
+  value_ += 1;
+}
+
+- (void)decrementValue {
+  lock_.Acquire(); // expected-note{{mutex acquired here}}
+  value_ -= 1;
+} // expected-warning{{mutex 'self.lock_' is still held at the end of 
function}}
+
+@end
Index: lib/Analysis/ThreadSafetyCommon.cpp
===
--- lib/Analysis/ThreadSafetyCommon.cpp
+++ lib/Analysis/ThreadSafetyCommon.cpp
@@ -211,6 +211,8 @@
 return translateCXXThisExpr(cast(S), Ctx);
   case Stmt::MemberExprClass:
 return translateMemberExpr(cast(S), Ctx);
+  case Stmt::ObjCIvarRefExprClass:
+return translateObjCIVarRefExpr(cast(S), Ctx);
   case Stmt::CallExprClass:
 return translateCallExpr(cast(S), Ctx);
   case Stmt::CXXMemberCallExprClass:
@@ -349,6 +351,19 @@
   return P;
 }
 
+til::SExpr *SExprBuilder::translateObjCIVarRefExpr(const ObjCIvarRefExpr *IVRE,
+   CallingContext *Ctx) {
+  til::SExpr *BE = translate(IVRE->getBase(), Ctx);
+  til::SExpr *E = new (Arena) til::SApply(BE);
+
+  const auto *D = cast(IVRE->getDecl()->getCanonicalDecl());
+
+  til::Project *P = new (Arena) til::Project(E, D);
+  if (hasCppPointerType(BE))
+P->setArrow(true);
+  return P;
+}
+
 til::SExpr *SExprBuilder::translateCallExpr(const CallExpr *CE,
 CallingContext *Ctx,
 const Expr *SelfE) {
Index: include/clang/Analysis/Analyses/ThreadSafetyCommon.h
===
--- include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -397,6 +397,8 @@
CallingContext *Ctx) ;
   til::SExpr *translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx);
   til::SExpr *translateMemberExpr(const MemberExpr *ME, CallingContext *Ctx);
+  til::SExpr *translateObjCIVarRefExpr(const ObjCIvarRefExpr *ME,
+   CallingContext *Ctx);
   til::SExpr *translateCallExpr(const CallExpr *CE, CallingContext *Ctx,
 const Expr *SelfE = nullptr);
   til::SExpr *translateCXXMemberCallExpr(const CXXMemberCallExpr *ME,


Index: test/SemaObjCXX/warn-thread-safety-analysis.mm
===
--- /dev/null
+++ test/SemaObjCXX/warn-thread-safety-analysis.mm
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -Wno-objc-root-class %s
+
+class __attribute__((lockable)) Lock {
+public:
+  void Acquire() __attribute__((exclusive_lock_function())) {}
+  void Release() __attribute__((unlock_function())) {}
+};
+
+class __attribute__((scoped_lockable)) AutoLock {
+public:
+  AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock)))
+  : lock_(lock) {
+lock.Acquire();
+  }
+  ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
+
+private:
+  Lock &lock_;
+};
+
+@interface MyInterface {
+@private
+  Lock lock_;
+  int value_;
+}
+
+- (void)incrementValue;
+- (void)decrementValue;
+
+@end
+
+@implementation MyInterface
+
+- (void)incrementValue {
+  AutoLock lock(lock_);
+  value_ += 1;
+}
+
+- (void)decrementValue {
+  lock_.Acquire(); // expected-note{{mutex acquired here}}
+  value_ -= 1;
+} // expected-warning{{mutex 'self.lock_' is still held at the end of function}}
+
+@end
Index: lib/Analysis/ThreadSafetyCommon.cpp
=

[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:388
 &NamingStyles) {
+  assert(D && D->getIdentifier() && !D->getName().empty() && !D->isImplicit() 
&&
+ "Decl must be an explicit identifier with a name.");

> Speaking of which, the result of getIdentifier() is never used, so the check 
> should probably be D->isIdentifier() both in this function and in the caller.

Scratch that. It's not worth the trouble, IMO. 
`D->getDeclName().isIdentifier()` is more verbose and does not buy us anything 
compared to `D->getIdentifier()` which expresses the intent well enough.



https://reviews.llvm.org/D52179



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


[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Artem Belevich via Phabricator via cfe-commits
tra marked an inline comment as done.
tra added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:551-552
 if (Decl->isMain() || !Decl->isUserProvided() ||
-Decl->isUsualDeallocationFunction() ||
-Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
 Decl->size_overridden_methods() > 0)

aaron.ballman wrote:
> Why are these being removed?
D51808 changes signature of isUsualDeallocationFunction(), which made me update 
the code here, which lead to @rsmith suggesting that this change is redundant 
and could use cleaning up, which led to this change.

Any Decl which would return true for isUsualDeallocationFunction()  or for 
is*Operator(), will always return nullptr for getIdentifier() because 
D->getName().isIdentifier() would be false.

Speaking of which, the result of getIdentifier() is never used, so the check 
should probably be D->isIdentifier() both in this function and in the caller.



https://reviews.llvm.org/D52179



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


[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 165841.
tra added a comment.

- Check that D is non-null


https://reviews.llvm.org/D52179

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp


Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -385,6 +385,9 @@
 const NamedDecl *D,
 const std::vector>
 &NamingStyles) {
+  assert(D && D->getIdentifier() && !D->getName().empty() && !D->isImplicit() 
&&
+ "Decl must be an explicit identifier with a name.");
+
   if (isa(D) && NamingStyles[SK_ObjcIvar])
 return SK_ObjcIvar;
   
@@ -548,8 +551,6 @@
 
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isMain() || !Decl->isUserProvided() ||
-Decl->isUsualDeallocationFunction() ||
-Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
 Decl->size_overridden_methods() > 0)
   return SK_Invalid;
 


Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -385,6 +385,9 @@
 const NamedDecl *D,
 const std::vector>
 &NamingStyles) {
+  assert(D && D->getIdentifier() && !D->getName().empty() && !D->isImplicit() &&
+ "Decl must be an explicit identifier with a name.");
+
   if (isa(D) && NamingStyles[SK_ObjcIvar])
 return SK_ObjcIvar;
   
@@ -548,8 +551,6 @@
 
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isMain() || !Decl->isUserProvided() ||
-Decl->isUsualDeallocationFunction() ||
-Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
 Decl->size_overridden_methods() > 0)
   return SK_Invalid;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-17 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a reviewer: rsmith.
zturner added a comment.

What about the timings of clang-cl without /MP?


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-09-17 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM too.


https://reviews.llvm.org/D30882



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


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-09-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

@dexonsmith, does my change address your concerns?


https://reviews.llvm.org/D30882



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


[PATCH] D51910: [Modules] Add platform feature to requires clause

2018-09-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: docs/Modules.rst:476-477
+
+*platform-environment*
+  A platform-environment variant (e.g. ``linux-gnueabi``, ``windows-msvc``) is 
available.
 

rsmith wrote:
> What is the reason to allow these to be combined into a single feature name 
> rather than treating them as two distinct features? (Eg, `requires linux, 
> gnueabi` rather than `requires linux-gnueabi`)?
No specific reason other than the convenience of writing triple like 
requirements. But thinking more about it, it might make more sense to have it 
decoupled and written as a combination to avoid confusion. Will update the 
patch to reflect that. 


https://reviews.llvm.org/D51910



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


[PATCH] D52141: Thread safety analysis: Run more tests with capability attributes [NFC]

2018-09-17 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342418: Thread safety analysis: Run more tests with 
capability attributes [NFC] (authored by aaronpuchert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52141?vs=165662&id=165835#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52141

Files:
  test/SemaCXX/thread-safety-annotations.h
  test/SemaCXX/warn-thread-safety-analysis.cpp
  test/SemaCXX/warn-thread-safety-negative.cpp
  test/SemaCXX/warn-thread-safety-verbose.cpp

Index: test/SemaCXX/thread-safety-annotations.h
===
--- test/SemaCXX/thread-safety-annotations.h
+++ test/SemaCXX/thread-safety-annotations.h
@@ -0,0 +1,42 @@
+// Macros to enable testing of both variants of the thread safety analysis.
+
+#if USE_CAPABILITY
+#define LOCKABLE__attribute__((capability("mutex")))
+#define ASSERT_EXCLUSIVE_LOCK(...)  __attribute__((assert_capability(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...) __attribute__((assert_shared_capability(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)__attribute__((acquire_capability(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)   __attribute__((acquire_shared_capability(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__((try_acquire_capability(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)__attribute__((try_acquire_shared_capability(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...)   __attribute__((requires_capability(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...)  __attribute__((requires_shared_capability(__VA_ARGS__)))
+#else
+#define LOCKABLE__attribute__((lockable))
+#define ASSERT_EXCLUSIVE_LOCK(...)  __attribute__((assert_exclusive_lock(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...) __attribute__((assert_shared_lock(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)__attribute__((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)   __attribute__((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)__attribute__((shared_trylock_function(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...)   __attribute__((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...)  __attribute__((shared_locks_required(__VA_ARGS__)))
+#endif
+
+// Lock semantics only
+#define UNLOCK_FUNCTION(...)__attribute__((unlock_function(__VA_ARGS__)))
+#define GUARDED_VAR __attribute__((guarded_var))
+#define PT_GUARDED_VAR  __attribute__((pt_guarded_var))
+
+// Capabilities only
+#define EXCLUSIVE_UNLOCK_FUNCTION(...)  __attribute__((release_capability(__VA_ARGS__)))
+#define SHARED_UNLOCK_FUNCTION(...) __attribute__((release_shared_capability(__VA_ARGS__)))
+#define GUARDED_BY(x)   __attribute__((guarded_by(x)))
+#define PT_GUARDED_BY(x)__attribute__((pt_guarded_by(x)))
+
+// Common
+#define SCOPED_LOCKABLE __attribute__((scoped_lockable))
+#define ACQUIRED_AFTER(...) __attribute__((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...)__attribute__((acquired_before(__VA_ARGS__)))
+#define LOCK_RETURNED(x)__attribute__((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__((locks_excluded(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS   __attribute__((no_thread_safety_analysis))
Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -6,42 +6,7 @@
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 -Wc++98-compat %s
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
 
-#define SCOPED_LOCKABLE  __attribute__((scoped_lockable))
-#define GUARDED_BY(x)__attribute__((guarded_by(x)))
-#define GUARDED_VAR  __attribute__((guarded_var))
-#define PT_GUARDED_BY(x) __attribute__((pt_guarded_by(x)))
-#define PT_GUARDED_VAR   __attribute__((pt_guarded_var))
-#define ACQUIRED_AFTER(...)  __attribute__((acquired_after(__VA_ARGS__)))
-#define ACQUIRED_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__)))
-
-#if USE_CAPABILITY
-#define LOCKABLE__attribute__((capability("mutex")))
-#define ASSERT_EXCLUSIVE_LOCK(...)  __attribute__((assert_capability(__VA_ARGS__)))
-#define ASSERT_SHARED_LOCK(...) __attribute__((assert_shared_capability(__VA_ARGS__)))
-#define EXCLUSIVE_LOCK_FUNCTION(...)__attribute__((acquire_capability(__VA_ARGS__)))
-#define SHARED_LOCK_FUNCTION(...)   __attribute__((acquire_shared_capability(

r342418 - Thread safety analysis: Run more tests with capability attributes [NFC]

2018-09-17 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Mon Sep 17 14:37:22 2018
New Revision: 342418

URL: http://llvm.org/viewvc/llvm-project?rev=342418&view=rev
Log:
Thread safety analysis: Run more tests with capability attributes [NFC]

Summary:
We run the tests for -Wthread-safety-{negative,verbose} with the new
attributes as well as the old ones. Also put the macros in a header so
that we don't have to copy them all around.

The warn-thread-safety-parsing.cpp test checks for warnings depending on
the actual attribute name, so it can't undergo the same treatment.

Together with D49275 this should fix PR33754.

Reviewers: aaron.ballman, delesley, grooverdan

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/thread-safety-annotations.h
Modified:
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-negative.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-verbose.cpp

Added: cfe/trunk/test/SemaCXX/thread-safety-annotations.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/thread-safety-annotations.h?rev=342418&view=auto
==
--- cfe/trunk/test/SemaCXX/thread-safety-annotations.h (added)
+++ cfe/trunk/test/SemaCXX/thread-safety-annotations.h Mon Sep 17 14:37:22 2018
@@ -0,0 +1,42 @@
+// Macros to enable testing of both variants of the thread safety analysis.
+
+#if USE_CAPABILITY
+#define LOCKABLE__attribute__((capability("mutex")))
+#define ASSERT_EXCLUSIVE_LOCK(...)  
__attribute__((assert_capability(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...) 
__attribute__((assert_shared_capability(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)
__attribute__((acquire_capability(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)   
__attribute__((acquire_shared_capability(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) 
__attribute__((try_acquire_capability(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)
__attribute__((try_acquire_shared_capability(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...)   
__attribute__((requires_capability(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...)  
__attribute__((requires_shared_capability(__VA_ARGS__)))
+#else
+#define LOCKABLE__attribute__((lockable))
+#define ASSERT_EXCLUSIVE_LOCK(...)  
__attribute__((assert_exclusive_lock(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...) 
__attribute__((assert_shared_lock(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)
__attribute__((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)   
__attribute__((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) 
__attribute__((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)
__attribute__((shared_trylock_function(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...)   
__attribute__((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...)  
__attribute__((shared_locks_required(__VA_ARGS__)))
+#endif
+
+// Lock semantics only
+#define UNLOCK_FUNCTION(...)
__attribute__((unlock_function(__VA_ARGS__)))
+#define GUARDED_VAR __attribute__((guarded_var))
+#define PT_GUARDED_VAR  __attribute__((pt_guarded_var))
+
+// Capabilities only
+#define EXCLUSIVE_UNLOCK_FUNCTION(...)  
__attribute__((release_capability(__VA_ARGS__)))
+#define SHARED_UNLOCK_FUNCTION(...) 
__attribute__((release_shared_capability(__VA_ARGS__)))
+#define GUARDED_BY(x)   __attribute__((guarded_by(x)))
+#define PT_GUARDED_BY(x)__attribute__((pt_guarded_by(x)))
+
+// Common
+#define SCOPED_LOCKABLE __attribute__((scoped_lockable))
+#define ACQUIRED_AFTER(...) 
__attribute__((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...)
__attribute__((acquired_before(__VA_ARGS__)))
+#define LOCK_RETURNED(x)__attribute__((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) 
__attribute__((locks_excluded(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS   
__attribute__((no_thread_safety_analysis))

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=342418&r1=342417&r2=342418&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Mon Sep 17 14:37:22 
2018
@@ -6,42 +6,7 @@
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety 
-std=c++11 -Wc++98-compat %s
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
 
-#define SCOPED_LOCKABLE  __a

[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-17 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, hans, zturner.
Herald added a reviewer: JDevlieghere.
Herald added a subscriber: cfe-commits.

This is very preliminary change which adds support for (`clang-cl`) `/MP` 
(Build with multiple processes). Doc for `/MP` is here 
.

Support for `-j` to the `clang` driver could also be added along the way.

I would simply like a general advice on this change. **I don't plan to commit 
this as it is**. If the general idea seems good, I'll cut it down in several 
smaller pieces.

The change about having explicit return codes (`Program.h / enum 
ProgramReturnCode`) should probably be discussed separately, although if you 
have an opinion about that, please do.

Some timings //(I ran each configuration several time to ensure the figures are 
stable)//

  Build LLVM + Clang + LLD (at r341847) inside VS2017:
  
  (Intel Xeon Haswell 6 cores / 12 HW threads, 3.5 GHz, 15M cache, 128 GB RAM, 
SSD 550 MB/s)
  
  - With VS2017 15.8.3: (56m 43 sec) 2 parallel msbuild
  - With Clang /MP + LLD (trunk r341847) [1]: (51m 8sec) 2 parallel msbuild
  
  
  (Intel Xeon Skylake 18 cores / 36 HW threads, x2 (Dual CPU), 72 HW threads 
total, 2.3 GHz, 24.75M cache, 128 GB RAM, NVMe 4.6 GB/s)
  
  - With VS2017 15.8.3: (12m 8sec) 32 parallel msbuild
  - With Clang /MP + LLD (trunk r341847) [1]: (9m 22sec) 32 parallel msbuild
  
  [1] running clang-cl.exe compiled with VS2017 15.8.3 at r341847

Please add anyone who might want to review this. Many thanks in advance!


Repository:
  rC Clang

https://reviews.llvm.org/D52193

Files:
  clang/trunk/include/clang/Driver/CLCompatOptions.td
  clang/trunk/include/clang/Driver/Compilation.h
  clang/trunk/include/clang/Driver/Driver.h
  clang/trunk/include/clang/Driver/Job.h
  clang/trunk/lib/Driver/Compilation.cpp
  clang/trunk/lib/Driver/Driver.cpp
  clang/trunk/lib/Driver/Job.cpp
  clang/trunk/tools/driver/cc1_main.cpp
  clang/trunk/tools/driver/cc1as_main.cpp
  clang/trunk/tools/driver/cc1gen_reproducer_main.cpp
  clang/trunk/tools/driver/driver.cpp
  llvm/trunk/include/llvm/Support/Program.h
  llvm/trunk/lib/Support/GraphWriter.cpp
  llvm/trunk/lib/Support/Program.cpp
  llvm/trunk/lib/Support/Windows/DynamicLibrary.inc
  llvm/trunk/lib/Support/Windows/Process.inc
  llvm/trunk/lib/Support/Windows/Program.inc
  llvm/trunk/lib/Support/Windows/WindowsSupport.h
  llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
  llvm/trunk/tools/bugpoint/OptimizerDriver.cpp
  llvm/trunk/tools/bugpoint/ToolRunner.cpp
  llvm/trunk/tools/bugpoint/ToolRunner.h
  llvm/trunk/tools/dsymutil/MachOUtils.cpp
  llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
  llvm/trunk/unittests/Support/ProgramTest.cpp
  llvm/trunk/utils/not/not.cpp

Index: clang/trunk/tools/driver/driver.cpp
===
--- clang/trunk/tools/driver/driver.cpp
+++ clang/trunk/tools/driver/driver.cpp
@@ -199,11 +199,11 @@
   }
 }
 
-extern int cc1_main(ArrayRef Argv, const char *Argv0,
+extern bool cc1_main(ArrayRef Argv, const char *Argv0,
 void *MainAddr);
-extern int cc1as_main(ArrayRef Argv, const char *Argv0,
+extern bool cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
-extern int cc1gen_reproducer_main(ArrayRef Argv,
+extern bool cc1gen_reproducer_main(ArrayRef Argv,
   const char *Argv0, void *MainAddr);
 
 static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
@@ -304,7 +304,7 @@
 TheDriver.setInstalledDir(InstalledPathParent);
 }
 
-static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
+static bool ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
   void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
   if (Tool == "")
 return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
@@ -316,15 +316,15 @@
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
<< "Valid tools include '-cc1' and '-cc1as'.\n";
-  return 1;
+  return false;
 }
 
 int main(int argc_, const char **argv_) {
   llvm::InitLLVM X(argc_, argv_);
   SmallVector argv(argv_, argv_ + argc_);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
-return 1;
+return (int)llvm::sys::ProgramReturnCode::Failure;
 
   llvm::InitializeAllTargets();
   auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
@@ -379,7 +379,9 @@
   auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
   argv.resize(newEnd - argv.begin());
 }
-return ExecuteCC1Tool(argv, argv[1] + 4);
+bool R = ExecuteCC1Tool(argv, argv[1] + 4);
+return int(R ? llvm::sys::ProgramReturnCode::Success
+ : llvm::sys::ProgramReturnCode::Failure);
   }
 
   bool CanonicalPrefixes = true;
@@ -456,39 +458,32 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   std::unique_ptr C(TheDriver.BuildCompilat

[PATCH] D52141: Thread safety analysis: Run more tests with capability attributes [NFC]

2018-09-17 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked an inline comment as done.
aaronpuchert added a comment.

Makes sense to me. Thanks for the review!


Repository:
  rC Clang

https://reviews.llvm.org/D52141



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


[clang-tools-extra] r342417 - [clang-tidy] Fix tests for performance-for-range-copy

2018-09-17 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Mon Sep 17 14:28:08 2018
New Revision: 342417

URL: http://llvm.org/viewvc/llvm-project?rev=342417&view=rev
Log:
[clang-tidy] Fix tests for performance-for-range-copy

Test failed as D52120 made ExprMutationAnalyzer smarter, fixed by:
- Add move-ctor for `Mutable` to make it actually movable.
- Properly implement `remove_reference`.

The failed test case is:
void negativeVarIsMoved() {
  for (auto M : View>()) {
auto Moved = std::move(M);
  }
}
Before D52120, `std::move(M)` itself is considered as a mutation to `M`,
while after D52120 it's only considered as a cast to rvalue, the
move-assignment is what causes the actual mutation. The test case didn't
mock things properly so the intended move-assignement was actually a
copy-assignment.

Modified:
clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp?rev=342417&r1=342416&r2=342417&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp Mon 
Sep 17 14:28:08 2018
@@ -4,6 +4,10 @@ namespace std {
 
 template 
 struct remove_reference { typedef _Tp type; };
+template 
+struct remove_reference<_Tp&> { typedef _Tp type; };
+template 
+struct remove_reference<_Tp&&> { typedef _Tp type; };
 
 template 
 constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
@@ -103,6 +107,7 @@ void f() {
 struct Mutable {
   Mutable() {}
   Mutable(const Mutable &) = default;
+  Mutable(Mutable&&) = default;
   Mutable(const Mutable &, const Mutable &) {}
   void setBool(bool B) {}
   bool constMethod() const {


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


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

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

I played around with it, and this seemed a bit cleaner. Since I would only 
match against the definition of the record (and the definition of its methods), 
the matcher would need to look like this: `stmt(hasDescendant(blahBlah(...)))`, 
and I'd only be able to retrieve (with my limited knowledge) the entire method 
definition, not the actual `FieldDecl` in the case of a match.
I didn'd do a whole lot of AST based analysis, so feel free to correct me on 
this one ^-^


Repository:
  rC Clang

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] D52191: Fix logic around determining use of frame pointer with -pg.

2018-09-17 Thread Stephen Hines via Phabricator via cfe-commits
srhines created this revision.
srhines added a reviewer: dblaikie.
Herald added a subscriber: cfe-commits.

As part of r342165, I rewrote the logic to check whether
-fno-omit-frame-pointer was passed after a -fomit-frame-pointer
argument. This CL switches that logic to use the consolidated
shouldUseFramePointer() function. This fixes a potential issue where -pg
gets used with -fomit-frame-pointer on a platform that must always retain
frame pointers.


Repository:
  rC Clang

https://reviews.llvm.org/D52191

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4956,8 +4956,7 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (Args.hasFlag(options::OPT_fomit_frame_pointer,
- options::OPT_fno_omit_frame_pointer, /*default=*/false))
+if (shouldUseFramePointer(Args, Triple))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4956,8 +4956,7 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (Args.hasFlag(options::OPT_fomit_frame_pointer,
- options::OPT_fno_omit_frame_pointer, /*default=*/false))
+if (shouldUseFramePointer(Args, Triple))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-09-17 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Thanks! The usual question: would it be easier to implement using AST matchers?


Repository:
  rC Clang

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] D52183: [analyzer] ExplodedGraph printing fixes

2018-09-17 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342413: [analyzer] ExplodedGraph printing fixes (authored by 
george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52183?vs=165818&id=165825#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52183

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp

Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -461,12 +461,15 @@
 
 namespace llvm {
 
-  template<> struct GraphTraits {
+  template <> struct GraphTraits {
+using GraphTy = clang::ento::ExplodedGraph *;
 using NodeRef = clang::ento::ExplodedNode *;
 using ChildIteratorType = clang::ento::ExplodedNode::succ_iterator;
-using nodes_iterator = llvm::df_iterator;
+using nodes_iterator = llvm::df_iterator;
 
-static NodeRef getEntryNode(NodeRef N) { return N; }
+static NodeRef getEntryNode(const GraphTy G) {
+  return *G->roots_begin();
+}
 
 static ChildIteratorType child_begin(NodeRef N) {
   if (N->succ_size() == 1 && (*N->succ_begin())->isTrivial()) {
@@ -482,27 +485,14 @@
   return N->succ_end();
 }
 
-static nodes_iterator nodes_begin(NodeRef N) { return df_begin(N); }
-
-static nodes_iterator nodes_end(NodeRef N) { return df_end(N); }
-  };
-
-  template<> struct GraphTraits {
-using NodeRef = const clang::ento::ExplodedNode *;
-using ChildIteratorType = clang::ento::ExplodedNode::const_succ_iterator;
-using nodes_iterator = llvm::df_iterator;
-
-static NodeRef getEntryNode(NodeRef N) { return N; }
-
-static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
-
-static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
-
-static nodes_iterator nodes_begin(NodeRef N) { return df_begin(N); }
+static nodes_iterator nodes_begin(const GraphTy G) {
+  return df_begin(G);
+}
 
-static nodes_iterator nodes_end(NodeRef N) { return df_end(N); }
+static nodes_iterator nodes_end(const GraphTy G) {
+  return df_end(G);
+}
   };
-
 } // namespace llvm
 
 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2947,35 +2947,37 @@
 //===--===//
 
 #ifndef NDEBUG
-static ExprEngine* GraphPrintCheckerState;
-static SourceManager* GraphPrintSourceManager;
-
 namespace llvm {
 
 template<>
-struct DOTGraphTraits : public DefaultDOTGraphTraits {
+struct DOTGraphTraits : public DefaultDOTGraphTraits {
   DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
 
   // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
   // work.
-  static std::string getNodeAttributes(const ExplodedNode *N, void*) {
+  static std::string getNodeAttributes(const ExplodedNode *N,
+   ExplodedGraph *G) {
 return {};
   }
 
   // De-duplicate some source location pretty-printing.
-  static void printLocation(raw_ostream &Out, SourceLocation SLoc) {
+  static void printLocation(raw_ostream &Out,
+SourceLocation SLoc,
+const SourceManager &SM,
+StringRef Postfix="\\l") {
 if (SLoc.isFileID()) {
   Out << "\\lline="
-<< GraphPrintSourceManager->getExpansionLineNumber(SLoc)
+<< SM.getExpansionLineNumber(SLoc)
 << " col="
-<< GraphPrintSourceManager->getExpansionColumnNumber(SLoc)
-<< "\\l";
+<< SM.getExpansionColumnNumber(SLoc)
+<< Postfix;
 }
   }
 
   static void dumpProgramPoint(ProgramPoint Loc,
const ASTContext &Context,
llvm::raw_string_ostream &Out) {
+const SourceManager &SM = Context.getSourceManager();
 switch (Loc.getKind()) {
 case ProgramPoint::BlockEntranceKind:
   Out << "Block Entrance: B"
@@ -3020,15 +3022,15 @@
   ImplicitCallPoint PC = Loc.castAs();
   Out << "PreCall: ";
   PC.getDecl()->print(Out, Context.getLangOpts());
-  printLocation(Out, PC.getLocation());
+  printLocation(Out, PC.getLocation(), SM);
   break;
 }
 
 case ProgramPoint::PostImplicitCallKind: {
   ImplicitCallPoint PC = Loc.castAs();
   Out << "PostCall: ";
   PC.getDecl()->print(Out, Context.getLangOpts());
-  printLocation(Out, PC.

[PATCH] D51886: [analyzer][UninitializedObjectChecker] Using the new const methods of ImmutableList

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Hmm, how did i miss it?


Repository:
  rC Clang

https://reviews.llvm.org/D51886



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


r342413 - [analyzer] ExplodedGraph printing fixes

2018-09-17 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Sep 17 13:46:53 2018
New Revision: 342413

URL: http://llvm.org/viewvc/llvm-project?rev=342413&view=rev
Log:
[analyzer] ExplodedGraph printing fixes

Fixes a number of issues:

 - Global variables are not used for communication
 - Trait should be defined on a graph, not on a node
 - Defining the trait on a graph allows us to use a correct allocator,
   no longer crashing while printing trimmed graphs

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=342413&r1=342412&r2=342413&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
Mon Sep 17 13:46:53 2018
@@ -461,12 +461,15 @@ public:
 
 namespace llvm {
 
-  template<> struct GraphTraits {
+  template <> struct GraphTraits {
+using GraphTy = clang::ento::ExplodedGraph *;
 using NodeRef = clang::ento::ExplodedNode *;
 using ChildIteratorType = clang::ento::ExplodedNode::succ_iterator;
-using nodes_iterator = llvm::df_iterator;
+using nodes_iterator = llvm::df_iterator;
 
-static NodeRef getEntryNode(NodeRef N) { return N; }
+static NodeRef getEntryNode(const GraphTy G) {
+  return *G->roots_begin();
+}
 
 static ChildIteratorType child_begin(NodeRef N) {
   if (N->succ_size() == 1 && (*N->succ_begin())->isTrivial()) {
@@ -482,27 +485,14 @@ namespace llvm {
   return N->succ_end();
 }
 
-static nodes_iterator nodes_begin(NodeRef N) { return df_begin(N); }
-
-static nodes_iterator nodes_end(NodeRef N) { return df_end(N); }
-  };
-
-  template<> struct GraphTraits {
-using NodeRef = const clang::ento::ExplodedNode *;
-using ChildIteratorType = clang::ento::ExplodedNode::const_succ_iterator;
-using nodes_iterator = llvm::df_iterator;
-
-static NodeRef getEntryNode(NodeRef N) { return N; }
-
-static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
-
-static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
-
-static nodes_iterator nodes_begin(NodeRef N) { return df_begin(N); }
+static nodes_iterator nodes_begin(const GraphTy G) {
+  return df_begin(G);
+}
 
-static nodes_iterator nodes_end(NodeRef N) { return df_end(N); }
+static nodes_iterator nodes_end(const GraphTy G) {
+  return df_end(G);
+}
   };
-
 } // namespace llvm
 
 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp?rev=342413&r1=342412&r2=342413&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp Mon Sep 17 13:46:53 2018
@@ -226,7 +226,7 @@ void Environment::print(raw_ostream &Out
 
   PrintingPolicy PP = Context.getPrintingPolicy();
 
-  Out << NL << NL << "Expressions by stack frame:" << NL;
+  Out << NL << "Expressions by stack frame:" << NL;
   WithLC->dumpStack(Out, "", NL, Sep, [&](const LocationContext *LC) {
 for (auto I : ExprBindings) {
   if (I.first.getLocationContext() != LC)

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=342413&r1=342412&r2=342413&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Sep 17 13:46:53 2018
@@ -2947,35 +2947,37 @@ void ExprEngine::VisitMSAsmStmt(const MS
 
//===--===//
 
 #ifndef NDEBUG
-static ExprEngine* GraphPrintCheckerState;
-static SourceManager* GraphPrintSourceManager;
-
 namespace llvm {
 
 template<>
-struct DOTGraphTraits : public DefaultDOTGraphTraits {
+struct DOTGraphTraits : public DefaultDOTGraphTraits {
   DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
 
   // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
   // work.
-  static std::string getNodeAttributes(const ExplodedNode *N, void*) {
+  static std::string getNodeAttributes(const ExplodedNode *N,
+   ExplodedGraph *G) {
 return {};
   }
 
   // De-dupli

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

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

@george.karpenkov @xazax.hun, is this how you imagined checking whether an 
access is guarded?


Repository:
  rC Clang

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] D51886: [analyzer][UninitializedObjectChecker] Using the new const methods of ImmutableList

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

Ping :)


Repository:
  rC Clang

https://reviews.llvm.org/D51886



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


[PATCH] D52189: [analyzer] Fix a crash regression on casting opaque symbolic pointers from unrelated base classes to derived classes.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 165821.
NoQ added a comment.

Add a bit more discussion into the comments.


https://reviews.llvm.org/D52189

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.cpp


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -70,5 +70,30 @@
   clang_analyzer_eval(c->x); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(c->y); // expected-warning{{TRUE}}
 }
+} // namespace base_to_derived_double_inheritance
+
+namespace base_to_derived_opaque_class {
+class NotInt {
+public:
+  operator int() { return !x; } // no-crash
+  int x;
+};
+
+typedef struct Opaque *OpaqueRef;
+
+class Transparent {
+public:
+  int getNotInt() { return NI; }
+  NotInt NI;
+};
+
+class SubTransparent : public Transparent {};
+
+SubTransparent *castToDerived(Transparent *TRef) {
+  return (SubTransparent *)TRef;
 }
 
+void counterValue(OpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+} // namespace base_to_derived_opaque_class
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -375,8 +375,18 @@
 MR = Uncasted;
   }
 
+  // If we're casting a symbolic base pointer to a derived class, use
+  // CXXDerivedObjectRegion to represent the cast. If it's a pointer to an
+  // unrelated type, it must be a weird reinterpret_cast and we have to
+  // be fine with ElementRegion. TODO: Should we instead make
+  // Derived{TargetClass, Element{SourceClass, SR}}?
   if (const auto *SR = dyn_cast(MR)) {
-return loc::MemRegionVal(MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+QualType T = SR->getSymbol()->getType();
+const CXXRecordDecl *SourceClass = T->getPointeeCXXRecordDecl();
+if (TargetClass->isDerivedFrom(SourceClass))
+  return loc::MemRegionVal(
+  MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+return loc::MemRegionVal(GetElementZeroRegion(SR, TargetType));
   }
 
   // We failed if the region we ended up with has perfect type info.


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -70,5 +70,30 @@
   clang_analyzer_eval(c->x); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(c->y); // expected-warning{{TRUE}}
 }
+} // namespace base_to_derived_double_inheritance
+
+namespace base_to_derived_opaque_class {
+class NotInt {
+public:
+  operator int() { return !x; } // no-crash
+  int x;
+};
+
+typedef struct Opaque *OpaqueRef;
+
+class Transparent {
+public:
+  int getNotInt() { return NI; }
+  NotInt NI;
+};
+
+class SubTransparent : public Transparent {};
+
+SubTransparent *castToDerived(Transparent *TRef) {
+  return (SubTransparent *)TRef;
 }
 
+void counterValue(OpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+} // namespace base_to_derived_opaque_class
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -375,8 +375,18 @@
 MR = Uncasted;
   }
 
+  // If we're casting a symbolic base pointer to a derived class, use
+  // CXXDerivedObjectRegion to represent the cast. If it's a pointer to an
+  // unrelated type, it must be a weird reinterpret_cast and we have to
+  // be fine with ElementRegion. TODO: Should we instead make
+  // Derived{TargetClass, Element{SourceClass, SR}}?
   if (const auto *SR = dyn_cast(MR)) {
-return loc::MemRegionVal(MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+QualType T = SR->getSymbol()->getType();
+const CXXRecordDecl *SourceClass = T->getPointeeCXXRecordDecl();
+if (TargetClass->isDerivedFrom(SourceClass))
+  return loc::MemRegionVal(
+  MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+return loc::MemRegionVal(GetElementZeroRegion(SR, TargetType));
   }
 
   // We failed if the region we ended up with has perfect type info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52189: [analyzer] Fix a crash regression on casting opaque symbolic pointers from unrelated base classes to derived classes.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, 
baloghadamsoftware.

Commit https://reviews.llvm.org/D51191 causes a crash when a pointer to a 
completely unrelated type `UnrelatedT` (eg., opaque struct pattern) is being 
casted from base class `BaseT` to derived class `DerivedT`, which results in an 
ill-formed region `Derived{SymRegion{$}, DerivedT}`.

I guess we should prevent these from appearing somehow.


Repository:
  rC Clang

https://reviews.llvm.org/D52189

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.cpp


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -70,5 +70,30 @@
   clang_analyzer_eval(c->x); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(c->y); // expected-warning{{TRUE}}
 }
+} // namespace base_to_derived_double_inheritance
+
+namespace base_to_derived_opaque_class {
+class NotInt {
+public:
+  operator int() { return !x; } // no-crash
+  int x;
+};
+
+typedef struct Opaque *OpaqueRef;
+
+class Transparent {
+public:
+  int getNotInt() { return NI; }
+  NotInt NI;
+};
+
+class SubTransparent : public Transparent {};
+
+SubTransparent *castToDerived(Transparent *TRef) {
+  return (SubTransparent *)TRef;
 }
 
+void counterValue(OpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+} // namespace base_to_derived_opaque_class
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -375,8 +375,17 @@
 MR = Uncasted;
   }
 
+  // If we're casting a symbolic base pointer to a derived class, use
+  // CXXDerivedObjectRegion to represent the cast. If it's a pointer to an
+  // unrelated type, it must be a weird reinterpret_cast and we have to
+  // be fine with ElementRegion.
   if (const auto *SR = dyn_cast(MR)) {
-return loc::MemRegionVal(MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+QualType T = SR->getSymbol()->getType();
+const CXXRecordDecl *SourceClass = T->getPointeeCXXRecordDecl();
+if (TargetClass->isDerivedFrom(SourceClass))
+  return loc::MemRegionVal(
+  MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+return loc::MemRegionVal(GetElementZeroRegion(SR, TargetType));
   }
 
   // We failed if the region we ended up with has perfect type info.


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -70,5 +70,30 @@
   clang_analyzer_eval(c->x); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(c->y); // expected-warning{{TRUE}}
 }
+} // namespace base_to_derived_double_inheritance
+
+namespace base_to_derived_opaque_class {
+class NotInt {
+public:
+  operator int() { return !x; } // no-crash
+  int x;
+};
+
+typedef struct Opaque *OpaqueRef;
+
+class Transparent {
+public:
+  int getNotInt() { return NI; }
+  NotInt NI;
+};
+
+class SubTransparent : public Transparent {};
+
+SubTransparent *castToDerived(Transparent *TRef) {
+  return (SubTransparent *)TRef;
 }
 
+void counterValue(OpaqueRef ORef) {
+  castToDerived(reinterpret_cast(ORef))->getNotInt();
+}
+} // namespace base_to_derived_opaque_class
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -375,8 +375,17 @@
 MR = Uncasted;
   }
 
+  // If we're casting a symbolic base pointer to a derived class, use
+  // CXXDerivedObjectRegion to represent the cast. If it's a pointer to an
+  // unrelated type, it must be a weird reinterpret_cast and we have to
+  // be fine with ElementRegion.
   if (const auto *SR = dyn_cast(MR)) {
-return loc::MemRegionVal(MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+QualType T = SR->getSymbol()->getType();
+const CXXRecordDecl *SourceClass = T->getPointeeCXXRecordDecl();
+if (TargetClass->isDerivedFrom(SourceClass))
+  return loc::MemRegionVal(
+  MRMgr.getCXXDerivedObjectRegion(TargetClass, SR));
+return loc::MemRegionVal(GetElementZeroRegion(SR, TargetType));
   }
 
   // We failed if the region we ended up with has perfect type info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:388
 &NamingStyles) {
+  assert(D->getIdentifier() && !D->getName().empty() && !D->isImplicit() &&
+ "Decl must be an explicit identifier with a name.");

Can you also assert `D` is nonnull here? (`isa<>` used to take care of that, so 
it's a minor regression in checking.)



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:551-552
 if (Decl->isMain() || !Decl->isUserProvided() ||
-Decl->isUsualDeallocationFunction() ||
-Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
 Decl->size_overridden_methods() > 0)

Why are these being removed?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52179



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


[PATCH] D52133: [analyzer] A testing facility for testing relationships between symbols.

2018-09-17 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:273
+
+  for (auto I : State->get()) {
+SymbolRef Sym = I.first;

Sidenote: this code fragment is so common I wonder whether we should have a 
helper/facility for that.


https://reviews.llvm.org/D52133



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


[PATCH] D52133: [analyzer] A testing facility for testing relationships between symbols.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Mm, i mean, that reason as good as well.


https://reviews.llvm.org/D52133



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


[PATCH] D52133: [analyzer] A testing facility for testing relationships between symbols.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added a comment.

In https://reviews.llvm.org/D52133#1237312, @george.karpenkov wrote:

> @NoQ Actually I agree with @baloghadamsoftware that it makes sense to have a 
> separate test, as this functionality should be tested regardless of 
> svalbuilder-rearrange-comparisons existence.


That's why i added a spearate test.


https://reviews.llvm.org/D52133



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


[PATCH] D52133: [analyzer] A testing facility for testing relationships between symbols.

2018-09-17 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@NoQ Actually I agree with @baloghadamsoftware that it makes sense to have a 
separate test, as this functionality should be tested regardless of 
svalbuilder-rearrange-comparisons existence.


https://reviews.llvm.org/D52133



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


[PATCH] D52120: [analyzer] Treat std::{move, forward} as casts in ExprMutationAnalyzer.

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342409: [analyzer] Treat std::{move,forward} as casts in 
ExprMutationAnalyzer. (authored by shuaiwang, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52120

Files:
  cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
  cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
+++ cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -304,7 +304,16 @@
nonConstReferenceType()
 .bind(NodeID::value)),
 Stm, Context);
-  return findExprMutation(Casts);
+  if (const Stmt *S = findExprMutation(Casts))
+return S;
+  // Treat std::{move,forward} as cast.
+  const auto Calls =
+  match(findAll(callExpr(callee(namedDecl(
+ hasAnyName("::std::move", "::std::forward"))),
+ hasArgument(0, equalsNode(Exp)))
+.bind("expr")),
+Stm, Context);
+  return findExprMutation(Calls);
 }
 
 const Stmt *ExprMutationAnalyzer::findRangeLoopMutation(const Expr *Exp) {
@@ -360,7 +369,9 @@
   const auto IsInstantiated = hasDeclaration(isInstantiated());
   const auto FuncDecl = hasDeclaration(functionDecl().bind("func"));
   const auto Matches = match(
-  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl),
+  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
+  unless(callee(namedDecl(hasAnyName(
+  "::std::move", "::std::forward"),
  cxxConstructExpr(NonConstRefParam, IsInstantiated,
   FuncDecl)))
   .bind(NodeID::value)),
Index: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -66,6 +66,25 @@
   return s;
 }
 
+const std::string StdRemoveReference =
+"namespace std {"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; }; }";
+
+const std::string StdMove =
+"namespace std {"
+"template typename remove_reference::type&& "
+"move(T&& t) noexcept {"
+"return static_cast::type&&>(t); } }";
+
+const std::string StdForward =
+"namespace std {"
+"template T&& "
+"forward(typename remove_reference::type& t) noexcept { return t; }"
+"template T&& "
+"forward(typename remove_reference::type&&) noexcept { return t; } }";
+
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
@@ -373,36 +392,87 @@
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
-  // Technically almost the same as ByNonConstRRefArgument, just double checking
-  const auto AST = tooling::buildASTFromCode(
-  "namespace std {"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template typename std::remove_reference::type&& "
-  "move(T&& t) noexcept; }"
-  "void f() { struct A {}; A x; std::move(x); }");
-  const auto Results =
+  auto AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"void f() { struct A {}; A x; std::move(x); }");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x)"));
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "void f() { struct A {}; A x, y; std::move(x) = y; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x) = y"));
+
+  AST = tooling::buildASTFromCode(StdRemoveReference + StdMove +
+  "void f() { int x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "struct S { S(); S(const S&); S& operator=(const S&); };"
+  "void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+

[PATCH] D52120: [analyzer] Treat std::{move, forward} as casts in ExprMutationAnalyzer.

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342409: [analyzer] Treat std::{move,forward} as casts in 
ExprMutationAnalyzer. (authored by shuaiwang, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52120?vs=165801&id=165813#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52120

Files:
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: lib/Analysis/ExprMutationAnalyzer.cpp
===
--- lib/Analysis/ExprMutationAnalyzer.cpp
+++ lib/Analysis/ExprMutationAnalyzer.cpp
@@ -304,7 +304,16 @@
nonConstReferenceType()
 .bind(NodeID::value)),
 Stm, Context);
-  return findExprMutation(Casts);
+  if (const Stmt *S = findExprMutation(Casts))
+return S;
+  // Treat std::{move,forward} as cast.
+  const auto Calls =
+  match(findAll(callExpr(callee(namedDecl(
+ hasAnyName("::std::move", "::std::forward"))),
+ hasArgument(0, equalsNode(Exp)))
+.bind("expr")),
+Stm, Context);
+  return findExprMutation(Calls);
 }
 
 const Stmt *ExprMutationAnalyzer::findRangeLoopMutation(const Expr *Exp) {
@@ -360,7 +369,9 @@
   const auto IsInstantiated = hasDeclaration(isInstantiated());
   const auto FuncDecl = hasDeclaration(functionDecl().bind("func"));
   const auto Matches = match(
-  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl),
+  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
+  unless(callee(namedDecl(hasAnyName(
+  "::std::move", "::std::forward"),
  cxxConstructExpr(NonConstRefParam, IsInstantiated,
   FuncDecl)))
   .bind(NodeID::value)),
Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -66,6 +66,25 @@
   return s;
 }
 
+const std::string StdRemoveReference =
+"namespace std {"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; }; }";
+
+const std::string StdMove =
+"namespace std {"
+"template typename remove_reference::type&& "
+"move(T&& t) noexcept {"
+"return static_cast::type&&>(t); } }";
+
+const std::string StdForward =
+"namespace std {"
+"template T&& "
+"forward(typename remove_reference::type& t) noexcept { return t; }"
+"template T&& "
+"forward(typename remove_reference::type&&) noexcept { return t; } }";
+
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
@@ -373,36 +392,87 @@
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
-  // Technically almost the same as ByNonConstRRefArgument, just double checking
-  const auto AST = tooling::buildASTFromCode(
-  "namespace std {"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template typename std::remove_reference::type&& "
-  "move(T&& t) noexcept; }"
-  "void f() { struct A {}; A x; std::move(x); }");
-  const auto Results =
+  auto AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"void f() { struct A {}; A x; std::move(x); }");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x)"));
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "void f() { struct A {}; A x, y; std::move(x) = y; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x) = y"));
+
+  AST = tooling::buildASTFromCode(StdRemoveReference + StdMove +
+  "void f() { int x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "struct S { S(); S(const S&); S& operator=(const S&); };"
+  "void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"struct S { 

r342409 - [analyzer] Treat std::{move, forward} as casts in ExprMutationAnalyzer.

2018-09-17 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Mon Sep 17 13:10:56 2018
New Revision: 342409

URL: http://llvm.org/viewvc/llvm-project?rev=342409&view=rev
Log:
[analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.

Summary:
This is a follow up of D52008 and should make the analyzer being able to handle 
perfect forwardings in real world cases where forwardings are done through 
multiple layers of function calls with `std::forward`.

Fixes PR38891.

Reviewers: lebedev.ri, JonasToth, george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, 
cfe-commits

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

Modified:
cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Modified: cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp?rev=342409&r1=342408&r2=342409&view=diff
==
--- cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp (original)
+++ cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp Mon Sep 17 13:10:56 2018
@@ -304,7 +304,16 @@ const Stmt *ExprMutationAnalyzer::findCa
nonConstReferenceType()
 .bind(NodeID::value)),
 Stm, Context);
-  return findExprMutation(Casts);
+  if (const Stmt *S = findExprMutation(Casts))
+return S;
+  // Treat std::{move,forward} as cast.
+  const auto Calls =
+  match(findAll(callExpr(callee(namedDecl(
+ hasAnyName("::std::move", "::std::forward"))),
+ hasArgument(0, equalsNode(Exp)))
+.bind("expr")),
+Stm, Context);
+  return findExprMutation(Calls);
 }
 
 const Stmt *ExprMutationAnalyzer::findRangeLoopMutation(const Expr *Exp) {
@@ -360,7 +369,9 @@ const Stmt *ExprMutationAnalyzer::findFu
   const auto IsInstantiated = hasDeclaration(isInstantiated());
   const auto FuncDecl = hasDeclaration(functionDecl().bind("func"));
   const auto Matches = match(
-  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl),
+  findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
+  unless(callee(namedDecl(hasAnyName(
+  "::std::move", "::std::forward"),
  cxxConstructExpr(NonConstRefParam, IsInstantiated,
   FuncDecl)))
   .bind(NodeID::value)),

Modified: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp?rev=342409&r1=342408&r2=342409&view=diff
==
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp (original)
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp Mon Sep 17 
13:10:56 2018
@@ -66,6 +66,25 @@ std::string removeSpace(std::string s) {
   return s;
 }
 
+const std::string StdRemoveReference =
+"namespace std {"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; }; }";
+
+const std::string StdMove =
+"namespace std {"
+"template typename remove_reference::type&& "
+"move(T&& t) noexcept {"
+"return static_cast::type&&>(t); } }";
+
+const std::string StdForward =
+"namespace std {"
+"template T&& "
+"forward(typename remove_reference::type& t) noexcept { return t; }"
+"template T&& "
+"forward(typename remove_reference::type&&) noexcept { return t; } }";
+
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
@@ -373,36 +392,87 @@ TEST(ExprMutationAnalyzerTest, ByConstRR
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
-  // Technically almost the same as ByNonConstRRefArgument, just double 
checking
-  const auto AST = tooling::buildASTFromCode(
-  "namespace std {"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template typename std::remove_reference::type&& "
-  "move(T&& t) noexcept; }"
-  "void f() { struct A {}; A x; std::move(x); }");
-  const auto Results =
+  auto AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"void f() { struct A {}; A x; std::move(x); 
}");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x)"));
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "void f() { struct A {

[clang-tools-extra] r342408 - Fix build failure caused by D52157

2018-09-17 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Mon Sep 17 13:10:33 2018
New Revision: 342408

URL: http://llvm.org/viewvc/llvm-project?rev=342408&view=rev
Log:
Fix build failure caused by D52157

Modified:
clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp?rev=342408&r1=342407&r2=342408&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp Mon Sep 
17 13:10:33 2018
@@ -115,7 +115,7 @@ TEST_F(QueryEngineTest, Basic) {
 
   Str.clear();
 
-  EXPECT_FALSE(MatchQuery(isArrow()).run(OS, S));
+  EXPECT_FALSE(MatchQuery(isMain()).run(OS, S));
 
   EXPECT_EQ("Not a valid top-level matcher.\n", OS.str());
 }


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


Re: r342214 - remove 11 years old videos from the homepage. if you have a suggestion, please drop me an email

2018-09-17 Thread David Blaikie via cfe-commits
If you're going to remove these, might as well remove the html files they
link to?

On the other hand, might be worth keeping these around/linked to, but for
posterity/archival purposes, rather than as sources of legitimately useful
information for people trying to use LLVM today.

On Fri, Sep 14, 2018 at 2:02 AM Sylvestre Ledru via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sylvestre
> Date: Fri Sep 14 02:00:48 2018
> New Revision: 342214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342214&view=rev
> Log:
> remove 11 years old videos from the homepage. if you have a suggestion,
> please drop me an email
>
> Modified:
> cfe/trunk/www/index.html
>
> Modified: cfe/trunk/www/index.html
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/www/index.html?rev=342214&r1=342213&r2=342214&view=diff
>
> ==
> --- cfe/trunk/www/index.html (original)
> +++ cfe/trunk/www/index.html Fri Sep 14 02:00:48 2018
> @@ -74,16 +74,6 @@
>   motivations for starting work on a new front-end that could
>   meet these needs.
>
> -  A good (but quite dated) introduction to Clang can be found in the
> - following video lectures:
> -
> -  
> -Clang Introduction
> -(May 2007)
> -Features and Performance of
> -Clang  (July 2007)
> -  
> -
>For a more detailed comparison between Clang and other compilers,
> please
>   see the Clang comparison page.
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r342165 - Support -fno-omit-frame-pointer with -pg.

2018-09-17 Thread David Blaikie via cfe-commits
Seems like it might be problematic to have this separate implementation of
checking whether frame pointers are enabled compared to the canonical one
(the one actually used to enable/disable frame pointers) in the static
"shouldUseFramePointer" Function?

(eg: apparently on some targets (mustUseNonLeafFramePointerForTarget) frame
pointers are enabled regardless of the arguments - looks like in that case
this would still produce an error if you combined -fomit-frame-pointer with
-pg on such a platform, even though frame pointers would still be emitted?)

On Thu, Sep 13, 2018 at 12:51 PM Stephen Hines via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: srhines
> Date: Thu Sep 13 12:50:02 2018
> New Revision: 342165
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342165&view=rev
> Log:
> Support -fno-omit-frame-pointer with -pg.
>
> Summary:
> Previously, any instance of -fomit-frame-pointer would make it such that
> -pg was an invalid flag combination. If -fno-omit-frame-pointer is
> passed later on the command line (such that it actually takes effect),
> -pg should be allowed.
>
> Reviewers: nickdesaulniers
>
> Reviewed By: nickdesaulniers
>
> Subscribers: manojgupta, nickdesaulniers, cfe-commits, kongyi, chh, pirama
>
> Differential Revision: https://reviews.llvm.org/D51713
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/Driver/clang_f_opts.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=342165&r1=342164&r2=342165&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep 13 12:50:02 2018
> @@ -4910,7 +4910,8 @@ void Clang::ConstructJob(Compilation &C,
>}
>
>if (Arg *A = Args.getLastArg(options::OPT_pg))
> -if (Args.hasArg(options::OPT_fomit_frame_pointer))
> +if (Args.hasFlag(options::OPT_fomit_frame_pointer,
> + options::OPT_fno_omit_frame_pointer,
> /*default=*/false))
>D.Diag(diag::err_drv_argument_not_allowed_with) <<
> "-fomit-frame-pointer"
><<
> A->getAsString(Args);
>
>
> Modified: cfe/trunk/test/Driver/clang_f_opts.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=342165&r1=342164&r2=342165&view=diff
>
> ==
> --- cfe/trunk/test/Driver/clang_f_opts.c (original)
> +++ cfe/trunk/test/Driver/clang_f_opts.c Thu Sep 13 12:50:02 2018
> @@ -531,3 +531,8 @@
>  // RUN: %clang -### -S -fno-delete-null-pointer-checks
> -fdelete-null-pointer-checks %s 2>&1 | FileCheck
> -check-prefix=CHECK-NULL-POINTER-CHECKS %s
>  // CHECK-NO-NULL-POINTER-CHECKS: "-fno-delete-null-pointer-checks"
>  // CHECK-NULL-POINTER-CHECKS-NOT: "-fno-delete-null-pointer-checks"
> +
> +// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck
> -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
> +// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg
> %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
> +// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
> +// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with
> '-pg'
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D52179#1237194, @JonasToth wrote:

> Is the condition for this assertion checked beforehand or could this create 
> runtime failures?


It's checked by the (only) caller of the function on line 791:

if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
  if (!Decl->getIdentifier() || Decl->getName().empty() || 
Decl->isImplicit())
return;
  
  ...
  StyleKind SK = findStyleKind(Decl, NamingStyles);
  if (SK == SK_Invalid)
return;
  ...
   }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52179



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


[PATCH] D52133: [analyzer] A testing facility for testing relationships between symbols.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added a comment.

> Should not it we have its own test in `expr-inspection.c`?

This isn't usually necessary when we're testing all code paths anyway, but i 
guess it's worth it to test our sanity-check warnings.




Comment at: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:65
 REGISTER_SET_WITH_PROGRAMSTATE(MarkedSymbols, SymbolRef)
+REGISTER_MAP_WITH_PROGRAMSTATE(DenotedSymbols, SymbolRef, const void *)
 

baloghadamsoftware wrote:
> Why const `void *`?
Whoops, i was incorrectly recalling that it doesn't work because the respective 
type trait structures aren't defined for non-void pointers, but that must have 
been some other data structure.


https://reviews.llvm.org/D52133



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


[PATCH] D52133: [analyzer] A testing facility for testing relationships between symbols.

2018-09-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 165810.
NoQ added a comment.

Address comments. Add more sanity checks and test them.


https://reviews.llvm.org/D52133

Files:
  docs/analyzer/DebugChecks.rst
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  test/Analysis/expr-inspection.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c

Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -1,10 +1,8 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-binary-operation-simplification=true -verify -analyzer-config eagerly-assume=false %s
 
-// Temporary xfailing, as debug printing functionality has changed.
-// XFAIL: *
-
-void clang_analyzer_dump(int x);
 void clang_analyzer_eval(int x);
+void clang_analyzer_denote(int x, const char *literal);
+void clang_analyzer_express(int x);
 
 void exit(int);
 
@@ -29,907 +27,951 @@
 
 void compare_different_symbol_equal() {
   int x = f(), y = f();
-  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
-  clang_analyzer_dump(y); // expected-warning{{conj_$9{int}}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 0}}
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  clang_analyzer_express(x == y); // expected-warning {{$x - $y == 0}}
 }
 
 void compare_different_symbol_plus_left_int_equal() {
-  int x = f()+1, y = f();
-  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
-  clang_analyzer_dump(y); // expected-warning{{conj_$9{int}}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 1}}
+  int x = f(), y = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  x += 1;
+  clang_analyzer_express(x == y); // expected-warning {{$y - $x == 1}}
 }
 
 void compare_different_symbol_minus_left_int_equal() {
-  int x = f()-1, y = f();
-  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}}
-  clang_analyzer_dump(y); // expected-warning{{conj_$9{int}}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 1}}
+  int x = f(), y = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  x -= 1;
+  clang_analyzer_express(x == y); // expected-warning {{$x - $y == 1}}
 }
 
 void compare_different_symbol_plus_right_int_equal() {
-  int x = f(), y = f()+2;
-  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
-  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) + 2}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 2}}
+  int x = f(), y = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  y += 2;
+  clang_analyzer_express(y); // expected-warning {{$y + 2}}
+  clang_analyzer_express(x == y); // expected-warning {{$x - $y == 2}}
 }
 
 void compare_different_symbol_minus_right_int_equal() {
-  int x = f(), y = f()-2;
-  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
-  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) - 2}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 2}}
+  int x = f(), y = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  y -= 2;
+  clang_analyzer_express(y); // expected-warning {{$y - 2}}
+  clang_analyzer_express(x == y); // expected-warning {{$y - $x == 2}}
 }
 
 void compare_different_symbol_plus_left_plus_right_int_equal() {
-  int x = f()+2, y = f()+1;
-  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
-  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) + 1}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 1}}
+  int x = f(), y = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  x += 2;
+  y += 1;
+  clang_analyzer_express(x); // expected-warning {{$x + 2}}
+  clang_analyzer_express(y); // expected-warning {{$y + 1}}
+  clang_analyzer_express(x == y); // expected-warning {{$y - $x == 1}}
 }
 
 void compare_different_symbol_plus_left_minus_right_int_equal() {
-  int x = f()+2, y = f()-1;
-  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
-  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) - 1}}
-  clang_analyzer_dump(x == y);
-  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 3}}
+  int x = f(), y = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_denote(y, "$y");
+  x += 2;
+  y -= 1;
+  clang_analyzer_express(x); // expected-warning {{$x + 2}}
+  clang_analyzer_express(y); // expected-warning {{$y - 1}}
+  clang_analyzer_express(x == y); // expected-warning {{$y - $x == 3}}
 }
 
 void compare_different_symbol_minus_left_plus_right_int_equal() {
-  i

[PATCH] D52187: [clang-tidy] use CHECK-NOTES in bugprone-unused-return-value

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, alexfh, hokein.
Herald added subscribers: cfe-commits, xazax.hun.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52187

Files:
  test/clang-tidy/bugprone-unused-return-value-custom.cpp
  test/clang-tidy/bugprone-unused-return-value.cpp

Index: test/clang-tidy/bugprone-unused-return-value.cpp
===
--- test/clang-tidy/bugprone-unused-return-value.cpp
+++ test/clang-tidy/bugprone-unused-return-value.cpp
@@ -74,93 +74,116 @@
 
 void warning() {
   std::async(increment, 42);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::async(std::launch::async, increment, 42);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   Foo F;
   std::launder(&F);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::remove(nullptr, nullptr, 1);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::remove_if(nullptr, nullptr, nullptr);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::unique(nullptr, nullptr);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::unique_ptr UPtr;
   UPtr.release();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::string Str;
   Str.empty();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   std::vector Vec;
   Vec.empty();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
 
   // test discarding return values inside different kinds of statements
 
   auto Lambda = [] { std::remove(nullptr, nullptr, 1); };
-  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:22: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:22: note: cast the expression to void to silence this warning
 
   if (true)
 std::remove(nullptr, nullptr, 1);
-  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  // CHECK-NOTES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
   else if (true)
 std::remove(nullptr, nullpt

[PATCH] D52186: [clang-tidy] use CHECK-NOTES in bugprone-forwarding-reference-overload

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, alexfh, hokein.
Herald added subscribers: cfe-commits, xazax.hun.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52186

Files:
  test/clang-tidy/bugprone-forwarding-reference-overload.cpp


Index: test/clang-tidy/bugprone-forwarding-reference-overload.cpp
===
--- test/clang-tidy/bugprone-forwarding-reference-overload.cpp
+++ test/clang-tidy/bugprone-forwarding-reference-overload.cpp
@@ -20,27 +20,34 @@
 class Test1 {
 public:
   template  Test1(T &&n);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a 
forwarding reference can hide the copy and move constructors 
[bugprone-forwarding-reference-overload]
+  // CHECK-NOTES: [[@LINE-1]]:25: warning: constructor accepting a forwarding 
reference can hide the copy and move constructors 
[bugprone-forwarding-reference-overload]
+  // CHECK-NOTES: 48:3: note: copy constructor declared here
+  // CHECK-NOTES: 49:3: note: copy constructor declared here
+  // CHECK-NOTES: 50:3: note: move constructor declared here
 
   template  Test1(T &&n, int i = 5, ...);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a 
forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding 
reference can hide the copy and move constructors
+  // CHECK-NOTES: 48:3: note: copy constructor declared here
+  // CHECK-NOTES: 49:3: note: copy constructor declared here
+  // CHECK-NOTES: 50:3: note: move constructor declared here
 
   template ::type>
   Test1(T &&n);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a 
forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding 
reference can hide the copy and move constructors
+  // CHECK-NOTES: 48:3: note: copy constructor declared here
+  // CHECK-NOTES: 49:3: note: copy constructor declared here
+  // CHECK-NOTES: 50:3: note: move constructor declared here
 
   template 
   Test1(T &&n, typename foo::enable_if::type i = 5, ...);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a 
forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding 
reference can hide the copy and move constructors
+  // CHECK-NOTES: 48:3: note: copy constructor declared here
+  // CHECK-NOTES: 49:3: note: copy constructor declared here
+  // CHECK-NOTES: 50:3: note: move constructor declared here
 
   Test1(const Test1 &other) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here
-
   Test1(Test1 &other) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here
-
   Test1(Test1 &&other) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: move constructor declared here
 };
 
 template  class Test2 {
@@ -96,10 +103,10 @@
 class Test4 {
 public:
   template  Test4(T &&n);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a 
forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding 
reference can hide the copy and move constructors
 
   Test4(const Test4 &rhs);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here
+  // CHECK-NOTES: :[[@LINE-1]]:3: note: copy constructor declared here
 };
 
 // Nothing can be hidden, the copy constructor is implicitly deleted.
@@ -114,10 +121,10 @@
 class Test6 {
 public:
   template  Test6(T &&n);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a 
forwarding reference can hide the move constructor
+  // CHECK-NOTES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding 
reference can hide the move constructor
 
   Test6(Test6 &&rhs);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: move constructor declared here
+  // CHECK-NOTES: :[[@LINE-1]]:3: note: move constructor declared here
 private:
   Test6(const Test6 &rhs);
 };
@@ -141,5 +148,5 @@
 public:
   template  >
   constexpr variant(_Arg&& __arg) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: constructor accepting a 
forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: :[[@LINE-1]]:13: warning: constructor accepting a forwarding 
reference can hide the copy and move constructors
 };


Index: test/clang-tidy/bugprone-forwarding-reference-overload.cpp
===
--- test/clang-tidy/bugprone-forwarding-reference-overload.cpp
+++ test/clang-tidy/bugprone-forwarding-reference-overload.cpp
@@ -20,27 +20,34 @@
 class Test1 {
 public:
   template  Test1(T &&n);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructor accepting a forwarding reference can hide the copy and move constructors [bugprone-forwarding-reference-overload]
+  // CHECK-NOTE

[PATCH] D52185: [clang-tidy] use CHECK-NOTES in tests for bugprone-forward-declaration-namespace

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, alexfh, hokein.
Herald added subscribers: cfe-commits, xazax.hun.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52185

Files:
  test/clang-tidy/bugprone-forward-declaration-namespace.cpp


Index: test/clang-tidy/bugprone-forward-declaration-namespace.cpp
===
--- test/clang-tidy/bugprone-forward-declaration-namespace.cpp
+++ test/clang-tidy/bugprone-forward-declaration-namespace.cpp
@@ -3,19 +3,19 @@
 namespace {
 // This is a declaration in a wrong namespace.
 class T_A;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'na' [bugprone-forward-declaration-namespace]
-// CHECK-MESSAGES: note: a declaration of 'T_A' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but 
a definition with the same name 'T_A' found in another namespace '(global)' 
[bugprone-forward-declaration-namespace]
-// CHECK-MESSAGES: note: a definition of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'na' [bugprone-forward-declaration-namespace]
+// CHECK-NOTES: note: a declaration of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a 
definition with the same name 'T_A' found in another namespace '(global)' 
[bugprone-forward-declaration-namespace]
+// CHECK-NOTES: note: a definition of 'T_A' is found here
 }
 
 namespace na {
 // This is a declaration in a wrong namespace.
 class T_A;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'(anonymous)'
-// CHECK-MESSAGES: note: a declaration of 'T_A' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but 
a definition with the same name 'T_A' found in another namespace '(global)'
-// CHECK-MESSAGES: note: a definition of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'(anonymous)'
+// CHECK-NOTES: note: a declaration of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a 
definition with the same name 'T_A' found in another namespace '(global)'
+// CHECK-NOTES: note: a definition of 'T_A' is found here
 }
 
 class T_A;
@@ -25,8 +25,8 @@
 };
 
 class NESTED;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: no definition found for 'NESTED', 
but a definition with the same name 'NESTED' found in another namespace 
'(anonymous namespace)::nq::(anonymous)'
-// CHECK-MESSAGES: note: a definition of 'NESTED' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: no definition found for 'NESTED', but 
a definition with the same name 'NESTED' found in another namespace '(anonymous 
namespace)::nq::(anonymous)'
+// CHECK-NOTES: note: a definition of 'NESTED' is found here
 
 namespace {
 namespace nq {
@@ -38,10 +38,10 @@
 
 namespace na {
 class T_B;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
-// CHECK-MESSAGES: note: a declaration of 'T_B' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but 
a definition with the same name 'T_B' found in another namespace 'nb'
-// CHECK-MESSAGES: note: a definition of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
+// CHECK-NOTES: note: a declaration of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but a 
definition with the same name 'T_B' found in another namespace 'nb'
+// CHECK-NOTES: note: a definition of 'T_B' is found here
 }
 
 namespace nb {
@@ -56,10 +56,10 @@
 
 namespace na {
 class T_B;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
-// CHECK-MESSAGES: note: a declaration of 'T_B' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but 
a definition with the same name 'T_B' found in another namespace 'nb'
-// CHECK-MESSAGES: note: a definition of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
+// CHECK-NOTES: note: a declaration of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but a 
definition with the same name 'T_B' found in another namespace 'nb'
+// CHECK-NOTES: no

[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Is the condition for this assertion checked beforehand or could this create 
runtime failures?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52179



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


[PATCH] D52120: [analyzer] Treat std::{move, forward} as casts in ExprMutationAnalyzer.

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 165801.
shuaiwang marked an inline comment as done.
shuaiwang added a comment.

Added test case with copy-ctor & assignment operator taking value as param.


Repository:
  rC Clang

https://reviews.llvm.org/D52120

Files:
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -66,6 +66,25 @@
   return s;
 }
 
+const std::string StdRemoveReference =
+"namespace std {"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; };"
+"template struct remove_reference { typedef T type; }; }";
+
+const std::string StdMove =
+"namespace std {"
+"template typename remove_reference::type&& "
+"move(T&& t) noexcept {"
+"return static_cast::type&&>(t); } }";
+
+const std::string StdForward =
+"namespace std {"
+"template T&& "
+"forward(typename remove_reference::type& t) noexcept { return t; }"
+"template T&& "
+"forward(typename remove_reference::type&&) noexcept { return t; } }";
+
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
@@ -373,36 +392,87 @@
 }
 
 TEST(ExprMutationAnalyzerTest, Move) {
-  // Technically almost the same as ByNonConstRRefArgument, just double checking
-  const auto AST = tooling::buildASTFromCode(
-  "namespace std {"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template struct remove_reference { typedef T type; };"
-  "template typename std::remove_reference::type&& "
-  "move(T&& t) noexcept; }"
-  "void f() { struct A {}; A x; std::move(x); }");
-  const auto Results =
+  auto AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"void f() { struct A {}; A x; std::move(x); }");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x)"));
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "void f() { struct A {}; A x, y; std::move(x) = y; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("std::move(x) = y"));
+
+  AST = tooling::buildASTFromCode(StdRemoveReference + StdMove +
+  "void f() { int x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "struct S { S(); S(const S&); S& operator=(const S&); };"
+  "void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"struct S { S(); S(S&&); S& operator=(S&&); };"
+"void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("y = std::move(x)"));
+
+  AST =
+  tooling::buildASTFromCode(StdRemoveReference + StdMove +
+"struct S { S(); S(const S&); S(S&&);"
+"S& operator=(const S&); S& operator=(S&&); };"
+"void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("y = std::move(x)"));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "struct S { S(); S(const S&); S(S&&);"
+  "S& operator=(const S&); S& operator=(S&&); };"
+  "void f() { const S x; S y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(StdRemoveReference + StdMove +
+  "struct S { S(); S(S); S& operator=(S); };"
+  "void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = tooling::buildASTFromCode(
+  StdRemoveReference + StdMove +
+  "struct S{}; void f() { S x, y; y = std::move(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTCont

[PATCH] D52157: [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342407: [ASTMatchers] Let isArrow also support 
UnresolvedMemberExpr… (authored by shuaiwang, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52157

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -2235,6 +2235,32 @@
 
 
 
+MatcherCXXDependentScopeMemberExpr>isArrow
+Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
+int a;
+static int b;
+  };
+  template 
+  class Z {
+void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
+
+
+
 MatcherCXXMethodDecl>isConst
 Matches if the given method declaration is const.
 
@@ -3228,11 +3254,20 @@
 Given
   class Y {
 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
 int a;
 static int b;
   };
+  template 
+  class Z {
+void x() { this->m; }
+  };
 memberExpr(isArrow())
   matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
 
 
 
@@ -3886,6 +3921,32 @@
 
 
 
+MatcherUnresolvedMemberExpr>isArrow
+Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
+int a;
+static int b;
+  };
+  template 
+  class Z {
+void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
+
+
+
 MatcherVarDecl>hasAutomaticStorageDuration
 Matches a variable declaration that has automatic storage duration.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -4697,13 +4697,24 @@
 /// \code
 ///   class Y {
 /// void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+/// template  void f() { this->f(); f(); }
 /// int a;
 /// static int b;
 ///   };
+///   template 
+///   class Z {
+/// void x() { this->m; }
+///   };
 /// \endcode
 /// memberExpr(isArrow())
 ///   matches this->x, x, y.x, a, this->b
-AST_MATCHER(MemberExpr, isArrow) {
+/// cxxDependentScopeMemberExpr(isArrow())
+///   matches this->m
+/// unresolvedMemberExpr(isArrow())
+///   matches this->f, f
+AST_POLYMORPHIC_MATCHER(
+isArrow, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
+ CXXDependentScopeMemberExpr)) {
   return Node.isArrow();
 }
 
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -765,6 +765,11 @@
   memberExpr(isArrow(;
   EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
  memberExpr(isArrow(;
+  EXPECT_TRUE(matches("template  class Y { void x() { this->m; } };",
+  cxxDependentScopeMemberExpr(isArrow(;
+  EXPECT_TRUE(
+  notMatches("template  class Y { void x() { (*this).m; } };",
+ cxxDependentScopeMemberExpr(isArrow(;
 }
 
 TEST(IsArrow, MatchesStaticMemberVariablesViaArrow) {
@@ -783,6 +788,14 @@
   memberExpr(isArrow(;
   EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
  me

[PATCH] D52157: [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 165799.
shuaiwang marked an inline comment as done.
shuaiwang added a comment.

Addressed review comment.


Repository:
  rC Clang

https://reviews.llvm.org/D52157

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -440,7 +440,8 @@
   Error.get()).isNull());
   EXPECT_EQ("Incorrect type for arg 1. "
 "(Expected = Matcher) != "
-"(Actual = Matcher&Matcher)",
+"(Actual = Matcher&Matcher"
+")",
 Error->toString());
 }
 
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -27,7 +27,7 @@
nullptr));
 
   // Do not accept non-toplevel matchers.
-  EXPECT_FALSE(Finder.addDynamicMatcher(isArrow(), nullptr));
+  EXPECT_FALSE(Finder.addDynamicMatcher(isMain(), nullptr));
   EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), nullptr));
 }
 
Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -765,6 +765,11 @@
   memberExpr(isArrow(;
   EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
  memberExpr(isArrow(;
+  EXPECT_TRUE(matches("template  class Y { void x() { this->m; } };",
+  cxxDependentScopeMemberExpr(isArrow(;
+  EXPECT_TRUE(
+  notMatches("template  class Y { void x() { (*this).m; } };",
+ cxxDependentScopeMemberExpr(isArrow(;
 }
 
 TEST(IsArrow, MatchesStaticMemberVariablesViaArrow) {
@@ -783,6 +788,14 @@
   memberExpr(isArrow(;
   EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
  memberExpr(isArrow(;
+  EXPECT_TRUE(
+  matches("class Y { template  void x() { this->x(); } };",
+  unresolvedMemberExpr(isArrow(;
+  EXPECT_TRUE(matches("class Y { template  void x() { x(); } };",
+  unresolvedMemberExpr(isArrow(;
+  EXPECT_TRUE(
+  notMatches("class Y { template  void x() { (*this).x(); } };",
+ unresolvedMemberExpr(isArrow(;
 }
 
 TEST(ConversionDeclaration, IsExplicit) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4697,13 +4697,24 @@
 /// \code
 ///   class Y {
 /// void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+/// template  void f() { this->f(); f(); }
 /// int a;
 /// static int b;
 ///   };
+///   template 
+///   class Z {
+/// void x() { this->m; }
+///   };
 /// \endcode
 /// memberExpr(isArrow())
 ///   matches this->x, x, y.x, a, this->b
-AST_MATCHER(MemberExpr, isArrow) {
+/// cxxDependentScopeMemberExpr(isArrow())
+///   matches this->m
+/// unresolvedMemberExpr(isArrow())
+///   matches this->f, f
+AST_POLYMORPHIC_MATCHER(
+isArrow, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
+ CXXDependentScopeMemberExpr)) {
   return Node.isArrow();
 }
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2235,6 +2235,32 @@
 
 
 
+MatcherCXXDependentScopeMemberExpr>isArrow
+Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
+int a;
+static int b;
+  };
+  template 
+  class Z {
+void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
+
+
+
 MatcherCXXMethodDecl>isConst
 Matches if the given method declaration is const.
 
@@ -3228,11 +3254,20 @@
 Given
   class Y {
 void x() { this->x(); x(); Y y; y.x(); a; this->b; 

r342407 - [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-09-17 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Mon Sep 17 11:48:43 2018
New Revision: 342407

URL: http://llvm.org/viewvc/llvm-project?rev=342407&view=rev
Log:
[ASTMatchers] Let isArrow also support UnresolvedMemberExpr, 
CXXDependentScopeMemberExpr

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=342407&r1=342406&r2=342407&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Sep 17 11:48:43 2018
@@ -2235,6 +2235,32 @@ cxxConstructorDecl(hasAnyConstructorInit
 
 
 
+MatcherCXXDependentScopeMemberExpr>isArrow
+Matches member expressions 
that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
+int a;
+static int b;
+  };
+  template 
+  class Z {
+void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
+
+
+
 MatcherCXXMethodDecl>isConst
 Matches if the given method 
declaration is const.
 
@@ -3228,11 +3254,20 @@ Member calls on the implicit this pointe
 Given
   class Y {
 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
 int a;
 static int b;
   };
+  template 
+  class Z {
+void x() { this->m; }
+  };
 memberExpr(isArrow())
   matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
 
 
 
@@ -3886,6 +3921,32 @@ Example matches a || b (matcher = binary
 
 
 
+MatcherUnresolvedMemberExpr>isArrow
+Matches member expressions 
that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+template  void f() { this->f(); f(); }
+int a;
+static int b;
+  };
+  template 
+  class Z {
+void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f, f
+
+
+
 MatcherVarDecl>hasAutomaticStorageDuration
 Matches 
a variable declaration that has automatic storage duration.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=342407&r1=342406&r2=342407&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Sep 17 11:48:43 2018
@@ -4697,13 +4697,24 @@ AST_MATCHER(CXXMethodDecl, isUserProvide
 /// \code
 ///   class Y {
 /// void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+/// template  void f() { this->f(); f(); }
 /// int a;
 /// static int b;
 ///   };
+///   template 
+///   class Z {
+/// void x() { this->m; }
+///   };
 /// \endcode
 /// memberExpr(isArrow())
 ///   matches this->x, x, y.x, a, this->b
-AST_MATCHER(MemberExpr, isArrow) {
+/// cxxDependentScopeMemberExpr(isArrow())
+///   matches this->m
+/// unresolvedMemberExpr(isArrow())
+///   matches this->f, f
+AST_POLYMORPHIC_MATCHER(
+isArrow, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
+ CXXDependentScopeMemberExpr)) {
   return Node.isArrow();
 }
 

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=342407&r1=342406&r2=342407&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/u

Re: r342053 - [CodeGen] Align rtti and vtable data

2018-09-17 Thread Eric Christopher via cfe-commits
Thanks for looking Jordan!

On Mon, Sep 17, 2018, 11:16 AM Jordan Rupprecht 
wrote:

> > Interesting, what kind of failures?
> >
> > If they are causing you problems, of course feel free to revert.
> >
> > Dave
>
> Turns out they are all real issues which running the test under asan
> mode flags as global-buffer-overflow. I'm guessing the over-alignment
> was hiding the bug as reads there would be zero initialized, but now
> they are reading other non-zero data and crashing on that.
>
> So, this patch just exposes some buggy code. Let's not revert it.
> Sorry for the false alarm!
>
> -- Jordan
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52118: [Loopinfo] Remove one latch case in getLoopID. NFC.

2018-09-17 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342406: [Loopinfo] Remove one latch-case in getLoopID. NFC. 
(authored by Meinersbur, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52118?vs=165567&id=165798#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52118

Files:
  llvm/trunk/lib/Analysis/LoopInfo.cpp


Index: llvm/trunk/lib/Analysis/LoopInfo.cpp
===
--- llvm/trunk/lib/Analysis/LoopInfo.cpp
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp
@@ -213,26 +213,21 @@
 
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
-  if (BasicBlock *Latch = getLoopLatch()) {
-LoopID = Latch->getTerminator()->getMetadata(LLVMContext::MD_loop);
-  } else {
-assert(!getLoopLatch() &&
-   "The loop should have no single latch at this point");
-// Go through the latch blocks and check the terminator for the metadata.
-SmallVector LatchesBlocks;
-getLoopLatches(LatchesBlocks);
-for (BasicBlock *BB : LatchesBlocks) {
-  TerminatorInst *TI = BB->getTerminator();
-  MDNode *MD = TI->getMetadata(LLVMContext::MD_loop);
-
-  if (!MD)
-return nullptr;
-
-  if (!LoopID)
-LoopID = MD;
-  else if (MD != LoopID)
-return nullptr;
-}
+
+  // Go through the latch blocks and check the terminator for the metadata.
+  SmallVector LatchesBlocks;
+  getLoopLatches(LatchesBlocks);
+  for (BasicBlock *BB : LatchesBlocks) {
+TerminatorInst *TI = BB->getTerminator();
+MDNode *MD = TI->getMetadata(LLVMContext::MD_loop);
+
+if (!MD)
+  return nullptr;
+
+if (!LoopID)
+  LoopID = MD;
+else if (MD != LoopID)
+  return nullptr;
   }
   if (!LoopID || LoopID->getNumOperands() == 0 ||
   LoopID->getOperand(0) != LoopID)


Index: llvm/trunk/lib/Analysis/LoopInfo.cpp
===
--- llvm/trunk/lib/Analysis/LoopInfo.cpp
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp
@@ -213,26 +213,21 @@
 
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
-  if (BasicBlock *Latch = getLoopLatch()) {
-LoopID = Latch->getTerminator()->getMetadata(LLVMContext::MD_loop);
-  } else {
-assert(!getLoopLatch() &&
-   "The loop should have no single latch at this point");
-// Go through the latch blocks and check the terminator for the metadata.
-SmallVector LatchesBlocks;
-getLoopLatches(LatchesBlocks);
-for (BasicBlock *BB : LatchesBlocks) {
-  TerminatorInst *TI = BB->getTerminator();
-  MDNode *MD = TI->getMetadata(LLVMContext::MD_loop);
-
-  if (!MD)
-return nullptr;
-
-  if (!LoopID)
-LoopID = MD;
-  else if (MD != LoopID)
-return nullptr;
-}
+
+  // Go through the latch blocks and check the terminator for the metadata.
+  SmallVector LatchesBlocks;
+  getLoopLatches(LatchesBlocks);
+  for (BasicBlock *BB : LatchesBlocks) {
+TerminatorInst *TI = BB->getTerminator();
+MDNode *MD = TI->getMetadata(LLVMContext::MD_loop);
+
+if (!MD)
+  return nullptr;
+
+if (!LoopID)
+  LoopID = MD;
+else if (MD != LoopID)
+  return nullptr;
   }
   if (!LoopID || LoopID->getNumOperands() == 0 ||
   LoopID->getOperand(0) != LoopID)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52118: [Loopinfo] Remove one latch case in getLoopID. NFC.

2018-09-17 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In https://reviews.llvm.org/D52118#1235897, @jdoerfert wrote:

> > save an iteration over the loop's basic blocks (which is what getLoopLatch 
> > does)
>
> I'm not sure this is true. getLoopLatch() in LoopInfoImpl.h 
>  only traverses the children of the header in the inverse graph.
>  That should, I think, be similar to predecessors(Header) in case
>  of the IR CFG.


You're right. I changed the summary/commit message accordingly.


Repository:
  rC Clang

https://reviews.llvm.org/D52118



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


[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-09-17 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

Ping.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51657



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


[PATCH] D51808: [CUDA] Ignore uncallable functions when we check for usual deallocators.

2018-09-17 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 165794.
tra added a comment.

Addressed Richard's comments.
Moved clang-tidy changes into separate review https://reviews.llvm.org/D52179.


https://reviews.llvm.org/D51808

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCUDA/usual-deallocators.cu
  clang/test/SemaCUDA/call-host-fn-from-device.cu
  clang/test/SemaCUDA/usual-deallocators.cu

Index: clang/test/SemaCUDA/usual-deallocators.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/usual-deallocators.cu
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device \
+// RUN:   -emit-llvm -o /dev/null -verify=device
+// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown \
+// RUN:   -emit-llvm -o /dev/null -verify=host
+// RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown -fcuda-is-device \
+// RUN:   -emit-llvm -o /dev/null -verify=device
+// RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown \
+// RUN:   -emit-llvm -o /dev/null -verify=host
+
+#include "Inputs/cuda.h"
+extern __host__ void host_fn();
+extern __device__ void dev_fn();
+extern __host__ __device__ void hd_fn();
+
+struct H1D1 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __device__ void operator delete(void *) { dev_fn(); };
+};
+
+struct h1D1 {
+  __host__ void operator delete(void *) = delete;
+  // host-note@-1 {{'operator delete' has been explicitly marked deleted here}}
+  __device__ void operator delete(void *) { dev_fn(); };
+};
+
+struct H1d1 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __device__ void operator delete(void *) = delete;
+  // device-note@-1 {{'operator delete' has been explicitly marked deleted here}}
+};
+
+struct H1D2 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
+};
+
+struct H2D1 {
+  __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
+  __device__ void operator delete(void *) { dev_fn(); };
+};
+
+struct H2D2 {
+  __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
+  __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
+};
+
+struct H1D1D2 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __device__ void operator delete(void *) { dev_fn(); };
+  __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
+};
+
+struct H1H2D1 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
+  __device__ void operator delete(void *) { dev_fn(); };
+};
+
+struct H1H2D2 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
+  __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
+};
+
+struct H1H2D1D2 {
+  __host__ void operator delete(void *) { host_fn(); };
+  __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
+  __device__ void operator delete(void *) { dev_fn(); };
+  __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
+};
+
+
+template 
+__host__ __device__ void test_hd(void *p) {
+  T *t = (T *)p;
+  delete t;
+  // host-error@-1 {{attempt to use a deleted function}}
+  // device-error@-2 {{attempt to use a deleted function}}
+}
+
+__host__ __device__ void tests_hd(void *t) {
+  test_hd(t);
+  test_hd(t);
+  // host-note@-1 {{in instantiation of function template specialization 'test_hd' requested here}}
+  test_hd(t);
+  // device-note@-1 {{in instantiation of function template specialization 'test_hd' requested here}}
+  test_hd(t);
+  test_hd(t);
+  test_hd(t);
+  test_hd(t);
+  test_hd(t);
+  test_hd(t);
+  test_hd(t);
+  test_hd(t);
+}
Index: clang/test/SemaCUDA/call-host-fn-from-device.cu
===
--- clang/test/SemaCUDA/call-host-fn-from-device.cu
+++ clang/test/SemaCUDA/call-host-fn-from-device.cu
@@ -41,12 +41,12 @@
   operator Dummy() { return Dummy(); }
   // expected-note@-1 {{'operator Dummy' declared here}}
 
-  __host__ void operator delete(void*);
-  __device__ void operator delete(void*, size_t);
+  __host__ void operator delete(void *) { host_fn(); };
+  __device__ void operator delete(void*, __SIZE_TYPE__);
 };
 
 struct U {
-  __device__ void operator delete(void*, size_t) = delete;
+  __device__ void operator delete(void*, __SIZE_TYPE__) = delete;
   __host__ __device__ void operator delete(void*);
 };
 
Index: clang/test/CodeGenCUDA/usual-deallocators.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/usual-deallocators.cu
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device \
+// RUN:   -emi

[PATCH] D52179: [clang-tidy] Replace redundant checks with an assert().

2018-09-17 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: alexfh, rsmith.
Herald added subscribers: bixia, xazax.hun, jlebar, sanjoy.

findStyleKind is only called if D is an explicit identifier with a name,
so the checks for operators will never return true. The explicit assert()
enforces this invariant.


https://reviews.llvm.org/D52179

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp


Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -385,6 +385,9 @@
 const NamedDecl *D,
 const std::vector>
 &NamingStyles) {
+  assert(D->getIdentifier() && !D->getName().empty() && !D->isImplicit() &&
+ "Decl must be an explicit identifier with a name.");
+
   if (isa(D) && NamingStyles[SK_ObjcIvar])
 return SK_ObjcIvar;
   
@@ -548,8 +551,6 @@
 
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isMain() || !Decl->isUserProvided() ||
-Decl->isUsualDeallocationFunction() ||
-Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
 Decl->size_overridden_methods() > 0)
   return SK_Invalid;
 


Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -385,6 +385,9 @@
 const NamedDecl *D,
 const std::vector>
 &NamingStyles) {
+  assert(D->getIdentifier() && !D->getName().empty() && !D->isImplicit() &&
+ "Decl must be an explicit identifier with a name.");
+
   if (isa(D) && NamingStyles[SK_ObjcIvar])
 return SK_ObjcIvar;
   
@@ -548,8 +551,6 @@
 
   if (const auto *Decl = dyn_cast(D)) {
 if (Decl->isMain() || !Decl->isUserProvided() ||
-Decl->isUsualDeallocationFunction() ||
-Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
 Decl->size_overridden_methods() > 0)
   return SK_Invalid;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r342053 - [CodeGen] Align rtti and vtable data

2018-09-17 Thread Jordan Rupprecht via cfe-commits
> Interesting, what kind of failures?
>
> If they are causing you problems, of course feel free to revert.
>
> Dave

Turns out they are all real issues which running the test under asan
mode flags as global-buffer-overflow. I'm guessing the over-alignment
was hiding the bug as reads there would be zero initialized, but now
they are reading other non-zero data and crashing on that.

So, this patch just exposes some buggy code. Let's not revert it.
Sorry for the false alarm!

-- Jordan


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52158: [clang-tidy] Remove duplicated logic in UnnecessaryValueParamCheck and use FunctionParmMutationAnalyzer instead.

2018-09-17 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342403: [clang-tidy] Remove duplicated logic in 
UnnecessaryValueParamCheck and use… (authored by shuaiwang, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52158

Files:
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h


Index: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
@@ -12,6 +12,7 @@
 
 #include "../ClangTidy.h"
 #include "../utils/IncludeInserter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 
 namespace clang {
 namespace tidy {
@@ -29,11 +30,14 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void registerPPCallbacks(CompilerInstance &Compiler) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  void onEndOfTranslationUnit() override;
 
 private:
   void handleMoveFix(const ParmVarDecl &Var, const DeclRefExpr &CopyArgument,
  const ASTContext &Context);
 
+  llvm::DenseMap
+  MutationAnalyzers;
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
 };
Index: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -13,7 +13,6 @@
 #include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
 #include "../utils/TypeTraits.h"
-#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
@@ -92,21 +91,11 @@
   const auto *Param = Result.Nodes.getNodeAs("param");
   const auto *Function = Result.Nodes.getNodeAs("functionDecl");
 
-  // Do not trigger on non-const value parameters when they are mutated either
-  // within the function body or within init expression(s) when the function is
-  // a ctor.
-  if (ExprMutationAnalyzer(*Function->getBody(), *Result.Context)
-  .isMutated(Param))
+  FunctionParmMutationAnalyzer &Analyzer =
+  MutationAnalyzers.try_emplace(Function, *Function, *Result.Context)
+  .first->second;
+  if (Analyzer.isMutated(Param))
 return;
-  // CXXCtorInitializer might also mutate Param but they're not part of 
function
-  // body, so check them separately here.
-  if (const auto *Ctor = dyn_cast(Function)) {
-for (const auto *Init : Ctor->inits()) {
-  if (ExprMutationAnalyzer(*Init->getInit(), *Result.Context)
-  .isMutated(Param))
-return;
-}
-  }
 
   const bool IsConstQualified =
   Param->getType().getCanonicalType().isConstQualified();
@@ -186,6 +175,10 @@
 utils::IncludeSorter::toString(IncludeStyle));
 }
 
+void UnnecessaryValueParamCheck::onEndOfTranslationUnit() {
+  MutationAnalyzers.clear();
+}
+
 void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl &Var,
const DeclRefExpr &CopyArgument,
const ASTContext &Context) {


Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
@@ -12,6 +12,7 @@
 
 #include "../ClangTidy.h"
 #include "../utils/IncludeInserter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 
 namespace clang {
 namespace tidy {
@@ -29,11 +30,14 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void registerPPCallbacks(CompilerInstance &Compiler) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  void onEndOfTranslationUnit() override;
 
 private:
   void handleMoveFix(const ParmVarDecl &Var, const DeclRefExpr &CopyArgument,
  const ASTContext &Context);
 
+  llvm::DenseMap
+  MutationAnalyzers;
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
 };
Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -13,7 +13,6 @@

[clang-tools-extra] r342403 - [clang-tidy] Remove duplicated logic in UnnecessaryValueParamCheck and use FunctionParmMutationAnalyzer instead.

2018-09-17 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Mon Sep 17 10:59:51 2018
New Revision: 342403

URL: http://llvm.org/viewvc/llvm-project?rev=342403&view=rev
Log:
[clang-tidy] Remove duplicated logic in UnnecessaryValueParamCheck and use 
FunctionParmMutationAnalyzer instead.

Reviewers: alexfh, JonasToth, george.karpenkov

Subscribers: xazax.hun, kristof.beyls, chrib, a.sidorin, Szelethus, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=342403&r1=342402&r2=342403&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Mon Sep 17 10:59:51 2018
@@ -13,7 +13,6 @@
 #include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
 #include "../utils/TypeTraits.h"
-#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
@@ -92,21 +91,11 @@ void UnnecessaryValueParamCheck::check(c
   const auto *Param = Result.Nodes.getNodeAs("param");
   const auto *Function = Result.Nodes.getNodeAs("functionDecl");
 
-  // Do not trigger on non-const value parameters when they are mutated either
-  // within the function body or within init expression(s) when the function is
-  // a ctor.
-  if (ExprMutationAnalyzer(*Function->getBody(), *Result.Context)
-  .isMutated(Param))
+  FunctionParmMutationAnalyzer &Analyzer =
+  MutationAnalyzers.try_emplace(Function, *Function, *Result.Context)
+  .first->second;
+  if (Analyzer.isMutated(Param))
 return;
-  // CXXCtorInitializer might also mutate Param but they're not part of 
function
-  // body, so check them separately here.
-  if (const auto *Ctor = dyn_cast(Function)) {
-for (const auto *Init : Ctor->inits()) {
-  if (ExprMutationAnalyzer(*Init->getInit(), *Result.Context)
-  .isMutated(Param))
-return;
-}
-  }
 
   const bool IsConstQualified =
   Param->getType().getCanonicalType().isConstQualified();
@@ -186,6 +175,10 @@ void UnnecessaryValueParamCheck::storeOp
 utils::IncludeSorter::toString(IncludeStyle));
 }
 
+void UnnecessaryValueParamCheck::onEndOfTranslationUnit() {
+  MutationAnalyzers.clear();
+}
+
 void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl &Var,
const DeclRefExpr &CopyArgument,
const ASTContext &Context) {

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h?rev=342403&r1=342402&r2=342403&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.h 
Mon Sep 17 10:59:51 2018
@@ -12,6 +12,7 @@
 
 #include "../ClangTidy.h"
 #include "../utils/IncludeInserter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 
 namespace clang {
 namespace tidy {
@@ -29,11 +30,14 @@ public:
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void registerPPCallbacks(CompilerInstance &Compiler) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  void onEndOfTranslationUnit() override;
 
 private:
   void handleMoveFix(const ParmVarDecl &Var, const DeclRefExpr &CopyArgument,
  const ASTContext &Context);
 
+  llvm::DenseMap
+  MutationAnalyzers;
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
 };


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


[PATCH] D52058: Add Parameters to DW_AT_name Attribute of Template Variables

2018-09-17 Thread Matthew Voss via Phabricator via cfe-commits
ormris updated this revision to Diff 165789.
ormris added a comment.

- Removed unneeded comment
- Renamed variable


Repository:
  rC Clang

https://reviews.llvm.org/D52058

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-template-member.cpp

Index: test/CodeGenCXX/debug-info-template-member.cpp
===
--- test/CodeGenCXX/debug-info-template-member.cpp
+++ test/CodeGenCXX/debug-info-template-member.cpp
@@ -22,6 +22,19 @@
 // CHECK: [[X]] = !DIGlobalVariableExpression(var: [[XV:.*]], expr: !DIExpression())
 // CHECK: [[XV]] = distinct !DIGlobalVariable(name: "x",
 // CHECK-SAME:type: ![[OUTER_FOO_INNER_ID:[0-9]+]]
+//
+// CHECK: {{![0-9]+}} = distinct !DIGlobalVariable(
+// CHECK-SAME: name: "var"
+// CHECK-SAME: templateParams: {{![0-9]+}}
+// CHECK: !DITemplateTypeParameter(name: "T", type: [[TY:![0-9]+]])
+// CHECK: {{![0-9]+}} = distinct !DIGlobalVariable(
+// CHECK-SAME: name: "var"
+// CHECK-SAME: templateParams: {{![0-9]+}}
+// CHECK: !DITemplateTypeParameter(name: "P", type: {{![0-9]+}})
+// CHECK: {{![0-9]+}} = distinct !DIGlobalVariable(
+// CHECK-SAME: name: "varray"
+// CHECK-SAME: templateParams: {{![0-9]+}}
+// CHECK: !DITemplateValueParameter(name: "N", type: [[TY]], value: i32 1)
 
 // CHECK: ![[OUTER_FOO_INNER_ID:[0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "inner"{{.*}}, identifier:
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
@@ -103,3 +116,15 @@
 // declaration/reference in the compile unit.
 // CHECK: !DISubprogram(name: "MyClass"
 // CHECK-SAME:  scope: [[C]]
+
+template 
+T var = T();
+template 
+P var = P();
+template 
+T varray[N];
+void f3() {
+  var = 1;
+  var = 1;
+  varray[0] = 1;
+}
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -248,6 +248,11 @@
   llvm::DINodeArray CollectFunctionTemplateParams(const FunctionDecl *FD,
   llvm::DIFile *Unit);
 
+  /// A helper function to collect debug info for function template
+  /// parameters.
+  llvm::DINodeArray CollectVarTemplateParams(const VarDecl *VD,
+ llvm::DIFile *Unit);
+
   /// A helper function to collect debug info for template
   /// parameters.
   llvm::DINodeArray
@@ -645,7 +650,9 @@
   /// Collect various properties of a VarDecl.
   void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
unsigned &LineNo, QualType &T, StringRef &Name,
-   StringRef &LinkageName, llvm::DIScope *&VDContext);
+   StringRef &LinkageName,
+   llvm::MDTuple *&TemplateParameters,
+   llvm::DIScope *&VDContext);
 
   /// Allocate a copy of \p A using the DebugInfoNames allocator
   /// and return a reference to it. If multiple arguments are given the strings
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -41,6 +41,7 @@
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
@@ -1776,6 +1777,30 @@
   return llvm::DINodeArray();
 }
 
+llvm::DINodeArray CGDebugInfo::CollectVarTemplateParams(const VarDecl *VL,
+llvm::DIFile *Unit) {
+  if (auto *TS = dyn_cast(VL)) {
+if (TS->getSpecializedTemplateOrPartial()
+.is()) {
+  const TemplateParameterList *TList =
+  TS->getSpecializedTemplateOrPartial()
+  .get()
+  ->getTemplateParameters();
+  return CollectTemplateParams(TList, TS->getTemplateArgs().asArray(),
+   Unit);
+}
+
+if (TS->getSpecializedTemplateOrPartial().is()) {
+  const TemplateParameterList *TList = TS->getSpecializedTemplateOrPartial()
+   .get()
+   ->getTemplateParameters();
+  return CollectTemplateParams(TList, TS->getTemplateArgs().asArray(),
+   Unit);
+}
+  }
+  return llvm::DINodeArray();
+}
+
 llvm::DINodeArray CGDebugInfo::CollectCXXTemplateParams(
 const ClassTemplateSpecializationDecl *TSpecial, llvm::DIFile *Unit) {
   // Always get the full list of parameters, not just the ones from
@@ -3070,6 +3095,7 @@
 void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
   unsigned &LineNo, QualType &T,
   StringRef &Name, StringRef &Li

[PATCH] D52076: [CodeComplete] Add completions for filenames in #include directives.

2018-09-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 165787.
sammccall marked an inline comment as done.
sammccall added a comment.

Handle completion after a backslash in MSVC-compat mode.


Repository:
  rC Clang

https://reviews.llvm.org/D52076

Files:
  include/clang-c/Index.h
  include/clang/Lex/CodeCompletionHandler.h
  include/clang/Lex/Lexer.h
  include/clang/Lex/Preprocessor.h
  include/clang/Parse/Parser.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/Sema.h
  lib/Frontend/ASTUnit.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  lib/Parse/Parser.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/included-files.cpp
  tools/libclang/CIndexCodeCompletion.cpp

Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -499,6 +499,10 @@
   contexts = CXCompletionContext_NaturalLanguage;
   break;
 }
+case CodeCompletionContext::CCC_IncludedFile: {
+  contexts = CXCompletionContext_IncludedFile;
+  break;
+}
 case CodeCompletionContext::CCC_SelectorName: {
   contexts = CXCompletionContext_ObjCSelectorName;
   break;
Index: test/CodeCompletion/included-files.cpp
===
--- /dev/null
+++ test/CodeCompletion/included-files.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a
+// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h
+
+// Quoted string shows header-ish files from CWD, and all from system.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:5:13 %t/main.cc | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1-NOT: foo.cc"
+// CHECK-1: foo.h"
+// CHECK-1: foosys"
+
+// Quoted string with dir shows header-ish files in that subdir.
+#include "a/foosys"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:12:13 %t/main.cc | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2-NOT: foo.h"
+// CHECK-2: foosys.h"
+// CHECK-2-NOT: foosys"
+
+// Angled string showes all files, but only in system dirs.
+#include 
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:19:13 %t/main.cc | FileCheck -check-prefix=CHECK-3 %s
+// CHECK-3-NOT: foo.cc>
+// CHECK-3-NOT: foo.h>
+// CHECK-3: foosys>
+
+// Backslash handling.
+#include "a\foosys"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:26:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-4 %s
+// CHECK-4: foosys.h"
+
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -32,6 +32,8 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -7994,6 +7996,114 @@
   // for the expanded tokens.
 }
 
+// This handles completion inside an #include filename, e.g. #include  NativeRelDir = StringRef(RelDir);
+  llvm::sys::path::native(NativeRelDir);
+  auto FS = getSourceManager().getFileManager().getVirtualFileSystem();
+
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_IncludedFile);
+  llvm::DenseSet SeenResults; // To deduplicate results.
+
+  // Helper: adds one file or directory completion result.
+  auto AddCompletion = [&](StringRef Filename, bool IsDirectory) {
+SmallString<64> TypedChunk = Filename;
+// Directory completion is up to the slash, e.g. ' : '"');
+auto R = SeenResults.insert(TypedChunk);
+if (R.second) { // New completion
+  const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
+  *R.first = InternedTyped; // Avoid dangling StringRef.
+  CodeCompletionBuilder Builder(CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo());
+  Builder.AddTypedTextChunk(InternedTyped);
+  // The result is a "Pattern", which is pretty opaque.
+  // We may want to include the real filename to allow smart ranking.
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+  };
+
+  // Helper: scans IncludeDir for nice files, and adds results for each.
+  auto AddFilesFromIncludeDir = [&](StringRef IncludeDir, bool IsSystem) {
+llvm::SmallString<128> Dir = IncludeDir;
+if (!NativeRelDir.empty())
+  llvm::sys::path::append(Dir, NativeRelDir);
+
+std::error_code EC;
+unsigned Count = 0;
+for (auto It = FS->dir_begin(Dir, EC);
+ !EC && It != vfs::directory_iterator(); It.increment(EC)) {
+  if (++Count == 2500)

Re: r342053 - [CodeGen] Align rtti and vtable data

2018-09-17 Thread David Green via cfe-commits
Hello


Interesting, what kind of failures?


If they are causing you problems, of course feel free to revert.

Dave


From: Eric Christopher 
Sent: 17 September 2018 18:07:47
To: David Green
Cc: cfe-commits@lists.llvm.org
Subject: Re: r342053 - [CodeGen] Align rtti and vtable data

Hi David,

I'm seeing test failures after this patch. I'm trying to get a test case 
reduced, but can we revert until we figure it out?

Thanks!

-eric

On Wed, Sep 12, 2018 at 7:10 AM David Green via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: dmgreen
Date: Wed Sep 12 07:09:06 2018
New Revision: 342053

URL: http://llvm.org/viewvc/llvm-project?rev=342053&view=rev
Log:
[CodeGen] Align rtti and vtable data

Previously the alignment on the newly created rtti/typeinfo data was largely
not set, meaning that DataLayout::getPreferredAlignment was free to overalign
it to 16 bytes. This causes unnecessary code bloat.

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

Modified:
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
cfe/trunk/test/CodeGenCXX/vtable-align.cpp
cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=342053&r1=342052&r2=342053&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Sep 12 07:09:06 2018
@@ -119,10 +119,10 @@ llvm::GlobalVariable *CodeGenVTables::Ge

   llvm::ArrayType *ArrayType =
 llvm::ArrayType::get(CGM.Int8PtrTy, Builder.getVTTComponents().size());
+  unsigned Align = CGM.getDataLayout().getABITypeAlignment(CGM.Int8PtrTy);

-  llvm::GlobalVariable *GV =
-CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType,
-  llvm::GlobalValue::ExternalLinkage);
+  llvm::GlobalVariable *GV = CGM.CreateOrReplaceCXXRuntimeVariable(
+  Name, ArrayType, llvm::GlobalValue::ExternalLinkage, Align);
   GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
   return GV;
 }

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=342053&r1=342052&r2=342053&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Sep 12 07:09:06 2018
@@ -756,9 +756,11 @@ CodeGenVTables::GenerateConstructionVTab
   if (Linkage == llvm::GlobalVariable::AvailableExternallyLinkage)
 Linkage = llvm::GlobalVariable::InternalLinkage;

+  unsigned Align = CGM.getDataLayout().getABITypeAlignment(VTType);
+
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
-CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
+  CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage, Align);
   CGM.setGVProperties(VTable, RD);

   // V-tables are always unnamed_addr.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342053&r1=342052&r2=342053&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Sep 12 07:09:06 2018
@@ -3099,10 +3099,9 @@ CodeGenModule::GetAddrOfGlobal(GlobalDec
   IsForDefinition);
 }

-llvm::GlobalVariable *
-CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name,
-  llvm::Type *Ty,
-  llvm::GlobalValue::LinkageTypes Linkage) 
{
+llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable(
+StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage,
+unsigned Alignment) {
   llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name);
   llvm::GlobalVariable *OldGV = nullptr;

@@ -3138,6 +3137,8 @@ CodeGenModule::CreateOrReplaceCXXRuntime
   !GV->hasAvailableExternallyLinkage())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

+  GV->setAlignment(Alignment);
+
   return GV;
 }


Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=342053&r1=342052&r2=342053&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Sep 12 07:09:06 2018
@@ -764,7 +764,8 @@ public:
   /// bitcast to the new variable.
   llvm::GlobalVariabl

Re: r342053 - [CodeGen] Align rtti and vtable data

2018-09-17 Thread Eric Christopher via cfe-commits
Hi David,

I'm seeing test failures after this patch. I'm trying to get a test case
reduced, but can we revert until we figure it out?

Thanks!

-eric

On Wed, Sep 12, 2018 at 7:10 AM David Green via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dmgreen
> Date: Wed Sep 12 07:09:06 2018
> New Revision: 342053
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342053&view=rev
> Log:
> [CodeGen] Align rtti and vtable data
>
> Previously the alignment on the newly created rtti/typeinfo data was
> largely
> not set, meaning that DataLayout::getPreferredAlignment was free to
> overalign
> it to 16 bytes. This causes unnecessary code bloat.
>
> Differential Revision: https://reviews.llvm.org/D51416
>
> Modified:
> cfe/trunk/lib/CodeGen/CGVTT.cpp
> cfe/trunk/lib/CodeGen/CGVTables.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.h
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
> cfe/trunk/test/CodeGenCXX/vtable-align.cpp
> cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=342053&r1=342052&r2=342053&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Sep 12 07:09:06 2018
> @@ -119,10 +119,10 @@ llvm::GlobalVariable *CodeGenVTables::Ge
>
>llvm::ArrayType *ArrayType =
>  llvm::ArrayType::get(CGM.Int8PtrTy,
> Builder.getVTTComponents().size());
> +  unsigned Align = CGM.getDataLayout().getABITypeAlignment(CGM.Int8PtrTy);
>
> -  llvm::GlobalVariable *GV =
> -CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType,
> -
> llvm::GlobalValue::ExternalLinkage);
> +  llvm::GlobalVariable *GV = CGM.CreateOrReplaceCXXRuntimeVariable(
> +  Name, ArrayType, llvm::GlobalValue::ExternalLinkage, Align);
>GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
>return GV;
>  }
>
> Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=342053&r1=342052&r2=342053&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Sep 12 07:09:06 2018
> @@ -756,9 +756,11 @@ CodeGenVTables::GenerateConstructionVTab
>if (Linkage == llvm::GlobalVariable::AvailableExternallyLinkage)
>  Linkage = llvm::GlobalVariable::InternalLinkage;
>
> +  unsigned Align = CGM.getDataLayout().getABITypeAlignment(VTType);
> +
>// Create the variable that will hold the construction vtable.
>llvm::GlobalVariable *VTable =
> -CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
> +  CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage, Align);
>CGM.setGVProperties(VTable, RD);
>
>// V-tables are always unnamed_addr.
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342053&r1=342052&r2=342053&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Sep 12 07:09:06 2018
> @@ -3099,10 +3099,9 @@ CodeGenModule::GetAddrOfGlobal(GlobalDec
>IsForDefinition);
>  }
>
> -llvm::GlobalVariable *
> -CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name,
> -  llvm::Type *Ty,
> -  llvm::GlobalValue::LinkageTypes
> Linkage) {
> +llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable(
> +StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes
> Linkage,
> +unsigned Alignment) {
>llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name);
>llvm::GlobalVariable *OldGV = nullptr;
>
> @@ -3138,6 +3137,8 @@ CodeGenModule::CreateOrReplaceCXXRuntime
>!GV->hasAvailableExternallyLinkage())
>  GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
>
> +  GV->setAlignment(Alignment);
> +
>return GV;
>  }
>
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=342053&r1=342052&r2=342053&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Sep 12 07:09:06 2018
> @@ -764,7 +764,8 @@ public:
>/// bitcast to the new variable.
>llvm::GlobalVariable *
>CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
> -llvm::Glo

[PATCH] D52178: [clang-tidy] use CHECK-NOTES in tests for bugprone-argument-comment

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: alexfh, aaron.ballman, hokein.
Herald added subscribers: cfe-commits, xazax.hun.

This patch uses CHECK-NOTES for the tests.
Its part of an effort to test *ALL* generated diagnostics in clang-tidy,
as emitted notes were previously ignored.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52178

Files:
  test/clang-tidy/bugprone-argument-comment-gmock.cpp
  test/clang-tidy/bugprone-argument-comment-strict.cpp
  test/clang-tidy/bugprone-argument-comment.cpp

Index: test/clang-tidy/bugprone-argument-comment.cpp
===
--- test/clang-tidy/bugprone-argument-comment.cpp
+++ test/clang-tidy/bugprone-argument-comment.cpp
@@ -7,10 +7,10 @@
 
 void f(int x, int y);
 void g() {
-  // CHECK-MESSAGES: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
-  // CHECK-MESSAGES: :[[@LINE-3]]:12: note: 'x' declared here
-  // CHECK-MESSAGES: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
-  // CHECK-MESSAGES: :[[@LINE-5]]:19: note: 'y' declared here
+  // CHECK-NOTES: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
+  // CHECK-NOTES: [[@LINE-3]]:12: note: 'x' declared here
+  // CHECK-NOTES: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
+  // CHECK-NOTES: [[@LINE-5]]:19: note: 'y' declared here
   f(/*y=*/0, /*z=*/0);
   // CHECK-FIXES: {{^}}  f(/*y=*/0, /*z=*/0);
 
@@ -46,14 +46,17 @@
 void templates() {
   variadic(/*xxx=*/0, /*yyy=*/1);
   variadic2(/*zzU=*/0, /*xxx=*/1, /*yyy=*/2);
-  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument name 'zzU' in comment does not match parameter name 'zzz'
+  // CHECK-NOTES: [[@LINE-1]]:13: warning: argument name 'zzU' in comment does not match parameter name 'zzz'
+  // CHECK-NOTES: [[@LINE-2]]:13: note: FIX-IT applied suggested code changes
+  // CHECK-NOTES: :[[@LINE-7]]:20: note: 'zzz' declared here
   // CHECK-FIXES: variadic2(/*zzz=*/0, /*xxx=*/1, /*yyy=*/2);
 }
 
 #define FALSE 0
 void qqq(bool aaa);
 void f2() { qqq(/*bbb=*/FALSE); }
-// CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
+// CHECK-NOTES: [[@LINE-1]]:17: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
+// CHECK-NOTES: [[@LINE-3]]:15: note: 'aaa' declared here
 // CHECK-FIXES: void f2() { qqq(/*bbb=*/FALSE); }
 
 void f3(bool _with_underscores_);
@@ -64,26 +67,32 @@
 namespace ThisEditDistanceAboveThreshold {
 void f4(int xxx);
 void g() { f4(/*xyz=*/0); }
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'xyz' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'xyz' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
 // CHECK-FIXES: void g() { f4(/*xyz=*/0); }
 }
 
 namespace OtherEditDistanceAboveThreshold {
 void f5(int xxx, int yyy);
 void g() { f5(/*Zxx=*/0, 0); }
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-2]]:15: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-4]]:13: note: 'xxx' declared here
 // CHECK-FIXES: void g() { f5(/*xxx=*/0, 0); }
 struct C2 {
   C2(int xxx, int yyy);
 };
 C2 c2(/*Zxx=*/0, 0);
-// CHECK-MESSAGES: [[@LINE-1]]:7: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:7: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-2]]:7: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-5]]:10: note: 'xxx' declared here
 // CHECK-FIXES: C2 c2(/*xxx=*/0, 0);
 }
 
 namespace OtherEditDistanceBelowThreshold {
 void f6(int xxx, int yyy);
 void g() { f6(/*xxy=*/0, 0); }
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'xxy' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'xxy' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
 // CHECK-FIXES: void g() { f6(/*xxy=*/0, 0); }
 }
Index: test/clang-tidy/bugprone-argument-comment-strict.cpp
===
--- test/clang-tidy/bugprone-argument-comment-strict.cpp
+++ test/clang-tidy/bugprone-argument-comment-strict.cpp
@@ -5,15 +5,24 @@
 void g(int x_);
 void ignores_underscores() {
   f(/*With_Underscores=*/0);
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument name 'With_Underscores' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-1]]:5: warning: argument name 'With_Underscores' in comment does not match parameter name

[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-09-17 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added inline comments.



Comment at: include/clang/Basic/OpenCLExtensionTypes.def:27
+
+INTEL_SGAVC_TYPE(mce_payload_t, McePayload)
+INTEL_SGAVC_TYPE(ime_payload_t, ImePayload)

Anastasia wrote:
> AlexeySachkov wrote:
> > Anastasia wrote:
> > > From the specification of this extension I can't quite see if these types 
> > > have to be in Clang instead of the header. Can you please elaborate on 
> > > any example where it wouldn't be possible for this type to be declared in 
> > > the header using the technique explained in:
> > > https://clang.llvm.org/docs/UsersManual.html#opencl-extensions 
> > We cannot define these types in header because their layout is not defined 
> > in specification, i.e. all of these types are opaque
> This is not the reason to add functionality to Clang. You can easily sort 
> such things with target specific headers or even general headers (see 
> `ndrange_t` for example). Spec doesn't have to describe everything. The 
> question is whether there is something about those types that can't be 
> handled using standard include mechanisms. Usually it's prohibited behaviors 
> that can't be represented with such mechanisms. Like if some operations have 
> to be disallowed or allowed (since in OpenCL C you can't define user defined 
> operators) with the types.
> 
> I think the trend is to avoid adding complexity into Clang, unless there is 
> no other way to implement some feature correctly.
Major part of these types must support initialization only by zero. 
intel_sub_group_avc_mce_payload_t and intel_sub_group_avc_mce_result_t must 
support initialization only via special builtins defined in the spec. 
Corresponding errors must be reported. I think we can't implement this behavior 
using standard include mechanism, can we?

Possible value of the additional complexity, except builtin declaration, is 
that the patch is quite generic. So next time anyone wants to implement an 
extension with a type restrictions which can't be handled with the include 
mechanism, all that they needs to do is to modify this single file.


Repository:
  rC Clang

https://reviews.llvm.org/D51484



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


[PATCH] D49549: Change 'clang-test' to 'check-clang' on the hacking webpage

2018-09-17 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Hey Arnaud, let me know if you want me to commit this for you.


Repository:
  rC Clang

https://reviews.llvm.org/D49549



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


[PATCH] D51432: [AArch64] Unwinding support for return address signing

2018-09-17 Thread Luke Cheeseman via Phabricator via cfe-commits
LukeCheeseman updated this revision to Diff 165775.
LukeCheeseman added a comment.

return an error code when trying to sign return addresses and cross unwinding


https://reviews.llvm.org/D51432

Files:
  include/libunwind.h
  src/DwarfInstructions.hpp
  src/DwarfParser.hpp
  src/Registers.hpp
  src/dwarf2.h

Index: src/dwarf2.h
===
--- src/dwarf2.h
+++ src/dwarf2.h
@@ -49,7 +49,10 @@
   // GNU extensions
   DW_CFA_GNU_window_save  = 0x2D,
   DW_CFA_GNU_args_size= 0x2E,
-  DW_CFA_GNU_negative_offset_extended = 0x2F
+  DW_CFA_GNU_negative_offset_extended = 0x2F,
+
+  // AARCH64 extensions
+  DW_CFA_AARCH64_negate_ra_state  = 0x2D
 };
 
 
Index: src/Registers.hpp
===
--- src/Registers.hpp
+++ src/Registers.hpp
@@ -1783,7 +1783,7 @@
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t padding; // 16-byte align
+uint64_t __ra_sign_state; // RA sign state register
   };
 
   GPRs_registers;
@@ -1819,6 +1819,8 @@
 return false;
   if (regNum > 95)
 return false;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   return true;
@@ -1829,16 +1831,21 @@
 return _registers.__pc;
   if (regNum == UNW_REG_SP)
 return _registers.__sp;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return _registers.__ra_sign_state;
   if ((regNum >= 0) && (regNum < 32))
 return _registers.__x[regNum];
+
   _LIBUNWIND_ABORT("unsupported arm64 register");
 }
 
 inline void Registers_arm64::setRegister(int regNum, uint64_t value) {
   if (regNum == UNW_REG_IP)
 _registers.__pc = value;
   else if (regNum == UNW_REG_SP)
 _registers.__sp = value;
+  else if (regNum == UNW_ARM64_RA_SIGN_STATE)
+_registers.__ra_sign_state = value;
   else if ((regNum >= 0) && (regNum < 32))
 _registers.__x[regNum] = value;
   else
Index: src/DwarfParser.hpp
===
--- src/DwarfParser.hpp
+++ src/DwarfParser.hpp
@@ -666,6 +666,14 @@
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
+
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+case DW_CFA_AARCH64_negate_ra_state:
+  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
+  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
+  break;
+#endif
+
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {
Index: src/DwarfInstructions.hpp
===
--- src/DwarfInstructions.hpp
+++ src/DwarfInstructions.hpp
@@ -198,6 +198,24 @@
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+  // If the target is aarch64 then the return address may have been signed
+  // using the v8.3 pointer authentication extensions. The original
+  // return address needs to be authenticated before the return address is
+  // restored. autia1716 is used instead of autia as autia1716 assembles
+  // to a NOP on pre-v8.3a architectures.
+  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
+#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+return UNW_ECROSSRASIGNING;
+#else
+register unsigned long long x17 __asm("x17") = returnAddress;
+register unsigned long long x16 __asm("x16") = cfa;
+asm("autia1716": "+r"(x17): "r"(x16));
+returnAddress = x17;
+#endif
+  }
+#endif
+
   // Return address is address after call site instruction, so setting IP to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);
Index: include/libunwind.h
===
--- include/libunwind.h
+++ include/libunwind.h
@@ -57,6 +57,9 @@
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
+#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
+#endif
 };
 
 struct unw_context_t {
@@ -547,6 +550,8 @@
   UNW_ARM64_X31 = 31,
   UNW_ARM64_SP  = 31,
   // reserved block
+  UNW_ARM64_RA_SIGN_STATE = 34,
+  // reserved block
   UNW_ARM64_D0  = 64,
   UNW_ARM64_D1  = 65,
   UNW_ARM64_D2  = 66,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51223: Update tests for new YAMLIO polymorphic traits

2018-09-17 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a subscriber: tpr.
nhaehnle added a comment.

Adding @tpr as a subscriber due to the (admittedly maybe a bit indirect) 
MsgPack connection.


Repository:
  rC Clang

https://reviews.llvm.org/D51223



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


[PATCH] D52076: [CodeComplete] Add completions for filenames in #include directives.

2018-09-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Lex/Lexer.cpp:2086
+  StringRef PartialPath(PathStart, CompletionPoint - PathStart);
+  auto Slash = PartialPath.rfind('/');
+  StringRef Dir =

This will probably break for backslash includes.
We should probably also handle backslashes here when `LangOpts.MSVCCompat` is 
true.


Repository:
  rC Clang

https://reviews.llvm.org/D52076



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


[PATCH] D51432: [AArch64] Unwinding support for return address signing

2018-09-17 Thread Luke Cheeseman via Phabricator via cfe-commits
LukeCheeseman added inline comments.



Comment at: src/Registers.hpp:1835
+  if (((regNum >= 0) && (regNum < 32)) || regNum == UNW_ARM64_RA_SIGN_STATE)
 return _registers.__x[regNum];
+

olista01 wrote:
> When regNum == UNW_ARM64_RA_SIGN_STATE, the index into __x is out of range. 
> We'll need to add new storage to hold this value, I'd suggest replacing the 
> current padding value in the GPRs struct, as that will avoid changing the 
> layout expected by the context save/restore functions.
Good catch. Thanks, I didn't check the struct definition.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51432



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


[PATCH] D52141: Thread safety analysis: Run more tests with capability attributes [NFC]

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

LGTM, with a minor formatting nit.




Comment at: test/SemaCXX/thread-safety-annotations.h:29
+#define PT_GUARDED_VAR  __attribute__((pt_guarded_var))
+// Capabilities only
+#define EXCLUSIVE_UNLOCK_FUNCTION(...)  
__attribute__((release_capability(__VA_ARGS__)))

Can you add another newline above this comment, to fit my sense of aesthetics? 
:-P


Repository:
  rC Clang

https://reviews.llvm.org/D52141



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


[PATCH] D51789: [clang] Add the exclude_from_explicit_instantiation attribute

2018-09-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 165768.
ldionne added a comment.

Add example of how to use the attribute, per Aaron's comment.


Repository:
  rC Clang

https://reviews.llvm.org/D51789

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  
clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp

Index: clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test that we properly merge the exclude_from_explicit_instantiation
+// attribute on redeclarations.
+
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
+
+template 
+struct Foo {
+  // Declaration without the attribute, definition with the attribute.
+  void func1();
+
+  // Declaration with the attribute, definition without the attribute.
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void func2();
+
+  // Declaration with the attribute, definition with the attribute.
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void func3();
+};
+
+template 
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION void Foo::func1() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+void Foo::func2() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION void Foo::func3() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+struct Empty { };
+extern template struct Foo;
+
+int main() {
+  Foo foo;
+  foo.func1(); // expected-note{{in instantiation of}}
+  foo.func2(); // expected-note{{in instantiation of}}
+  foo.func3(); // expected-note{{in instantiation of}}
+}
Index: clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -Wno-unused-local-typedef -fsyntax-only -verify %s
+
+// Test that extern instantiation declarations cause members marked with
+// the exclude_from_explicit_instantiation attribute to be instantiated in
+// the current TU.
+
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
+
+template 
+struct Foo {
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void non_static_member_function1();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function2();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static inline void static_member_function1();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function2();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member;
+
+  struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION member_class1 {
+static void static_member_function() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+  };
+
+  struct member_class2 {
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+  };
+};
+
+template 
+inline void Foo::non_static_member_function1() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+void Foo::non_static_member_function2() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+inline void Foo::static_member_function1() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+void Foo::static_member_function2() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+int Foo::static_data_member = T::invalid; // expected-error{{no member named 'invalid' in 'Empty'}}
+
+struct Empty { };
+extern template struct Foo;
+
+int main() {
+  Foo foo;
+  foo.non_static_member_function1();   // expected-note{{in instantiation of}}
+  foo.non_static_member_function2();   // expe

[PATCH] D52173: Python bindings TypeError in reparse method

2018-09-17 Thread Axel Tillequin via Phabricator via cfe-commits
bdcht created this revision.
bdcht added a reviewer: clang.
bdcht added a project: clang.
Herald added a subscriber: cfe-commits.

In method 'reparse' of the python bindings (cindex.py), a TypeError is raised 
when 'unsaved_files_array' is set from name/value arguments when using Python3.
(This is due to Python3 mess with bytes vs unicode str...)
The way this unsaved_files_array is set here is not consistent with similar 
code in other methods like 'from_source' or 'codeComplete'. This proposed fix 
just
replicates what is done in from_source/codeComplete to set this ctypes 
unsaved_files_array.


Repository:
  rC Clang

https://reviews.llvm.org/D52173

Files:
  bindings/python/clang/cindex.py


Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -2983,8 +2983,8 @@
 print(value)
 if not isinstance(value, str):
 raise TypeError('Unexpected unsaved file contents.')
-unsaved_files_array[i].name = name
-unsaved_files_array[i].contents = value
+unsaved_files_array[i].name = b(name)
+unsaved_files_array[i].contents = b(value)
 unsaved_files_array[i].length = len(value)
 ptr = conf.lib.clang_reparseTranslationUnit(self, len(unsaved_files),
 unsaved_files_array, options)


Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -2983,8 +2983,8 @@
 print(value)
 if not isinstance(value, str):
 raise TypeError('Unexpected unsaved file contents.')
-unsaved_files_array[i].name = name
-unsaved_files_array[i].contents = value
+unsaved_files_array[i].name = b(name)
+unsaved_files_array[i].contents = b(value)
 unsaved_files_array[i].length = len(value)
 ptr = conf.lib.clang_reparseTranslationUnit(self, len(unsaved_files),
 unsaved_files_array, options)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51789: [clang] Add the exclude_from_explicit_instantiation attribute

2018-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2990
+on static and non-static member functions of class templates, static data
+members of class templates and member classes of class templates.
+  }];

An example that demonstrates how the attribute behaves would be appreciated. 
Having some exposition that explains why a user might want to write this 
attribute themselves would also be good.


Repository:
  rC Clang

https://reviews.llvm.org/D51789



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


[PATCH] D51789: [clang] Add the exclude_from_explicit_instantiation attribute

2018-09-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 165766.
ldionne added a comment.

Reformat warning message and run clang-format on changed lines.


Repository:
  rC Clang

https://reviews.llvm.org/D51789

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  
clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp
  
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp

Index: clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test that we properly merge the exclude_from_explicit_instantiation
+// attribute on redeclarations.
+
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
+
+template 
+struct Foo {
+  // Declaration without the attribute, definition with the attribute.
+  void func1();
+
+  // Declaration with the attribute, definition without the attribute.
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void func2();
+
+  // Declaration with the attribute, definition with the attribute.
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void func3();
+};
+
+template 
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION void Foo::func1() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+void Foo::func2() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION void Foo::func3() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+struct Empty { };
+extern template struct Foo;
+
+int main() {
+  Foo foo;
+  foo.func1(); // expected-note{{in instantiation of}}
+  foo.func2(); // expected-note{{in instantiation of}}
+  foo.func3(); // expected-note{{in instantiation of}}
+}
Index: clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -Wno-unused-local-typedef -fsyntax-only -verify %s
+
+// Test that extern instantiation declarations cause members marked with
+// the exclude_from_explicit_instantiation attribute to be instantiated in
+// the current TU.
+
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
+
+template 
+struct Foo {
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void non_static_member_function1();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function2();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static inline void static_member_function1();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function2();
+
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member;
+
+  struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION member_class1 {
+static void static_member_function() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+  };
+
+  struct member_class2 {
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+  };
+};
+
+template 
+inline void Foo::non_static_member_function1() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+void Foo::non_static_member_function2() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+inline void Foo::static_member_function1() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+void Foo::static_member_function2() {
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}
+}
+
+template 
+int Foo::static_data_member = T::invalid; // expected-error{{no member named 'invalid' in 'Empty'}}
+
+struct Empty { };
+extern template struct Foo;
+
+int main() {
+  Foo foo;
+  foo.non_static_member_function1();   // expected-note{{in instantiation of}}
+  foo.non_static_member_function2();   // ex

[PATCH] D51789: [clang] Add the exclude_from_explicit_instantiation attribute

2018-09-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4683-4686
+  "Member '%0' marked with 'exclude_from_explicit_instantiation' attribute is "
+  "not defined but an explicit template instantiation declaration exists. "
+  "Reliance on this member being defined by an explicit template instantiation 
"
+  "will lead to link errors.">;

rsmith wrote:
> Diagnostics should start with a lowercase letter and not end with a period.
> 
> That said, I'm not sure I see why this diagnostic is correct / useful. If the 
> entity is never used, then there's no link error. And if it is ever used, 
> then you should get an implicit instantiation like normal, and we already 
> have a diagnostic for the case where an entity is implicitly instantiated and 
> no definition is available.
> Diagnostics should start with a lowercase letter and not end with a period.

Done.

> That said, I'm not sure I see why this diagnostic is correct / useful. If the 
> entity is never used, then there's no link error. And if it is ever used, 
> then you should get an implicit instantiation like normal, and we already 
> have a diagnostic for the case where an entity is implicitly instantiated and 
> no definition is available.

This is not what happens right now. If you don't provide a definition but you 
try to call the function, an extern call will be produced (and that will result 
in a link error because any potential explicit instantiation won't provide the 
function). For example:

```
cat <
struct Foo {
  __attribute__((exclude_from_explicit_instantiation)) static void 
static_member_function();
};

extern template struct Foo;

int main() {
  Foo::static_member_function();
}
EOF
```

Results in the following LLVM IR:

```
; Function Attrs: noinline norecurse nounwind optnone
define i32 @main() #0 {
entry:
  call void @_ZN3FooIiE22static_member_functionEv()
  ret i32 0
}

declare void @_ZN3FooIiE22static_member_functionEv() #1
```

I guess we should be getting a warning or an error on the point of implicit 
instantiation instead, or is this behavior acceptable?




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2581-2582
+if (Function->hasAttr()) {
+  if (TSK == TSK_ExplicitInstantiationDeclaration &&
+  !Pattern->isDefined()) {
+Diag(Function->getLocation(),

rsmith wrote:
> Nit: we prefer to left-align continuation lines (clang-format will do that 
> for you).
Thanks for the heads up. I ran clang-format on all the lines I touched in this 
file.


Repository:
  rC Clang

https://reviews.llvm.org/D51789



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


[PATCH] D52157: [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

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

LGTM, with a request for the documentation.




Comment at: include/clang/ASTMatchers/ASTMatchers.h:4698-4702
 ///   class Y {
 /// void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
 /// int a;
 /// static int b;
 ///   };

Can you update the example to show how this works on the new kinds of member 
expressions?


Repository:
  rC Clang

https://reviews.llvm.org/D52157



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


[PATCH] D51867: [Diagnostics] Add error handling to FormatDiagnostic()

2018-09-17 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Hi Volodymyr, do you think you might take another look?


Repository:
  rC Clang

https://reviews.llvm.org/D51867



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


[PATCH] D52098: [Index] Add an option to collect macros from preprocesor.

2018-09-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/Index/IndexingAction.h:44
   bool IndexImplicitInstantiation = false;
+  bool IndexMacrosInPreprocessor = false;
 };

ilya-biryukov wrote:
> Maybe add a comment or change a name to indicate that this currently only 
> indexes macro definitions?
> Macro usages are still only indexed in `createIndexingAction`.
Done. Added a comment about this. I think `InPreprocessor` also indicates this 
to some extend.



Comment at: include/clang/Index/IndexingAction.h:53
 /// Recursively indexes all decls in the AST.
-/// Note that this does not index macros.
 void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,

ilya-biryukov wrote:
> This does not yet index macro references, maybe keep a mention of this in a 
> comment?
Covered this in the `IndexMacrosInPreprocessor` option, which seems to be a 
better place to document this. 



Comment at: include/clang/Index/IndexingAction.h:59
 /// Recursively indexes \p Decls.
-/// Note that this does not index macros.
-void indexTopLevelDecls(ASTContext &Ctx, ArrayRef Decls,
+void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP,
+ArrayRef Decls,

ilya-biryukov wrote:
> It means we won't have the API to index AST without the preprocessor.
> I don't have a strong opinion on whether this change is fine, our usages look 
> ok, but not sure if someone has a use-case that might break.
> 
> We could take a slightly more backwards-compatible approach, add an overload 
> without the preprocessor and assert that the `IndexMacrosInPreprocessor` 
> option is set to false.
> Not worth the trouble if all the clients want macros, though. WDYT?
yeah, not sure if it's worth the trouble. In theory, a PP should always be 
available when AST is available (I hope the index library could enforce 
somehow). And having two overloads with slightly different behaviors seems 
worse than unknown backward compatibility.



Comment at: unittests/Index/IndexTests.cpp:30
+  std::string QName;
+  SymbolRoleSet Roles;
+  SymbolInfo Info;

ilya-biryukov wrote:
> Roles and Info are neither tested nor output currently. Consider simplifying 
> the test code by collecting only qual names and using strings everywhere.
> More info could always be added when needed. 
> 
> Feel free to ignore, e.g. if you feel we need this for future revisions.
Sure.



Comment at: unittests/Index/IndexTests.cpp:61
+S.Roles = Roles;
+if (MI)
+  S.Info = getSymbolInfoForMacro(*MI);

ilya-biryukov wrote:
> Can this actually happen? It seems weird to have a macro occurrence without a 
> `MacroInfo`.
> Maybe try asserting that MI is non-null instead?
this can happen for macros that are #undefined. Not relevant anymore.  


Repository:
  rC Clang

https://reviews.llvm.org/D52098



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


[PATCH] D52098: [Index] Add an option to collect macros from preprocesor.

2018-09-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 165761.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- addressed review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D52098

Files:
  include/clang/Index/IndexingAction.h
  lib/Index/IndexingAction.cpp
  unittests/CMakeLists.txt
  unittests/Index/CMakeLists.txt
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- /dev/null
+++ unittests/Index/IndexTests.cpp
@@ -0,0 +1,125 @@
+//===--- IndexTests.cpp - Test indexing actions -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Index/IndexDataConsumer.h"
+#include "clang/Index/IndexSymbol.h"
+#include "clang/Index/IndexingAction.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace index {
+
+struct TestSymbol {
+  std::string QName;
+  // FIXME: add more information.
+};
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TestSymbol &S) {
+  return OS << S.QName;
+}
+
+namespace {
+class Indexer : public IndexDataConsumer {
+public:
+  bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
+   ArrayRef, SourceLocation,
+   ASTNodeInfo) override {
+const auto *ND = llvm::dyn_cast(D);
+if (!ND)
+  return true;
+TestSymbol S;
+S.QName = ND->getQualifiedNameAsString();
+Symbols.push_back(std::move(S));
+return true;
+  }
+
+  bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *,
+SymbolRoleSet, SourceLocation) override {
+TestSymbol S;
+S.QName = Name->getName();
+Symbols.push_back(std::move(S));
+return true;
+  }
+
+  std::vector Symbols;
+};
+
+class IndexAction : public ASTFrontendAction {
+public:
+  IndexAction(std::shared_ptr Index,
+  IndexingOptions Opts = IndexingOptions())
+  : Index(std::move(Index)), Opts(Opts) {}
+
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override {
+class Consumer : public ASTConsumer {
+  std::shared_ptr Index;
+  std::shared_ptr PP;
+  IndexingOptions Opts;
+
+public:
+  Consumer(std::shared_ptr Index, std::shared_ptr PP,
+   IndexingOptions Opts)
+  : Index(std::move(Index)), PP(std::move(PP)), Opts(Opts) {}
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+std::vector DeclsToIndex(
+Ctx.getTranslationUnitDecl()->decls().begin(),
+Ctx.getTranslationUnitDecl()->decls().end());
+indexTopLevelDecls(Ctx, *PP, DeclsToIndex, *Index, Opts);
+  }
+};
+return llvm::make_unique(Index, CI.getPreprocessorPtr(), Opts);
+  }
+
+private:
+  std::shared_ptr Index;
+  IndexingOptions Opts;
+};
+
+using testing::Contains;
+using testing::Not;
+using testing::UnorderedElementsAre;
+
+MATCHER_P(QName, Name, "") { return arg.QName == Name; }
+
+TEST(IndexTest, Simple) {
+  auto Index = std::make_shared();
+  tooling::runToolOnCode(new IndexAction(Index), "class X {}; void f() {}");
+  EXPECT_THAT(Index->Symbols, UnorderedElementsAre(QName("X"), QName("f")));
+}
+
+TEST(IndexTest, IndexPreprocessorMacros) {
+  std::string Code = "#define INDEX_MAC 1";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexMacrosInPreprocessor = true;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("INDEX_MAC")));
+
+  Opts.IndexMacrosInPreprocessor = false;
+  Index->Symbols.clear();
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, UnorderedElementsAre());
+}
+
+} // namespace
+} // namespace index
+} // namespace clang
Index: unittests/Index/CMakeLists.txt
===
--- /dev/null
+++ unittests/Index/CMakeLists.txt
@@ -0,0 +1,18 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Support
+  )
+
+add_clang_unittest(IndexTests
+  IndexTests.cpp
+  )
+
+target_link_libraries(IndexTests
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangIndex
+  clangLex
+  clangTooling
+  )
Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -

[PATCH] D52076: [CodeComplete] Add completions for filenames in #include directives.

2018-09-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

After experimenting, editor support for replacing non-identifier text before 
the cursor is... spotty at best.
So switched to just replacing the last path component.

(This makes me a bit sad because the completions now have closing quotes but 
not opening ones, which looks messy)




Comment at: lib/Lex/Lexer.cpp:1931
+  StringRef PartialPath(AfterQuote, CurPtr - 1 - AfterQuote);
+  auto Slash = PartialPath.rfind('/');
+  StringRef Dir =

ilya-biryukov wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > It's also valid to use `\` for path separators on Windows, maybe also 
> > > handle those?
> > > Clang also supports this when running e.g. `clang-cl /c foo.cpp`.
> > Ah yuck, that's true (for some value of "valid"). Pre-C++11 it was 
> > explicitly UB...
> > 
> > So if a codebase consistently uses backslashes, we're going to break that 
> > style at least sometimes: we can't know whether to complete `#include  > as ` > 
> > Any objection to just normalizing slashes for the whole include as part of 
> > completion?
> > e.g. `#include  > `#include `?
> > 
> > Anything else is going to be fiddly, probably only help a few users a 
> > little bit, and leave edge cases.
> If we normalize, we probably want a config option for Windows users to be 
> friendly to them.
> No good layer to add the option, though (except a compiler flag, but that 
> looks weird), so I don't think that's directly addressable. 
> 
> Also, do we want to actually change slashes **before** the path component we 
> are completing in the same include directive? 
> 1. If we do, I suspect we might have problems with the existing language 
> clients. We ran into problems when trying to add `.` to `->` fix-its.
> 2. If we don't, the completion label would look differently from what's 
> written. That's probably not a big deal.
So we can't reliably do the right thing here. e.g. consider completing a 
directory after `#include <` at the top of the file - which slash style?
I'm not sure that sometimes respecting `\`-style separators is better than 
never.
It's hard to see how we add an option for this, and unclear that it will help 
many people.

(Also this is totally nonstandard and the insertions we're suggesting will 
work. People can reasonably expect *some* friction from their tools if they're 
particular about an unusual style.)

> Also, do we want to actually change slashes before the path component we are 
> completing in the same include directive?

In the latest patch, these aren't part of the replacement range.



Comment at: lib/Sema/SemaCodeComplete.cpp:8021
+// Directory completion is up to the slash, e.g. ' : '"');
+auto R = SeenResults.insert(TypedChunk);

ilya-biryukov wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > Could we avoid adding `/`, `>` and `"` if it's currently missing?
> > > Otherwise it'll be annoying for editors that auto-add closing quotes and 
> > > completions when editing existing includes, i.e.
> > > ```
> > > // It's cool if we complete bar.h" (with closing quote) here:
> > > #include "foo/^
> > > // It's annoying if we complete an extra closing quote here:
> > > #include "foo/^"
> > > ```
> > Don't editors that add quotes/parens typically avoid duplicating them when 
> > they're typed/completed?
> > 
> > This isn't actually easy to do, because after completing `file.h` you want 
> > the cursor after the closing quote, and after completing `dir/` you want 
> > the cursor inside the closing quote. I don't see a way to do this with 
> > CodeCompletionString other than generating the quote in the former case but 
> > not the latter. (At least not one that doesn't break something else...)
> > Don't editors that add quotes/parens typically avoid duplicating them when 
> > they're typed/completed?
> They do that on typing, but not on completions, which are treated literally, 
> e.g. they'll an extra quote is actually added.
> I've checked in VSCode and it produces double quotes in those cases. Not sure 
> about the other editors that have this.
> That looks like a corner case my intuition is that other editors won't do 
> what we want either.
Added logic (to the lexer) to eat the closing quote.
This makes VSCode do the right thing. Some naive editors may still get this 
wrong though.



Comment at: lib/Sema/SemaCodeComplete.cpp:8028
+CodeCompleter->getCodeCompletionTUInfo());
+  Builder.AddTextChunk(InternedPrefix);
+  Builder.AddTypedTextChunk(InternedTyped);

ilya-biryukov wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > Maybe leave this out?
> > > When completing `std::^` the completion is `vector`, not `std::vector`.
> > > In the same spirit, for includes I would expect completions for `#include 
> > > ` to be `bar.h`, not ``.
> > I tried a few iterations here and this was the only one that didn'

[PATCH] D52076: [CodeComplete] Add completions for filenames in #include directives.

2018-09-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 165759.
sammccall added a comment.

Address comments.
Only complete last segment for better compatibility.


Repository:
  rC Clang

https://reviews.llvm.org/D52076

Files:
  include/clang-c/Index.h
  include/clang/Lex/CodeCompletionHandler.h
  include/clang/Lex/Lexer.h
  include/clang/Lex/Preprocessor.h
  include/clang/Parse/Parser.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/Sema.h
  lib/Frontend/ASTUnit.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  lib/Parse/Parser.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/included-files.cpp
  tools/libclang/CIndexCodeCompletion.cpp

Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -499,6 +499,10 @@
   contexts = CXCompletionContext_NaturalLanguage;
   break;
 }
+case CodeCompletionContext::CCC_IncludedFile: {
+  contexts = CXCompletionContext_IncludedFile;
+  break;
+}
 case CodeCompletionContext::CCC_SelectorName: {
   contexts = CXCompletionContext_ObjCSelectorName;
   break;
Index: test/CodeCompletion/included-files.cpp
===
--- /dev/null
+++ test/CodeCompletion/included-files.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a
+// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h
+
+// Quoted string shows header-ish files from CWD, and all from system.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:5:13 %t/main.cc | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1-NOT: foo.cc"
+// CHECK-1: foo.h"
+// CHECK-1: foosys"
+
+// Quoted string with dir shows header-ish files in that subdir.
+#include "a/foosys"
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:12:13 %t/main.cc | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2-NOT: foo.h"
+// CHECK-2: foosys.h"
+// CHECK-2-NOT: foosys"
+
+// Angled string showes all files, but only in system dirs.
+#include 
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:19:13 %t/main.cc | FileCheck -check-prefix=CHECK-3 %s
+// CHECK-3-NOT: foo.cc>
+// CHECK-3-NOT: foo.h>
+// CHECK-3: foosys>
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -32,6 +32,8 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -7994,6 +7996,114 @@
   // for the expanded tokens.
 }
 
+// This handles completion inside an #include filename, e.g. #include  NativeRelDir = StringRef(RelDir);
+  llvm::sys::path::native(NativeRelDir);
+  auto FS = getSourceManager().getFileManager().getVirtualFileSystem();
+
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_IncludedFile);
+  llvm::DenseSet SeenResults; // To deduplicate results.
+
+  // Helper: adds one file or directory completion result.
+  auto AddCompletion = [&](StringRef Filename, bool IsDirectory) {
+SmallString<64> TypedChunk = Filename;
+// Directory completion is up to the slash, e.g. ' : '"');
+auto R = SeenResults.insert(TypedChunk);
+if (R.second) { // New completion
+  const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
+  *R.first = InternedTyped; // Avoid dangling StringRef.
+  CodeCompletionBuilder Builder(CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo());
+  Builder.AddTypedTextChunk(InternedTyped);
+  // The result is a "Pattern", which is pretty opaque.
+  // We may want to include the real filename to allow smart ranking.
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+  };
+
+  // Helper: scans IncludeDir for nice files, and adds results for each.
+  auto AddFilesFromIncludeDir = [&](StringRef IncludeDir, bool IsSystem) {
+llvm::SmallString<128> Dir = IncludeDir;
+if (!NativeRelDir.empty())
+  llvm::sys::path::append(Dir, NativeRelDir);
+
+std::error_code EC;
+unsigned Count = 0;
+for (auto It = FS->dir_begin(Dir, EC);
+ !EC && It != vfs::directory_iterator(); It.increment(EC)) {
+  if (++Count == 2500) // If we happen to hit a huge directory,
+break; // bail out early so we're not too slow.
+  StringRef Filename = llvm::sys::path::filename(It->path());
+  switch (It->type()) {
+  case llvm::sys::fs::file_type::directory_fil

[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342393: [clang-tidy] fix PR37913, templated exception 
factory diagnosed correctly (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48714

Files:
  clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -2,6 +2,7 @@
 
 namespace std {
 class exception {};
+class invalid_argument : public exception {};
 } // namespace std
 
 class derived_exception : public std::exception {};
@@ -36,38 +37,38 @@
   try {
 throw non_derived_exception();
 // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-NOTES: 9:1: note: type defined here
+// CHECK-NOTES: 10:1: note: type defined here
   } catch (non_derived_exception &e) {
   }
   throw non_derived_exception();
   // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK-NOTES: 9:1: note: type defined here
+  // CHECK-NOTES: 10:1: note: type defined here
 
 // FIXME: More complicated kinds of inheritance should be checked later, but there is
 // currently no way use ASTMatchers for this kind of task.
 #if 0
   // Handle private inheritance cases correctly.
   try {
 throw bad_inheritance();
-// CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 10:1: note: type defined here
+// CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
+// CHECK NOTES: 11:1: note: type defined here
 throw no_good_inheritance();
-// CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 11:1: note: type defined here
+// CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
+// CHECK NOTES: 12:1: note: type defined here
 throw really_creative();
-// CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-// CHECK MESSAGES: 12:1: note: type defined here
+// CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
+// CHECK NOTES: 13:1: note: type defined here
   } catch (...) {
   }
   throw bad_inheritance();
-  // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 10:1: note: type defined here
+  // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
+  // CHECK NOTES: 11:1: note: type defined here
   throw no_good_inheritance();
-  // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 11:1: note: type defined here
+  // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
+  // CHECK NOTES: 12:1: note: type defined here
   throw really_creative();
-  // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-  // CHECK MESSAGES: 12:1: note: type defined here
+  // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
+  // CHECK NOTES: 13:1: note: type defined here
 #endif
 }
 
@@ -91,24 +92,40 @@
   throw deep_hierarchy(); // Ok
 
   try {
-throw terrible_idea(); // Ok, but multiple inheritance isn't clean
+throw terrible_idea();  // Ok, but multiple inheritance isn't clean
   } catch (std::exception &e) { // Can be caught as std::exception, even with multiple inheritance
   }
   throw terrible_idea(); // Ok, but multiple inheritance
 }
 
+void test_lambdas() {
+  auto BadLambda = []() { throw int(42); };
+  // CHECK-NOTES: [[@LINE-1]]:33: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+  auto GoodLambda = []() { throw derived_exception(); };
+}
+
 // Templated function that throws exception based on template type
 template 
 void ThrowException() { throw T(); }
 // CHECK-NOTES

[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 165756.
JonasToth added a comment.

get up to date to master


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48714

Files:
  clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  test/clang-tidy/hicpp-exception-baseclass.cpp

Index: test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- test/clang-tidy/hicpp-exception-baseclass.cpp
+++ test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -2,6 +2,7 @@
 
 namespace std {
 class exception {};
+class invalid_argument : public exception {};
 } // namespace std
 
 class derived_exception : public std::exception {};
@@ -36,38 +37,38 @@
   try {
 throw non_derived_exception();
 // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-NOTES: 9:1: note: type defined here
+// CHECK-NOTES: 10:1: note: type defined here
   } catch (non_derived_exception &e) {
   }
   throw non_derived_exception();
   // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK-NOTES: 9:1: note: type defined here
+  // CHECK-NOTES: 10:1: note: type defined here
 
 // FIXME: More complicated kinds of inheritance should be checked later, but there is
 // currently no way use ASTMatchers for this kind of task.
 #if 0
   // Handle private inheritance cases correctly.
   try {
 throw bad_inheritance();
-// CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 10:1: note: type defined here
+// CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
+// CHECK NOTES: 11:1: note: type defined here
 throw no_good_inheritance();
-// CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 11:1: note: type defined here
+// CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
+// CHECK NOTES: 12:1: note: type defined here
 throw really_creative();
-// CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-// CHECK MESSAGES: 12:1: note: type defined here
+// CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
+// CHECK NOTES: 13:1: note: type defined here
   } catch (...) {
   }
   throw bad_inheritance();
-  // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 10:1: note: type defined here
+  // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
+  // CHECK NOTES: 11:1: note: type defined here
   throw no_good_inheritance();
-  // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 11:1: note: type defined here
+  // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
+  // CHECK NOTES: 12:1: note: type defined here
   throw really_creative();
-  // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-  // CHECK MESSAGES: 12:1: note: type defined here
+  // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
+  // CHECK NOTES: 13:1: note: type defined here
 #endif
 }
 
@@ -91,24 +92,40 @@
   throw deep_hierarchy(); // Ok
 
   try {
-throw terrible_idea(); // Ok, but multiple inheritance isn't clean
+throw terrible_idea();  // Ok, but multiple inheritance isn't clean
   } catch (std::exception &e) { // Can be caught as std::exception, even with multiple inheritance
   }
   throw terrible_idea(); // Ok, but multiple inheritance
 }
 
+void test_lambdas() {
+  auto BadLambda = []() { throw int(42); };
+  // CHECK-NOTES: [[@LINE-1]]:33: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+  auto GoodLambda = []() { throw derived_exception(); };
+}
+
 // Templated function that throws exception based on template type
 template 
 void ThrowException() { throw T(); }
 // CHECK-NOTES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-NOTES: 120:1: note: type defined here
-// CHECK-NOTES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exc

[clang-tools-extra] r342393 - [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-09-17 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Mon Sep 17 06:55:10 2018
New Revision: 342393

URL: http://llvm.org/viewvc/llvm-project?rev=342393&view=rev
Log:
[clang-tidy] fix PR37913, templated exception factory diagnosed correctly

Summary:
PR37913 documents wrong behaviour for a templated exception factory function.
The check does misidentify dependent types as not derived from std::exception.

The fix to this problem is to ignore dependent types, the analysis works 
correctly
on the instantiated function.

Reviewers: aaron.ballman, alexfh, hokein, ilya-biryukov

Reviewed By: alexfh

Subscribers: lebedev.ri, nemanjai, mgorny, kbarton, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp?rev=342393&r1=342392&r2=342393&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp Mon 
Sep 17 06:55:10 2018
@@ -22,26 +22,44 @@ void ExceptionBaseclassCheck::registerMa
 return;
 
   Finder->addMatcher(
-  cxxThrowExpr(allOf(has(expr(unless(hasType(qualType(hasCanonicalType(
- hasDeclaration(cxxRecordDecl(isSameOrDerivedFrom(
- hasName("std::exception")),
- has(expr(unless(cxxUnresolvedConstructExpr(,
- eachOf(has(expr(hasType(namedDecl().bind("decl",
-anything(
+  cxxThrowExpr(
+  allOf(
+  unless(has(expr(anyOf(isTypeDependent(), isValueDependent(),
+  // The thrown value is not derived from 'std::exception'.
+  has(expr(unless(hasType(
+  qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
+  isSameOrDerivedFrom(hasName("::std::exception")),
+  // This condition is always true, but will bind to the
+  // template value if the thrown type is templated.
+  anyOf(has(expr(hasType(
+substTemplateTypeParmType().bind("templ_type",
+anything()),
+  // Bind to the declaration of the type of the value that
+  // is thrown. 'anything()' is necessary to always suceed
+  // in the 'eachOf' because builtin types are not
+  // 'namedDecl'.
+  eachOf(has(expr(hasType(namedDecl().bind("decl", 
anything(
   .bind("bad_throw"),
   this);
 }
 
 void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *BadThrow = Result.Nodes.getNodeAs("bad_throw");
+  assert(BadThrow && "Did not match the throw expression");
 
   diag(BadThrow->getSubExpr()->getBeginLoc(), "throwing an exception whose "
   "type %0 is not derived from "
   "'std::exception'")
   << BadThrow->getSubExpr()->getType() << BadThrow->getSourceRange();
 
-  const auto *TypeDecl = Result.Nodes.getNodeAs("decl");
-  if (TypeDecl != nullptr)
+  if (const auto *Template =
+  Result.Nodes.getNodeAs("templ_type"))
+diag(BadThrow->getSubExpr()->getBeginLoc(),
+ "type %0 is a template instantiation of %1", DiagnosticIDs::Note)
+<< BadThrow->getSubExpr()->getType()
+<< Template->getReplacedParameter()->getDecl();
+
+  if (const auto *TypeDecl = Result.Nodes.getNodeAs("decl"))
 diag(TypeDecl->getBeginLoc(), "type defined here", DiagnosticIDs::Note);
 }
 

Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp?rev=342393&r1=342392&r2=342393&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp Mon 
Sep 17 06:55:10 2018
@@ -2,6 +2,7 @@
 
 namespace std {
 class exception {};
+class invalid_argument : public exception {};
 } // namespace std
 
 class derived_exception : public std::exception {};
@@ -36,12 +37,12 @@ void problematic() {
   try {
 throw non_derived_exception();
 // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 
'non_derived_exception' is not derived from 'std::exception'
-// CHECK-NOTES: 9:1: note: type defined here
+// CHECK-NOTES: 10:1: note: type defined here
   } catch (non_deriv

[PATCH] D50171: [python] [tests] Update test_code_completion

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

@ilya-biryukov, gentle ping. I'd like to patch this for 7.0.0 in Gentoo. Do you 
think my patch would be good enough, or do you expect to submit something else 
soonish?


https://reviews.llvm.org/D50171



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


[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-09-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG




Comment at: test/clang-tidy/hicpp-exception-baseclass.cpp:191
+void templated_thrower() { throw T{}(); }
+// CHECK-MESSAGES: [[@LINE-1]]:34: warning: throwing an exception whose type 
'int' is not derived from 'std::exception'
+

JonasToth wrote:
> aaron.ballman wrote:
> > JonasToth wrote:
> > > hokein wrote:
> > > > JonasToth wrote:
> > > > > JonasToth wrote:
> > > > > > JonasToth wrote:
> > > > > > > alexfh wrote:
> > > > > > > > hokein wrote:
> > > > > > > > > I think giving message on the template function here is 
> > > > > > > > > confusing to users even it gets instantiated somewhere in 
> > > > > > > > > this TU -- because users have to find the location that 
> > > > > > > > > triggers the template instantiation.
> > > > > > > > > 
> > > > > > > > > Maybe 
> > > > > > > > > 1) Add a note which gives the instantiation location to the 
> > > > > > > > > message, or
> > > > > > > > > 2) ignore template case (some clang-tidy checks do this)
> > > > > > > > In this particular case it seems to be useful to get warnings 
> > > > > > > > from template instantiations. But the message will indeed be 
> > > > > > > > confusing.
> > > > > > > > 
> > > > > > > > Ideally, the message should have "in instantiation of xxx 
> > > > > > > > requested here" notes attached, as clang warnings do. But this 
> > > > > > > > is not working automatically, and it's implemented in Sema 
> > > > > > > > (`Sema::PrintInstantiationStack()` in 
> > > > > > > > lib/Sema/SemaTemplateInstantiate.cpp).
> > > > > > > > 
> > > > > > > > I wonder whether it's feasible to produce similar notes after 
> > > > > > > > Sema is dead? Maybe not the whole instantiation stack, but at 
> > > > > > > > least it should be possible to figure out that the enclosing 
> > > > > > > > function is a template instantiation or is a member function of 
> > > > > > > > an type that is an instantiation of a template. That would be 
> > > > > > > > useful for other checks as well.
> > > > > > > It should be possible to figure out, that the type comes from 
> > > > > > > template instantiation and that information could be added to the 
> > > > > > > warning.
> > > > > > > 
> > > > > > > I will take a look at Sema and think about something like this. 
> > > > > > > Unfortunatly i dont have a lot of time :/
> > > > > > I did look further into the issue, i think it is non-trivial.
> > > > > > 
> > > > > > The newly added case is not a templated exception perse, but there 
> > > > > > is a exception-factory, which is templated, that creates a normal 
> > > > > > exception.
> > > > > > 
> > > > > > I did add another note for template instantiations, but i could not 
> > > > > > figure out a way to give better diagnostics for the new use-case.
> > > > > @hokein and @alexfh Do you still have your concerns (the exception is 
> > > > > not a template value, but the factory creating them) or is this fix 
> > > > > acceptable?
> > > > I agree this is non-trivial. If we can't find a good solution at the 
> > > > moment, I'd prefer to ignore this case instead of adding some 
> > > > workarounds in the check, what do you think? 
> > > Honestly I would let it as is. This test case is not well readable, but 
> > > if we have something similar to
> > > 
> > > ```
> > > template 
> > > void SomeComplextFunction() {
> > > T ExceptionFactory;
> > > 
> > >if (SomeCondition) 
> > >  throw ExceptionFactory();
> > > }
> > > ```
> > > It is not that bad. And the check is still correct, just the code 
> > > triggering this condition just hides whats happening.
> > I don't think the diagnostic in this test is too confusing. Having the 
> > instantiation stack would be great, but that requires Sema support that we 
> > don't have access to, unfortunately.
> > 
> > The instantiation note currently isn't being printed in the test case, but 
> > I suspect that will add a bit of extra clarity to the message.
> The template note does not apply here, because the thrown value is not 
> templated.
The diagnostic here wouldn't be ideal, but if a proper fix is not feasible, I'd 
probably leave this as is. It's not the only check where instantiation stack in 
diagnostics would be helpful, and I don't expect this case to be frequent - if 
it is, let's wait for bug reports.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48714



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 165752.
JonasToth marked an inline comment as done.
JonasToth added a comment.

- use static functions instead anonymous namespace


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,121 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = &i;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = &i;
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 5 variables
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), TT2{42}, TT3;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+  // CHECK-FIXES: TemplatedType TT1(42);
+  // CHECK-FIXES: {{^  }}TemplatedType TT2{42};
+  // CHECK-FIXES: {{^  }}TemplatedType TT3;
+}
+
+void forbidden_transformations() {
+  for (int i = 0, j = 42; i < j; ++i)
+;
+}
+
+#define NULL 0
+#define MY_NICE_TYPE int **
+#define VAR_NAME(name) name##__LINE__
+#define A_BUNCH_OF_VARIABLES int m1 = 42, m2 = 43, m3 = 44;
+
+void macros() {
+  int *p1 = NULL, *p2 = NULL;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int *p1 = NULL;
+  // CHECK-FIXES: {{^  }}int *p2 = NULL;
+
+  // Macros are involved, so there will be no transformation
+  MY_NICE_TYPE p3, v1, v2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+
+  int VAR_NAME(v3),
+  VAR_NAME(v4),
+  VAR_NAME(v5);
+  // CHECK-MESSAGES: [[@LINE-3]]:3: warning: this statement declares 3 variables
+
+  A_BUNCH_OF_VARIABLES
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+}
Index: test/clang-tidy/readability-isolate-decl-cxx17.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate

Re: [clang-tools-extra] r342388 - [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void

2018-09-17 Thread IdrissRio via cfe-commits
Yes I have already make the fix commit. It was an error in the  tests. 

https://github.com/llvm-mirror/clang-tools-extra/commit/77ed1cd838a249d6134de9a6bdbe17ef46ecf946
 



Now on my Mac it compile and all the tests are ok. 
Should I try anything else ?

> Il giorno 17 set 2018, alle ore 15:14, Alexander Kornienko via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> ha scritto:
> 
> It looks like this commit breaks buildbots (e.g. 
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6711 
> ). 
> Could you take a look?
> 
> On Mon, Sep 17, 2018 at 2:33 PM Idriss Riouak via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: idrissrio
> Date: Mon Sep 17 05:29:29 2018
> New Revision: 342388
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=342388&view=rev 
> 
> Log:
> [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about 
> variable cast to void
> 
> Summary:
> Hello, i would like to suggest a fix for one of the checks in clang-tidy.The 
> bug was reported in https://bugs.llvm.org/show_bug.cgi?id=32575 
>  where you can find more 
> information.
> 
> For example:
> ```
> template 
> struct S {
>   template 
>   void g() const {
> int a;
> (void)a;
>   }
> };
> 
> void f() {
>   S().g();
> }
> ```
> 
> 
> this piece of code should not trigger any warning by the check 
> modernize-redundant-void-arg but when we execute the following command
> 
> 
> ```
> clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11
> ```
> 
> we obtain the following warning:
> 
> /Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6: 
> warning: redundant void argument list in function declaration 
> [modernize-redundant-void-arg]
> (void)a;
>  ^~~~
> 
> Reviewers: aaron.ballman, hokein, alexfh, JonasToth
> 
> Reviewed By: aaron.ballman, JonasToth
> 
> Subscribers: JonasToth, lebedev.ri, cfe-commits
> 
> Tags: #clang-tools-extra
> 
> Differential Revision: https://reviews.llvm.org/D52135 
> 
> 
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
> 
> Modified: 
> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=342388&r1=342387&r2=342388&view=diff
>  
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp 
> Mon Sep 17 05:29:29 2018
> @@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatc
>  return;
> 
>Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
> -  unless(isExternC()))
> +  unless(isInstantiated()), 
> unless(isExternC()))
>   .bind(FunctionId),
>   this);
>Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
> 
> Modified: 
> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342388&r1=342387&r2=342388&view=diff
>  
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
> Mon Sep 17 05:29:29 2018
> @@ -488,3 +488,64 @@ void lambda_expression_with_macro_test()
>// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list 
> in lambda expression [modernize-redundant-void-arg]
>// CHECK-FIXES: []() BODY;
>  }
> +
> +struct S_1 {
> +  void g_1(void) const {
> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument 
> list in function definition [modernize-redundant-void-arg]
> +// CHECK-FIXES: void g_1() const {
> +int a;
> +(void)a;
> +  }
> +
> +  void g_2() const {
> +int a;
> +(void)a;
> +  }
> +};
> +
> +template 
> +struct S_2 {
> +  void g_1(void) const {
> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void 

Re: [clang-tools-extra] r342388 - [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void

2018-09-17 Thread Alexander Kornienko via cfe-commits
Ah, now I see your fix in r342389. Thanks!

On Mon, Sep 17, 2018 at 3:15 PM Alexander Kornienko 
wrote:

> (If there's no clear idea of how to fix this, reverting until the fix is
> found is usually the best strategy.)
>
> On Mon, Sep 17, 2018 at 3:14 PM Alexander Kornienko 
> wrote:
>
>> It looks like this commit breaks buildbots (e.g.
>> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6711).
>> Could you take a look?
>>
>> On Mon, Sep 17, 2018 at 2:33 PM Idriss Riouak via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: idrissrio
>>> Date: Mon Sep 17 05:29:29 2018
>>> New Revision: 342388
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=342388&view=rev
>>> Log:
>>> [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains
>>> about variable cast to void
>>>
>>> Summary:
>>> Hello, i would like to suggest a fix for one of the checks in
>>> clang-tidy.The bug was reported in
>>> https://bugs.llvm.org/show_bug.cgi?id=32575 where you can find more
>>> information.
>>>
>>> For example:
>>> ```
>>> template 
>>> struct S {
>>>   template 
>>>   void g() const {
>>> int a;
>>> (void)a;
>>>   }
>>> };
>>>
>>> void f() {
>>>   S().g();
>>> }
>>> ```
>>>
>>>
>>> this piece of code should not trigger any warning by the check
>>> modernize-redundant-void-arg but when we execute the following command
>>>
>>>
>>> ```
>>> clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11
>>> ```
>>>
>>> we obtain the following warning:
>>>
>>> /Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6:
>>> warning: redundant void argument list in function declaration
>>> [modernize-redundant-void-arg]
>>> (void)a;
>>>  ^~~~
>>>
>>> Reviewers: aaron.ballman, hokein, alexfh, JonasToth
>>>
>>> Reviewed By: aaron.ballman, JonasToth
>>>
>>> Subscribers: JonasToth, lebedev.ri, cfe-commits
>>>
>>> Tags: #clang-tools-extra
>>>
>>> Differential Revision: https://reviews.llvm.org/D52135
>>>
>>> Modified:
>>>
>>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>>>
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=342388&r1=342387&r2=342388&view=diff
>>>
>>> ==
>>> ---
>>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>>> (original)
>>> +++
>>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Mon
>>> Sep 17 05:29:29 2018
>>> @@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatc
>>>  return;
>>>
>>>Finder->addMatcher(functionDecl(parameterCountIs(0),
>>> unless(isImplicit()),
>>> -  unless(isExternC()))
>>> +  unless(isInstantiated()),
>>> unless(isExternC()))
>>>   .bind(FunctionId),
>>>   this);
>>>Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
>>>
>>> Modified:
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342388&r1=342387&r2=342388&view=diff
>>>
>>> ==
>>> ---
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>>> (original)
>>> +++
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>>> Mon Sep 17 05:29:29 2018
>>> @@ -488,3 +488,64 @@ void lambda_expression_with_macro_test()
>>>// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument
>>> list in lambda expression [modernize-redundant-void-arg]
>>>// CHECK-FIXES: []() BODY;
>>>  }
>>> +
>>> +struct S_1 {
>>> +  void g_1(void) const {
>>> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void
>>> argument list in function definition [modernize-redundant-void-arg]
>>> +// CHECK-FIXES: void g_1() const {
>>> +int a;
>>> +(void)a;
>>> +  }
>>> +
>>> +  void g_2() const {
>>> +int a;
>>> +(void)a;
>>> +  }
>>> +};
>>> +
>>> +template 
>>> +struct S_2 {
>>> +  void g_1(void) const {
>>> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void
>>> argument list in function definition [modernize-redundant-void-arg]
>>> +// CHECK-FIXES: void g_1() const {
>>> +int a;
>>> +(void)a;
>>> +  }
>>> +
>>> +  void g_2() const {
>>> +int a;
>>> +(void)a;
>>> +  }
>>> +};
>>> +
>>> +template 
>>> +struct S_3 {
>>> +  template 
>>> +  void g_1(void) const {
>>> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void
>>> argument list in function definition [modernize-redundant-void-arg]
>>> +// CHECK-FIXES: void g_1() const

Re: [clang-tools-extra] r342388 - [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void

2018-09-17 Thread Alexander Kornienko via cfe-commits
(If there's no clear idea of how to fix this, reverting until the fix is
found is usually the best strategy.)

On Mon, Sep 17, 2018 at 3:14 PM Alexander Kornienko 
wrote:

> It looks like this commit breaks buildbots (e.g.
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6711).
> Could you take a look?
>
> On Mon, Sep 17, 2018 at 2:33 PM Idriss Riouak via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: idrissrio
>> Date: Mon Sep 17 05:29:29 2018
>> New Revision: 342388
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=342388&view=rev
>> Log:
>> [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains
>> about variable cast to void
>>
>> Summary:
>> Hello, i would like to suggest a fix for one of the checks in
>> clang-tidy.The bug was reported in
>> https://bugs.llvm.org/show_bug.cgi?id=32575 where you can find more
>> information.
>>
>> For example:
>> ```
>> template 
>> struct S {
>>   template 
>>   void g() const {
>> int a;
>> (void)a;
>>   }
>> };
>>
>> void f() {
>>   S().g();
>> }
>> ```
>>
>>
>> this piece of code should not trigger any warning by the check
>> modernize-redundant-void-arg but when we execute the following command
>>
>>
>> ```
>> clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11
>> ```
>>
>> we obtain the following warning:
>>
>> /Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6:
>> warning: redundant void argument list in function declaration
>> [modernize-redundant-void-arg]
>> (void)a;
>>  ^~~~
>>
>> Reviewers: aaron.ballman, hokein, alexfh, JonasToth
>>
>> Reviewed By: aaron.ballman, JonasToth
>>
>> Subscribers: JonasToth, lebedev.ri, cfe-commits
>>
>> Tags: #clang-tools-extra
>>
>> Differential Revision: https://reviews.llvm.org/D52135
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>>
>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=342388&r1=342387&r2=342388&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Mon
>> Sep 17 05:29:29 2018
>> @@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatc
>>  return;
>>
>>Finder->addMatcher(functionDecl(parameterCountIs(0),
>> unless(isImplicit()),
>> -  unless(isExternC()))
>> +  unless(isInstantiated()),
>> unless(isExternC()))
>>   .bind(FunctionId),
>>   this);
>>Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
>>
>> Modified:
>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342388&r1=342387&r2=342388&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>> Mon Sep 17 05:29:29 2018
>> @@ -488,3 +488,64 @@ void lambda_expression_with_macro_test()
>>// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument
>> list in lambda expression [modernize-redundant-void-arg]
>>// CHECK-FIXES: []() BODY;
>>  }
>> +
>> +struct S_1 {
>> +  void g_1(void) const {
>> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument
>> list in function definition [modernize-redundant-void-arg]
>> +// CHECK-FIXES: void g_1() const {
>> +int a;
>> +(void)a;
>> +  }
>> +
>> +  void g_2() const {
>> +int a;
>> +(void)a;
>> +  }
>> +};
>> +
>> +template 
>> +struct S_2 {
>> +  void g_1(void) const {
>> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument
>> list in function definition [modernize-redundant-void-arg]
>> +// CHECK-FIXES: void g_1() const {
>> +int a;
>> +(void)a;
>> +  }
>> +
>> +  void g_2() const {
>> +int a;
>> +(void)a;
>> +  }
>> +};
>> +
>> +template 
>> +struct S_3 {
>> +  template 
>> +  void g_1(void) const {
>> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument
>> list in function definition [modernize-redundant-void-arg]
>> +// CHECK-FIXES: void g_1() const {
>> +int a;
>> +(void)a;
>> +  }
>> +  template 
>> +  void g_2() const {
>> +int a;
>> +(void)a;
>> +  }
>> +};
>> +
>> +template 
>> +void g_3(void) {
>> +  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument
>> list in function

Re: [clang-tools-extra] r342388 - [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void

2018-09-17 Thread Alexander Kornienko via cfe-commits
It looks like this commit breaks buildbots (e.g.
http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6711).
Could you take a look?

On Mon, Sep 17, 2018 at 2:33 PM Idriss Riouak via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: idrissrio
> Date: Mon Sep 17 05:29:29 2018
> New Revision: 342388
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342388&view=rev
> Log:
> [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains
> about variable cast to void
>
> Summary:
> Hello, i would like to suggest a fix for one of the checks in
> clang-tidy.The bug was reported in
> https://bugs.llvm.org/show_bug.cgi?id=32575 where you can find more
> information.
>
> For example:
> ```
> template 
> struct S {
>   template 
>   void g() const {
> int a;
> (void)a;
>   }
> };
>
> void f() {
>   S().g();
> }
> ```
>
>
> this piece of code should not trigger any warning by the check
> modernize-redundant-void-arg but when we execute the following command
>
>
> ```
> clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11
> ```
>
> we obtain the following warning:
>
> /Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6:
> warning: redundant void argument list in function declaration
> [modernize-redundant-void-arg]
> (void)a;
>  ^~~~
>
> Reviewers: aaron.ballman, hokein, alexfh, JonasToth
>
> Reviewed By: aaron.ballman, JonasToth
>
> Subscribers: JonasToth, lebedev.ri, cfe-commits
>
> Tags: #clang-tools-extra
>
> Differential Revision: https://reviews.llvm.org/D52135
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=342388&r1=342387&r2=342388&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
> Mon Sep 17 05:29:29 2018
> @@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatc
>  return;
>
>Finder->addMatcher(functionDecl(parameterCountIs(0),
> unless(isImplicit()),
> -  unless(isExternC()))
> +  unless(isInstantiated()),
> unless(isExternC()))
>   .bind(FunctionId),
>   this);
>Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342388&r1=342387&r2=342388&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
> Mon Sep 17 05:29:29 2018
> @@ -488,3 +488,64 @@ void lambda_expression_with_macro_test()
>// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument
> list in lambda expression [modernize-redundant-void-arg]
>// CHECK-FIXES: []() BODY;
>  }
> +
> +struct S_1 {
> +  void g_1(void) const {
> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument
> list in function definition [modernize-redundant-void-arg]
> +// CHECK-FIXES: void g_1() const {
> +int a;
> +(void)a;
> +  }
> +
> +  void g_2() const {
> +int a;
> +(void)a;
> +  }
> +};
> +
> +template 
> +struct S_2 {
> +  void g_1(void) const {
> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument
> list in function definition [modernize-redundant-void-arg]
> +// CHECK-FIXES: void g_1() const {
> +int a;
> +(void)a;
> +  }
> +
> +  void g_2() const {
> +int a;
> +(void)a;
> +  }
> +};
> +
> +template 
> +struct S_3 {
> +  template 
> +  void g_1(void) const {
> +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument
> list in function definition [modernize-redundant-void-arg]
> +// CHECK-FIXES: void g_1() const {
> +int a;
> +(void)a;
> +  }
> +  template 
> +  void g_2() const {
> +int a;
> +(void)a;
> +  }
> +};
> +
> +template 
> +void g_3(void) {
> +  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument
> list in function definition [modernize-redundant-void-arg]
> +  // CHECK-FIXES: void g_3(){
> +  int a;
> +  (void)a;
> +}
> +
> +//Template instantiation
> +void f_testTemplate() {
> +  S_1();
> +  S_2();
> +  S_3();
> +  g_3();
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.l

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 5 inline comments as done.
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:71
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "make only one declaration per 
statement");
+

kbobyrev wrote:
> Maybe it's just me: this doesn't seem like a very clear diagnostic message, 
> probably needs better wording (can't think of anything in particular ATM, 
> though).
I updated the diagnostic to include the number of declared variables. I can 
reword again, for me its hard to think of something better.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 165749.
JonasToth marked an inline comment as done.
JonasToth added a comment.

- improve diagnostic to include number of declared variables


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,121 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = &i;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = &i;
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 5 variables
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), TT2{42}, TT3;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+  // CHECK-FIXES: TemplatedType TT1(42);
+  // CHECK-FIXES: {{^  }}TemplatedType TT2{42};
+  // CHECK-FIXES: {{^  }}TemplatedType TT3;
+}
+
+void forbidden_transformations() {
+  for (int i = 0, j = 42; i < j; ++i)
+;
+}
+
+#define NULL 0
+#define MY_NICE_TYPE int **
+#define VAR_NAME(name) name##__LINE__
+#define A_BUNCH_OF_VARIABLES int m1 = 42, m2 = 43, m3 = 44;
+
+void macros() {
+  int *p1 = NULL, *p2 = NULL;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int *p1 = NULL;
+  // CHECK-FIXES: {{^  }}int *p2 = NULL;
+
+  // Macros are involved, so there will be no transformation
+  MY_NICE_TYPE p3, v1, v2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+
+  int VAR_NAME(v3),
+  VAR_NAME(v4),
+  VAR_NAME(v5);
+  // CHECK-MESSAGES: [[@LINE-3]]:3: warning: this statement declares 3 variables
+
+  A_BUNCH_OF_VARIABLES
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+}
Index: test/clang-tidy/readability-isolate-decl-cxx17.cpp
===
--- /dev/null
+++ test/clang-tidy/readabili

[clang-tools-extra] r342389 - Fix

2018-09-17 Thread Idriss Riouak via cfe-commits
Author: idrissrio
Date: Mon Sep 17 05:58:19 2018
New Revision: 342389

URL: http://llvm.org/viewvc/llvm-project?rev=342389&view=rev
Log:
Fix

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342389&r1=342388&r2=342389&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
Mon Sep 17 05:58:19 2018
@@ -491,7 +491,7 @@ void lambda_expression_with_macro_test()
 
 struct S_1 {
   void g_1(void) const {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
 // CHECK-FIXES: void g_1() const {
 int a;
 (void)a;
@@ -506,7 +506,7 @@ struct S_1 {
 template 
 struct S_2 {
   void g_1(void) const {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
 // CHECK-FIXES: void g_1() const {
 int a;
 (void)a;
@@ -522,7 +522,7 @@ template 
 struct S_3 {
   template 
   void g_1(void) const {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
 // CHECK-FIXES: void g_1() const {
 int a;
 (void)a;
@@ -537,7 +537,7 @@ struct S_3 {
 template 
 void g_3(void) {
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
-  // CHECK-FIXES: void g_3(){
+  // CHECK-FIXES: void g_3() {
   int a;
   (void)a;
 }


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


[clang-tools-extra] r342388 - [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void

2018-09-17 Thread Idriss Riouak via cfe-commits
Author: idrissrio
Date: Mon Sep 17 05:29:29 2018
New Revision: 342388

URL: http://llvm.org/viewvc/llvm-project?rev=342388&view=rev
Log:
[Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about 
variable cast to void

Summary:
Hello, i would like to suggest a fix for one of the checks in clang-tidy.The 
bug was reported in https://bugs.llvm.org/show_bug.cgi?id=32575 where you can 
find more information.

For example:
```
template 
struct S {
  template 
  void g() const {
int a;
(void)a;
  }
};

void f() {
  S().g();
}
```


this piece of code should not trigger any warning by the check 
modernize-redundant-void-arg but when we execute the following command


```
clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11
```

we obtain the following warning:

/Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6: 
warning: redundant void argument list in function declaration 
[modernize-redundant-void-arg]
(void)a;
 ^~~~

Reviewers: aaron.ballman, hokein, alexfh, JonasToth

Reviewed By: aaron.ballman, JonasToth

Subscribers: JonasToth, lebedev.ri, cfe-commits

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=342388&r1=342387&r2=342388&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Mon 
Sep 17 05:29:29 2018
@@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatc
 return;
 
   Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
-  unless(isExternC()))
+  unless(isInstantiated()), 
unless(isExternC()))
  .bind(FunctionId),
  this);
   Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342388&r1=342387&r2=342388&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
Mon Sep 17 05:29:29 2018
@@ -488,3 +488,64 @@ void lambda_expression_with_macro_test()
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
   // CHECK-FIXES: []() BODY;
 }
+
+struct S_1 {
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+struct S_2 {
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+struct S_3 {
+  template 
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+  template 
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+void g_3(void) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
+  // CHECK-FIXES: void g_3(){
+  int a;
+  (void)a;
+}
+
+//Template instantiation
+void f_testTemplate() {
+  S_1();
+  S_2();
+  S_3();
+  g_3();
+}


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


[PATCH] D52135: [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void

2018-09-17 Thread Idriss via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE342388: [Clang-Tidy: modernize] Fix for 
modernize-redundant-void-arg: complains about… (authored by IdrissRio, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52135?vs=165741&id=165746#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52135

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  test/clang-tidy/modernize-redundant-void-arg.cpp


Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -49,7 +49,7 @@
 return;
 
   Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
-  unless(isExternC()))
+  unless(isInstantiated()), 
unless(isExternC()))
  .bind(FunctionId),
  this);
   Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -488,3 +488,64 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
   // CHECK-FIXES: []() BODY;
 }
+
+struct S_1 {
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+struct S_2 {
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+struct S_3 {
+  template 
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list 
in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+  template 
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+void g_3(void) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
+  // CHECK-FIXES: void g_3(){
+  int a;
+  (void)a;
+}
+
+//Template instantiation
+void f_testTemplate() {
+  S_1();
+  S_2();
+  S_3();
+  g_3();
+}


Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -49,7 +49,7 @@
 return;
 
   Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
-  unless(isExternC()))
+  unless(isInstantiated()), unless(isExternC()))
  .bind(FunctionId),
  this);
   Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -488,3 +488,64 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
   // CHECK-FIXES: []() BODY;
 }
+
+struct S_1 {
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+struct S_2 {
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+struct S_3 {
+  template 
+  void g_1(void) const {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: void g_1() const {
+int a;
+(void)a;
+  }
+  template 
+  void g_2() const {
+int a;
+(void)a;
+  }
+};
+
+template 
+void g_3(void) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+  // CHECK-FIXES: void g_3(){
+  int a;
+  (void)a;
+}
+

[PATCH] D52083: [clangd] Store OR iterator children in heap

2018-09-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> Seems like this optimization is not worth (yet?). As soon as we get more 
> proximity paths (and hence more OR iterator children) that might make sense.

WDYT about storing **all** the elements with the minimal doc-id outside the 
heap? I.e. we can pop **all** elements with the minimum doc-id on 'advance' and 
iterator creation.
That way we could potentially regain the improvements we've seen in the first 
version.


https://reviews.llvm.org/D52083



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 7 inline comments as done.
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:51
+
+return TypeAndName + " = " + Initializer + ";";
+  }

kbobyrev wrote:
> JonasToth wrote:
> > kbobyrev wrote:
> > > This seems to replace `int x = 5, y = 42;` with `int x = 5;int y = 42`. I 
> > > don't think that it becomes cleaner (in fact, without spaces in between 
> > > it looks cryptic). Consider formatting it or simply applying newlines (if 
> > > there were no newlines inbetween before).
> > I do not plan to do a lot of formatting here (maybe space or newline), 
> > because that clang-format area.
> While Clang-Tidy can apply Clang-Format on top of the Fix-Its, it will still 
> look weird in the Fix-Its previews. While supporting proper formatting, in 
> general, might be hard, it totally makes sense to do some basic formatting so 
> that editor integration warnings would look better, for example.
The current version adds a new line for each decl and keeps the indendation (as 
the other check does).

Because it does the slicing on commas the manual/custom formatting of the 
original code will stay. That might result in weird looking output for exotic 
variable declarations. I would like to ignore these cases, what do you think 
@kbobyrev ?



Comment at: clang-tidy/readability/IsolateDeclCheck.h:1
+//===--- IsolateDeclCheck.h - clang-tidy-*- C++ 
-*-===//
+//

kbobyrev wrote:
> nit: space between clang-tidy (also, in .cpp file)
That comes from the template `add_new_check.py`, do you want me to fix it there?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


  1   2   >