[PATCH] D60543: [clang] Update isDerivedFrom to support Objective-C classes 

2019-05-24 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore added a comment.
This revision is now accepted and ready to land.

Okay I now have an implementation of Option 2 that //works//.

I was hoping to find a more elegant solution but since this is the first 
working implementation of Option 2 I was able to produce, I figured I would 
present it to get feedback. My lack of familiarity with polymorphic matchers 
could be causing me to overlook some potential options. If anyone can think of 
a more elegant solution, I would be happy to implement it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543



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


[PATCH] D60543: [clang] Update isDerivedFrom to support Objective-C classes 

2019-05-24 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 201385.
stephanemoore marked an inline comment as done.
stephanemoore added a comment.

Add missing braces to multi-line if statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543

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

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -536,6 +536,38 @@
 cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"));
 }
 
+TEST(DeclarationMatcher, ObjCClassIsDerived) {
+  DeclarationMatcher IsDerivedFromX = objcInterfaceDecl(isDerivedFrom("X"));
+  EXPECT_TRUE(
+  matchesObjC("@interface X @end @interface Y : X @end", IsDerivedFromX));
+  EXPECT_TRUE(matchesObjC(
+  "@interface X @end @interface Y<__covariant ObjectType> : X @end",
+  IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@interface X @end", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@class X;", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@class Y;", IsDerivedFromX));
+
+  DeclarationMatcher IsAX = objcInterfaceDecl(isSameOrDerivedFrom("X"));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end", IsAX));
+  EXPECT_TRUE(matchesObjC("@interface X @end", IsAX));
+  EXPECT_TRUE(matchesObjC("@class X;", IsAX));
+  EXPECT_TRUE(notMatchesObjC("@interface Y @end", IsAX));
+  EXPECT_TRUE(notMatchesObjC("@class Y;", IsAX));
+
+  DeclarationMatcher ZIsDerivedFromX =
+  objcInterfaceDecl(hasName("Z"), isDerivedFrom("X"));
+  EXPECT_TRUE(matchesObjC(
+  "@interface X @end @interface Y : X @end @interface Z : Y @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(matchesObjC(
+  "@interface X @end typedef X Y; @interface Z : Y @end", ZIsDerivedFromX));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end typedef Y "
+  "V; typedef V W; @interface Z : W @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC(
+  "@interface Y @end typedef Y X; @interface Z : X @end", ZIsDerivedFromX));
+}
+
 TEST(DeclarationMatcher, IsLambda) {
   const auto IsLambda = cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(;
   EXPECT_TRUE(matches("auto x = []{};", IsLambda));
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2600,8 +2600,9 @@
   AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>(Name);
 }
 
-/// Matches C++ classes that are directly or indirectly derived from
-/// a class matching \c Base.
+/// Matches C++ classes that are directly or indirectly derived from a class
+/// matching \c Base, or Objective-C classes that directly or indirectly
+/// subclass a class matching \c Base.
 ///
 /// Note that a class is not considered to be derived from itself.
 ///
@@ -2621,31 +2622,94 @@
 ///   typedef Foo X;
 ///   class Bar : public Foo {};  // derived from a type that X is a typedef of
 /// \endcode
-AST_MATCHER_P(CXXRecordDecl, isDerivedFrom,
-  internal::Matcher, Base) {
-  return Finder->classIsDerivedFrom(, Base, Builder);
+///
+/// In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
+/// \code
+///   @interface NSObject @end
+///   @interface Bar : NSObject @end
+/// \endcode
+///
+/// Usable as: Matcher, Matcher
+AST_POLYMORPHIC_MATCHER_P(
+isDerivedFrom,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),
+internal::Matcher, Base) {
+  // Check if the node is a C++ struct/union/class.
+  if (const auto *RecordDecl = dyn_cast())
+return Finder->classIsDerivedFrom(RecordDecl, Base, Builder);
+
+  // Check if the node is an Objective-C class.
+  if (const auto *InterfaceDecl = dyn_cast()) {
+// Check if any of the superclasses of the class match.
+for (const ObjCInterfaceDecl *SuperClass = InterfaceDecl->getSuperClass();
+ SuperClass != nullptr; SuperClass = SuperClass->getSuperClass()) {
+  if (Base.matches(*SuperClass, Finder, Builder))
+return true;
+}
+  }
+
+  // No matches found.
+  return false;
 }
 
 /// Overloaded method as shortcut for \c isDerivedFrom(hasName(...)).
-AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isDerivedFrom, std::string, BaseName, 1) {
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+isDerivedFrom,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),
+std::string, BaseName, 1) {
   assert(!BaseName.empty());
-  return isDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
+
+  const auto M = isDerivedFrom(hasName(BaseName));
+
+  if 

[PATCH] D60543: [clang] Update isDerivedFrom to support Objective-C classes 

2019-05-24 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 201384.
stephanemoore added a comment.

Update isDerivedFrom and related matchers to polymorphic matchers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543

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

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -536,6 +536,38 @@
 cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"));
 }
 
+TEST(DeclarationMatcher, ObjCClassIsDerived) {
+  DeclarationMatcher IsDerivedFromX = objcInterfaceDecl(isDerivedFrom("X"));
+  EXPECT_TRUE(
+  matchesObjC("@interface X @end @interface Y : X @end", IsDerivedFromX));
+  EXPECT_TRUE(matchesObjC(
+  "@interface X @end @interface Y<__covariant ObjectType> : X @end",
+  IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@interface X @end", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@class X;", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@class Y;", IsDerivedFromX));
+
+  DeclarationMatcher IsAX = objcInterfaceDecl(isSameOrDerivedFrom("X"));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end", IsAX));
+  EXPECT_TRUE(matchesObjC("@interface X @end", IsAX));
+  EXPECT_TRUE(matchesObjC("@class X;", IsAX));
+  EXPECT_TRUE(notMatchesObjC("@interface Y @end", IsAX));
+  EXPECT_TRUE(notMatchesObjC("@class Y;", IsAX));
+
+  DeclarationMatcher ZIsDerivedFromX =
+  objcInterfaceDecl(hasName("Z"), isDerivedFrom("X"));
+  EXPECT_TRUE(matchesObjC(
+  "@interface X @end @interface Y : X @end @interface Z : Y @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(matchesObjC(
+  "@interface X @end typedef X Y; @interface Z : Y @end", ZIsDerivedFromX));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end typedef Y "
+  "V; typedef V W; @interface Z : W @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC(
+  "@interface Y @end typedef Y X; @interface Z : X @end", ZIsDerivedFromX));
+}
+
 TEST(DeclarationMatcher, IsLambda) {
   const auto IsLambda = cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(;
   EXPECT_TRUE(matches("auto x = []{};", IsLambda));
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2600,8 +2600,9 @@
   AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>(Name);
 }
 
-/// Matches C++ classes that are directly or indirectly derived from
-/// a class matching \c Base.
+/// Matches C++ classes that are directly or indirectly derived from a class
+/// matching \c Base, or Objective-C classes that directly or indirectly
+/// subclass a class matching \c Base.
 ///
 /// Note that a class is not considered to be derived from itself.
 ///
@@ -2621,31 +2622,91 @@
 ///   typedef Foo X;
 ///   class Bar : public Foo {};  // derived from a type that X is a typedef of
 /// \endcode
-AST_MATCHER_P(CXXRecordDecl, isDerivedFrom,
-  internal::Matcher, Base) {
-  return Finder->classIsDerivedFrom(, Base, Builder);
+///
+/// In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
+/// \code
+///   @interface NSObject @end
+///   @interface Bar : NSObject @end
+/// \endcode
+///
+/// Usable as: Matcher, Matcher
+AST_POLYMORPHIC_MATCHER_P(
+isDerivedFrom,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),
+internal::Matcher, Base) {
+  // Check if the node is a C++ struct/union/class.
+  if (const auto *RecordDecl = dyn_cast())
+return Finder->classIsDerivedFrom(RecordDecl, Base, Builder);
+
+  // Check if the node is an Objective-C class.
+  if (const auto *InterfaceDecl = dyn_cast()) {
+// Check if any of the superclasses of the class match.
+for (const ObjCInterfaceDecl *SuperClass = InterfaceDecl->getSuperClass();
+ SuperClass != nullptr; SuperClass = SuperClass->getSuperClass()) {
+  if (Base.matches(*SuperClass, Finder, Builder))
+return true;
+}
+  }
+
+  // No matches found.
+  return false;
 }
 
 /// Overloaded method as shortcut for \c isDerivedFrom(hasName(...)).
-AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isDerivedFrom, std::string, BaseName, 1) {
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+isDerivedFrom,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),
+std::string, BaseName, 1) {
   assert(!BaseName.empty());
-  return isDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
+
+  const auto M = isDerivedFrom(hasName(BaseName));
+
+  if (const auto *RecordDecl = 

[PATCH] D62442: [Driver] Update handling of c++ and runtime directories

2019-05-24 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, leonardchan, saugustine, echristo.
Herald added subscribers: cfe-commits, javed.absar, kubamracek.
Herald added a project: clang.

This is a follow up to r361432 and r361504 which addresses issues
introduced by those changes. Specifically, it avoids duplicating
file and runtime paths in case when the effective triple is the
same as the cannonical one. Furthermore, it fixes the broken multilib
setup in the Fuchsia driver and deduplicates some of the code.


Repository:
  rC Clang

https://reviews.llvm.org/D62442

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/Inputs/basic_fuchsia_tree/bin/.keep
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/asan/libc++.so
  clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/noexcept/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/asan/libc++.so
  clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/noexcept/libc++.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/asan/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/asan/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/.keep
  clang/test/Driver/fuchsia.c
  clang/test/Driver/fuchsia.cpp
  clang/test/Driver/linux-per-target-runtime-dir.c

Index: clang/test/Driver/linux-per-target-runtime-dir.c
===
--- clang/test/Driver/linux-per-target-runtime-dir.c
+++ clang/test/Driver/linux-per-target-runtime-dir.c
@@ -13,7 +13,6 @@
 // CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-PER-TARGET-RUNTIME: "--sysroot=[[SYSROOT]]"
 // CHECK-PER-TARGET-RUNTIME: "-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}c++"
-// CHECK-PER-TARGET-RUNTIME: "-L[[RESDIR]]{{/|}}x86_64-linux-gnu{{/|}}lib"
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=x86_64-linux-gnu \
Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -1,4 +1,5 @@
 // RUN: %clangxx %s -### -no-canonical-prefixes --target=x86_64-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 | FileCheck %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
@@ -44,29 +45,33 @@
 // CHECK-STATIC: "--pop-state"
 // CHECK-STATIC: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -nostdlib++ -fuse-ld=lld 2>&1 \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -nostdlib++ -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-NOSTDLIBXX
 // CHECK-NOSTDLIBXX-NOT: "-lc++"
 // CHECK-NOSTDLIBXX-NOT: "-lm"
 // CHECK-NOSTDLIBXX: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fsanitize=address \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=address \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fno-exceptions \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-NOEXCEPT-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fsanitize=address -fno-exceptions \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=address -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
 // CHECK-MULTILIB-X86: "-resource-dir" 

[PATCH] D62441: [analyzer] NFC: Introduce a convenient CallDescriptionMap class.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 201382.
NoQ added a comment.

Bring back an assertion in `findNode<>()`.


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

https://reviews.llvm.org/D62441

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -17,16 +17,24 @@
 namespace clang {
 namespace ento {
 
+// Find a node in the current AST that matches a matcher.
+template 
+const T *findNode(const Decl *Where, MatcherT What) {
+  using namespace ast_matchers;
+  auto Matches = match(decl(hasDescendant(What.bind("root"))),
+   *Where, Where->getASTContext());
+  assert(Matches.size() <= 1 && "Ambiguous match!");
+  assert(Matches.size() >= 1 && "Match not found!");
+  const T *Node = selectFirst("root", Matches);
+  assert(Node && "Type mismatch!");
+  return Node;
+}
+
 // Find a declaration in the current AST by name.
 template 
 const T *findDeclByName(const Decl *Where, StringRef Name) {
   using namespace ast_matchers;
-  auto Matcher = decl(hasDescendant(namedDecl(hasName(Name)).bind("d")));
-  auto Matches = match(Matcher, *Where, Where->getASTContext());
-  assert(Matches.size() == 1 && "Ambiguous name!");
-  const T *Node = selectFirst("d", Matches);
-  assert(Node && "Name not found!");
-  return Node;
+  return findNode(Where, namedDecl(hasName(Name)));
 }
 
 // A re-usable consumer that constructs ExprEngine out of CompilerInvocation.
Index: clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
@@ -0,0 +1,109 @@
+//===- unittests/StaticAnalyzer/CallDescriptionTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// Test that we can put a value into an int-type variable and load it
+// back from that variable. Test what happens if default bindings are used.
+class CallDescriptionConsumer : public ExprEngineConsumer {
+  const CallDescriptionMap 
+  void performTest(const Decl *D) {
+using namespace ast_matchers;
+
+if (!D->hasBody())
+  return;
+
+const CallExpr *CE = findNode(D, callExpr());
+const StackFrameContext *SFC =
+Eng.getAnalysisDeclContextManager().getStackFrame(D);
+ProgramStateRef State = Eng.getInitialState(SFC);
+CallEventRef<> Call =
+Eng.getStateManager().getCallEventManager().getCall(CE, State, SFC);
+
+const bool *LookupResult = CDM.lookup(*Call);
+// Check that we've found the function in the map
+// with the correct description.
+assert(LookupResult && *LookupResult);
+  }
+
+public:
+  CallDescriptionConsumer(CompilerInstance ,
+  const CallDescriptionMap )
+  : ExprEngineConsumer(C), CDM(CDM) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (const auto *D : DG)
+  performTest(D);
+return true;
+  }
+};
+
+class CallDescriptionAction : public ASTFrontendAction {
+  const CallDescriptionMap 
+
+public:
+  CallDescriptionAction(const CallDescriptionMap ) : CDM(CDM) {}
+
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef File) override {
+return llvm::make_unique(Compiler, CDM);
+  }
+};
+
+TEST(CallEvent, CallDescription) {
+  // Test simple name matching.
+  EXPECT_TRUE(tooling::runToolOnCode(
+  new CallDescriptionAction({
+  {{"bar"}, false},
+  {{"foo"}, true},
+  }), "void foo(); void bar() { foo(); }"));
+
+  // Test arguments check.
+  EXPECT_TRUE(tooling::runToolOnCode(
+  new CallDescriptionAction({
+  {{"foo", 1}, true},
+  {{"foo", 2}, false},
+  }), "void foo(int); void foo(int, int); void bar() { foo(1); }"));
+
+  // Test qualified names.
+  EXPECT_TRUE(tooling::runToolOnCode(
+  new CallDescriptionAction({
+  {{{"std", "basic_string", "c_str"}}, true},
+  }),
+  "namespace std { inline namespace __1 {"
+  "  template class basic_string {"
+  "  public:"
+  "T *c_str();"
+  "  };"
+  "}}"
+  "void foo() {"
+  "  using namespace std;"
+  "  basic_string 

[PATCH] D62441: [analyzer] Introduce a convenient CallDescriptionMap class.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet, 
mgorny.
Herald added a project: clang.

> "When choosing a container, remember vector is best;
>  Leave a comment to explain if you choose from the rest!"
> 
> -Tony Van Eerd, Postmodern C++ .

`CallDescriptionMap` would encapsulate the procedure of figuring out if any of 
the supported `CallDescription`s apply to a given `CallEvent`. Without such 
facility i constantly worry about somebody bashing me on reviews for using slow 
string switches and stuff. However when a `CallDescription` isn't a simple 
string, a linear lookup is almost unavoidable. So even though for now i only 
implement a linear lookup, i guess with a single interface we can later afford 
a string-map optimization specifically for simple `CallDescription`s.

I also add a few unittests for `CallDescription` with the help of this class.


Repository:
  rC Clang

https://reviews.llvm.org/D62441

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -17,16 +17,23 @@
 namespace clang {
 namespace ento {
 
+// Find a node in the current AST that matches a matcher.
+template 
+const T *findNode(const Decl *Where, MatcherT What) {
+  using namespace ast_matchers;
+  auto Matches = match(decl(hasDescendant(What.bind("root"))),
+   *Where, Where->getASTContext());
+  assert(Matches.size() <= 1 && "Ambiguous match!");
+  assert(Matches.size() >= 1 && "Match not found!");
+  const T *Node = selectFirst("root", Matches);
+  return Node;
+}
+
 // Find a declaration in the current AST by name.
 template 
 const T *findDeclByName(const Decl *Where, StringRef Name) {
   using namespace ast_matchers;
-  auto Matcher = decl(hasDescendant(namedDecl(hasName(Name)).bind("d")));
-  auto Matches = match(Matcher, *Where, Where->getASTContext());
-  assert(Matches.size() == 1 && "Ambiguous name!");
-  const T *Node = selectFirst("d", Matches);
-  assert(Node && "Name not found!");
-  return Node;
+  return findNode(Where, namedDecl(hasName(Name)));
 }
 
 // A re-usable consumer that constructs ExprEngine out of CompilerInvocation.
Index: clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
@@ -0,0 +1,109 @@
+//===- unittests/StaticAnalyzer/CallDescriptionTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// Test that we can put a value into an int-type variable and load it
+// back from that variable. Test what happens if default bindings are used.
+class CallDescriptionConsumer : public ExprEngineConsumer {
+  const CallDescriptionMap 
+  void performTest(const Decl *D) {
+using namespace ast_matchers;
+
+if (!D->hasBody())
+  return;
+
+const CallExpr *CE = findNode(D, callExpr());
+const StackFrameContext *SFC =
+Eng.getAnalysisDeclContextManager().getStackFrame(D);
+ProgramStateRef State = Eng.getInitialState(SFC);
+CallEventRef<> Call =
+Eng.getStateManager().getCallEventManager().getCall(CE, State, SFC);
+
+const bool *LookupResult = CDM.lookup(*Call);
+// Check that we've found the function in the map
+// with the correct description.
+assert(LookupResult && *LookupResult);
+  }
+
+public:
+  CallDescriptionConsumer(CompilerInstance ,
+  const CallDescriptionMap )
+  : ExprEngineConsumer(C), CDM(CDM) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (const auto *D : DG)
+  performTest(D);
+return true;
+  }
+};
+
+class CallDescriptionAction : public ASTFrontendAction {
+  const CallDescriptionMap 
+
+public:
+  CallDescriptionAction(const CallDescriptionMap ) : CDM(CDM) {}
+
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef File) override {
+return llvm::make_unique(Compiler, CDM);
+  }

[PATCH] D62440: [analyzer] NFC: Change evalCall() to provide a CallEvent.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.

This is mostly motivated by me being annoyed that in C many functions are 
implemented as builtins and everybody keeps forgetting about it while writing 
checkers, leading to checkers not working at all except on LIT tests, which is 
fairly hard to notice.

This is also a necessary step if we want to `evalCall()` calls that don't 
correspond to any `CallExpr`, such as automatic destructor calls.


Repository:
  rC Clang

https://reviews.llvm.org/D62440

Files:
  clang/include/clang/StaticAnalyzer/Core/Checker.h
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp

Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -650,7 +650,6 @@
 const ExplodedNodeSet ,
 const CallEvent ,
 ExprEngine ) {
-  const CallExpr *CE = cast(Call.getOriginExpr());
   for (const auto Pred : Src) {
 bool anyEvaluated = false;
 
@@ -659,16 +658,19 @@
 
 // Check if any of the EvalCall callbacks can evaluate the call.
 for (const auto EvalCallChecker : EvalCallCheckers) {
-  ProgramPoint::Kind K = ProgramPoint::PostStmtKind;
-  const ProgramPoint  =
-  ProgramPoint::getProgramPoint(CE, K, Pred->getLocationContext(),
-EvalCallChecker.Checker);
+  // TODO: Support the situation when the call doesn't correspond
+  // to any Expr.
+  ProgramPoint L = ProgramPoint::getProgramPoint(
+  cast(Call.getOriginExpr()),
+  ProgramPoint::PostStmtKind,
+  Pred->getLocationContext(),
+  EvalCallChecker.Checker);
   bool evaluated = false;
   { // CheckerContext generates transitions(populates checkDest) on
 // destruction, so introduce the scope to make sure it gets properly
 // populated.
 CheckerContext C(B, Eng, Pred, L);
-evaluated = EvalCallChecker(CE, C);
+evaluated = EvalCallChecker(Call, C);
   }
   assert(!(evaluated && anyEvaluated)
  && "There are more than one checkers evaluating the call");
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
@@ -71,7 +72,7 @@
   II_fsetpos(nullptr), II_clearerr(nullptr), II_feof(nullptr),
   II_ferror(nullptr), II_fileno(nullptr) {}
 
-  bool evalCall(const CallExpr *CE, CheckerContext ) const;
+  bool evalCall(const CallEvent , CheckerContext ) const;
   void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
 
 private:
@@ -103,11 +104,15 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(StreamMap, SymbolRef, StreamState)
 
 
-bool StreamChecker::evalCall(const CallExpr *CE, CheckerContext ) const {
-  const FunctionDecl *FD = C.getCalleeDecl(CE);
+bool StreamChecker::evalCall(const CallEvent , CheckerContext ) const {
+  const auto *FD = dyn_cast_or_null(Call.getDecl());
   if (!FD || FD->getKind() != Decl::Function)
 return false;
 
+  const auto *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return false;
+
   ASTContext  = C.getASTContext();
   if (!II_fopen)
 II_fopen = ("fopen");
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ 

[clang-tools-extra] r361687 - [clangd] tweaks: Add clangBasic dependency to LINK_LIBS

2019-05-24 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Fri May 24 18:35:14 2019
New Revision: 361687

URL: http://llvm.org/viewvc/llvm-project?rev=361687=rev
Log:
[clangd] tweaks: Add clangBasic dependency to LINK_LIBS

This is necessary to make builds with `-DBUILD_SHARED_LIBS=ON` work.

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

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt?rev=361687=361686=361687=diff
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt Fri May 24 
18:35:14 2019
@@ -17,6 +17,7 @@ add_clang_library(clangDaemonTweaks OBJE
 
   LINK_LIBS
   clangAST
+  clangBasic
   clangDaemon
   clangToolingCore
   )


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


r361686 - Permit static local structured bindings to be named from arbitrary scopes inside their declaring scope.

2019-05-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 24 18:04:17 2019
New Revision: 361686

URL: http://llvm.org/viewvc/llvm-project?rev=361686=rev
Log:
Permit static local structured bindings to be named from arbitrary scopes 
inside their declaring scope.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-decomposition.cpp
cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=361686=361685=361686=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 24 18:04:17 2019
@@ -63,6 +63,7 @@ class CXXDestructorDecl;
 class CXXFinalOverriderMap;
 class CXXIndirectPrimaryBaseSet;
 class CXXMethodDecl;
+class DecompositionDecl;
 class DiagnosticBuilder;
 class FriendDecl;
 class FunctionTemplateDecl;
@@ -3918,6 +3919,8 @@ public:
 /// x[0], x[1], and x[2] respectively, where x is the implicit
 /// DecompositionDecl of type 'int (&)[3]'.
 class BindingDecl : public ValueDecl {
+  /// The declaration that this binding binds to part of.
+  LazyDeclPtr Decomp;
   /// The binding represented by this declaration. References to this
   /// declaration are effectively equivalent to this expression (except
   /// that it is only evaluated once at the point of declaration of the
@@ -3941,6 +3944,10 @@ public:
   /// decomposition declaration, and when the initializer is type-dependent.
   Expr *getBinding() const { return Binding; }
 
+  /// Get the decomposition declaration that this binding represents a
+  /// decomposition of.
+  ValueDecl *getDecomposedDecl() const;
+
   /// Get the variable (if any) that holds the value of evaluating the binding.
   /// Only present for user-defined bindings for tuple-like types.
   VarDecl *getHoldingVar() const;
@@ -3953,6 +3960,9 @@ public:
 this->Binding = Binding;
   }
 
+  /// Set the decomposed variable for this BindingDecl.
+  void setDecomposedDecl(ValueDecl *Decomposed) { Decomp = Decomposed; }
+
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == Decl::Binding; }
 };
@@ -3980,6 +3990,8 @@ class DecompositionDecl final
 NumBindings(Bindings.size()) {
 std::uninitialized_copy(Bindings.begin(), Bindings.end(),
 getTrailingObjects());
+for (auto *B : Bindings)
+  B->setDecomposedDecl(this);
   }
 
   void anchor() override;

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=361686=361685=361686=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri May 24 18:04:17 2019
@@ -2929,6 +2929,12 @@ BindingDecl *BindingDecl::CreateDeserial
   return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr);
 }
 
+ValueDecl *BindingDecl::getDecomposedDecl() const {
+  ExternalASTSource *Source =
+  Decomp.isOffset() ? getASTContext().getExternalSource() : nullptr;
+  return cast_or_null(Decomp.get(Source));
+}
+
 VarDecl *BindingDecl::getHoldingVar() const {
   Expr *B = getBinding();
   if (!B)

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=361686=361685=361686=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 24 18:04:17 2019
@@ -3059,9 +3059,11 @@ ExprResult Sema::BuildDeclarationNameExp
   // FIXME: Support lambda-capture of BindingDecls, once CWG actually
   // decides how that's supposed to work.
   auto *BD = cast(VD);
-  if (BD->getDeclContext()->isFunctionOrMethod() &&
-  BD->getDeclContext() != CurContext)
-diagnoseUncapturableValueReference(*this, Loc, BD, CurContext);
+  if (BD->getDeclContext() != CurContext) {
+auto *DD = dyn_cast_or_null(BD->getDecomposedDecl());
+if (DD && DD->hasLocalStorage())
+  diagnoseUncapturableValueReference(*this, Loc, BD, CurContext);
+  }
   break;
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=361686=361685=361686=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri May 24 18:04:17 2019
@@ -1459,8 +1459,10 @@ void ASTDeclReader::VisitParmVarDecl(Par
 void ASTDeclReader::VisitDecompositionDecl(DecompositionDecl *DD) {
   VisitVarDecl(DD);

[PATCH] D62437: [clang-tidy] Splits fuchsia-default-arguments

2019-05-24 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 201375.
DiegoAstiazaran added a comment.

Reduces lines to 80 characters. The files have been also formatted by 
clang-format.
Types are replaced by auto in declarations where the type is spelled in cast.


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

https://reviews.llvm.org/D62437

Files:
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp

Index: clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
@@ -1,4 +1,4 @@
-//===--- FuchsiaTidyModule.cpp - clang-tidy===//
+//===--- FuchsiaTidyModule.cpp - clang-tidy ---===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
===
--- clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
+++ clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
@@ -1,4 +1,4 @@
-//===--- DefaultArgumentsDeclarationsCheck.h - clang-tidy --*- C++ -*-===//
+//===--- DefaultArgumentsDeclarationsCheck.h - clang-tidy ---*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
@@ -19,33 +19,33 @@
   Finder->addMatcher(parmVarDecl(hasDefaultArgument()).bind("decl"), this);
 }
 
-void DefaultArgumentsDeclarationsCheck::check(const MatchFinder::MatchResult ) {
-  const ParmVarDecl *D = Result.Nodes.getNodeAs("decl");
-  if (D == nullptr) return;
+void DefaultArgumentsDeclarationsCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *D = Result.Nodes.getNodeAs("decl");
+  if (D == nullptr)
+return;
 
   SourceRange DefaultArgRange = D->getDefaultArgRange();
 
-  if (DefaultArgRange.getEnd() != D->getEndLoc()) return;
-  
+  if (DefaultArgRange.getEnd() != D->getEndLoc())
+return;
+
   if (DefaultArgRange.getBegin().isMacroID()) {
 diag(D->getBeginLoc(),
-  "declaring a parameter with a default argument is disallowed");
+ "declaring a parameter with a default argument is disallowed");
 return;
   }
 
   SourceLocation StartLocation =
   D->getName().empty() ? D->getBeginLoc() : D->getLocation();
 
-  SourceRange RemovalRange(Lexer::getLocForEndOfToken(
-  StartLocation, 0,
-  *Result.SourceManager,
-  Result.Context->getLangOpts()
-),
-DefaultArgRange.getEnd()
-  );
+  SourceRange RemovalRange(
+  Lexer::getLocForEndOfToken(StartLocation, 0, *Result.SourceManager,
+ Result.Context->getLangOpts()),
+  DefaultArgRange.getEnd());
 
   diag(D->getBeginLoc(),
-"declaring a parameter with a default argument is disallowed")
+   "declaring a parameter with a default argument is disallowed")
   << D << FixItHint::CreateRemoval(RemovalRange);
 }
 
Index: clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
===
--- clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
+++ clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
@@ -1,4 +1,4 @@
-//===--- DefaultArgumentsCallsCheck.h - clang-tidy*- C++ -*-===//
+//===--- DefaultArgumentsCallsCheck.h - clang-tidy --*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
@@ -21,12 +21,13 @@
 
 void DefaultArgumentsCallsCheck::check(const MatchFinder::MatchResult ) {
   const auto *S = Result.Nodes.getNodeAs("stmt");
-  if (S == nullptr) return;
+  if (S == nullptr)
+return;
 
  

Re: r361340 - [Analysis] Link library dependencies to Analysis plugins

2019-05-24 Thread Akira Hatanaka via cfe-commits
I reverted the patch in r361685 to make the bot green again.

> On May 23, 2019, at 5:22 PM, Akira Hatanaka  wrote:
> 
> Hi Petr,
> 
> This seems to have caused Analysis/checker-plugins.c to fail. Can you 
> investigate it or revert your commit?
> 
> http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan/6381/consoleFull#-5275661368254eaf0-7326-4999-85b0-388101f2d404
> 
>> On May 21, 2019, at 5:47 PM, Petr Hosek via cfe-commits 
>>  wrote:
>> 
>> Author: phosek
>> Date: Tue May 21 17:47:37 2019
>> New Revision: 361340
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=361340=rev
>> Log:
>> [Analysis] Link library dependencies to Analysis plugins
>> 
>> These are needed to avoid undefined symbols which aren't satisfied
>> by Clang itself.
>> 
>> Differential Revision: https://reviews.llvm.org/D62174
>> 
>> Modified:
>>   cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
>>   cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
>>   cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
>> 
>> Modified: 
>> cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt?rev=361340=361339=361340=diff
>> ==
>> --- cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt 
>> (original)
>> +++ cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt 
>> Tue May 21 17:47:37 2019
>> @@ -1,11 +1,12 @@
>> set(LLVM_EXPORTED_SYMBOL_FILE 
>> ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
>> add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE 
>> CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
>> 
>> -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
>> +if(LLVM_ENABLE_PLUGINS)
>>  target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
>>clangAnalysis
>>clangAST
>>clangStaticAnalyzerCore
>> +clangStaticAnalyzerFrontend
>>LLVMSupport
>>)
>> endif()
>> 
>> Modified: 
>> cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt?rev=361340=361339=361340=diff
>> ==
>> --- cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt 
>> (original)
>> +++ cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt Tue 
>> May 21 17:47:37 2019
>> @@ -1,11 +1,12 @@
>> set(LLVM_EXPORTED_SYMBOL_FILE 
>> ${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
>> add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE 
>> CheckerOptionHandling.cpp PLUGIN_TOOL clang)
>> 
>> -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
>> +if(LLVM_ENABLE_PLUGINS)
>>  target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
>>clangAnalysis
>>clangAST
>>clangStaticAnalyzerCore
>> +clangStaticAnalyzerFrontend
>>LLVMSupport
>>)
>> endif()
>> 
>> Modified: cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt?rev=361340=361339=361340=diff
>> ==
>> --- cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt (original)
>> +++ cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt Tue May 21 
>> 17:47:37 2019
>> @@ -1,11 +1,12 @@
>> set(LLVM_EXPORTED_SYMBOL_FILE 
>> ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
>> add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL 
>> clang)
>> 
>> -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
>> +if(LLVM_ENABLE_PLUGINS)
>>  target_link_libraries(SampleAnalyzerPlugin PRIVATE
>>clangAnalysis
>>clangAST
>>clangStaticAnalyzerCore
>> +clangStaticAnalyzerFrontend
>>LLVMSupport
>>)
>> endif()
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

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


r361685 - Revert "[Analysis] Link library dependencies to Analysis plugins"

2019-05-24 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri May 24 17:50:03 2019
New Revision: 361685

URL: http://llvm.org/viewvc/llvm-project?rev=361685=rev
Log:
Revert "[Analysis] Link library dependencies to Analysis plugins"

This reverts commit r361340. The following builder has been broken for
the past few days because of this commit:

http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan/

Also revert r361399, which was committed to fix r361340.

Modified:
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt

Modified: 
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt?rev=361685=361684=361685=diff
==
--- cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt 
(original)
+++ cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt 
Fri May 24 17:50:03 2019
@@ -1,12 +1,11 @@
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
 add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE 
CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS)
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
 clangAnalysis
 clangAST
 clangStaticAnalyzerCore
-clangStaticAnalyzerFrontend
 LLVMSupport
 )
 endif()

Modified: cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt?rev=361685=361684=361685=diff
==
--- cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt 
(original)
+++ cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt Fri 
May 24 17:50:03 2019
@@ -1,12 +1,11 @@
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
 add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE 
CheckerOptionHandling.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS)
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
 clangAnalysis
 clangAST
 clangStaticAnalyzerCore
-clangStaticAnalyzerFrontend
 LLVMSupport
 )
 endif()

Modified: cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt?rev=361685=361684=361685=diff
==
--- cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt (original)
+++ cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt Fri May 24 
17:50:03 2019
@@ -1,12 +1,11 @@
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
 add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL 
clang)
 
-if(LLVM_ENABLE_PLUGINS)
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(SampleAnalyzerPlugin PRIVATE
 clangAnalysis
 clangAST
 clangStaticAnalyzerCore
-clangStaticAnalyzerFrontend
 LLVMSupport
 )
 endif()


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


[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In D60883#1516693 , @ABataev wrote:

> Just one question after looking at the test: how we're going to link the 
> device variable to its host copy? I think the address should be passed to the 
> runtime, no?


The runtime will take care of it by performing a copy of the host address into 
the device pointer.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883



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


[PATCH] D62420: Rename clangToolingRefactor to clangToolingRefactoring for consistency with its directory

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361684: Rename clangToolingRefactor to 
clangToolingRefactoring for consistency with its… (authored by nico, committed 
by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D62420?vs=201316=201370#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62420

Files:
  clang-apply-replacements/CMakeLists.txt
  clang-apply-replacements/tool/CMakeLists.txt
  clang-tidy/utils/CMakeLists.txt
  clangd/CMakeLists.txt
  tool-template/CMakeLists.txt
  unittests/clang-apply-replacements/CMakeLists.txt
  unittests/clang-tidy/CMakeLists.txt


Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -37,5 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: unittests/clang-apply-replacements/CMakeLists.txt
===
--- unittests/clang-apply-replacements/CMakeLists.txt
+++ unittests/clang-apply-replacements/CMakeLists.txt
@@ -16,5 +16,5 @@
   clangApplyReplacements
   clangBasic
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang-tidy/utils/CMakeLists.txt
===
--- clang-tidy/utils/CMakeLists.txt
+++ clang-tidy/utils/CMakeLists.txt
@@ -23,5 +23,5 @@
   clangBasic
   clangLex
   clangTidy
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -125,7 +125,7 @@
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactor
+  clangToolingRefactoring
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}
   )
Index: clang-apply-replacements/tool/CMakeLists.txt
===
--- clang-apply-replacements/tool/CMakeLists.txt
+++ clang-apply-replacements/tool/CMakeLists.txt
@@ -12,7 +12,7 @@
   clangFormat
   clangRewrite
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 install(TARGETS clang-apply-replacements
Index: clang-apply-replacements/CMakeLists.txt
===
--- clang-apply-replacements/CMakeLists.txt
+++ clang-apply-replacements/CMakeLists.txt
@@ -10,7 +10,7 @@
   clangBasic
   clangRewrite
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 include_directories(
Index: tool-template/CMakeLists.txt
===
--- tool-template/CMakeLists.txt
+++ tool-template/CMakeLists.txt
@@ -13,5 +13,5 @@
   clangBasic
   clangFrontend
   clangTooling
-  clangToolingRefactor
+  clangToolingRefactoring
   )


Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -37,5 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: unittests/clang-apply-replacements/CMakeLists.txt
===
--- unittests/clang-apply-replacements/CMakeLists.txt
+++ unittests/clang-apply-replacements/CMakeLists.txt
@@ -16,5 +16,5 @@
   clangApplyReplacements
   clangBasic
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang-tidy/utils/CMakeLists.txt
===
--- clang-tidy/utils/CMakeLists.txt
+++ clang-tidy/utils/CMakeLists.txt
@@ -23,5 +23,5 @@
   clangBasic
   clangLex
   clangTidy
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -125,7 +125,7 @@
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactor
+  clangToolingRefactoring
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}
   )
Index: clang-apply-replacements/tool/CMakeLists.txt
===
--- clang-apply-replacements/tool/CMakeLists.txt
+++ clang-apply-replacements/tool/CMakeLists.txt
@@ -12,7 +12,7 @@
   clangFormat
   clangRewrite
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 install(TARGETS clang-apply-replacements
Index: clang-apply-replacements/CMakeLists.txt
===
--- clang-apply-replacements/CMakeLists.txt
+++ clang-apply-replacements/CMakeLists.txt
@@ 

[clang-tools-extra] r361684 - Rename clangToolingRefactor to clangToolingRefactoring for consistency with its directory

2019-05-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May 24 17:27:19 2019
New Revision: 361684

URL: http://llvm.org/viewvc/llvm-project?rev=361684=rev
Log:
Rename clangToolingRefactor to clangToolingRefactoring for consistency with its 
directory

See "[cfe-dev] The name of clang/lib/Tooling/Refactoring".

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

Modified:
clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/tool-template/CMakeLists.txt
clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt Fri May 24 
17:27:19 2019
@@ -10,7 +10,7 @@ add_clang_library(clangApplyReplacements
   clangBasic
   clangRewrite
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 include_directories(

Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt Fri 
May 24 17:27:19 2019
@@ -12,7 +12,7 @@ target_link_libraries(clang-apply-replac
   clangFormat
   clangRewrite
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 install(TARGETS clang-apply-replacements

Modified: clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt Fri May 24 17:27:19 
2019
@@ -23,5 +23,5 @@ add_clang_library(clangTidyUtils
   clangBasic
   clangLex
   clangTidy
-  clangToolingRefactor
+  clangToolingRefactoring
   )

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri May 24 17:27:19 2019
@@ -125,7 +125,7 @@ add_clang_library(clangDaemon
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactor
+  clangToolingRefactoring
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}
   )

Modified: clang-tools-extra/trunk/tool-template/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/tool-template/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/tool-template/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/tool-template/CMakeLists.txt Fri May 24 17:27:19 
2019
@@ -13,5 +13,5 @@ target_link_libraries(tool-template
   clangBasic
   clangFrontend
   clangTooling
-  clangToolingRefactor
+  clangToolingRefactoring
   )

Modified: 
clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt 
Fri May 24 17:27:19 2019
@@ -16,5 +16,5 @@ target_link_libraries(ClangApplyReplacem
   clangApplyReplacements
   clangBasic
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )

Modified: clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/CMakeLists.txt (original)
+++ 

r361684 - Rename clangToolingRefactor to clangToolingRefactoring for consistency with its directory

2019-05-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May 24 17:27:19 2019
New Revision: 361684

URL: http://llvm.org/viewvc/llvm-project?rev=361684=rev
Log:
Rename clangToolingRefactor to clangToolingRefactoring for consistency with its 
directory

See "[cfe-dev] The name of clang/lib/Tooling/Refactoring".

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

Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/tools/clang-refactor/CMakeLists.txt
cfe/trunk/tools/clang-rename/CMakeLists.txt
cfe/trunk/unittests/Rename/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt Fri May 24 17:27:19 2019
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_library(clangToolingRefactor
+add_clang_library(clangToolingRefactoring
   ASTSelection.cpp
   ASTSelectionRequirements.cpp
   AtomicChange.cpp

Modified: cfe/trunk/tools/clang-refactor/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- cfe/trunk/tools/clang-refactor/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-refactor/CMakeLists.txt Fri May 24 17:27:19 2019
@@ -19,5 +19,5 @@ target_link_libraries(clang-refactor
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )

Modified: cfe/trunk/tools/clang-rename/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-rename/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- cfe/trunk/tools/clang-rename/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-rename/CMakeLists.txt Fri May 24 17:27:19 2019
@@ -15,7 +15,7 @@ target_link_libraries(clang-rename
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 install(PROGRAMS clang-rename.py

Modified: cfe/trunk/unittests/Rename/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rename/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- cfe/trunk/unittests/Rename/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rename/CMakeLists.txt Fri May 24 17:27:19 2019
@@ -24,5 +24,5 @@ target_link_libraries(ClangRenameTests
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )

Modified: cfe/trunk/unittests/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CMakeLists.txt?rev=361684=361683=361684=diff
==
--- cfe/trunk/unittests/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt Fri May 24 17:27:19 2019
@@ -70,7 +70,7 @@ target_link_libraries(ToolingTests
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactor
+  clangToolingRefactoring
   LLVMTestingSupport
   )
 


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


[PATCH] D61707: [Preprocessor] Fix crash emitting note with framework location for "file not found" error.

2019-05-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D61707



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


LLVM buildmaster will be updated and restarted tonight

2019-05-24 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 7PM Pacific time today.

Thanks

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


[PATCH] D62437: [clang-tidy] Splits fuchsia-default-arguments

2019-05-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp:1
+//===--- DefaultArgumentsCallsCheck.cpp - 
clang-tidy---===//
+//

Please add space after clang-tidy.



Comment at: clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h:1
-//===--- DefaultArgumentsCheck.h - clang-tidy*- C++ 
-*-===//
+//===--- DefaultArgumentsCallsCheck.h - clang-tidy*- C++ 
-*-===//
 //

Please narrow to 80 symbols and add space after clang-tidy.



Comment at: 
clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h:1
+//===--- DefaultArgumentsDeclarationsCheck.h - clang-tidy --*- 
C++ -*-===//
+//

Please narrow to 80 symbols.



Comment at: clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp:1
 //===--- FuchsiaTidyModule.cpp - 
clang-tidy===//
 //

Please add space after clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62437



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


[PATCH] D62437: [clang-tidy] Splits fuchsia-default-arguments

2019-05-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention renaming of existing check in Release Notes (after list of new 
checks).




Comment at: 
clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp:23
+void DefaultArgumentsDeclarationsCheck::check(const MatchFinder::MatchResult 
) {
+  const ParmVarDecl *D = Result.Nodes.getNodeAs("decl");
+  if (D == nullptr) return;

You could use auto instead of type because type is spelled in cast.



Comment at: 
clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp:24
+  const ParmVarDecl *D = Result.Nodes.getNodeAs("decl");
+  if (D == nullptr) return;
+

Please run clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62437



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


[PATCH] D61817: [analyzer] Add a prunable note for skipping virtual base initializers in subclasses.

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361682: [analyzer] Add a prunable note for skipping vbase 
inits in subclasses. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61817?vs=201359=201364#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61817

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/diagnostics/initializer.cpp

Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2501,7 +2501,9 @@
   if (Optional Msg = T->generateMessage(BRC, R)) {
 PathDiagnosticLocation Loc =
 PathDiagnosticLocation::create(PP, BRC.getSourceManager());
-return std::make_shared(Loc, *Msg);
+auto Piece = std::make_shared(Loc, *Msg);
+Piece->setPrunable(T->isPrunable());
+return Piece;
   }
 
   return nullptr;
Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -216,6 +216,25 @@
LC->getDecl(),
LC->getCFG()->getNumBlockIDs());
 
+  // Display a prunable path note to the user if it's a virtual bases branch
+  // and we're taking the path that skips virtual base constructors.
+  if (L.getSrc()->getTerminator().isVirtualBaseBranch() &&
+  L.getDst() == *L.getSrc()->succ_begin()) {
+ProgramPoint P = L.withTag(getNoteTags().makeNoteTag(
+[](BugReporterContext &, BugReport &) -> std::string {
+  // TODO: Just call out the name of the most derived class
+  // when we know it.
+  return "Virtual base initialization skipped because "
+ "it has already been handled by the most derived class";
+}, /*IsPrunable=*/true));
+// Perform the transition.
+ExplodedNodeSet Dst;
+NodeBuilder Bldr(Pred, Dst, BuilderCtx);
+Pred = Bldr.generateNode(P, Pred->getState(), Pred);
+if (!Pred)
+  return;
+  }
+
   // Check if we are entering the EXIT block.
   if (Blk == &(L.getLocationContext()->getCFG()->getExit())) {
 assert(L.getLocationContext()->getCFG()->getExit().empty() &&
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -724,7 +724,15 @@
   const Stmt* S = nullptr;
   if (Optional BE = P.getAs()) {
 const CFGBlock *BSrc = BE->getSrc();
-S = BSrc->getTerminatorCondition();
+if (BSrc->getTerminator().isVirtualBaseBranch()) {
+  // TODO: VirtualBaseBranches should also appear for destructors.
+  // In this case we should put the diagnostic at the end of decl.
+  return PathDiagnosticLocation::createBegin(
+  P.getLocationContext()->getDecl(), SMng);
+
+} else {
+  S = BSrc->getTerminatorCondition();
+}
   } else if (Optional SP = P.getAs()) {
 S = SP->getStmt();
 if (P.getAs())
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -156,8 +156,6 @@
   /// The flag, which specifies the mode of inlining for the engine.
   InliningModes HowToInline;
 
-  NoteTag::Factory NoteTags;
-
 public:
   ExprEngine(cross_tu::CrossTranslationUnitContext , AnalysisManager ,
  SetOfConstDecls *VisitedCalleesIn,
@@ -399,7 +397,7 @@
   SymbolManager () { return SymMgr; }
   MemRegionManager () { return MRMgr; }
 
-  NoteTag::Factory () { return NoteTags; }
+  NoteTag::Factory () { return Engine.getNoteTags(); }
 
 
   // Functions for external checking of whether we have unfinished work
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -19,6 +19,7 @@
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h"
 #include 

[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361681: [CFG] Add branch to skip vbase inits when 
theyre handled by superclass. (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61816?vs=201354=201363#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61816

Files:
  cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
  cfe/trunk/lib/Analysis/CFG.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/test/Analysis/initializer.cpp
  cfe/trunk/test/Analysis/initializers-cfg-output.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -380,6 +380,11 @@
 }
   }
 
+  if (B->getTerminator().isVirtualBaseBranch()) {
+HandleVirtualBaseBranch(B, Pred);
+return;
+  }
+
   assert(B->succ_size() == 1 &&
  "Blocks with no terminator should have at most 1 successor.");
 
@@ -439,6 +444,29 @@
   }
 }
 
+void CoreEngine::HandleVirtualBaseBranch(const CFGBlock *B,
+ ExplodedNode *Pred) {
+  const LocationContext *LCtx = Pred->getLocationContext();
+  if (const auto *CallerCtor = dyn_cast_or_null(
+  LCtx->getStackFrame()->getCallSite())) {
+switch (CallerCtor->getConstructionKind()) {
+case CXXConstructExpr::CK_NonVirtualBase:
+case CXXConstructExpr::CK_VirtualBase: {
+  BlockEdge Loc(B, *B->succ_begin(), LCtx);
+  HandleBlockEdge(Loc, Pred);
+  return;
+}
+default:
+  break;
+}
+  }
+
+  // We either don't see a parent stack frame because we're in the top frame,
+  // or the parent stack frame doesn't initialize our virtual bases.
+  BlockEdge Loc(B, *(B->succ_begin() + 1), LCtx);
+  HandleBlockEdge(Loc, Pred);
+}
+
 /// generateNode - Utility method to generate nodes, hook up successors,
 ///  and add nodes to the worklist.
 void CoreEngine::generateNode(const ProgramPoint ,
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -428,25 +428,20 @@
 prepareForObjectConstruction(CE, State, LCtx, CC, CallOpts);
 break;
   }
-  case CXXConstructExpr::CK_VirtualBase:
+  case CXXConstructExpr::CK_VirtualBase: {
 // Make sure we are not calling virtual base class initializers twice.
 // Only the most-derived object should initialize virtual base classes.
-if (const Stmt *Outer = LCtx->getStackFrame()->getCallSite()) {
-  const CXXConstructExpr *OuterCtor = dyn_cast(Outer);
-  if (OuterCtor) {
-switch (OuterCtor->getConstructionKind()) {
-case CXXConstructExpr::CK_NonVirtualBase:
-case CXXConstructExpr::CK_VirtualBase:
-  // Bail out!
-  destNodes.Add(Pred);
-  return;
-case CXXConstructExpr::CK_Complete:
-case CXXConstructExpr::CK_Delegating:
-  break;
-}
-  }
-}
+const auto *OuterCtor = dyn_cast_or_null(
+LCtx->getStackFrame()->getCallSite());
+assert(
+(!OuterCtor ||
+ OuterCtor->getConstructionKind() == CXXConstructExpr::CK_Complete ||
+ OuterCtor->getConstructionKind() == CXXConstructExpr::CK_Delegating) &&
+("This virtual base should have already been initialized by "
+ "the most derived class!"));
+(void)OuterCtor;
 LLVM_FALLTHROUGH;
+  }
   case CXXConstructExpr::CK_NonVirtualBase:
 // In C++17, classes with non-virtual bases may be aggregates, so they would
 // be initialized as aggregates without a constructor call, so we may have
Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -35,7 +35,9 @@
   Options.ShouldConditionalizeStaticInitializers,
   /*addCXXNewAllocator=*/true,
   Options.ShouldIncludeRichConstructorsInCFG,
-  Options.ShouldElideConstructors, injector),
+  Options.ShouldElideConstructors,
+  /*addVirtualBaseBranches=*/true,
+  injector),
   Ctx(ASTCtx), Diags(diags), LangOpts(ASTCtx.getLangOpts()),
   PathConsumers(PDC), CreateStoreMgr(storemgr),
   

r361682 - [analyzer] Add a prunable note for skipping vbase inits in subclasses.

2019-05-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri May 24 16:37:11 2019
New Revision: 361682

URL: http://llvm.org/viewvc/llvm-project?rev=361682=rev
Log:
[analyzer] Add a prunable note for skipping vbase inits in subclasses.

When initialization of virtual base classes is skipped, we now tell the user
about it, because this aspect of C++ isn't very well-known.

The implementation is based on the new "note tags" feature (r358781).
In order to make use of it, allow note tags to produce prunable notes,
and move the note tag factory to CoreEngine.

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

Added:
cfe/trunk/test/Analysis/diagnostics/initializer.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=361682=361681=361682=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Fri 
May 24 16:37:11 2019
@@ -604,8 +604,10 @@ private:
   static int Kind;
 
   const Callback Cb;
+  const bool IsPrunable;
 
-  NoteTag(Callback &) : ProgramPointTag(), Cb(std::move(Cb)) {}
+  NoteTag(Callback &, bool IsPrunable)
+  : ProgramPointTag(), Cb(std::move(Cb)), IsPrunable(IsPrunable) {}
 
 public:
   static bool classof(const ProgramPointTag *T) {
@@ -628,15 +630,17 @@ public:
 return "Note Tag";
   }
 
+  bool isPrunable() const { return IsPrunable; }
+
   // Manage memory for NoteTag objects.
   class Factory {
 std::vector> Tags;
 
   public:
-const NoteTag *makeNoteTag(Callback &) {
+const NoteTag *makeNoteTag(Callback &, bool IsPrunable = false) {
   // We cannot use make_unique because we cannot access the private
   // constructor from inside it.
-  std::unique_ptr T(new NoteTag(std::move(Cb)));
+  std::unique_ptr T(new NoteTag(std::move(Cb), IsPrunable));
   Tags.push_back(std::move(T));
   return Tags.back().get();
 }

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=361682=361681=361682=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Fri 
May 24 16:37:11 2019
@@ -19,6 +19,7 @@
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
@@ -95,6 +96,10 @@ private:
   /// (This data is owned by AnalysisConsumer.)
   FunctionSummariesTy *FunctionSummaries;
 
+  /// Add path note tags along the path when we see that something interesting
+  /// is happening. This field is the allocator for such tags.
+  NoteTag::Factory NoteTags;
+
   void generateNode(const ProgramPoint ,
 ProgramStateRef State,
 ExplodedNode *Pred);
@@ -194,6 +199,8 @@ public:
 
   /// Enqueue a single node created as a result of statement processing.
   void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx);
+
+  NoteTag::Factory () { return NoteTags; }
 };
 
 // TODO: Turn into a class.

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=361682=361681=361682=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Fri 
May 24 16:37:11 2019
@@ -156,8 +156,6 @@ private:
   /// The flag, which specifies the mode of inlining for the engine.
   InliningModes HowToInline;
 
-  NoteTag::Factory NoteTags;
-
 public:
   ExprEngine(cross_tu::CrossTranslationUnitContext , AnalysisManager ,
  SetOfConstDecls *VisitedCalleesIn,
@@ -399,7 +397,7 @@ public:
   SymbolManager () { return SymMgr; }
   MemRegionManager () { return MRMgr; }
 
-  

r361681 - [CFG] Add branch to skip vbase inits when they're handled by superclass.

2019-05-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri May 24 16:37:08 2019
New Revision: 361681

URL: http://llvm.org/viewvc/llvm-project?rev=361681=rev
Log:
[CFG] Add branch to skip vbase inits when they're handled by superclass.

This patch adds the run-time CFG branch that would skip initialization of
virtual base classes depending on whether the constructor is called from a
superclass constructor or not. Previously the Static Analyzer was already
skipping virtual base-class initializers in such constructors, but it wasn't
skipping their arguments and their potential side effects, which was causing
pr41300 (and was generally incorrect). The previous skipping behavior is
now replaced with a hard assertion that we're not even getting there due
to how our CFG works.

The new CFG element is under a CFG build option so that not to break other
consumers of the CFG by this change. Static Analyzer support for this change
is implemented.

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

Modified:
cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/test/Analysis/initializer.cpp
cfe/trunk/test/Analysis/initializers-cfg-output.cpp

Modified: cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h?rev=361681=361680=361681=diff
==
--- cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h Fri May 24 16:37:08 
2019
@@ -459,6 +459,7 @@ public:
  bool addCXXNewAllocator = true,
  bool addRichCXXConstructors = true,
  bool markElidedCXXConstructors = true,
+ bool addVirtualBaseBranches = true,
  CodeInjector *injector = nullptr);
 
   AnalysisDeclContext *getContext(const Decl *D);

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=361681=361680=361681=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Fri May 24 16:37:08 2019
@@ -504,15 +504,19 @@ public:
 /// terminator statement is the same statement that branches control flow
 /// in evaluation of matching full expression.
 TemporaryDtorsBranch,
+/// A shortcut around virtual base initializers. It gets taken when
+/// virtual base classes have already been initialized by the constructor
+/// of the most derived class while we're in the base class.
+VirtualBaseBranch,
 
 /// Number of different kinds, for sanity checks. We subtract 1 so that
 /// to keep receiving compiler warnings when we don't cover all enum values
 /// in a switch.
-NumKindsMinusOne = TemporaryDtorsBranch
+NumKindsMinusOne = VirtualBaseBranch
   };
 
 private:
-  static constexpr int KindBits = 1;
+  static constexpr int KindBits = 2;
   static_assert((1 << KindBits) > NumKindsMinusOne,
 "Not enough room for kind!");
   llvm::PointerIntPair Data;
@@ -532,6 +536,9 @@ public:
   bool isTemporaryDtorsBranch() const {
 return getKind() == TemporaryDtorsBranch;
   }
+  bool isVirtualBaseBranch() const {
+return getKind() == VirtualBaseBranch;
+  }
 };
 
 /// Represents a single basic block in a source-level CFG.
@@ -552,11 +559,12 @@ public:
 /// Successors: the order in the set of successors is NOT arbitrary.  We
 ///  currently have the following orderings based on the terminator:
 ///
-/// Terminator   Successor Ordering
-///  -
-///   ifThen Block;  Else Block
-/// ? operator  LHS expression;  RHS expression
-/// &&, ||  expression that uses result of && or ||, RHS
+/// Terminator |   Successor Ordering
+///  --|
+///   if   |  Then Block;  Else Block
+/// ? operator |  LHS expression;  RHS expression
+/// logical and/or |  expression that consumes the op, RHS
+/// vbase inits|  already handled by the most derived class; not yet
 ///
 /// But note that any of that may be NULL in case of optimized-out edges.
 class CFGBlock {
@@ -1039,6 +1047,7 @@ public:
 bool AddCXXDefaultInitExprInCtors = false;
 bool AddRichCXXConstructors = false;
 bool MarkElidedCXXConstructors = false;
+  

[PATCH] D62437: [clang-tidy] Splits fuchsia-default-arguments

2019-05-24 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added a reviewer: juliehockett.
DiegoAstiazaran added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

Splits fuchsia-default-arguments check into two checks. 
fuchsia-default-arguments-calls warns if a function or method is called with 
default arguments. fuchsia-default-arguments-declarations warns if a function 
or method is declared with default parameters.

Resolves b38051


https://reviews.llvm.org/D62437

Files:
  clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsCheck.h
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia-default-arguments-calls.rst
  
clang-tools-extra/docs/clang-tidy/checks/fuchsia-default-arguments-declarations.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia-default-arguments.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-calls.cpp
  clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
  clang-tools-extra/test/clang-tidy/fuchsia-default-arguments.cpp

Index: clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
===
--- clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
+++ clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
@@ -1,26 +1,15 @@
-// RUN: %check_clang_tidy %s fuchsia-default-arguments %t
+// RUN: %check_clang_tidy %s fuchsia-default-arguments-declarations %t
 
 int foo(int value = 5) { return value; }
-// CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: int foo(int value) { return value; }
 
-int f() {
-  foo();
-  // CHECK-NOTES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
-  // CHECK-NOTES: [[@LINE-7]]:9: note: default parameter was declared here
-}
-
 int bar(int value) { return value; }
 
-int n() {
-  foo(0);
-  bar(0);
-}
-
 class Baz {
 public:
   int a(int value = 5) { return value; }
-  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
   // CHECK-FIXES: int a(int value) { return value; }
 
   int b(int value) { return value; }
@@ -29,7 +18,7 @@
 class Foo {
   // Fix should be suggested in declaration
   int a(int value = 53);
-  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
   // CHECK-FIXES: int a(int value);
 };
 
@@ -40,7 +29,7 @@
 
 // Elided functions
 void f(int = 5) {};
-// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: void f(int) {};
 
 void g(int) {};
@@ -49,12 +38,12 @@
 #define D(val) = val
 
 void h(int i D(5));
-// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES-NOT: void h(int i);
 
 void x(int i);
 void x(int i = 12);
-// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: void x(int i);
 
 void x(int i) {}
@@ -64,17 +53,8 @@
 };
 
 void S::x(int i = 12) {}
-// CHECK-NOTES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed 

[PATCH] D62435: Add Attribute NoThrow as an Exception Specifier Type

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

Seems like a nice approach to the problem, but we need to not break the 
libclang C ABI :)




Comment at: clang/include/clang-c/Index.h:202-204
+   * The cursor has a declspec(nothrow) exception specification.
+   */
+  CXCursor_ExceptionSpecificationKind_NoThrow,

This would renumber the later enumerators, resulting in an ABI break for our 
stable C ABI.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:6067-6068
   if (EST2 == EST_NoexceptTrue) return ESI1;
+  if (EST1 == EST_NoThrow) return ESI2;
+  if (EST2 == EST_NoThrow) return ESI1;
 

I think this should be checked earlier, in the spirit of allowing "real" syntax 
to be preferred to attributes. (Eg, given a declaration that's 
`__declspec(nothrow)` and one that's `noexcept`, we should keep the `noexcept` 
in the merged type.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62435



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


r361680 - Fix crash deserializing a CUDAKernelCallExpr with a +Asserts binary.

2019-05-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 24 16:26:07 2019
New Revision: 361680

URL: http://llvm.org/viewvc/llvm-project?rev=361680=rev
Log:
Fix crash deserializing a CUDAKernelCallExpr with a +Asserts binary.

The assertion in setConfig read from the (uninitialized) CONFIG
expression.

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=361680=361679=361680=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri May 24 16:26:07 2019
@@ -216,6 +216,8 @@ public:
 
 /// Represents a call to a CUDA kernel function.
 class CUDAKernelCallExpr final : public CallExpr {
+  friend class ASTStmtReader;
+
   enum { CONFIG, END_PREARG };
 
   // CUDAKernelCallExpr has some trailing objects belonging
@@ -241,20 +243,6 @@ public:
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
 
-  /// Sets the kernel configuration expression.
-  ///
-  /// Note that this method cannot be called if config has already been set to 
a
-  /// non-null value.
-  void setConfig(CallExpr *E) {
-assert(!getConfig() &&
-   "Cannot call setConfig if config is not null");
-setPreArg(CONFIG, E);
-setInstantiationDependent(isInstantiationDependent() ||
-  E->isInstantiationDependent());
-setContainsUnexpandedParameterPack(containsUnexpandedParameterPack() ||
-   E->containsUnexpandedParameterPack());
-  }
-
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;
   }

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=361680=361679=361680=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Fri May 24 16:26:07 2019
@@ -1904,7 +1904,7 @@ void ASTStmtReader::VisitSEHTryStmt(SEHT
 
 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
   VisitCallExpr(E);
-  E->setConfig(cast(Record.readSubExpr()));
+  E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
 }
 
 
//===--===//


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


[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

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

LGTM! Nicely done!


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

https://reviews.llvm.org/D61816



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


[PATCH] D62435: Add Attribute NoThrow as an Exception Specifier Type

2019-05-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rnk, lebedev.ri, aaron.ballman.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

In response to https://bugs.llvm.org/show_bug.cgi?id=33235, it became
clear that the current mechanism of hacking through checks for the
exception specification of a function gets confused really quickly when
there are alternate exception specifiers.

  

This patch introduces EST_NoThrow, which is the equivilent of
EST_noexcept when caused by EST_noThrow. The existing implementation is
left in place to cover functions with no FunctionProtoType.


Repository:
  rC Clang

https://reviews.llvm.org/D62435

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/ExceptionSpecificationType.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/nothrow-vs-exception-specs.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -742,6 +742,8 @@
 return CXCursor_ExceptionSpecificationKind_MSAny;
   case EST_BasicNoexcept:
 return CXCursor_ExceptionSpecificationKind_BasicNoexcept;
+  case EST_NoThrow:
+return CXCursor_ExceptionSpecificationKind_NoThrow;
   case EST_NoexceptFalse:
   case EST_NoexceptTrue:
   case EST_DependentNoexcept:
Index: clang/test/SemaCXX/nothrow-vs-exception-specs.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/nothrow-vs-exception-specs.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++17 -DCPP17
+
+__attribute__((nothrow)) void f1();
+static_assert(noexcept(f1()), "");
+void f1() noexcept;
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+void f1() noexcept(false);
+
+__attribute__((nothrow)) void f2();
+static_assert(noexcept(f2()), "");
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}
+// expected-note@-3 {{previous declaration is here}}
+void f2() noexcept(false);
+
+void f3() __attribute__((nothrow));
+static_assert(noexcept(f3()), "");
+void f3() noexcept;
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+void f3() noexcept(false);
+
+// Still noexcept due to throw()
+__attribute__((nothrow)) void f4() throw();
+static_assert(noexcept(f4()), "");
+
+// Still noexcept due to noexcept
+__attribute__((nothrow)) void f5() noexcept;
+static_assert(noexcept(f5()), "");
+
+// Still noexcept due to noexcept(true)
+__attribute__((nothrow)) void f6() noexcept(true);
+static_assert(noexcept(f6()), "");
+
+#ifndef CPP17
+// Doesn't override C++ implementation.
+__attribute__((nothrow)) void f7() throw(int);
+static_assert(!noexcept(f7()), "");
+#endif
+
+// Doesn't override C++ implementation.
+__attribute__((nothrow)) void f8() noexcept(false);
+static_assert(!noexcept(f8()), "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -130,6 +130,7 @@
   case ParsedAttr::AT_Regparm: \
   case ParsedAttr::AT_AnyX86NoCallerSavedRegisters:\
   case ParsedAttr::AT_AnyX86NoCfCheck: \
+  case ParsedAttr::AT_NoThrow: \
 CALLING_CONV_ATTRS_CASELIST
 
 // Microsoft-specific type qualifiers.
@@ -4516,7 +4517,7 @@
   // If the function declarator has a prototype (i.e. it is not () and
   // does not have a K identifier list), then the arguments are part
   // of the type, otherwise the argument list is ().
-  const DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
+  DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
   IsQualifiedFunction =
   FTI.hasMethodTypeQualifiers() || FTI.hasRefQualifier();
 
@@ -6945,6 +6946,38 @@
 return true;
   }
 
+  if (attr.getKind() == ParsedAttr::AT_NoThrow) {
+if (S.CheckAttrNoArgs(attr))
+  return true;
+
+// Delay if this is not a function type.
+if (!unwrapped.isFunctionType())
+  return false;
+
+// Otherwise we can process right away.
+auto *Proto = unwrapped.get()->getAs();
+
+// In the case where this is a 

[PATCH] D61817: [analyzer] Add a prunable note for skipping virtual base initializers in subclasses.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 201359.
NoQ added a comment.

Rebase.


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

https://reviews.llvm.org/D61817

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  clang/test/Analysis/diagnostics/initializer.cpp

Index: clang/test/Analysis/diagnostics/initializer.cpp
===
--- /dev/null
+++ clang/test/Analysis/diagnostics/initializer.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-output=text \
+// RUN:   -verify %s
+
+namespace note_on_skipped_vbases {
+struct A {
+  int x;
+  A() : x(0) {} // expected-note{{The value 0 is assigned to 'c.x'}}
+  A(int x) : x(x) {}
+};
+
+struct B : virtual A {
+  int y;
+  // This note appears only once, when this constructor is called from C.
+  // When this constructor is called from D, this note is still correct but
+  // it doesn't appear because it's pruned out because it's irrelevant to the
+  // bug report.
+  B(): // expected-note{{Virtual base initialization skipped because it has already been handled by the most derived class}}
+A(1),
+y(1 / x) // expected-warning{{Division by zero}}
+ // expected-note@-1{{Division by zero}}
+  {}
+};
+
+struct C : B {
+  C(): // expected-note{{Calling default constructor for 'A'}}
+   // expected-note@-1{{Returning from default constructor for 'A'}}
+B() // expected-note{{Calling default constructor for 'B'}}
+  {}
+};
+
+void test_note() {
+  C c; // expected-note{{Calling default constructor for 'C'}}
+}
+
+struct D: B {
+  D() : A(1), B() {}
+};
+
+void test_prunability() {
+  D d;
+  1 / 0; // expected-warning{{Division by zero}}
+ // expected-note@-1{{Division by zero}}
+}
+} // namespace note_on_skipped_vbases
Index: clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -724,7 +724,15 @@
   const Stmt* S = nullptr;
   if (Optional BE = P.getAs()) {
 const CFGBlock *BSrc = BE->getSrc();
-S = BSrc->getTerminatorCondition();
+if (BSrc->getTerminator().isVirtualBaseBranch()) {
+  // TODO: VirtualBaseBranches should also appear for destructors.
+  // In this case we should put the diagnostic at the end of decl.
+  return PathDiagnosticLocation::createBegin(
+  P.getLocationContext()->getDecl(), SMng);
+
+} else {
+  S = BSrc->getTerminatorCondition();
+}
   } else if (Optional SP = P.getAs()) {
 S = SP->getStmt();
 if (P.getAs())
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -216,6 +216,25 @@
LC->getDecl(),
LC->getCFG()->getNumBlockIDs());
 
+  // Display a prunable path note to the user if it's a virtual bases branch
+  // and we're taking the path that skips virtual base constructors.
+  if (L.getSrc()->getTerminator().isVirtualBaseBranch() &&
+  L.getDst() == *L.getSrc()->succ_begin()) {
+ProgramPoint P = L.withTag(getNoteTags().makeNoteTag(
+[](BugReporterContext &, BugReport &) -> std::string {
+  // TODO: Just call out the name of the most derived class
+  // when we know it.
+  return "Virtual base initialization skipped because "
+ "it has already been handled by the most derived class";
+}, /*IsPrunable=*/true));
+// Perform the transition.
+ExplodedNodeSet Dst;
+NodeBuilder Bldr(Pred, Dst, BuilderCtx);
+Pred = Bldr.generateNode(P, Pred->getState(), Pred);
+if (!Pred)
+  return;
+  }
+
   // Check if we are entering the EXIT block.
   if (Blk == &(L.getLocationContext()->getCFG()->getExit())) {
 assert(L.getLocationContext()->getCFG()->getExit().empty() &&
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2501,7 +2501,9 @@
   if (Optional Msg = T->generateMessage(BRC, R)) {
 PathDiagnosticLocation Loc =
 PathDiagnosticLocation::create(PP, BRC.getSourceManager());
-return std::make_shared(Loc, *Msg);
+auto Piece = std::make_shared(Loc, *Msg);
+Piece->setPrunable(T->isPrunable());
+return Piece;
   }
 
   return nullptr;

[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:451
+  if (const auto *CallerCtor = dyn_cast_or_null(
+  LCtx->getStackFrame()->getCallSite())) {
+switch (CallerCtor->getConstructionKind()) {

NoQ wrote:
> Charusso wrote:
> > NoQ wrote:
> > > Charusso wrote:
> > > > May it is worth to handle the call outside to see whether it is 
> > > > non-null.
> > > Mmm, what do you mean?
> > It was that which is `null`-proof:
> > ```
> > if (const Stmt *Outer = LCtx->getStackFrame()->getCallSite()) {
> >   const CXXConstructExpr *OuterCtor = dyn_cast(Outer);
> >   if (OuterCtor) {
> > // ...
> >   }
> > }
> > ```
> That's exactly what `_or_null` stands for in `dyn_cast_or_null`.
Hm, I believe I had problems with that nullability a year ago, but it was long 
ago. Thanks for the clarification.


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

https://reviews.llvm.org/D61816



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


[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:451
+  if (const auto *CallerCtor = dyn_cast_or_null(
+  LCtx->getStackFrame()->getCallSite())) {
+switch (CallerCtor->getConstructionKind()) {

Charusso wrote:
> NoQ wrote:
> > Charusso wrote:
> > > May it is worth to handle the call outside to see whether it is non-null.
> > Mmm, what do you mean?
> It was that which is `null`-proof:
> ```
> if (const Stmt *Outer = LCtx->getStackFrame()->getCallSite()) {
>   const CXXConstructExpr *OuterCtor = dyn_cast(Outer);
>   if (OuterCtor) {
> // ...
>   }
> }
> ```
That's exactly what `_or_null` stands for in `dyn_cast_or_null`.


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

https://reviews.llvm.org/D61816



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


[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:451
+  if (const auto *CallerCtor = dyn_cast_or_null(
+  LCtx->getStackFrame()->getCallSite())) {
+switch (CallerCtor->getConstructionKind()) {

NoQ wrote:
> Charusso wrote:
> > May it is worth to handle the call outside to see whether it is non-null.
> Mmm, what do you mean?
It was that which is `null`-proof:
```
if (const Stmt *Outer = LCtx->getStackFrame()->getCallSite()) {
  const CXXConstructExpr *OuterCtor = dyn_cast(Outer);
  if (OuterCtor) {
// ...
  }
}
```


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

https://reviews.llvm.org/D61816



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


[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/include/clang/Analysis/CFG.h:567
+/// &&, |||  expression that uses result of && or ||, RHS
+/// vbase inits   |  handled by superclass; not handled by superclass
 ///

Szelethus wrote:
> In the context of this patch, I understand what you mean, but without that, 
> this might not be a good description for a class this important.
> 
> How about
> 
> ```
> /// vbase inits   |  initialization handled by superclass;
> ///   |  initialization not handled by superclass
> ```
> ?
Because this is a doxygen table syntax, i'm trying to make it look reasonable 
both in comments and in doxygen. In this sense it's hard to make line breaks in 
cells.

Hmm, btw, doxygen also fails to handle `||` because it thinks that it's a table 
cell delimiter. Let me fix that as well:

{F8921651}



Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:451
+  if (const auto *CallerCtor = dyn_cast_or_null(
+  LCtx->getStackFrame()->getCallSite())) {
+switch (CallerCtor->getConstructionKind()) {

Charusso wrote:
> May it is worth to handle the call outside to see whether it is non-null.
Mmm, what do you mean?


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

https://reviews.llvm.org/D61816



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


[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 201354.
NoQ marked 14 inline comments as done.
NoQ added a comment.

In D61816#1504590 , @Szelethus wrote:

> Hmmm, how about this?
>  ...
>  You are right that all virtual bases as initialized before everything else, 
> but not all ctor delegations are skipped. If not this specific one, can 
> something similar screw us over?
>  edit: Twin of the abomination above:
>  ...
>  edit2: What if the order of inheritance changes?


`VBase1(int)` is skipped because `B` is not the most derived class, 
`VBase2(std::string)` is not skipped because `C` is the most derived class. 
That's the whole point of the branch; i don't see a problem. AST handles the 
initialization order for us, all we need is to branch around it correctly. 
Added these tests^^


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

https://reviews.llvm.org/D61816

Files:
  clang/include/clang/Analysis/AnalysisDeclContext.h
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/test/Analysis/initializer.cpp
  clang/test/Analysis/initializers-cfg-output.cpp

Index: clang/test/Analysis/initializers-cfg-output.cpp
===
--- clang/test/Analysis/initializers-cfg-output.cpp
+++ clang/test/Analysis/initializers-cfg-output.cpp
@@ -30,21 +30,25 @@
 class B : public virtual A {
 public:
   // CHECK:   B()
-  // CHECK:[B2 (ENTRY)]
-  // CHECK-NEXT: Succs (1): B1
+  // CHECK:[B3 (ENTRY)]
+  // CHECK-NEXT: Succs (1): B2
   // CHECK:[B1]
   // WARNINGS-NEXT: 1:  (CXXConstructExpr, class A)
   // ANALYZER-NEXT: 1:  (CXXConstructExpr, A() (Base initializer), class A)
   // CHECK-NEXT: 2: A([B1.1]) (Base initializer)
   // CHECK-NEXT: Preds (1): B2
   // CHECK-NEXT: Succs (1): B0
+  // CHECK:[B2]
+  // CHECK-NEXT: T: (See if most derived ctor has already initialized vbases)
+  // CHECK-NEXT: Preds (1): B3
+  // CHECK-NEXT: Succs (2): B0 B1
   // CHECK:[B0 (EXIT)]
-  // CHECK-NEXT: Preds (1): B1
+  // CHECK-NEXT: Preds (2): B1 B2
   B() {}
 
   // CHECK:   B(int i)
-  // CHECK:[B2 (ENTRY)]
-  // CHECK-NEXT: Succs (1): B1
+  // CHECK:[B3 (ENTRY)]
+  // CHECK-NEXT: Succs (1): B2
   // CHECK:[B1]
   // CHECK-NEXT: 1: i
   // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
@@ -53,29 +57,37 @@
   // CHECK-NEXT: 4: A([B1.3]) (Base initializer)
   // CHECK-NEXT: Preds (1): B2
   // CHECK-NEXT: Succs (1): B0
+  // CHECK:[B2]
+  // CHECK-NEXT: T: (See if most derived ctor has already initialized vbases)
+  // CHECK-NEXT: Preds (1): B3
+  // CHECK-NEXT: Succs (2): B0 B1
   // CHECK:[B0 (EXIT)]
-  // CHECK-NEXT: Preds (1): B1
+  // CHECK-NEXT: Preds (2): B1 B2
   B(int i) : A(i) {}
 };
 
 class C : public virtual A {
 public:
   // CHECK:   C()
-  // CHECK:[B2 (ENTRY)]
-  // CHECK-NEXT: Succs (1): B1
+  // CHECK:[B3 (ENTRY)]
+  // CHECK-NEXT: Succs (1): B2
   // CHECK:[B1]
   // WARNINGS-NEXT: 1:  (CXXConstructExpr, class A)
   // ANALYZER-NEXT: 1:  (CXXConstructExpr, A() (Base initializer), class A)
   // CHECK-NEXT: 2: A([B1.1]) (Base initializer)
   // CHECK-NEXT: Preds (1): B2
   // CHECK-NEXT: Succs (1): B0
+  // CHECK:[B2]
+  // CHECK-NEXT: T: (See if most derived ctor has already initialized vbases)
+  // CHECK-NEXT: Preds (1): B3
+  // CHECK-NEXT: Succs (2): B0 B1
   // CHECK:[B0 (EXIT)]
-  // CHECK-NEXT: Preds (1): B1
+  // CHECK-NEXT: Preds (2): B1 B2
   C() {}
 
   // CHECK:   C(int i)
-  // CHECK:[B2 (ENTRY)]
-  // CHECK-NEXT: Succs (1): B1
+  // CHECK:[B3 (ENTRY)]
+  // CHECK-NEXT: Succs (1): B2
   // CHECK:[B1]
   // CHECK-NEXT: 1: i
   // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
@@ -84,8 +96,12 @@
   // CHECK-NEXT: 4: A([B1.3]) (Base initializer)
   // CHECK-NEXT: Preds (1): B2
   // CHECK-NEXT: Succs (1): B0
+  // CHECK:[B2]
+  // CHECK-NEXT: T: (See if most derived ctor has already initialized vbases)
+  // CHECK-NEXT: Preds (1): B3
+  // CHECK-NEXT: Succs (2): B0 B1
   // CHECK:[B0 (EXIT)]
-  // CHECK-NEXT: Preds (1): B1
+  // CHECK-NEXT: Preds (2): B1 B2
   C(int i) : A(i) {}
 };
 
@@ -98,31 +114,38 @@
 };
 
 // CHECK:   TestOrder::TestOrder()
-// CHECK:[B2 (ENTRY)]
-// CHECK-NEXT: Succs (1): B1
+// CHECK:[B4 (ENTRY)]
+// CHECK-NEXT: Succs (1): B3
 // CHECK:[B1]
+// WARNINGS-NEXT: 1:  

[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-24 Thread Yaqi Ji via Phabricator via cfe-commits
yaqiji added a comment.

Thank you so much for reviewing the code and providing great feedbacks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-24 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore added a comment.

Looks good! Thanks for being patient with me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-24 Thread Yaqi Ji via Phabricator via cfe-commits
yaqiji updated this revision to Diff 201352.
yaqiji marked 3 inline comments as done.
yaqiji added a comment.

Added fix message, and change global to nonstatic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045

Files:
  clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m

Index: clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
+++ clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
@@ -1,10 +1,14 @@
 // RUN: %check_clang_tidy %s google-objc-global-variable-declaration %t
 
 @class NSString;
+
 static NSString* const myConstString = @"hello";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
+extern NSString* const GlobalConstant = @"hey";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'GlobalConstant' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+
 static NSString* MyString = @"hi";
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'MyString' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* gMyString = @"hi";
@@ -25,13 +29,23 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
+static NSString* const notCap = @"NotBeginWithCap";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'notCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+// CHECK-FIXES: static NSString* const kNotCap = @"NotBeginWithCap";
+
 static NSString* const k_Alpha = @"SecondNotAlpha";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
+static NSString* const SecondNotCap = @"SecondNotCapOrNumber";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'SecondNotCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+// CHECK-FIXES: static NSString* const kSecondNotCap = @"SecondNotCapOrNumber";
+
 static NSString* const kGood = @"hello";
 static NSString* const XYGood = @"hello";
+static NSString* const X1Good = @"hello";
 static NSString* gMyIntGood = 0;
+extern NSString* Y2Good;
 
 extern NSString* const GTLServiceErrorDomain;
 
@@ -42,8 +56,8 @@
 
 @implementation Foo
 - (void)f {
-int x = 0;
-static int bar;
-static const int baz = 42;
+  int x = 0;
+  static int bar;
+  static const int baz = 42;
 }
 @end
Index: clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -23,29 +23,35 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
-}
+AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
+  if (IsConst && (Decl->getStorageClass() != SC_Static)) {
+// No fix available if it is not a static constant, since it is difficult
+// to determine the proper fix in this case.
+return FixItHint();
+  }
+
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
   }
   char SC = Decl->getName()[1];
   if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) {
-// No fix available if the prefix is correct but the second character is not
-// alphabetical, since it is difficult to determine the proper fix in this
-// case.
+// No fix available if the prefix is correct but the second character is
+// not alphabetical, since it is difficult to determine the proper fix in
+// this case.

[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-24 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked an inline comment as done.
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4385
+// Use the global scope for static members.
+DContext = getContextDescriptor(
+   cast(CGM.getContext().getTranslationUnitDecl()), TheCU);

akhuang wrote:
> dblaikie wrote:
> > akhuang wrote:
> > > @dblaikie I'm using the global scope here because if the class type is 
> > > used as the scope it runs into the [[ 
> > > https://github.com/llvm/llvm-project/blob/a2ee80b084e5c0b20364ed4379384706f5e059b1/llvm/lib/IR/DIBuilder.cpp#L630
> > >  | assert message ]] `Context of a global variable should not be a type 
> > > with identifier`. Is there a reason for the assert? 
> > I think it's generally how LLVM handles definitions for the most part - 
> > putting them at the global scope.
> > 
> > Though I'm confused by this patch - it has a source change in clang, but a 
> > test in LLVM. Generally there should be testing to cover where the source 
> > change is, I think?
> yep, there should be a test for this - added now. 
So for the global scope, it seems like [[ 
https://github.com/llvm-mirror/clang/blob/900624ef605b60c613342dac071228539a402ce9/lib/CodeGen/CGDebugInfo.cpp#L3274
 | elsewhere ]], when creating the debug info for a static data member global 
variable, the scope is set to be the global scope. But it would be helpful for 
codeview debug info if the scope remained as the class type, partially so we 
can use the class type information in the variable name that we emit.

Does it seem reasonable to remove the assert for global variable scope so that 
the scope can be the class here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167



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


Re: r361562 - Use clang_cc1 instead of clang in CodeGen test.

2019-05-24 Thread Alina Sbirlea via cfe-commits
Hi Douglas,

Please let me know if the build is fixed after r361674.

Thank you,
Alina


On Fri, May 24, 2019 at 2:26 PM  wrote:

> Hi Alina,
>
> This test that you added seems to fail on targets that don't build the x86
> backend, for example:
>
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/1855
>
>  TEST 'Clang :: CodeGen/loop-vectorize.c' FAILED
> 
> Script:
> --
> : 'RUN: at line 1';
>  /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang
> -cc1 -internal-isystem
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
> -nostdsysteminc -triple x86_64 -target-cpu x86-64 -S -O1 -vectorize-loops
> -emit-llvm -o -
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> |
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> -check-prefix=CHECK-ENABLE-VECT
> : 'RUN: at line 2';
>  /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang
> -cc1 -internal-isystem
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
> -nostdsysteminc -triple x86_64 -target-cpu x86-64 -S -O1 -emit-llvm -o -
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> |
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> -check-prefix=CHECK-DISABLE-VECT
> : 'RUN: at line 3';
>  /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang
> -cc1 -internal-isystem
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
> -nostdsysteminc -triple x86_64 -target-cpu x86-64
> -fexperimental-new-pass-manager -S -O1 -vectorize-loops -emit-llvm -o -
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> |
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> -check-prefix=CHECK-ENABLE-VECT
> : 'RUN: at line 4';
>  /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang
> -cc1 -internal-isystem
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
> -nostdsysteminc -triple x86_64 -target-cpu x86-64
> -fexperimental-new-pass-manager -S -O1 -emit-llvm -o -
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> |
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
> -check-prefix=CHECK-DISABLE-VECT
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c:7:23:
> error: CHECK-ENABLE-VECT: expected string not found in input
> // CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
>   ^
> :9:25: note: scanning from here
> define void @for_test() local_unnamed_addr #0 {
> ^
> :11:5: note: possible intended match here
>  %A = alloca [1000 x double], align 16
> ^
>
> --
>
> Can you take a look into fixing the test or running it only when the x86
> backend is present?
>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of Alina
> Sbirlea via cfe-commits
> Sent: Thursday, May 23, 2019 15:08
> To: cfe-commits@lists.llvm.org
> Subject: r361562 - Use clang_cc1 instead of clang in CodeGen test.
>
> Author: asbirlea
> Date: Thu May 23 15:07:37 2019
> New Revision: 361562
>
> URL: http://llvm.org/viewvc/llvm-project?rev=361562=rev
> Log:
> Use clang_cc1 instead of clang in CodeGen test.
>
> Modified:
> cfe/trunk/test/CodeGen/loop-vectorize.c
>
> Modified: cfe/trunk/test/CodeGen/loop-vectorize.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/loop-vectorize.c?rev=361562=361561=361562=diff
>
> ==
> --- cfe/trunk/test/CodeGen/loop-vectorize.c (original)
> +++ cfe/trunk/test/CodeGen/loop-vectorize.c Thu May 23 15:07:37 2019
> @@ -1,7 +1,7 @@
> -// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s |
> FileCheck %s -check-prefix=CHECK-ENABLE-VECT -// RUN: %clang -target x86_64
> -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s
> -check-prefix=CHECK-DISABLE-VECT -// RUN: %clang -target x86_64
> -fexperimental-new-pass-manager -S -c -O1 -fvectorize -emit-llvm -o - %s |
> FileCheck %s 

[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-24 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore marked 2 inline comments as done.
stephanemoore added a comment.

(sorry I forgot to send this earlier)

Two small things and then I think everything is good.




Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:29
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
+  if (IsConst && Decl->hasExternalStorage()) {
+// No fix available if it is a extern global constant, since it is 
difficult

This condition is probably technically fine since I don't believe it's possible 
for variables with auto or register storage classes to get here but if we were 
worried about that then I think we could change the condition to something like 
this:
```
if (IsConst && (Decl->getStorageClass() != SC_Static)) {
```



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:16-18
 NSString* globalString = @"test";
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: non-const global variable 
'globalString' must have a name which starts with 'g[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: NSString* gGlobalString = @"test";

This is definitely outside the scope of this commit but this fix seems like it 
would only be appropriate in an implementation file 樂



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:32
 
+static NSString* const notCap = @"NotBeginWithCap";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'notCap' 
must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]

Isn't this a case where we would expect `kNotCap` as a suggested fixit?



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:39
 
+static NSString* const SecondNotCap = @"SecondNotCapOrNumber";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'SecondNotCap' must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]

Isn't this a case where we would expect `kSecondNotCap` as a suggested fixit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


r361674 - Mark tests as x86.

2019-05-24 Thread Alina Sbirlea via cfe-commits
Author: asbirlea
Date: Fri May 24 14:49:27 2019
New Revision: 361674

URL: http://llvm.org/viewvc/llvm-project?rev=361674=rev
Log:
Mark tests as x86.

Modified:
cfe/trunk/test/CodeGen/loop-unroll.c
cfe/trunk/test/CodeGen/loop-vectorize.c

Modified: cfe/trunk/test/CodeGen/loop-unroll.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/loop-unroll.c?rev=361674=361673=361674=diff
==
--- cfe/trunk/test/CodeGen/loop-unroll.c (original)
+++ cfe/trunk/test/CodeGen/loop-unroll.c Fri May 24 14:49:27 2019
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
 // RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
 // RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// REQUIRES: x86-registered-target
 
 // CHECK-ENABLE-UNROLL-LABEL: @for_test()
 // CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]

Modified: cfe/trunk/test/CodeGen/loop-vectorize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/loop-vectorize.c?rev=361674=361673=361674=diff
==
--- cfe/trunk/test/CodeGen/loop-vectorize.c (original)
+++ cfe/trunk/test/CodeGen/loop-vectorize.c Fri May 24 14:49:27 2019
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -emit-llvm -o - %s 
| FileCheck %s -check-prefix=CHECK-DISABLE-VECT
 // RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -vectorize-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT
 // RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-VECT
+// REQUIRES: x86-registered-target
 
 // CHECK-ENABLE-VECT-LABEL: @for_test()
 // CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>


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


[PATCH] D60974: Clang IFSO driver action.

2019-05-24 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 201339.
plotfi added a comment.

More test improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/class-template-specialization.cpp
  clang/test/InterfaceStubs/externstatic.c
  clang/test/InterfaceStubs/function-template-specialization.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/inline.h
  clang/test/InterfaceStubs/object.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/visibility.cpp
  clang/test/InterfaceStubs/weak.cpp

Index: clang/test/InterfaceStubs/weak.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/weak.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
+// RUN: FileCheck --check-prefix=CHECK-YAML %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
+// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+// CHECK: Symbols:
+// CHECK-NEXT:  _Z8weakFuncv: { Type: Func, Weak: true }
+// CHECK-NEXT:  _Z10strongFuncv: { Type: Func }
+
+// CHECK-YAML: Symbols:
+// CHECK-YAML-NEXT:   - Name:_Z8weakFuncv
+// CHECK-YAML-NEXT: Type:STT_FUNC
+// CHECK-YAML-NEXT: Binding: STB_WEAK
+// CHECK-YAML-NEXT:   - Name:_Z10strongFuncv
+// CHECK-YAML-NEXT: Type:STT_FUNC
+// CHECK-YAML-NEXT: Binding: STB_GLOBAL
+
+// CHECK-SYMBOLS: _Z10strongFuncv
+// CHECK-SYMBOLS: _Z8weakFuncv
+__attribute__((weak)) void weakFunc() {}
+int strongFunc() { return 42; }
Index: clang/test/InterfaceStubs/visibility.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/visibility.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden \
+// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden \
+// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | FileCheck %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | FileCheck %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-readelf -s - 2>&1 | \
+// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+// Always Be Hidden:
+// CHECK-CMD-HIDDEN-NOT: _Z6hiddenv
+// CHECK-NOT: _Z6hiddenv
+__attribute__((visibility("hidden"))) void hidden() {}
+
+// Always Be Visible:
+// CHECK-CMD-HIDDEN: _Z9nothiddenv
+// CHECK: _Z9nothiddenv
+__attribute__((visibility("default"))) void nothidden() {}
+
+// Do Whatever -fvisibility says:
+// CHECK-CMD-HIDDEN-NOT: _Z10cmdVisiblev
+// CHECK: _Z10cmdVisiblev
+void cmdVisible() {}
+
+// CHECK-SYMBOLS: DEFAULT{{.*}} _Z10cmdVisiblev
+// CHECK-SYMBOLS: HIDDEN {{.*}} _Z6hiddenv
+// CHECK-SYMBOLS: DEFAULT{{.*}} _Z9nothiddenv
Index: clang/test/InterfaceStubs/template-namespace-function.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/template-namespace-function.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
+// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+// CHECK: Symbols:
+// CHECK-NEXT:  _ZN3qux3barEii: { Type: Func }
+// CHECK-NEXT:  _ZN3baz3addIiEET_S1_S1_: { Type: Func }
+// CHECK-NEXT:  _Z4fbarff: { Type: Func }
+// CHECK-NEXT:  _ZN3baz3addIfEET_S1_S1_: { Type: Func }
+
+// Same symbols just different order.
+// CHECK-SYMBOLS:   _Z4fbarff
+// CHECK-SYMBOLS-NEXT:  _ZN3baz3addIfEET_S1_S1_
+// CHECK-SYMBOLS-NEXT:  _ZN3baz3addIiEET_S1_S1_

[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-24 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 201338.
jkorous added a comment.

- simplify link libraries in cmake
- fix Release build (messed-up asserts)


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

https://reviews.llvm.org/D58418

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryScanner.cpp
  clang/lib/DirectoryWatcher/DirectoryScanner.h
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,427 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace clang {
+static bool operator==(const DirectoryWatcher::Event ,
+   const DirectoryWatcher::Event ) {
+  return lhs.Filename == rhs.Filename &&
+ static_cast(lhs.Kind) == static_cast(rhs.Kind);
+}
+} // namespace clang
+
+namespace {
+
+struct DirectoryWatcherTestFixture {
+  std::string TestRootDir;
+  std::string TestWatchedDir;
+
+  DirectoryWatcherTestFixture() {
+SmallString<128> pathBuf;
+std::error_code UniqDirRes = createUniqueDirectory("dirwatcher", pathBuf);
+assert(!UniqDirRes);
+TestRootDir = pathBuf.str();
+path::append(pathBuf, "watch");
+TestWatchedDir = pathBuf.str();
+std::error_code CreateDirRes = create_directory(TestWatchedDir, false);
+assert(!CreateDirRes);
+  }
+
+  ~DirectoryWatcherTestFixture() { remove_directories(TestRootDir); }
+
+  SmallString<128> getPathInWatched(const std::string ) {
+SmallString<128> pathBuf;
+pathBuf = TestWatchedDir;
+path::append(pathBuf, testFile);
+return pathBuf;
+  }
+
+  void addFile(const std::string ) {
+Expected ft = openNativeFileForWrite(getPathInWatched(testFile),
+ CD_CreateNew, OF_None);
+if (ft) {
+  closeFile(*ft);
+} else {
+  llvm::errs() << llvm::toString(ft.takeError()) << "\n";
+  llvm::errs() << getPathInWatched(testFile) << "\n";
+  llvm_unreachable("Couldn't create test file.");
+}
+  }
+
+  void deleteFile(const std::string ) {
+std::error_code EC =
+remove(getPathInWatched(testFile), /*IgnoreNonExisting=*/false);
+ASSERT_FALSE(EC);
+  }
+};
+
+std::string EventKindToString(const DirectoryWatcher::Event::EventKind K) {
+  switch (K) {
+  case DirectoryWatcher::Event::EventKind::Added:
+return "Added";
+  case DirectoryWatcher::Event::EventKind::Removed:
+return "Removed";
+  case DirectoryWatcher::Event::EventKind::Modified:
+return "Modified";
+  case DirectoryWatcher::Event::EventKind::WatchedDirRemoved:
+return "WatchedDirRemoved";
+  case DirectoryWatcher::Event::EventKind::WatcherGotInvalidated:
+return "WatcherGotInvalidated";
+  }
+  llvm_unreachable("unknown event kind");
+}
+
+struct VerifyingConsumer {
+  std::vector ExpectedInitial;
+  std::vector ExpectedNonInitial;
+  std::vector OptionalNonInitial;
+  std::vector UnexpectedInitial;
+  std::vector UnexpectedNonInitial;
+  std::mutex Mtx;
+  std::condition_variable ResultIsReady;
+
+  VerifyingConsumer(
+  const std::vector ,
+  const std::vector ,
+  const std::vector  = {})
+  : ExpectedInitial(ExpectedInitial),
+ExpectedNonInitial(ExpectedNonInitial),
+OptionalNonInitial(OptionalNonInitial) {}
+
+  // This method is used by DirectoryWatcher
+  void consume(DirectoryWatcher::Event E, bool IsInitial) {
+if (IsInitial)
+  consumeInitial(E);
+else
+  consumeNonInitial(E);
+  }
+
+  void consumeInitial(DirectoryWatcher::Event E) {
+std::unique_lock L(Mtx);
+auto It = std::find(ExpectedInitial.begin(), ExpectedInitial.end(), E);
+if (It == ExpectedInitial.end()) {
+  UnexpectedInitial.push_back(E);
+} else {
+  ExpectedInitial.erase(It);
+}
+if (Result())
+  ResultIsReady.notify_one();
+  }
+
+  

[PATCH] D62429: Fix linkage of _ZTS strings for types involving incomplete classes to match the Itanium ABI rules.

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without this patch, type_info objects for pointers to incomplete classes
compare unequal with libc++ when formed in multiple translation units,
because each translation unit has its own copy of the _ZTS symbol, in
violation of the Itanium ABI's uniqueness rule.


Repository:
  rC Clang

https://reviews.llvm.org/D62429

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/rtti-linkage.cpp

Index: test/CodeGenCXX/rtti-linkage.cpp
===
--- test/CodeGenCXX/rtti-linkage.cpp
+++ test/CodeGenCXX/rtti-linkage.cpp
@@ -3,27 +3,36 @@
 
 #include 
 
-// CHECK-BOTH: _ZTSP1C = internal constant
-// CHECK-BOTH: _ZTS1C = internal constant
+// CHECK: _ZTSP1C = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSP1C = linkonce_odr hidden constant
+// CHECK: _ZTS1C = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTS1C = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTI1C = internal constant
 // CHECK-BOTH: _ZTIP1C = internal constant
-// CHECK-BOTH: _ZTSPP1C = internal constant
+// CHECK: _ZTSPP1C = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSPP1C = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIPP1C = internal constant
-// CHECK-BOTH: _ZTSM1Ci = internal constant
+// CHECK: _ZTSM1Ci = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSM1Ci = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIM1Ci = internal constant
-// CHECK-BOTH: _ZTSPM1Ci = internal constant
+// CHECK: _ZTSPM1Ci = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSPM1Ci = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIPM1Ci = internal constant
-// CHECK-BOTH: _ZTSM1CS_ = internal constant
+// CHECK: _ZTSM1CS_ = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSM1CS_ = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIM1CS_ = internal constant
-// CHECK-BOTH: _ZTSM1CPS_ = internal constant
+// CHECK: _ZTSM1CPS_ = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSM1CPS_ = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIM1CPS_ = internal constant
-// CHECK-BOTH: _ZTSM1A1C = internal constant
+// CHECK: _ZTSM1A1C = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSM1A1C = linkonce_odr hidden constant
 // CHECK: _ZTS1A = linkonce_odr constant
 // CHECK-WITH-HIDDEN: _ZTS1A = linkonce_odr hidden constant
 // CHECK: _ZTI1A = linkonce_odr constant
 // CHECK-WITH-HIDDEN: _ZTI1A = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIM1A1C = internal constant
-// CHECK-BOTH: _ZTSM1AP1C = internal constant
+// CHECK: _ZTSM1AP1C = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTSM1AP1C = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIM1AP1C = internal constant
 
 // CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -3155,18 +3155,6 @@
 /// should have for the given type.
 static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule ,
  QualType Ty) {
-  // Itanium C++ ABI 2.9.5p7:
-  //   In addition, it and all of the intermediate abi::__pointer_type_info
-  //   structs in the chain down to the abi::__class_type_info for the
-  //   incomplete class type must be prevented from resolving to the
-  //   corresponding type_info structs for the complete class type, possibly
-  //   by making them local static objects. Finally, a dummy class RTTI is
-  //   generated for the incomplete type that will not resolve to the final
-  //   complete class RTTI (because the latter need not exist), possibly by
-  //   making it a local static object.
-  if (ContainsIncompleteClassType(Ty))
-return llvm::GlobalValue::InternalLinkage;
-
   switch (Ty->getLinkage()) {
   case NoLinkage:
   case InternalLinkage:
@@ -3184,6 +3172,11 @@
 
 if (const RecordType *Record = dyn_cast(Ty)) {
   const CXXRecordDecl *RD = cast(Record->getDecl());
+  // If the class is incomplete, we're forming the pointee of an incomplete
+  // pointer typeinfo. This linkage will only be used for the type name;
+  // give it linkonce_odr linkage.
+  if (!RD->isCompleteDefinition())
+return llvm::GlobalValue::LinkOnceODRLinkage;
   if (RD->hasAttr())
 return llvm::GlobalValue::WeakODRLinkage;
   if (CGM.getTriple().isWindowsItaniumEnvironment())
@@ -3255,20 +3248,20 @@
 
 llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
   QualType Ty,
-  llvm::GlobalVariable::LinkageTypes Linkage,
-  llvm::GlobalValue::VisibilityTypes Visibility,
+  llvm::GlobalVariable::LinkageTypes TypeNameLinkage,
+  llvm::GlobalValue::VisibilityTypes TypeNameVisibility,
   llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass) {
   // Add the vtable pointer.
   BuildVTablePointer(cast(Ty));
 
   // And the 

RE: r361562 - Use clang_cc1 instead of clang in CodeGen test.

2019-05-24 Thread via cfe-commits
Hi Alina,

This test that you added seems to fail on targets that don't build the x86 
backend, for example:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/1855

 TEST 'Clang :: CodeGen/loop-vectorize.c' FAILED 

Script:
--
: 'RUN: at line 1';   
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang 
-cc1 -internal-isystem 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
 -nostdsysteminc -triple x86_64 -target-cpu x86-64 -S -O1 -vectorize-loops 
-emit-llvm -o - 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 | 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 -check-prefix=CHECK-ENABLE-VECT
: 'RUN: at line 2';   
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang 
-cc1 -internal-isystem 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
 -nostdsysteminc -triple x86_64 -target-cpu x86-64 -S -O1 -emit-llvm -o - 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 | 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 -check-prefix=CHECK-DISABLE-VECT
: 'RUN: at line 3';   
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang 
-cc1 -internal-isystem 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
 -nostdsysteminc -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -vectorize-loops -emit-llvm -o - 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 | 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 -check-prefix=CHECK-ENABLE-VECT
: 'RUN: at line 4';   
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang 
-cc1 -internal-isystem 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/9.0.0/include
 -nostdsysteminc -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -emit-llvm -o - 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 | 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c
 -check-prefix=CHECK-DISABLE-VECT
--
Exit Code: 1

Command Output (stderr):
--
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGen/loop-vectorize.c:7:23:
 error: CHECK-ENABLE-VECT: expected string not found in input
// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
  ^
:9:25: note: scanning from here
define void @for_test() local_unnamed_addr #0 {
^
:11:5: note: possible intended match here
 %A = alloca [1000 x double], align 16
^

--

Can you take a look into fixing the test or running it only when the x86 
backend is present?

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Alina 
Sbirlea via cfe-commits
Sent: Thursday, May 23, 2019 15:08
To: cfe-commits@lists.llvm.org
Subject: r361562 - Use clang_cc1 instead of clang in CodeGen test.

Author: asbirlea
Date: Thu May 23 15:07:37 2019
New Revision: 361562

URL: http://llvm.org/viewvc/llvm-project?rev=361562=rev
Log:
Use clang_cc1 instead of clang in CodeGen test.

Modified:
cfe/trunk/test/CodeGen/loop-vectorize.c

Modified: cfe/trunk/test/CodeGen/loop-vectorize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/loop-vectorize.c?rev=361562=361561=361562=diff
==
--- cfe/trunk/test/CodeGen/loop-vectorize.c (original)
+++ cfe/trunk/test/CodeGen/loop-vectorize.c Thu May 23 15:07:37 2019
@@ -1,7 +1,7 @@
-// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT -// RUN: %clang -target x86_64 -S 
-c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-VECT -// RUN: %clang -target x86_64 
-fexperimental-new-pass-manager -S -c -O1 -fvectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT -// RUN: %clang -target x86_64 
-fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 
+-vectorize-loops -emit-llvm -o - %s | 

r361670 - Default arguments are potentially constant evaluated.

2019-05-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 24 14:08:12 2019
New Revision: 361670

URL: http://llvm.org/viewvc/llvm-project?rev=361670=rev
Log:
Default arguments are potentially constant evaluated.

We need to eagerly instantiate constexpr functions used in them even if
the default argument is never actually used, because we might evaluate
portions of it when performing semantic checks.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/default1.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=361670=361669=361670=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 24 14:08:12 2019
@@ -14739,6 +14739,7 @@ static bool isPotentiallyConstantEvaluat
 case Sema::ExpressionEvaluationContext::ConstantEvaluated:
   // -- a manifestly constant-evaluated expression,
 case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
+case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
 case Sema::ExpressionEvaluationContext::DiscardedStatement:
   // -- a potentially-evaluated expression,
 case Sema::ExpressionEvaluationContext::UnevaluatedList:
@@ -14754,11 +14755,6 @@ static bool isPotentiallyConstantEvaluat
 case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
   // Expressions in this context are never evaluated.
   return false;
-
-case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
-  // FIXME: This is wrong. Default arguemnts are potentially constant
-  // evaluated even if they are never used.
-  return false;
   }
   llvm_unreachable("Invalid context");
 }

Modified: cfe/trunk/test/SemaCXX/default1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default1.cpp?rev=361670=361669=361670=diff
==
--- cfe/trunk/test/SemaCXX/default1.cpp (original)
+++ cfe/trunk/test/SemaCXX/default1.cpp Fri May 24 14:08:12 2019
@@ -78,3 +78,21 @@ void PR20769(int = 2);
 
 void PR20769_b(int = 1);
 void PR20769_b() { void PR20769_b(int = 2); }
+
+#if __cplusplus >= 201103L
+template constexpr int f1() { return 0; }
+// This is OK, but in order to see that we must instantiate f, despite it
+// being in an unused default argument.
+void g1(char c = {f1()}) {} // expected-warning {{braces around scalar}}
+
+// This is formally ill-formed, but we choose to not trigger instantiation here
+// (at least, not until g2 is actually called in a way that uses the default
+// argument).
+template int f2() { return T::error; }
+void g2(int c = f2()) {}
+
+// FIXME: Provide a note pointing at the first use of the default argument?
+template int f3() { return T::error; } // expected-error {{no 
members}}
+void g3(int c = f3()) {} // expected-note {{in instantiation of}}
+void use_g3() { g3(); }
+#endif


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


[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

In D61472#1516642 , @craig.topper 
wrote:

> In D61472#1515994 , @spatel wrote:
>
> > I haven't looked closely at the series of transforms that gets us here, so 
> > let me ask: would it be more efficient to produce the add/inc/dec machine 
> > instructions directly rather than LEA? Or do we do this because the 
> > 3-address opportunity helps register allocation, so this late reversal is a 
> > special-case of the more generally useful transforms that produce LEA in 
> > the 1st place?
>
>
> I believe a lot of these are caused TwoAddressInstructionPass converting to 
> three address sometimes when it maybe shouldn't. I think there's some overlap 
> with the test diffs in D52109 . But I don't 
> think the change I made in that diff is correct. There appear to be some test 
> changes here that aren't affected by that patch either. So maybe there are 
> other issues in TwoAddressInstruction heuristics.


Ok - these diffs look alright, so LGTM. Maybe we can adjust the earlier 
transforms to avoid some back-and-forth though as follow-up work.


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

https://reviews.llvm.org/D61472



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


r361668 - Refactor use-marking to better match standard terminology. No

2019-05-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 24 13:42:25 2019
New Revision: 361668

URL: http://llvm.org/viewvc/llvm-project?rev=361668=rev
Log:
Refactor use-marking to better match standard terminology. No
functionality change intended.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=361668=361667=361668=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 24 13:42:25 2019
@@ -14730,55 +14730,84 @@ ExprResult Sema::HandleExprEvaluationCon
   return TransformToPotentiallyEvaluated(E);
 }
 
-/// Are we within a context in which some evaluation could be performed (be it
-/// constant evaluation or runtime evaluation)? Sadly, this notion is not quite
-/// captured by C++'s idea of an "unevaluated context".
-static bool isEvaluatableContext(Sema ) {
+/// Are we in a context that is potentially constant evaluated per C++20
+/// [expr.const]p12?
+static bool isPotentiallyConstantEvaluatedContext(Sema ) {
+  /// C++2a [expr.const]p12:
+  //   An expression or conversion is potentially constant evaluated if it is
   switch (SemaRef.ExprEvalContexts.back().Context) {
-case Sema::ExpressionEvaluationContext::Unevaluated:
-case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
-  // Expressions in this context are never evaluated.
-  return false;
-
-case Sema::ExpressionEvaluationContext::UnevaluatedList:
 case Sema::ExpressionEvaluationContext::ConstantEvaluated:
+  // -- a manifestly constant-evaluated expression,
 case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
 case Sema::ExpressionEvaluationContext::DiscardedStatement:
-  // Expressions in this context could be evaluated.
+  // -- a potentially-evaluated expression,
+case Sema::ExpressionEvaluationContext::UnevaluatedList:
+  // -- an immediate subexpression of a braced-init-list,
+
+  // -- [FIXME] an expression of the form & cast-expression that occurs
+  //within a templated entity
+  // -- a subexpression of one of the above that is not a subexpression of
+  // a nested unevaluated operand.
   return true;
 
+case Sema::ExpressionEvaluationContext::Unevaluated:
+case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
+  // Expressions in this context are never evaluated.
+  return false;
+
 case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
-  // Referenced declarations will only be used if the construct in the
-  // containing expression is used, at which point we'll be given another
-  // turn to mark them.
+  // FIXME: This is wrong. Default arguemnts are potentially constant
+  // evaluated even if they are never used.
   return false;
   }
   llvm_unreachable("Invalid context");
 }
 
+namespace {
+enum class OdrUseContext {
+  /// Declarations in this context are not odr-used.
+  None,
+  /// Declarations in this context are formally odr-used, but this is a
+  /// dependent context.
+  Dependent,
+  /// Declarations in this context are odr-used but not actually used (yet).
+  FormallyOdrUsed,
+  /// Declarations in this context are used.
+  Used
+};
+}
+
 /// Are we within a context in which references to resolved functions or to
 /// variables result in odr-use?
-static bool isOdrUseContext(Sema , bool SkipDependentUses = true) {
-  // An expression in a template is not really an expression until it's been
-  // instantiated, so it doesn't trigger odr-use.
-  if (SkipDependentUses && SemaRef.CurContext->isDependentContext())
-return false;
+static OdrUseContext isOdrUseContext(Sema ) {
+  OdrUseContext Result;
 
   switch (SemaRef.ExprEvalContexts.back().Context) {
 case Sema::ExpressionEvaluationContext::Unevaluated:
 case Sema::ExpressionEvaluationContext::UnevaluatedList:
 case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
-case Sema::ExpressionEvaluationContext::DiscardedStatement:
-  return false;
+  return OdrUseContext::None;
 
 case Sema::ExpressionEvaluationContext::ConstantEvaluated:
 case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
-  return true;
+  Result = OdrUseContext::Used;
+  break;
+
+case Sema::ExpressionEvaluationContext::DiscardedStatement:
+  Result = OdrUseContext::FormallyOdrUsed;
+  break;
 
 case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
-  return false;
+  // A default argument formally results in odr-use, but doesn't actually
+  // result in a use in any real sense until it itself is used.
+  Result = OdrUseContext::FormallyOdrUsed;
+  break;
   }
-  llvm_unreachable("Invalid context");
+
+  if (SemaRef.CurContext->isDependentContext())
+return OdrUseContext::Dependent;
+
+  return Result;
 }
 
 static bool 

[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Just one question after looking at the test: how we're going to link the device 
variable to its host copy? I think the address should be passed to the runtime, 
no?




Comment at: lib/CodeGen/CGOpenMPRuntime.h:1628
+  /// Return whether the unified_shared_memory has been specified.
+  virtual bool hasRequiresUnifiedSharedMemory();
 };

ABataev wrote:
> Do we need to make it virtual?
Still not answered


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-24 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 201321.
jkorous added a comment.

Specify what "file modified" means and add a test for metadata change


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

https://reviews.llvm.org/D58418

Files:
  clang/cmake/modules/AddClang.cmake
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryScanner.cpp
  clang/lib/DirectoryWatcher/DirectoryScanner.h
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,424 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace clang {
+static bool operator==(const DirectoryWatcher::Event ,
+   const DirectoryWatcher::Event ) {
+  return lhs.Filename == rhs.Filename &&
+ static_cast(lhs.Kind) == static_cast(rhs.Kind);
+}
+} // namespace clang
+
+namespace {
+
+struct DirectoryWatcherTestFixture {
+  std::string TestRootDir;
+  std::string TestWatchedDir;
+
+  DirectoryWatcherTestFixture() {
+SmallString<128> pathBuf;
+assert(!createUniqueDirectory("dirwatcher", pathBuf));
+TestRootDir = pathBuf.str();
+path::append(pathBuf, "watch");
+TestWatchedDir = pathBuf.str();
+assert(!create_directory(TestWatchedDir, false));
+  }
+
+  ~DirectoryWatcherTestFixture() { remove_directories(TestRootDir); }
+
+  SmallString<128> getPathInWatched(const std::string ) {
+SmallString<128> pathBuf;
+pathBuf = TestWatchedDir;
+path::append(pathBuf, testFile);
+return pathBuf;
+  }
+
+  void addFile(const std::string ) {
+Expected ft = openNativeFileForWrite(getPathInWatched(testFile),
+ CD_CreateNew, OF_None);
+if (ft) {
+  closeFile(*ft);
+} else {
+  llvm::errs() << llvm::toString(ft.takeError()) << "\n";
+  llvm::errs() << getPathInWatched(testFile) << "\n";
+  llvm_unreachable("Couldn't create test file.");
+}
+  }
+
+  void deleteFile(const std::string ) {
+std::error_code EC =
+remove(getPathInWatched(testFile), /*IgnoreNonExisting=*/false);
+ASSERT_FALSE(EC);
+  }
+};
+
+std::string EventKindToString(const DirectoryWatcher::Event::EventKind K) {
+  switch (K) {
+  case DirectoryWatcher::Event::EventKind::Added:
+return "Added";
+  case DirectoryWatcher::Event::EventKind::Removed:
+return "Removed";
+  case DirectoryWatcher::Event::EventKind::Modified:
+return "Modified";
+  case DirectoryWatcher::Event::EventKind::WatchedDirRemoved:
+return "WatchedDirRemoved";
+  case DirectoryWatcher::Event::EventKind::WatcherGotInvalidated:
+return "WatcherGotInvalidated";
+  }
+  llvm_unreachable("unknown event kind");
+}
+
+struct VerifyingConsumer {
+  std::vector ExpectedInitial;
+  std::vector ExpectedNonInitial;
+  std::vector OptionalNonInitial;
+  std::vector UnexpectedInitial;
+  std::vector UnexpectedNonInitial;
+  std::mutex Mtx;
+  std::condition_variable ResultIsReady;
+
+  VerifyingConsumer(
+  const std::vector ,
+  const std::vector ,
+  const std::vector  = {})
+  : ExpectedInitial(ExpectedInitial),
+ExpectedNonInitial(ExpectedNonInitial),
+OptionalNonInitial(OptionalNonInitial) {}
+
+  // This method is used by DirectoryWatcher
+  void consume(DirectoryWatcher::Event E, bool IsInitial) {
+if (IsInitial)
+  consumeInitial(E);
+else
+  consumeNonInitial(E);
+  }
+
+  void consumeInitial(DirectoryWatcher::Event E) {
+std::unique_lock L(Mtx);
+auto It = std::find(ExpectedInitial.begin(), ExpectedInitial.end(), E);
+if (It == ExpectedInitial.end()) {
+  UnexpectedInitial.push_back(E);
+} else {
+  ExpectedInitial.erase(It);
+}
+if (Result())
+  ResultIsReady.notify_one();
+  }
+
+  void consumeNonInitial(DirectoryWatcher::Event E) {
+

[PATCH] D61970: [CodeGen][ObjC] Call objc_autoreleaseReturnValue and objc_retainAutoreleasedReturnValue instead of objc_autorelease and objc_retain in MRR

2019-05-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak abandoned this revision.
ahatanak added a comment.

This isn't the right way to make a call to `objc_autorelease` a tail call, so 
I'm closing this for now. If we decide to convert calls to `objc_autorelease` 
and `objc_retain` to calls to `objc_autoreleaseReturnValue` and 
`objc_retainAutoreleasedReturnValue` for other reasons in the future, I can 
reopen this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61970



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


[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D61472#1515994 , @spatel wrote:

> I haven't looked closely at the series of transforms that gets us here, so 
> let me ask: would it be more efficient to produce the add/inc/dec machine 
> instructions directly rather than LEA? Or do we do this because the 3-address 
> opportunity helps register allocation, so this late reversal is a 
> special-case of the more generally useful transforms that produce LEA in the 
> 1st place?


I believe a lot of these are caused TwoAddressInstructionPass converting to 
three address sometimes when it maybe shouldn't. I think there's some overlap 
with the test diffs in D52109 . But I don't 
think the change I made in that diff is correct. There appear to be some test 
changes here that aren't affected by that patch either. So maybe there are 
other issues in TwoAddressInstruction heuristics.


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

https://reviews.llvm.org/D61472



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D59402#1516589 , @aaronpuchert 
wrote:

> Perhaps we could clarify in the docs that fix-it hints on warnings are 
> appropriate only if they don't change anything except suppressing the warning.


That sounds like a great idea. Do you want to put together a quick 
documentation patch? :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D62279: Use LTO capable linker

2019-05-24 Thread Wink Saville via Phabricator via cfe-commits
winksaville added a comment.

So this compiles and as such improves on what we currently have and as such I 
think it should be merged,
although there maybe other solutions. It still fails `ninja stage2-check-all` 
with the gtest problem which
@beanz is working on resolving.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62279



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith marked an inline comment as done.
rsmith added a comment.

Looks good with a few largely-mechanical changes.




Comment at: include/clang/Basic/DiagnosticParseKinds.td:30
   "GNU-style inline assembly is disabled">;
-def err_asm_goto_not_supported_yet : Error<
-  "'asm goto' constructs are not supported yet">;
+def err_asm_goto_can_not_have_output : Error<
+  "'asm goto' cannot have output constraints">;

Nit: `can_not` -> `cannot`



Comment at: lib/Parse/ParseStmtAsm.cpp:806
 // Parse the asm-string list for clobbers if present.
-if (Tok.isNot(tok::r_paren)) {
+if (!AteExtraColon && Tok.isNot(tok::r_paren) &&
+isTokenStringLiteral()) {

Nit: the `Tok.isNot(tok::r_paren)` check here is redundant, since 
`isTokenStringLiteral()` covers that check.



Comment at: lib/Parse/ParseStmtAsm.cpp:821
   }
+  if (!isGotoAsm && Tok.isNot(tok::r_paren)) {
+Diag(Tok, diag::err_expected) << tok::r_paren;

I think this should be:

```
  if (!isGotoAsm && (Tok.isNot(tok::r_paren) || AteExtraColon)) {
```

otherwise we'll accept a spurious extra colon split from a `::` at the end of a 
non-`goto` `asm`. Eg, I think in C++:

```
void f() { asm("" : : :: ); }
```

... would be incorrectly accepted, because we'll parse the final `::` as 
introducing the clobbers list, consume the `::` token, pass this check because 
the next token is now `)`, and never notice we didn't use the second half of 
the `::` token.



Comment at: lib/Sema/SemaStmtAsm.cpp:659-671
+if (NS->getIdentifier(i))
+  MyList.emplace_back(std::make_pair(NS->getIdentifier(i)->getName(),
+ Exprs[i]));
+  for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; ++i)
+if (NS->getIdentifier(i))
+  MyList.emplace_back(std::make_pair(NS->getIdentifier(i)->getName(),
+ Exprs[i]));

jyu2 wrote:
> rsmith wrote:
> > This is still exposing / relying on an implementation detail of 
> > `GCCAsmStmt`. Please replace `getIdentifier` with `getOuptutIdentifier` / 
> > `getInputIdentifier` / `getLabelIdentifier`, adjust the indexing to match, 
> > and remove `GCCAsmStmt::getIdentifier`. Or alternatively, iterate over 
> > `Names` here rather than walking the parts of the `GCCAsmStmt`.
> Changed.  Like this!!!
This is really neat, thanks!



Comment at: lib/Sema/SemaStmtAsm.cpp:672
+  // Sort NamedOperandList.
+  stable_sort(NamedOperandList.begin(), NamedOperandList.end(),
+  [](const NamedOperand , const NamedOperand ) {

Nit: explicitly spell this as `std::stable_sort` instead of relying on ADL to 
find it from the `std::` in the type of `NamedOperand`.


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

https://reviews.llvm.org/D56571



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


[PATCH] D62420: Rename clangToolingRefactor to clangToolingRefactoring for consistency with its directory

2019-05-24 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rsmith.
Herald added subscribers: llvm-commits, kadircet, arphaman, jkorous, mgorny.
Herald added a project: LLVM.

See "[cfe-dev] The name of clang/lib/Tooling/Refactoring".


https://reviews.llvm.org/D62420

Files:
  clang-tools-extra/clang-apply-replacements/CMakeLists.txt
  clang-tools-extra/clang-apply-replacements/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/tool-template/CMakeLists.txt
  clang-tools-extra/unittests/clang-apply-replacements/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/tools/clang-refactor/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/unittests/Rename/CMakeLists.txt
  clang/unittests/Tooling/CMakeLists.txt
  llvm/utils/gn/secondary/clang/lib/Tooling/Refactoring/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/Refactoring/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/Refactoring/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/Refactoring/BUILD.gn
@@ -1,5 +1,5 @@
 static_library("Refactoring") {
-  output_name = "clangToolingRefactor"
+  output_name = "clangToolingRefactoring"
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
 "//clang/lib/AST",
Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -70,7 +70,7 @@
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactor
+  clangToolingRefactoring
   LLVMTestingSupport
   )
 
Index: clang/unittests/Rename/CMakeLists.txt
===
--- clang/unittests/Rename/CMakeLists.txt
+++ clang/unittests/Rename/CMakeLists.txt
@@ -24,5 +24,5 @@
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang/tools/clang-rename/CMakeLists.txt
===
--- clang/tools/clang-rename/CMakeLists.txt
+++ clang/tools/clang-rename/CMakeLists.txt
@@ -15,7 +15,7 @@
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
 
 install(PROGRAMS clang-rename.py
Index: clang/tools/clang-refactor/CMakeLists.txt
===
--- clang/tools/clang-refactor/CMakeLists.txt
+++ clang/tools/clang-refactor/CMakeLists.txt
@@ -19,5 +19,5 @@
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_library(clangToolingRefactor
+add_clang_library(clangToolingRefactoring
   ASTSelection.cpp
   ASTSelectionRequirements.cpp
   AtomicChange.cpp
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -37,5 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang-tools-extra/unittests/clang-apply-replacements/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-apply-replacements/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-apply-replacements/CMakeLists.txt
@@ -16,5 +16,5 @@
   clangApplyReplacements
   clangBasic
   clangToolingCore
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang-tools-extra/tool-template/CMakeLists.txt
===
--- clang-tools-extra/tool-template/CMakeLists.txt
+++ clang-tools-extra/tool-template/CMakeLists.txt
@@ -13,5 +13,5 @@
   clangBasic
   clangFrontend
   clangTooling
-  clangToolingRefactor
+  clangToolingRefactoring
   )
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -125,7 +125,7 @@
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactor
+  clangToolingRefactoring
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}
   )
Index: clang-tools-extra/clang-tidy/utils/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/utils/CMakeLists.txt
+++ 

[PATCH] D62419: [LibTooling] Add `before` and `after` selectors for selecting point-ranges relative to nodes.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.

The `before` and `after` selectors allow users to specify a zero-length range --
a point -- at the relevant location in an AST-node's source.  Point ranges can
be useful, for example, to insert a change using an API that takes a range to be
modified (e.g. `tooling::change()`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62419

Files:
  clang/include/clang/Tooling/Refactoring/RangeSelector.h
  clang/lib/Tooling/Refactoring/RangeSelector.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -21,13 +21,15 @@
 using namespace ast_matchers;
 
 namespace {
-using ::testing::AllOf;
-using ::testing::HasSubstr;
-using MatchResult = MatchFinder::MatchResult;
 using ::llvm::Expected;
 using ::llvm::Failed;
 using ::llvm::HasValue;
 using ::llvm::StringError;
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+using ::testing::Property;
+
+using MatchResult = MatchFinder::MatchResult;
 
 struct TestMatch {
   // The AST unit from which `result` is built. We bundle it because it backs
@@ -117,6 +119,53 @@
Failed(withUnboundNodeMessage()));
 }
 
+MATCHER_P(EqualsCharSourceRange, Range, "") {
+  return Range.getAsRange() == arg.getAsRange() &&
+ Range.isTokenRange() == arg.isTokenRange();
+}
+
+TEST(RangeSelectorTest, BeforeOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  StringRef Call = "call";
+  TestMatch Match = matchCode(Code, callExpr().bind(Call));
+  const auto* E = Match.Result.Nodes.getNodeAs(Call);
+  assert(E != nullptr);
+  auto ExprBegin = E->getSourceRange().getBegin();
+  EXPECT_THAT_EXPECTED(
+  before(node(Call))(Match.Result),
+  HasValue(EqualsCharSourceRange(
+  CharSourceRange::getCharRange(ExprBegin, ExprBegin;
+}
+
+TEST(RangeSelectorTest, AfterOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  StringRef Call = "call";
+  TestMatch Match = matchCode(Code, callExpr().bind(Call));
+  const auto* E = Match.Result.Nodes.getNodeAs(Call);
+  assert(E != nullptr);
+  const SourceRange Range = E->getSourceRange();
+  // The end token, a right paren, is one character wide, so advance by one,
+  // bringing us to the semicolon.
+  const SourceLocation SemiLoc = Range.getEnd().getLocWithOffset(1);
+  const auto ExpectedAfter = CharSourceRange::getCharRange(SemiLoc, SemiLoc);
+
+  // Test with a char range.
+  auto CharRange = CharSourceRange::getCharRange(Range.getBegin(), SemiLoc);
+  EXPECT_THAT_EXPECTED(after(charRange(CharRange))(Match.Result),
+   HasValue(EqualsCharSourceRange(ExpectedAfter)));
+
+  // Test with a token range.
+  auto TokenRange = CharSourceRange::getTokenRange(Range);
+  EXPECT_THAT_EXPECTED(after(charRange(TokenRange))(Match.Result),
+   HasValue(EqualsCharSourceRange(ExpectedAfter)));
+}
+
 TEST(RangeSelectorTest, RangeOp) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
Index: clang/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- clang/lib/Tooling/Refactoring/RangeSelector.cpp
+++ clang/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -104,6 +104,28 @@
   return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
 }
 
+RangeSelector tooling::before(RangeSelector Selector) {
+  return [Selector](const MatchResult ) -> Expected {
+Expected SelectedRange = Selector(Result);
+if (!SelectedRange)
+  return SelectedRange.takeError();
+return CharSourceRange::getCharRange(SelectedRange->getBegin());
+  };
+}
+
+RangeSelector tooling::after(RangeSelector Selector) {
+  return [Selector](const MatchResult ) -> Expected {
+Expected SelectedRange = Selector(Result);
+if (!SelectedRange)
+  return SelectedRange.takeError();
+if (SelectedRange->isCharRange())
+  return CharSourceRange::getCharRange(SelectedRange->getEnd());
+return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
+SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
+Result.Context->getLangOpts()));
+  };
+}
+
 RangeSelector tooling::node(std::string ID) {
   return [ID](const MatchResult ) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
Index: clang/include/clang/Tooling/Refactoring/RangeSelector.h
===
--- clang/include/clang/Tooling/Refactoring/RangeSelector.h
+++ clang/include/clang/Tooling/Refactoring/RangeSelector.h
@@ -37,6 

[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D59402#1516567 , @aaronpuchert 
wrote:

> If that is wrong, then my reading is that fix-it hints for warnings must 
> always be applied to a note, because the recovery must be a no-op.


Not true, because some warnings provide fix-it hints that don't actually change 
anything except suppressing the warning, for example `-Wshift-op-parentheses`.

Perhaps we could clarify in the docs that fix-it hints on warnings are 
appropriate only if they don't change anything except suppressing the warning.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked an inline comment as done.
aaronpuchert added a comment.

In D59402#1516482 , @rsmith wrote:

> In D59402#1516479 , @aaronpuchert 
> wrote:
>
> > In D59402#1516432 , @aaron.ballman 
> > wrote:
> >
> > > Also, we're not attempting to recover from the error, which is a good 
> > > point that @thakis raised. aka, if you apply the fix-it, you should also 
> > > treat the declaration as though it were declared `static`.
> >
> >
> > I think the recovery rule only applies to errors, there is no need to 
> > recover from a warning.
>
>
> That is incorrect, because `-Werror` can be used to promote warnings to 
> errors. Please see 
> https://clang.llvm.org/docs/InternalsManual.html#fix-it-hints for the rule 
> and rationale; if it's insufficiently clear on this, we should fix it.


Ok, but can't we generally recover from warnings with a no-op, because it's 
still valid C++? Neither parser nor the rest of Sema should be held up by this. 
Don't we in fact have to recover with a no-op to be compliant with the standard?

So my understanding of the rules is that the recovery rule only applies to 
"actual" errors, which would prevent continuing if we didn't recover. If that 
is wrong, then my reading is that fix-it hints for warnings must always be 
applied to a note, because the recovery must be a no-op. Otherwise the rules 
are pretty clear, except that perhaps "when it’s very likely they match the 
user’s intent" is open to interpretation. But I think we agreed here that it is 
not "very likely", so it should be a note.




Comment at: lib/Sema/SemaDecl.cpp:13225-13230
   if (FunctionNoProtoTypeLoc FTL = TL.getAs())
-Diag(PossibleZeroParamPrototype->getLocation(),
+Diag(PossiblePrototype->getLocation(),
  diag::note_declaration_not_a_prototype)
-<< PossibleZeroParamPrototype
+<< PossiblePrototype
 << FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
 }

rsmith wrote:
> If we produce this note, we should not also produce the "add static" 
> suggestion.
They are exclusive because we suggest `static` only if `PossiblePrototype` is 
false, and this note only when it's true. But you're right that this isn't 
obvious, I'll make it an if/else.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-05-24 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361664: [Analyzer] Checker for non-determinism caused by 
iteration of unordered… (authored by mgrang, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59279?vs=190472=201310#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59279

Files:
  cfe/trunk/docs/analyzer/checkers.rst
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
  cfe/trunk/test/Analysis/ptr-iter.cpp
  cfe/trunk/www/analyzer/alpha_checks.html

Index: cfe/trunk/www/analyzer/alpha_checks.html
===
--- cfe/trunk/www/analyzer/alpha_checks.html
+++ cfe/trunk/www/analyzer/alpha_checks.html
@@ -1068,6 +1068,24 @@
 Name, DescriptionExample
 
 
+
+alpha.nondeterminism.PointerIteration
+(C++)
+Check for non-determinism caused by iterating unordered containers of pointers.
+
+
+// C++
+void test() {
+ int a = 1, b = 2;
+ std::unordered_set UnorderedPtrSet = {, };
+
+ for (auto i : UnorderedPtrSet) // warn
+   f(i);
+}
+
+
+
+
 
 alpha.nondeterminism.PointerSorting
 (C++)
Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1340,6 +1340,10 @@
 
 let ParentPackage = NonDeterminismAlpha in {
 
+def PointerIterationChecker : Checker<"PointerIteration">,
+  HelpText<"Checks for non-determinism caused by iteration of unordered containers of pointers">,
+  Documentation;
+
 def PointerSortingChecker : Checker<"PointerSorting">,
   HelpText<"Check for non-determinism caused by sorting of pointers">,
   Documentation;
Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -846,3 +846,64 @@
   template
   BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);
 }
+
+namespace std {
+
+template< class T = void >
+struct less;
+
+template< class T >
+struct allocator;
+
+template< class Key >
+struct hash;
+
+template<
+  class Key,
+  class Compare = std::less,
+  class Alloc = std::allocator
+> class set {
+  public:
+set(initializer_list __list) {}
+
+class iterator {
+public:
+  iterator(Key *key): ptr(key) {}
+  iterator operator++() { ++ptr; return *this; }
+  bool operator!=(const iterator ) const { return ptr != other.ptr; }
+  const Key *() const { return *ptr; }
+private:
+  Key *ptr;
+};
+
+  public:
+Key *val;
+iterator begin() const { return iterator(val); }
+iterator end() const { return iterator(val + 1); }
+};
+
+template<
+  class Key,
+  class Hash = std::hash,
+  class Compare = std::less,
+  class Alloc = std::allocator
+> class unordered_set {
+  public:
+unordered_set(initializer_list __list) {}
+
+class iterator {
+public:
+  iterator(Key *key): ptr(key) {}
+  iterator operator++() { ++ptr; return *this; }
+  bool operator!=(const iterator ) const { return ptr != other.ptr; }
+  const Key *() const { return *ptr; }
+private:
+  Key *ptr;
+};
+
+  public:
+Key *val;
+iterator begin() const { return iterator(val); }
+iterator end() const { return iterator(val + 1); }
+};
+}
Index: cfe/trunk/test/Analysis/ptr-iter.cpp
===
--- cfe/trunk/test/Analysis/ptr-iter.cpp
+++ cfe/trunk/test/Analysis/ptr-iter.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 %s -analyzer-output=text -verify \
+// RUN: -analyzer-checker=core,alpha.nondeterminism.PointerIteration
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+template
+void f(T x);
+
+void PointerIteration() {
+  int a = 1, b = 2;
+  std::set OrderedIntSet = {a, b};
+  std::set OrderedPtrSet = {, };
+  std::unordered_set UnorderedIntSet = {a, b};
+  std::unordered_set UnorderedPtrSet = {, };
+
+  for (auto i : OrderedIntSet) // no-warning
+f(i);
+
+  for (auto i : OrderedPtrSet) // no-warning
+f(i);
+
+  for (auto i : UnorderedIntSet) // no-warning
+f(i);
+
+  for (auto i : UnorderedPtrSet) // expected-warning {{Iteration of pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerIteration]
+// expected-note@-1 {{Iteration of pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerIteration]
+f(i);
+}

r361664 - [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-05-24 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Fri May 24 12:24:08 2019
New Revision: 361664

URL: http://llvm.org/viewvc/llvm-project?rev=361664=rev
Log:
[Analyzer] Checker for non-determinism caused by iteration of unordered 
container of pointers

Summary: Added a checker for non-determinism caused by iterating unordered 
containers like std::unordered_set containing pointer elements.

Reviewers: NoQ, george.karpenkov, whisperity, Szelethus, baloghadamsoftware

Reviewed By: Szelethus

Subscribers: mgorny, xazax.hun, baloghadamsoftware, szepet, rnkovacs, 
a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, jdoerfert, Charusso, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
cfe/trunk/test/Analysis/ptr-iter.cpp
Modified:
cfe/trunk/docs/analyzer/checkers.rst
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/www/analyzer/alpha_checks.html

Modified: cfe/trunk/docs/analyzer/checkers.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/checkers.rst?rev=361664=361663=361664=diff
==
--- cfe/trunk/docs/analyzer/checkers.rst (original)
+++ cfe/trunk/docs/analyzer/checkers.rst Fri May 24 12:24:08 2019
@@ -211,8 +211,8 @@ Check for uninitialized values being ret
 .. _cplusplus-checkers:
 
 
-cpluslus
-
+cplusplus
+^
 
 C++ Checkers.
 
@@ -1951,6 +1951,20 @@ Check for out-of-bounds access in string
int y = strlen((char *)); // warn
  }
 
+alpha.nondeterminism.PointerIteration (C++)
+"""
+Check for non-determinism caused by iterating unordered containers of pointers.
+
+.. code-block:: c
+
+ void test() {
+  int a = 1, b = 2;
+  std::unordered_set UnorderedPtrSet = {, };
+
+  for (auto i : UnorderedPtrSet) // warn
+f(i);
+ }
+
 alpha.nondeterminism.PointerSorting (C++)
 "
 Check for non-determinism caused by sorting of pointers.

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=361664=361663=361664=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Fri May 24 
12:24:08 2019
@@ -1340,6 +1340,10 @@ def UnixAPIPortabilityChecker : Checker<
 
 let ParentPackage = NonDeterminismAlpha in {
 
+def PointerIterationChecker : Checker<"PointerIteration">,
+  HelpText<"Checks for non-determinism caused by iteration of unordered 
containers of pointers">,
+  Documentation;
+
 def PointerSortingChecker : Checker<"PointerSorting">,
   HelpText<"Check for non-determinism caused by sorting of pointers">,
   Documentation;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=361664=361663=361664=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri May 24 12:24:08 
2019
@@ -75,6 +75,7 @@ add_clang_library(clangStaticAnalyzerChe
   OSObjectCStyleCast.cpp
   PaddingChecker.cpp
   PointerArithChecker.cpp
+  PointerIterationChecker.cpp
   PointerSortingChecker.cpp
   PointerSubChecker.cpp
   PthreadLockChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp?rev=361664=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp Fri May 
24 12:24:08 2019
@@ -0,0 +1,100 @@
+//== PointerIterationChecker.cpp --- -*- C++ 
-*--=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines PointerIterationChecker which checks for non-determinism
+// caused due to iteration of unordered containers of pointer elements.
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"

[PATCH] D62343: [cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361663: [cmake] Remove old unused version of FindZ3.cmake 
from clang [NFC] (authored by dhinton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62343?vs=201058=201308#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62343

Files:
  cmake/modules/FindZ3.cmake




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


r361663 - [cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

2019-05-24 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Fri May 24 12:21:21 2019
New Revision: 361663

URL: http://llvm.org/viewvc/llvm-project?rev=361663=rev
Log:
[cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

Summary: This file was moved to llvm in D54978, r356929, but the old
file was never removed.

Reviewed By: beanz

Tags: #clang

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

Removed:
cfe/trunk/cmake/modules/FindZ3.cmake

Removed: cfe/trunk/cmake/modules/FindZ3.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/FindZ3.cmake?rev=361662=auto
==
(empty)


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


r361662 - Adding an explicit triple to this test to appease build bots.

2019-05-24 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 24 12:19:00 2019
New Revision: 361662

URL: http://llvm.org/viewvc/llvm-project?rev=361662=rev
Log:
Adding an explicit triple to this test to appease build bots.

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

Modified: cfe/trunk/test/AST/ast-dump-stmt-json.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.m?rev=361662=361661=361662=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt-json.m (original)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.m Fri May 24 12:19:00 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wno-unused -fblocks -fobjc-exceptions -ast-dump=json 
-ast-dump-filter Test %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -Wno-unused -fblocks 
-fobjc-exceptions -ast-dump=json -ast-dump-filter Test %s | FileCheck %s
 
 void TestBlockExpr(int x) {
   ^{ x; };


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


[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 201307.
gtbercea added a comment.

- Add test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -26,42 +26,35 @@
 // CHECK: [[VAR:@.+]] = global double 1.00e+01
 // CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
 
-// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
-// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
 
 // CHECK: [[N_CASTED:%.+]] = alloca i64
 // CHECK: [[SUM_CASTED:%.+]] = alloca i64
 
-// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
-// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [2 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [2 x i8*]
 
 // CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
 // CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
 
-// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
 // CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
-// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 // CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
 
-// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
 // CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
-// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
 // CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
 
-// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 2
-// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
-// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
-// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 2
-// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
-// CHECK: store double* [[VAR]], double** [[BCAST6]]
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 
-// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
-
-// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 2, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
 
 #endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -2598,7 +2598,8 @@
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
-  (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
+  (Stack->hasRequiresDeclWithClause() ||
+   !Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
   SourceLocation ELoc = E->getExprLoc();
Index: lib/CodeGen/CGOpenMPRuntime.h

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-05-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/llvm/IR/IRBuilder.h:110
   : Context(context), DefaultFPMathTag(FPMathTag),
-DefaultOperandBundles(OpBundles) {
+IsFPConstrained(false), DefaultConstrainedExcept(nullptr),
+DefaultConstrainedRounding(nullptr), DefaultOperandBundles(OpBundles) {

Instead of adding these here, make these inline initializers on lines 100-102.



Comment at: include/llvm/IR/IRBuilder.h:228
+  /// Enable/Disable use of constrained floating point math
+  void setIsConstrainedFP(bool IsCon) { IsFPConstrained = IsCon; }
+

kpn wrote:
> kbarton wrote:
> > This is a minor quibble, but the method is setIsConstrainedFP, while the 
> > member is IsFPConstrained. 
> > I'm not sure if that is intentionally different, or an oversight. 
> Yeah, that's an oversight. Fixed.
IS this fixed?



Comment at: include/llvm/IR/IRBuilder.h:1249
+if (IsFPConstrained)
+  return CreateConstrainedFAdd(L, R, FMFSource, Name, nullptr, nullptr);
+

Why set the last 2 to nullptr when you have defaults for these?



Comment at: include/llvm/IR/IRBuilder.h:1259
+  Instruction *FMFSource = nullptr,
   const Twine  = "",
+  MDNode *RoundingMD = nullptr,   
+  MDNode *ExceptMD = nullptr) {

The last 2 parameters are never actually used except in the test.  Are these 
really important to have if they are never used in source?



Comment at: include/llvm/IR/IRBuilder.h:1408
 
+  CallInst *CreateConstrainedFRem(Value *L, Value *R, 
+  Instruction *FMFSource = nullptr, 

All these CreateConstrainedXXX should be distilled down to a single function 
that takes the intrinsic as a parameter.


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

https://reviews.llvm.org/D53157



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-05-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

Ok, from the Linux kernel's perspective, I believe we have worked out all 
underlying issues in LLVM wrt callbr that would prevent us from using asm goto 
successfully.  This patch now has my blessing; thanks for all the hard work 
that went into this large feature.  Please wait for a final LGTM from @rsmith .


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

https://reviews.llvm.org/D56571



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


r361660 - Add JSON dumping tests for ObjC statements; add support for dumping @catch catch-all statements.

2019-05-24 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 24 11:58:29 2019
New Revision: 361660

URL: http://llvm.org/viewvc/llvm-project?rev=361660=rev
Log:
Add JSON dumping tests for ObjC statements; add support for dumping @catch 
catch-all statements.

Added:
cfe/trunk/test/AST/ast-dump-stmt-json.m
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=361660=361659=361660=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Fri May 24 11:58:29 2019
@@ -260,6 +260,7 @@ public:
   void VisitLabelStmt(const LabelStmt *LS);
   void VisitGotoStmt(const GotoStmt *GS);
   void VisitWhileStmt(const WhileStmt *WS);
+  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
 
   void visitTextComment(const comments::TextComment *C,
 const comments::FullComment *);

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361660=361659=361660=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Fri May 24 11:58:29 2019
@@ -966,6 +966,13 @@ void JSONNodeDumper::VisitWhileStmt(cons
   attributeOnlyIfTrue("hasVar", WS->hasVarStorage());
 }
 
+void JSONNodeDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt* OACS) {
+  // FIXME: it would be nice for the ASTNodeTraverser would handle the catch
+  // parameter the same way for C++ and ObjC rather. In this case, C++ gets a
+  // null child node and ObjC gets no child node.
+  attributeOnlyIfTrue("isCatchAll", OACS->getCatchParamDecl() == nullptr);
+}
+
 StringRef JSONNodeDumper::getCommentCommandName(unsigned CommandID) const {
   if (Traits)
 return Traits->getCommandInfo(CommandID)->Name;

Added: cfe/trunk/test/AST/ast-dump-stmt-json.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.m?rev=361660=auto
==
--- cfe/trunk/test/AST/ast-dump-stmt-json.m (added)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.m Fri May 24 11:58:29 2019
@@ -0,0 +1,719 @@
+// RUN: %clang_cc1 -Wno-unused -fblocks -fobjc-exceptions -ast-dump=json 
-ast-dump-filter Test %s | FileCheck %s
+
+void TestBlockExpr(int x) {
+  ^{ x; };
+}
+
+void TestExprWithCleanup(int x) {
+  ^{ x; };
+}
+
+@interface A
+@end
+
+void TestObjCAtCatchStmt() {
+  @try {
+  } @catch(A *a) {
+  } @catch(...) {
+  } @finally {
+  }
+}
+
+
+// CHECK:  "kind": "FunctionDecl", 
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 6, 
+// CHECK-NEXT:   "file": "{{.*}}", 
+// CHECK-NEXT:   "line": 3
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 1, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 3
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 1, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 5
+// CHECK-NEXT:   }
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "name": "TestBlockExpr", 
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void (int)"
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}", 
+// CHECK-NEXT:"kind": "ParmVarDecl", 
+// CHECK-NEXT:"loc": {
+// CHECK-NEXT: "col": 24, 
+// CHECK-NEXT: "file": "{{.*}}", 
+// CHECK-NEXT: "line": 3
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 20, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 3
+// CHECK-NEXT: }, 
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "col": 24, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 3
+// CHECK-NEXT: }
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"isUsed": true, 
+// CHECK-NEXT:"name": "x", 
+// CHECK-NEXT:"type": {
+// CHECK-NEXT: "qualType": "int"
+// CHECK-NEXT:}
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}", 
+// CHECK-NEXT:"kind": "CompoundStmt", 
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 27, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 3
+// CHECK-NEXT: }, 
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "col": 1, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 5
+// CHECK-NEXT: }
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT:  "id": "0x{{.*}}", 
+// CHECK-NEXT:  "kind": "ExprWithCleanups", 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3, 
+// 

[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361658: [OpenMP] Add test for requires and unified shared 
memory clause with declare… (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62407?vs=201275=201298#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62407

Files:
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+
+// CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
+
+// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 2
+// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
+// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
+// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 2
+// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
+// CHECK: store double* [[VAR]], double** [[BCAST6]]
+
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** 
[[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* 
[[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x 
i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+
+#endif


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+

r361658 - [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Fri May 24 11:48:42 2019
New Revision: 361658

URL: http://llvm.org/viewvc/llvm-project?rev=361658=rev
Log:
[OpenMP] Add test for requires and unified shared memory clause with declare 
target link

Summary:
This patch adds a test for requires with unified share memory clause when a 
declare target link is present.

This test needs to go in prior to changes to declare target link for comparison 
purposes.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Added: cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp?rev=361658=auto
==
--- cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp 
(added)
+++ cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp Fri 
May 24 11:48:42 2019
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+
+// CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
+
+// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 2
+// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
+// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
+// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 2
+// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
+// CHECK: store double* [[VAR]], double** [[BCAST6]]
+
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** 
[[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* 
[[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x 
i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+
+#endif


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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D59402#1516479 , @aaronpuchert 
wrote:

> In D59402#1516432 , @aaron.ballman 
> wrote:
>
> > Also, we're not attempting to recover from the error, which is a good point 
> > that @thakis raised. aka, if you apply the fix-it, you should also treat 
> > the declaration as though it were declared `static`.
>
>
> I think the recovery rule only applies to errors, there is no need to recover 
> from a warning.


That is incorrect, because `-Werror` can be used to promote warnings to errors. 
Please see https://clang.llvm.org/docs/InternalsManual.html#fix-it-hints for 
the rule and rationale; if it's insufficiently clear on this, we should fix it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11810
+  << var
+  << ((var->getStorageClass() != SC_Extern)
+  ? FixItHint::CreateInsertion(var->getBeginLoc(), "static ")

It would be more appropriate to suppress the fixit if any storage class 
specifier is present, since a declaration can have only one such specifier.



Comment at: lib/Sema/SemaDecl.cpp:13225-13230
   if (FunctionNoProtoTypeLoc FTL = TL.getAs())
-Diag(PossibleZeroParamPrototype->getLocation(),
+Diag(PossiblePrototype->getLocation(),
  diag::note_declaration_not_a_prototype)
-<< PossibleZeroParamPrototype
+<< PossiblePrototype
 << FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
 }

If we produce this note, we should not also produce the "add static" suggestion.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D59402#1516432 , @aaron.ballman 
wrote:

> Also, we're not attempting to recover from the error, which is a good point 
> that @thakis raised. aka, if you apply the fix-it, you should also treat the 
> declaration as though it were declared `static`.


I think the recovery rule only applies to errors, there is no need to recover 
from a warning. If we attempted recovery from a warning, we might generate 
different object code depending on the warning level.

But I think your original comment nails it: we can't be really sure that this 
is the right fix, and my empirical data doesn't (necessarily) translate well to 
writing new code with the warning on.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D62404: [clang-tidy] Fix null pointer dereference in readability-identifier-naming

2019-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D62404#1516243 , @markstegeman 
wrote:

> I haven't yet been able to figure out how to properly add a test for this 
> bug, since the expected result is a failure to compile while the current 
> test/clang-tidy/readability-identifier-naming.cpp must compile to pass.
>
> Any suggestions?


The way we usually handle this is to create a separate test file that exhibits 
the previously crashing code with a comment saying the test case used to crash. 
IIRC, you can use a CHECK line to check that you get the expected error.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62404



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D59402#1516421 , @aaronpuchert 
wrote:

> I guess you're referring to "[fix-it hints] should only be used when it’s 
> very likely they match the user’s intent".


Also, we're not attempting to recover from the error, which is a good point 
that @thakis raised. aka, if you apply the fix-it, you should also treat the 
declaration as though it were declared `static`.

> When turning on the warning on an existing code base, I think that `static` 
> is almost always right. But when writing new code with the warning active, it 
> might indeed not be the right thing. It could be that the declaration has 
> been forgotten, or it has a typo. We wouldn't want users to apply `static` 
> blindly, so a note explaining when it is appropriate does actually make a lot 
> of sense. Perhaps I can also detect if this is in a header and not emit the 
> note then. (Or emit a note suggesting `inline`.)
> 
> @aaron.ballman Would moving the fix-it to a note alleviate your concerns?

Yes, it would -- you also wouldn't have to attempt the recovery in this case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D62413: [OpenCL][PR41727] Prevent ICE on global dtors

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added subscribers: ebevhan, yaxunl.

Preserve address spaces of global objects while generating 'atexit' stub.


https://reviews.llvm.org/D62413

Files:
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenOpenCLCXX/atexit.cl

Index: test/CodeGenOpenCLCXX/atexit.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/atexit.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct S {
+  ~S(){};
+};
+S s;
+
+//CHECK-LABEL: define internal void @__cxx_global_var_init()
+// call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.S addrspace(4)*)* @_ZNU3AS41SD1Ev to void (i8*)*), i8 addrspace(1)* getelementptr inbounds (%struct.S, %struct.S addrspace(1)* @s, i32 0, i32 0), i8 addrspace(1)* @__dso_handle)
+
+//declare i32 @__cxa_atexit(void (i8*)*, i8 addrspace(1)*, i8 addrspace(1)*)
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2299,8 +2299,19 @@
   llvm::Type *dtorTy =
 llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, false)->getPointerTo();
 
+  // Preserve address space of addr.
+  auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0;
+  auto AddrInt8PtrTy =
+  AddrAS ? CGF.Int8Ty->getPointerTo(AddrAS) : CGF.Int8PtrTy;
+
+  // Create a variable that binds the atexit to this shared object.
+  llvm::Constant *handle =
+  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  auto *GV = cast(handle->stripPointerCasts());
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
+
   // extern "C" int __cxa_atexit(void (*f)(void *), void *p, void *d);
-  llvm::Type *paramTys[] = { dtorTy, CGF.Int8PtrTy, CGF.Int8PtrTy };
+  llvm::Type *paramTys[] = {dtorTy, AddrInt8PtrTy, handle->getType()};
   llvm::FunctionType *atexitTy =
 llvm::FunctionType::get(CGF.IntTy, paramTys, false);
 
@@ -2309,12 +2320,6 @@
   if (llvm::Function *fn = dyn_cast(atexit.getCallee()))
 fn->setDoesNotThrow();
 
-  // Create a variable that binds the atexit to this shared object.
-  llvm::Constant *handle =
-  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
-  auto *GV = cast(handle->stripPointerCasts());
-  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
-
   if (!addr)
 // addr is null when we are trying to register a dtor annotated with
 // __attribute__((destructor)) in a constructor function. Using null here is
@@ -2324,7 +2329,7 @@
 
   llvm::Value *args[] = {llvm::ConstantExpr::getBitCast(
  cast(dtor.getCallee()), dtorTy),
- llvm::ConstantExpr::getBitCast(addr, CGF.Int8PtrTy),
+ llvm::ConstantExpr::getBitCast(addr, AddrInt8PtrTy),
  handle};
   CGF.EmitNounwindRuntimeCall(atexit, args);
 }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3533,8 +3533,12 @@
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
  StringRef Name) {
-  auto *Ret =
-  GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr);
+  auto PtrTy =
+  getContext().getLangOpts().OpenCL
+  ? llvm::PointerType::get(
+Ty, getContext().getTargetAddressSpace(LangAS::opencl_global))
+  : llvm::PointerType::getUnqual(Ty);
+  auto *Ret = GetOrCreateLLVMGlobal(Name, PtrTy, nullptr);
   setDSOLocal(cast(Ret->stripPointerCasts()));
   return Ret;
 }
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
+#include "TargetInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Intrinsics.h"
@@ -118,8 +119,17 @@
 CXXDestructorDecl *Dtor = Record->getDestructor();
 
 Func = CGM.getAddrAndTypeOfCXXStructor(GlobalDecl(Dtor, Dtor_Complete));
-Argument = llvm::ConstantExpr::getBitCast(
-Addr.getPointer(), CGF.getTypes().ConvertType(Type)->getPointerTo());
+// FIXME: A solution is needed for opencl_constant. We could create
+// atexit_constant, but more generic solution would probably be to mangle
+// address space?
+auto DestTy = CGF.getTypes().ConvertType(Type)->getPointerTo(
+CGM.getContext().getTargetAddressSpace(LangAS::opencl_global));
+auto SrcAS = D.getType().getQualifiers().getAddressSpace();
+if (LangAS::opencl_global == SrcAS)
+  Argument = llvm::ConstantExpr::getBitCast(Addr.getPointer(), 

[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

After some offline discussion, the patch is accepted. It is required to 
demonstrate the changes in 
https://reviews.llvm.org/D60883


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert planned changes to this revision.
aaronpuchert added a comment.

I guess you're referring to "[fix-it hints] should only be used when it’s very 
likely they match the user’s intent".

When turning on the warning on an existing code base, I think that `static` is 
almost always right. But when writing new code with the warning active, it 
might indeed not be the right thing. It could be that the declaration has been 
forgotten, or it has a typo. We wouldn't want users to apply `static` blindly, 
so a note explaining when it is appropriate does actually make a lot of sense. 
Perhaps I can also detect if this is in a header and not emit the note then. 
(Or emit a note suggesting `inline`.)

@aaron.ballman Would moving the fix-it to a note alleviate your concerns?


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
version 1 here: https://reviews.llvm.org/D62412






On Fri, May 24, 2019 at 1:36 PM Yitzhak Mandelbaum 
wrote:

> So, it only shows up in Release build, I assume because the assert is left
> out:
>   for (const auto  : Rule.Cases) {
> assert(Case.Explanation != nullptr &&
>"clang-tidy checks must have an explanation by default;"
>" explicitly provide an empty explanation if none is desired");
>   }
> I can think of a few solutions, please let me know if there's a
> standard/preferred approach:
>
> 1. Use std::all_of.
> assert(std::all_of(Rule.Cases.cbegin(), Rule.Cases.cend(), [](const
> RewriteRule::Case ) { return C.Explanation != nullptr; }
>&& ...);
>
> 2. Trivially use the variable.
> I could add a trivial use to the loop
>   for (const auto  : Rule.Cases) {
> +   (void)Case;
> assert(Case.Explanation != nullptr &&
>"clang-tidy checks must have an explanation by default;"
>" explicitly provide an empty explanation if none is desired");
>   }
>
> 3. Use llvm_unreachable instead.
> Rewrite the assert to
> if (Case.Explanation == nullptr)
>   llvm_unreachable(...)
>
> On Fri, May 24, 2019 at 1:16 PM Yitzhak Mandelbaum 
> wrote:
>
>> looking now...
>>
>> On Fri, May 24, 2019 at 12:49 PM Ilya Biryukov 
>> wrote:
>>
>>> This seems to produce warnings about unused variables:
>>> …/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
>>> warning: unused variable 'Case' [-Wunused-variable]
>>>
>>>   for (const auto  : Rule.Cases) {
>>>
>>> Could you take a look?
>>>
>>> On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
>>> revi...@reviews.llvm.org> wrote:
>>>
 This revision was automatically updated to reflect the committed
 changes.
 Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
 require Explanation field. (authored by ymandel, committed by ).
 Herald added a project: LLVM.
 Herald added a subscriber: llvm-commits.

 Changed prior to commit:
   https://reviews.llvm.org/D62340?vs=201256=201272#toc

 Repository:
   rL LLVM

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

 https://reviews.llvm.org/D62340

 Files:
   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h

 clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp


 Index:
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
 ===
 --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
 +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
 @@ -31,10 +31,14 @@
  // };
  class TransformerClangTidyCheck : public ClangTidyCheck {
  public:
 +  // All cases in \p R must have a non-null \c Explanation, even
 though \c
 +  // Explanation is optional for RewriteRule in general. Because the
 primary
 +  // purpose of clang-tidy checks is to provide users with
 diagnostics, we
 +  // assume that a missing explanation is a bug.  If no explanation is
 desired,
 +  // indicate that explicitly (for example, by passing `text("no
 explanation")`
 +  //  to `makeRule` as the `Explanation` argument).
TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
 -ClangTidyContext *Context)
 -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
 -
 +ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) final;
void check(const ast_matchers::MatchFinder::MatchResult )
 final;

 Index:
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
 ===
 ---
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
 +++
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
 @@ -13,6 +13,17 @@
  namespace utils {
  using tooling::RewriteRule;

 +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
 R,
 + StringRef Name,
 + ClangTidyContext
 *Context)
 +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
 +  for (const auto  : Rule.Cases) {
 +assert(Case.Explanation != nullptr &&
 +   "clang-tidy checks must have an explanation by default;"
 +   " explicitly provide an empty explanation if none is
 desired");
 +  }
 +}
 +
  void TransformerClangTidyCheck::registerMatchers(
  ast_matchers::MatchFinder *Finder) {

[PATCH] D62412: [LibTooling] Fix unused-variable warning after r361647.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.

A range-for was added in r361647 where the range variable was only used in an
assertion.  As a result, it warned for Release builds. This revision
restructures the assertion to avoid the problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62412

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp


Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -7,21 +7,23 @@
 
//===--===//
 
 #include "TransformerClangTidyCheck.h"
+#include 
 
 namespace clang {
 namespace tidy {
 namespace utils {
 using tooling::RewriteRule;
 
-TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
  StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), Rule(std::move(R)) {
-  for (const auto  : Rule.Cases) {
-assert(Case.Explanation != nullptr &&
-   "clang-tidy checks must have an explanation by default;"
-   " explicitly provide an empty explanation if none is desired");
-  }
+  assert(std::all_of(Rule.Cases.begin(), Rule.Cases.end(),
+ [](const RewriteRule::Case ) {
+   return C.Explanation != nullptr;
+ }) &&
+ "clang-tidy checks must have an explanation by default;"
+ " explicitly provide an empty explanation if none is desired");
 }
 
 void TransformerClangTidyCheck::registerMatchers(


Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -7,21 +7,23 @@
 //===--===//
 
 #include "TransformerClangTidyCheck.h"
+#include 
 
 namespace clang {
 namespace tidy {
 namespace utils {
 using tooling::RewriteRule;
 
-TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
  StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), Rule(std::move(R)) {
-  for (const auto  : Rule.Cases) {
-assert(Case.Explanation != nullptr &&
-   "clang-tidy checks must have an explanation by default;"
-   " explicitly provide an empty explanation if none is desired");
-  }
+  assert(std::all_of(Rule.Cases.begin(), Rule.Cases.end(),
+ [](const RewriteRule::Case ) {
+   return C.Explanation != nullptr;
+ }) &&
+ "clang-tidy checks must have an explanation by default;"
+ " explicitly provide an empty explanation if none is desired");
 }
 
 void TransformerClangTidyCheck::registerMatchers(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Just add it to the original patch


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In D62407#1516298 , @ABataev wrote:

> Just one question - why it is not the part of the whole patch for the unified 
> memory support in clang?


This test will need to change in the unified memory case. That's why its being 
introduced.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D62279: Use LTO capable linker

2019-05-24 Thread Wink Saville via Phabricator via cfe-commits
winksaville updated this revision to Diff 201288.
winksaville added a comment.

Added libcxxabi and rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62279

Files:
  clang/cmake/caches/DistributionExample-stage2.cmake
  clang/cmake/caches/DistributionExample.cmake


Index: clang/cmake/caches/DistributionExample.cmake
===
--- clang/cmake/caches/DistributionExample.cmake
+++ clang/cmake/caches/DistributionExample.cmake
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all
Index: clang/cmake/caches/DistributionExample-stage2.cmake
===
--- clang/cmake/caches/DistributionExample-stage2.cmake
+++ clang/cmake/caches/DistributionExample-stage2.cmake
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 


Index: clang/cmake/caches/DistributionExample.cmake
===
--- clang/cmake/caches/DistributionExample.cmake
+++ clang/cmake/caches/DistributionExample.cmake
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all
Index: clang/cmake/caches/DistributionExample-stage2.cmake
===
--- clang/cmake/caches/DistributionExample-stage2.cmake
+++ clang/cmake/caches/DistributionExample-stage2.cmake
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-24 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361653: [NewPassManager] Add tuning option: LoopUnrolling 
[clang-change] (authored by asbirlea, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D61620?vs=198704=201285#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61620

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/loop-unroll.c


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1051,6 +1051,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// 

r361653 - [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-24 Thread Alina Sbirlea via cfe-commits
Author: asbirlea
Date: Fri May 24 10:40:52 2019
New Revision: 361653

URL: http://llvm.org/viewvc/llvm-project?rev=361653=rev
Log:
[NewPassManager] Add tuning option: LoopUnrolling [clang-change]

Summary:
Use CodeGenOpts's setting for loop unrolling.
[to be coupled with D61618]

Reviewers: chandlerc

Subscribers: jlebar, dmgreen, cfe-commits, llvm-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/loop-unroll.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=361653=361652=361653=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri May 24 10:40:52 2019
@@ -1051,6 +1051,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;

Added: cfe/trunk/test/CodeGen/loop-unroll.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/loop-unroll.c?rev=361653=auto
==
--- cfe/trunk/test/CodeGen/loop-unroll.c (added)
+++ cfe/trunk/test/CodeGen/loop-unroll.c Fri May 24 10:40:52 2019
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}


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


r361652 - Add support for dumping Objective C AST declaration nodes to JSON.

2019-05-24 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 24 10:39:55 2019
New Revision: 361652

URL: http://llvm.org/viewvc/llvm-project?rev=361652=rev
Log:
Add support for dumping Objective C AST declaration nodes to JSON.

Added:
cfe/trunk/test/AST/ast-dump-decl-json.m
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=361652=361651=361652=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Fri May 24 10:39:55 2019
@@ -218,6 +218,19 @@ public:
   void VisitAccessSpecDecl(const AccessSpecDecl *ASD);
   void VisitFriendDecl(const FriendDecl *FD);
 
+  void VisitObjCIvarDecl(const ObjCIvarDecl *D);
+  void VisitObjCMethodDecl(const ObjCMethodDecl *D);
+  void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D);
+  void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
+  void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D);
+  void VisitObjCProtocolDecl(const ObjCProtocolDecl *D);
+  void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
+  void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
+  void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
+  void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
+  void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
+  void VisitBlockDecl(const BlockDecl *D);
+
   void VisitDeclRefExpr(const DeclRefExpr *DRE);
   void VisitPredefinedExpr(const PredefinedExpr *PE);
   void VisitUnaryOperator(const UnaryOperator *UO);

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361652=361651=361652=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Fri May 24 10:39:55 2019
@@ -150,7 +150,15 @@ void JSONNodeDumper::Visit(const CXXCtor
 }
 
 void JSONNodeDumper::Visit(const OMPClause *C) {}
-void JSONNodeDumper::Visit(const BlockDecl::Capture ) {}
+
+void JSONNodeDumper::Visit(const BlockDecl::Capture ) {
+  JOS.attribute("kind", "Capture");
+  attributeOnlyIfTrue("byref", C.isByRef());
+  attributeOnlyIfTrue("nested", C.isNested());
+  if (C.getVariable())
+JOS.attribute("var", createBareDeclRef(C.getVariable()));
+}
+
 void JSONNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation ) {
   JOS.attribute("associationKind", A.getTypeSourceInfo() ? "case" : "default");
   attributeOnlyIfTrue("selected", A.isSelected());
@@ -215,9 +223,11 @@ llvm::json::Object JSONNodeDumper::creat
 }
 
 llvm::json::Object JSONNodeDumper::createBareDeclRef(const Decl *D) {
-  llvm::json::Object Ret{
-  {"id", createPointerRepresentation(D)},
-  {"kind", (llvm::Twine(D->getDeclKindName()) + "Decl").str()}};
+  llvm::json::Object Ret{{"id", createPointerRepresentation(D)}};
+  if (!D)
+return Ret;
+
+  Ret["kind"] = (llvm::Twine(D->getDeclKindName()) + "Decl").str();
   if (const auto *ND = dyn_cast(D))
 Ret["name"] = ND->getDeclName().getAsString();
   if (const auto *VD = dyn_cast(D))
@@ -645,6 +655,147 @@ void JSONNodeDumper::VisitFriendDecl(con
 JOS.attribute("type", createQualType(T->getType()));
 }
 
+void JSONNodeDumper::VisitObjCIvarDecl(const ObjCIvarDecl *D) {
+  VisitNamedDecl(D);
+  JOS.attribute("type", createQualType(D->getType()));
+  attributeOnlyIfTrue("synthesized", D->getSynthesize());
+  switch (D->getAccessControl()) {
+  case ObjCIvarDecl::None: JOS.attribute("access", "none"); break;
+  case ObjCIvarDecl::Private: JOS.attribute("access", "private"); break;
+  case ObjCIvarDecl::Protected: JOS.attribute("access", "protected"); break;
+  case ObjCIvarDecl::Public: JOS.attribute("access", "public"); break;
+  case ObjCIvarDecl::Package: JOS.attribute("access", "package"); break;
+  }
+}
+
+void JSONNodeDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
+  VisitNamedDecl(D);
+  JOS.attribute("returnType", createQualType(D->getReturnType()));
+  JOS.attribute("instance", D->isInstanceMethod());
+  attributeOnlyIfTrue("variadic", D->isVariadic());
+}
+
+void JSONNodeDumper::VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D) {
+  VisitNamedDecl(D);
+  JOS.attribute("type", createQualType(D->getUnderlyingType()));
+  attributeOnlyIfTrue("bounded", D->hasExplicitBound());
+  switch (D->getVariance()) {
+  case ObjCTypeParamVariance::Invariant:
+break;
+  case ObjCTypeParamVariance::Covariant:
+JOS.attribute("variance", "covariant");
+break;
+  case ObjCTypeParamVariance::Contravariant:
+JOS.attribute("variance", "contravariant");
+break;
+  }
+}
+
+void JSONNodeDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
+  VisitNamedDecl(D);
+  

Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
So, it only shows up in Release build, I assume because the assert is left
out:
  for (const auto  : Rule.Cases) {
assert(Case.Explanation != nullptr &&
   "clang-tidy checks must have an explanation by default;"
   " explicitly provide an empty explanation if none is desired");
  }
I can think of a few solutions, please let me know if there's a
standard/preferred approach:

1. Use std::all_of.
assert(std::all_of(Rule.Cases.cbegin(), Rule.Cases.cend(), [](const
RewriteRule::Case ) { return C.Explanation != nullptr; }
   && ...);

2. Trivially use the variable.
I could add a trivial use to the loop
  for (const auto  : Rule.Cases) {
+   (void)Case;
assert(Case.Explanation != nullptr &&
   "clang-tidy checks must have an explanation by default;"
   " explicitly provide an empty explanation if none is desired");
  }

3. Use llvm_unreachable instead.
Rewrite the assert to
if (Case.Explanation == nullptr)
  llvm_unreachable(...)

On Fri, May 24, 2019 at 1:16 PM Yitzhak Mandelbaum 
wrote:

> looking now...
>
> On Fri, May 24, 2019 at 12:49 PM Ilya Biryukov 
> wrote:
>
>> This seems to produce warnings about unused variables:
>> …/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
>> warning: unused variable 'Case' [-Wunused-variable]
>>
>>   for (const auto  : Rule.Cases) {
>>
>> Could you take a look?
>>
>> On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> This revision was automatically updated to reflect the committed changes.
>>> Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
>>> require Explanation field. (authored by ymandel, committed by ).
>>> Herald added a project: LLVM.
>>> Herald added a subscriber: llvm-commits.
>>>
>>> Changed prior to commit:
>>>   https://reviews.llvm.org/D62340?vs=201256=201272#toc
>>>
>>> Repository:
>>>   rL LLVM
>>>
>>> CHANGES SINCE LAST ACTION
>>>   https://reviews.llvm.org/D62340/new/
>>>
>>> https://reviews.llvm.org/D62340
>>>
>>> Files:
>>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>>
>>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>>>
>>>
>>> Index:
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>> ===
>>> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>> @@ -31,10 +31,14 @@
>>>  // };
>>>  class TransformerClangTidyCheck : public ClangTidyCheck {
>>>  public:
>>> +  // All cases in \p R must have a non-null \c Explanation, even though
>>> \c
>>> +  // Explanation is optional for RewriteRule in general. Because the
>>> primary
>>> +  // purpose of clang-tidy checks is to provide users with diagnostics,
>>> we
>>> +  // assume that a missing explanation is a bug.  If no explanation is
>>> desired,
>>> +  // indicate that explicitly (for example, by passing `text("no
>>> explanation")`
>>> +  //  to `makeRule` as the `Explanation` argument).
>>>TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
>>> -ClangTidyContext *Context)
>>> -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
>>> -
>>> +ClangTidyContext *Context);
>>>void registerMatchers(ast_matchers::MatchFinder *Finder) final;
>>>void check(const ast_matchers::MatchFinder::MatchResult )
>>> final;
>>>
>>> Index:
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>> ===
>>> ---
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>> +++
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>> @@ -13,6 +13,17 @@
>>>  namespace utils {
>>>  using tooling::RewriteRule;
>>>
>>> +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
>>> R,
>>> + StringRef Name,
>>> + ClangTidyContext
>>> *Context)
>>> +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
>>> +  for (const auto  : Rule.Cases) {
>>> +assert(Case.Explanation != nullptr &&
>>> +   "clang-tidy checks must have an explanation by default;"
>>> +   " explicitly provide an empty explanation if none is
>>> desired");
>>> +  }
>>> +}
>>> +
>>>  void TransformerClangTidyCheck::registerMatchers(
>>>  ast_matchers::MatchFinder *Finder) {
>>>Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
>>> @@ -44,15 +55,13 @@
>>>if (Transformations->empty())
>>>  return;
>>>
>>> -  StringRef Message = "no explanation";
>>> -  if (Case.Explanation) {
>>> -if (Expected E = 

[PATCH] D62406: [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361651: [WebAssembly] Use linker as linker 
shortname. (authored by sbc, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62406?vs=201276=201284#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62406

Files:
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.h


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain )
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver ,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList ) const {
   const ToolChain  = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain );
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain )
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain )
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver ,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList ) const {
   const ToolChain  = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain );
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain )
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361651 - [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Fri May 24 10:36:07 2019
New Revision: 361651

URL: http://llvm.org/viewvc/llvm-project?rev=361651=rev
Log:
[WebAssembly] Use "linker" as linker shortname.

This is in line with other platforms.

Also, move the single statement methods into the header (also
in line with other platform).

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

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=361651=361650=361651=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Fri May 24 10:36:07 2019
@@ -22,9 +22,6 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain )
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver ,
@@ -34,10 +31,6 @@ static std::string getMultiarchTriple(co
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList ) const {
   const ToolChain  = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=361651=361650=361651=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Fri May 24 10:36:07 2019
@@ -20,9 +20,10 @@ namespace wasm {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain );
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain )
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,


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


[PATCH] D62406: [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Dan Gohman via Phabricator via cfe-commits
sunfish accepted this revision.
sunfish added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62406



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


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
looking now...

On Fri, May 24, 2019 at 12:49 PM Ilya Biryukov  wrote:

> This seems to produce warnings about unused variables:
> …/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
> warning: unused variable 'Case' [-Wunused-variable]
>
>   for (const auto  : Rule.Cases) {
>
> Could you take a look?
>
> On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
>> require Explanation field. (authored by ymandel, committed by ).
>> Herald added a project: LLVM.
>> Herald added a subscriber: llvm-commits.
>>
>> Changed prior to commit:
>>   https://reviews.llvm.org/D62340?vs=201256=201272#toc
>>
>> Repository:
>>   rL LLVM
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D62340/new/
>>
>> https://reviews.llvm.org/D62340
>>
>> Files:
>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>>
>>
>> Index:
>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>> ===
>> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>> @@ -31,10 +31,14 @@
>>  // };
>>  class TransformerClangTidyCheck : public ClangTidyCheck {
>>  public:
>> +  // All cases in \p R must have a non-null \c Explanation, even though
>> \c
>> +  // Explanation is optional for RewriteRule in general. Because the
>> primary
>> +  // purpose of clang-tidy checks is to provide users with diagnostics,
>> we
>> +  // assume that a missing explanation is a bug.  If no explanation is
>> desired,
>> +  // indicate that explicitly (for example, by passing `text("no
>> explanation")`
>> +  //  to `makeRule` as the `Explanation` argument).
>>TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
>> -ClangTidyContext *Context)
>> -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
>> -
>> +ClangTidyContext *Context);
>>void registerMatchers(ast_matchers::MatchFinder *Finder) final;
>>void check(const ast_matchers::MatchFinder::MatchResult ) final;
>>
>> Index:
>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>> ===
>> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>> @@ -13,6 +13,17 @@
>>  namespace utils {
>>  using tooling::RewriteRule;
>>
>> +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
>> R,
>> + StringRef Name,
>> + ClangTidyContext
>> *Context)
>> +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
>> +  for (const auto  : Rule.Cases) {
>> +assert(Case.Explanation != nullptr &&
>> +   "clang-tidy checks must have an explanation by default;"
>> +   " explicitly provide an empty explanation if none is
>> desired");
>> +  }
>> +}
>> +
>>  void TransformerClangTidyCheck::registerMatchers(
>>  ast_matchers::MatchFinder *Finder) {
>>Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
>> @@ -44,15 +55,13 @@
>>if (Transformations->empty())
>>  return;
>>
>> -  StringRef Message = "no explanation";
>> -  if (Case.Explanation) {
>> -if (Expected E = Case.Explanation(Result))
>> -  Message = *E;
>> -else
>> -  llvm::errs() << "Error in explanation: " <<
>> llvm::toString(E.takeError())
>> -   << "\n";
>> +  Expected Explanation = Case.Explanation(Result);
>> +  if (!Explanation) {
>> +llvm::errs() << "Error in explanation: "
>> + << llvm::toString(Explanation.takeError()) << "\n";
>> +return;
>>}
>> -  DiagnosticBuilder Diag = diag(RootLoc, Message);
>> +  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
>>for (const auto  : *Transformations) {
>>  Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
>>}
>> Index:
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>> ===
>> ---
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>> +++
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>> @@ -26,15 +26,18 @@
>>using tooling::change;
>>using tooling::node;
>>using tooling::statement;
>> +  using tooling::text;
>>using tooling::stencil::cat;
>>
>>

[PATCH] D62343: [cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

2019-05-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62343



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


[PATCH] D62156: [Sema][PR41730] Diagnose addr space mismatch while constructing objects

2019-05-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3653
+def note_ovl_candidate_illegal_constructor_adrspace_mismatch : Note<
+"candidate constructor ignored: address space mismatch between object and 
constructor">;
 def note_ovl_candidate_bad_deduction : Note<

"candidate constructor ignored: cannot be used to construct an object in 
address space %0"?



Comment at: lib/Sema/SemaDeclCXX.cpp:8229
+  if (FTI.hasMethodTypeCVRUQualifiers()) {
+FTI.MethodQualifiers->forEachCVRUQualifier(
 [&](DeclSpec::TQ TypeQual, StringRef QualName, SourceLocation SL) {

Anastasia wrote:
> rjmccall wrote:
> > rjmccall wrote:
> > > We want to catch `_Atomic`, too, so please just change this loop to 
> > > ignore address-space qualifiers, using a flag to decide whether to call 
> > > `setInvalidType`.
> > If there aren't any qualifiers we're skipping, the flag isn't necessary.
> We are skipping addr space currently. I use this flag to avoid setting 
> declaration as invalid below if it's only qualified by an addr space.
Okay.  Does `forEachQualifier` not visit address-space qualifiers?

Please leave a comment explaining that that's the intended behavior: we should 
visit everything except an address space.



Comment at: lib/Sema/SemaOverload.cpp:6095
+// Check that addr space of an object being constructed is convertible to
+// the one ctor qualified with.
+if (!Qualifiers::isAddressSpaceSupersetOf(

"Check that the constructor is capable of constructing an object in the 
destination address space."

Should there be an exception here for trivial default/copy/move constructors?



Comment at: test/CodeGenCXX/address-space-of-this.cpp:3
 // RUN: %clang_cc1 %s -std=c++17 -triple=spir -emit-llvm -o - | FileCheck %s
+// XFAIL: *
 

Is there nothing in this test that's worth continuing to check while we work on 
fixing this problem?


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

https://reviews.llvm.org/D62156



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


[PATCH] D62368: Add support for Hygon Dhyana processor

2019-05-24 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

Regarding the Scudo side of the patch: the code has to be able to compile with 
gcc as well, and not necessarily the latest version.
This won't compile on systems without a `signature_HYGON_*`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Just one question - why it is not the part of the whole patch for the unified 
memory support in clang?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, jdoerfert, guansong.
Herald added a project: clang.

This patch adds a test for requires with unified share memory clause when a 
declare target link is present.

This test needs to go in prior to changes to declare target link for comparison 
purposes.


Repository:
  rC Clang

https://reviews.llvm.org/D62407

Files:
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+
+// CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
+
+// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 2
+// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
+// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
+// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 2
+// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
+// CHECK: store double* [[VAR]], double** [[BCAST6]]
+
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** 
%16, i8** %17, i64* getelementptr inbounds ([3 x i64], [3 x i64]* 
[[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x 
i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+
+#endif


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: 

r361650 - [ASTImporter] Call to HandleNameConflict in VisitRecordDecl mistakeningly using Name instead of SearchName

2019-05-24 Thread Shafik Yaghmour via cfe-commits
Author: shafik
Date: Fri May 24 09:53:44 2019
New Revision: 361650

URL: http://llvm.org/viewvc/llvm-project?rev=361650=rev
Log:
[ASTImporter] Call to HandleNameConflict in VisitRecordDecl mistakeningly using 
Name instead of SearchName

Summary:
https://reviews.llvm.org/D51633 added error handling to the 
ASTNodeImporter::VisitRecordDecl for the conflicting names case. This could 
lead to erroneous return of an error in that case since we should have been 
using SearchName. Name may be empty in the case where we find the name via 
D->getTypedefNameForAnonDecl()->getDeclName().

This fix is very similar to https://reviews.llvm.org/D59665

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=361650=361649=361650=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri May 24 09:53:44 2019
@@ -2585,7 +2585,7 @@ ExpectedDecl ASTNodeImporter::VisitRecor
 } // for
 
 if (!ConflictingDecls.empty() && SearchName) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)


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


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Ilya Biryukov via cfe-commits
This seems to produce warnings about unused variables:
…/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
warning: unused variable 'Case' [-Wunused-variable]

  for (const auto  : Rule.Cases) {

Could you take a look?

On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
revi...@reviews.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
> require Explanation field. (authored by ymandel, committed by ).
> Herald added a project: LLVM.
> Herald added a subscriber: llvm-commits.
>
> Changed prior to commit:
>   https://reviews.llvm.org/D62340?vs=201256=201272#toc
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D62340/new/
>
> https://reviews.llvm.org/D62340
>
> Files:
>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>
>
> Index: clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
> ===
> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
> @@ -31,10 +31,14 @@
>  // };
>  class TransformerClangTidyCheck : public ClangTidyCheck {
>  public:
> +  // All cases in \p R must have a non-null \c Explanation, even though \c
> +  // Explanation is optional for RewriteRule in general. Because the
> primary
> +  // purpose of clang-tidy checks is to provide users with diagnostics, we
> +  // assume that a missing explanation is a bug.  If no explanation is
> desired,
> +  // indicate that explicitly (for example, by passing `text("no
> explanation")`
> +  //  to `makeRule` as the `Explanation` argument).
>TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
> -ClangTidyContext *Context)
> -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
> -
> +ClangTidyContext *Context);
>void registerMatchers(ast_matchers::MatchFinder *Finder) final;
>void check(const ast_matchers::MatchFinder::MatchResult ) final;
>
> Index:
> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
> ===
> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
> @@ -13,6 +13,17 @@
>  namespace utils {
>  using tooling::RewriteRule;
>
> +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
> R,
> + StringRef Name,
> + ClangTidyContext
> *Context)
> +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
> +  for (const auto  : Rule.Cases) {
> +assert(Case.Explanation != nullptr &&
> +   "clang-tidy checks must have an explanation by default;"
> +   " explicitly provide an empty explanation if none is desired");
> +  }
> +}
> +
>  void TransformerClangTidyCheck::registerMatchers(
>  ast_matchers::MatchFinder *Finder) {
>Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
> @@ -44,15 +55,13 @@
>if (Transformations->empty())
>  return;
>
> -  StringRef Message = "no explanation";
> -  if (Case.Explanation) {
> -if (Expected E = Case.Explanation(Result))
> -  Message = *E;
> -else
> -  llvm::errs() << "Error in explanation: " <<
> llvm::toString(E.takeError())
> -   << "\n";
> +  Expected Explanation = Case.Explanation(Result);
> +  if (!Explanation) {
> +llvm::errs() << "Error in explanation: "
> + << llvm::toString(Explanation.takeError()) << "\n";
> +return;
>}
> -  DiagnosticBuilder Diag = diag(RootLoc, Message);
> +  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
>for (const auto  : *Transformations) {
>  Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
>}
> Index:
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
> ===
> ---
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
> +++
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
> @@ -26,15 +26,18 @@
>using tooling::change;
>using tooling::node;
>using tooling::statement;
> +  using tooling::text;
>using tooling::stencil::cat;
>
>StringRef C = "C", T = "T", E = "E";
> -  return tooling::makeRule(ifStmt(hasCondition(expr().bind(C)),
> -  hasThen(stmt().bind(T)),
> -  

[PATCH] D62406: [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, jgravelle-google, 
dschuff.
Herald added a project: clang.
sbc100 added a reviewer: dschuff.

This is in line with other platforms.

Also, move the single statement methods into the header (also
in line with other platform).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62406

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain );
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain )
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain )
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver ,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList ) const {
   const ToolChain  = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain );
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain )
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain )
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver ,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList ) const {
   const ToolChain  = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >