r351528 - Fix failing MSan bots

2019-01-18 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Jan 18 00:43:22 2019
New Revision: 351528

URL: http://llvm.org/viewvc/llvm-project?rev=351528&view=rev
Log:
Fix failing MSan bots

Revert r351508-351514, this block of changes introduced a consistent
MSan failure on the sanitizer bots.

Removed:
cfe/trunk/test/Analysis/os_object_base.h
cfe/trunk/test/Analysis/os_smart_ptr.h
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

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

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

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

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
cfe/trunk/test/Analysis/test-separate-retaincount.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=351528&r1=351527&r2=351528&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Fri 
Jan 18 00:43:22 2019
@@ -95,7 +95,7 @@ protected:
   friend class BugReportEquivClass;
   friend class BugReporter;
 
-  const BugType& BT;
+  BugType& BT;
   const Decl *DeclWithIssue = nullptr;
   std::string ShortDescription;
   std::string Description;
@@ -164,15 +164,15 @@ private:
   void popInterestingSymbolsAndRegions();
 
 public:
-  BugReport(const BugType& bt, StringRef desc, const ExplodedNode *errornode)
+  BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode)
   : BT(bt), Description(desc), ErrorNode(errornode) {}
 
-  BugReport(const BugType& bt, StringRef shortDesc, StringRef desc,
+  BugReport(BugType& bt, StringRef shortDesc, StringRef desc,
 const ExplodedNode *errornode)
   : BT(bt), ShortDescription(shortDesc), Description(desc),
 ErrorNode(errornode) {}
 
-  BugReport(const BugType &bt, StringRef desc, PathDiagnosticLocation l)
+  BugReport(BugType &bt, StringRef desc, PathDiagnosticLocation l)
   : BT(bt), Description(desc), Location(l) {}
 
   /// Create a BugReport with a custom uniqueing location.
@@ -190,7 +190,7 @@ public:
   virtual ~BugReport();
 
   const BugType& getBugType() const { return BT; }
-  //BugType& getBugType() { return BT; }
+  BugType& getBugType() { return BT; }
 
   /// True when the report has an execution path associated with it.
   ///
@@ -481,7 +481,7 @@ public:
 return {};
   }
 
-  void Register(const BugType *BT);
+  void Register(BugType *BT);
 
   /// Add the given report to the set of reports tracked by BugReporter.
   ///

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h?rev=351528&r1=351527&r2=351528&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h Fri Jan 
18 00:43:22 2019
@@ -38,14 +38,12 @@ private:
   virtual void anchor();
 
 public:
-  BugType(CheckName Check, StringRef Name, StringRef Cat,
-  bool SuppressOnSink=false)
+  BugType(CheckName Check, StringRef Name, StringRef Cat)
   : Check(Check), Name(Name), Category(Cat), Checker(nullptr),
-SuppressOnSink(SuppressOnSink) {}
-  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat,
-  bool SuppressOnSink=false)
+SuppressOnSink(false) {}
+  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
   : Check(Checker->getCheckName()), Name(Name), Category(Cat),
-Checker(Checker), SuppressOnSink(SuppressOnSink) {}
+Checker(Checker), SuppressOnSink(false) {}
   virtual ~BugType() = default;
 
   StringRef getName() const { return Name; }
@@ -66,6 +64,7 @@ public:
   ///  type should be suppressed if the end node of the report is 
post-dominated
   ///  by a sink node.
   bo

Re: r351514 - [analyzer] Introduce proper diagnostic for freeing unowned object

2019-01-18 Thread Vlad Tsyrklevich via cfe-commits
Hi, I've reverted r351508-351514 as they were causing MSan failures on the
sanitizer bots. It looks like isLeak is not initialized by one of the
RefCountReport constructors and it is not immediately obvious to me what an
appropriate value for it is. You can observe the failures here
,
they look like the following:

FAIL: Clang :: Analysis/inlining/path-notes.m (525 of 13800)
 TEST 'Clang :: Analysis/inlining/path-notes.m'
FAILED 
Script:
--
: 'RUN: at line 1';
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang
-cc1 -internal-isystem
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
-nostdsysteminc -analyze -analyzer-constraints=range
-analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount
-analyzer-output=text -analyzer-config
suppress-null-return-paths=false -fblocks -verify
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/path-notes.m
: 'RUN: at line 2';
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang
-cc1 -internal-isystem
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
-nostdsysteminc -analyze -analyzer-constraints=range
-analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount
-analyzer-output=plist-multi-file -analyzer-config
suppress-null-return-paths=false -fblocks
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/path-notes.m
-o 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Analysis/inlining/Output/path-notes.m.tmp.plist
: 'RUN: at line 3';   cat
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Analysis/inlining/Output/path-notes.m.tmp.plist
| diff -u -w -I "/" -I ".:" -I "version"
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.m.plist
-
--
Exit Code: 77

Command Output (stderr):
--
==93612==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0xa0635a8 in
clang::ento::retaincountchecker::RefCountReport::getRanges()
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h:65:9
#1 0xa18bb67 in
clang::ento::BugReporterVisitor::getDefaultEndPath(clang::ento::BugReporterContext&,
clang::ento::ExplodedNode const*, clang::ento::BugReport&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:176:27
#2 0xa05cf02 in
clang::ento::retaincountchecker::RefCountReportVisitor::getEndPath(clang::ento::BugReporterContext&,
clang::ento::ExplodedNode const*, clang::ento::BugReport&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:681:10
#3 0xa15b9aa in
generateVisitorsDiagnostics(clang::ento::BugReport*,
clang::ento::ExplodedNode const*, clang::ento::BugReporterContext&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2564:29
#4 0xa1429dc in findValidReport
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2621:9
#5 0xa1429dc in
clang::ento::GRBugReporter::generatePathDiagnostics(llvm::ArrayRef,
llvm::ArrayRef&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2670
#6 0xa14f991 in
clang::ento::BugReporter::generateDiagnosticForConsumerMap(clang::ento::BugReport*,
llvm::ArrayRef,
llvm::ArrayRef)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3092:5
#7 0xa13cbc1 in
clang::ento::BugReporter::FlushReport(clang::ento::BugReportEquivClass&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2948:7
#8 0xa13a171 in clang::ento::BugReporter::FlushReports()
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2254:5
#9 0x99e9463 in RunPathSensitiveChecks
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:752:24
#10 0x99e9463 in (anonymous
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:716
#11 0x99ca7d6 in HandleDeclsCallGraph
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:507:5
#12 0x99ca7d6 in runAnalysisOnTranslationUnit
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend

[PATCH] D56856: [tooling] Add a new argument adjuster for deleting plugin related command line args

2019-01-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 182469.
kadircet added a comment.

- Address comments


Repository:
  rC Clang

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

https://reviews.llvm.org/D56856

Files:
  include/clang/Tooling/ArgumentsAdjusters.h
  lib/Tooling/ArgumentsAdjusters.cpp
  unittests/Tooling/ToolingTest.cpp


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -450,6 +450,37 @@
   EXPECT_TRUE(HasFlag("-w"));
 }
 
+// Check getClangStripPluginsAdjuster strips plugin related args.
+TEST(ClangToolTest, StripPluginsAdjuster) {
+  FixedCompilationDatabase Compilations(
+  "/", {"-Xclang", "-add-plugin", "-Xclang", "random-plugin"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+  [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [&FinalArgs](const std::string &Flag) {
+return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
+   FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("-Xclang"));
+  EXPECT_FALSE(HasFlag("-add-plugin"));
+  EXPECT_FALSE(HasFlag("-random-plugin"));
+}
+
 namespace {
 /// Find a target name such that looking for it in TargetRegistry by that name
 /// returns the same target. We expect that there is at least one target
Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -108,5 +108,27 @@
   };
 }
 
+ArgumentsAdjuster getStripPluginsAdjuster() {
+  return [](const CommandLineArguments &Args, StringRef /*unused*/) {
+CommandLineArguments AdjustedArgs;
+for (size_t I = 0, E = Args.size(); I != E; I++) {
+  // According to https://clang.llvm.org/docs/ClangPlugins.html
+  // plugin arguments are in the form:
+  // -Xclang {-load, -plugin, -plugin-arg-, -add-plugin}
+  // -Xclang 
+  if (I + 4 < E && Args[I] == "-Xclang" &&
+  (Args[I + 1] == "-load" || Args[I + 1] == "-plugin" ||
+   llvm::StringRef(Args[I + 1]).startswith("-plugin-arg-") ||
+   Args[I + 1] == "-add-plugin") &&
+  Args[I + 2] == "-Xclang") {
+I += 3;
+continue;
+  }
+  AdjustedArgs.push_back(Args[I]);
+}
+return AdjustedArgs;
+  };
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: include/clang/Tooling/ArgumentsAdjusters.h
===
--- include/clang/Tooling/ArgumentsAdjusters.h
+++ include/clang/Tooling/ArgumentsAdjusters.h
@@ -61,6 +61,10 @@
 const char *Extra,
 ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
 
+/// Gets an argument adjuster which strips plugin related command line
+/// arguments.
+ArgumentsAdjuster getStripPluginsAdjuster();
+
 /// Gets an argument adjuster which adjusts the arguments in sequence
 /// with the \p First adjuster and then with the \p Second one.
 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -450,6 +450,37 @@
   EXPECT_TRUE(HasFlag("-w"));
 }
 
+// Check getClangStripPluginsAdjuster strips plugin related args.
+TEST(ClangToolTest, StripPluginsAdjuster) {
+  FixedCompilationDatabase Compilations(
+  "/", {"-Xclang", "-add-plugin", "-Xclang", "random-plugin"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+  [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [&FinalArgs](const std::string &Flag) {
+return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
+   FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("-Xclang"));
+  EXPECT_FALSE(HasFlag("-add-plugin"));
+  EXPECT_FALSE(HasFlag("-random-plugin"));
+}
+
 namespace {
 /// Find a target name such that looking for it in TargetRegistry by that name
 /// returns the same 

r351531 - [tooling] Add a new argument adjuster for deleting plugin related command line args

2019-01-18 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Fri Jan 18 01:00:31 2019
New Revision: 351531

URL: http://llvm.org/viewvc/llvm-project?rev=351531&view=rev
Log:
[tooling] Add a new argument adjuster for deleting plugin related command line 
args

Summary:
Currently both clangd and clang-tidy makes use of this mechanism so
putting it into tooling so that all tools can make use of it.

Reviewers: ilya-biryukov, sammccall

Subscribers: ioeric, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h
cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h?rev=351531&r1=351530&r2=351531&view=diff
==
--- cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h (original)
+++ cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h Fri Jan 18 01:00:31 
2019
@@ -61,6 +61,10 @@ ArgumentsAdjuster getInsertArgumentAdjus
 const char *Extra,
 ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
 
+/// Gets an argument adjuster which strips plugin related command line
+/// arguments.
+ArgumentsAdjuster getStripPluginsAdjuster();
+
 /// Gets an argument adjuster which adjusts the arguments in sequence
 /// with the \p First adjuster and then with the \p Second one.
 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,

Modified: cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp?rev=351531&r1=351530&r2=351531&view=diff
==
--- cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp (original)
+++ cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp Fri Jan 18 01:00:31 2019
@@ -108,5 +108,27 @@ ArgumentsAdjuster combineAdjusters(Argum
   };
 }
 
+ArgumentsAdjuster getStripPluginsAdjuster() {
+  return [](const CommandLineArguments &Args, StringRef /*unused*/) {
+CommandLineArguments AdjustedArgs;
+for (size_t I = 0, E = Args.size(); I != E; I++) {
+  // According to https://clang.llvm.org/docs/ClangPlugins.html
+  // plugin arguments are in the form:
+  // -Xclang {-load, -plugin, -plugin-arg-, -add-plugin}
+  // -Xclang 
+  if (I + 4 < E && Args[I] == "-Xclang" &&
+  (Args[I + 1] == "-load" || Args[I + 1] == "-plugin" ||
+   llvm::StringRef(Args[I + 1]).startswith("-plugin-arg-") ||
+   Args[I + 1] == "-add-plugin") &&
+  Args[I + 2] == "-Xclang") {
+I += 3;
+continue;
+  }
+  AdjustedArgs.push_back(Args[I]);
+}
+return AdjustedArgs;
+  };
+}
+
 } // end namespace tooling
 } // end namespace clang

Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=351531&r1=351530&r2=351531&view=diff
==
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Fri Jan 18 01:00:31 2019
@@ -450,6 +450,37 @@ TEST(ClangToolTest, StripDependencyFileA
   EXPECT_TRUE(HasFlag("-w"));
 }
 
+// Check getClangStripPluginsAdjuster strips plugin related args.
+TEST(ClangToolTest, StripPluginsAdjuster) {
+  FixedCompilationDatabase Compilations(
+  "/", {"-Xclang", "-add-plugin", "-Xclang", "random-plugin"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+  [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [&FinalArgs](const std::string &Flag) {
+return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
+   FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("-Xclang"));
+  EXPECT_FALSE(HasFlag("-add-plugin"));
+  EXPECT_FALSE(HasFlag("-random-plugin"));
+}
+
 namespace {
 /// Find a target name such that looking for it in TargetRegistry by that name
 /// returns the same target. We expect that there is at least one target


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


[PATCH] D56856: [tooling] Add a new argument adjuster for deleting plugin related command line args

2019-01-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351531: [tooling] Add a new argument adjuster for deleting 
plugin related command line… (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56856?vs=182469&id=182472#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56856

Files:
  include/clang/Tooling/ArgumentsAdjusters.h
  lib/Tooling/ArgumentsAdjusters.cpp
  unittests/Tooling/ToolingTest.cpp


Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -108,5 +108,27 @@
   };
 }
 
+ArgumentsAdjuster getStripPluginsAdjuster() {
+  return [](const CommandLineArguments &Args, StringRef /*unused*/) {
+CommandLineArguments AdjustedArgs;
+for (size_t I = 0, E = Args.size(); I != E; I++) {
+  // According to https://clang.llvm.org/docs/ClangPlugins.html
+  // plugin arguments are in the form:
+  // -Xclang {-load, -plugin, -plugin-arg-, -add-plugin}
+  // -Xclang 
+  if (I + 4 < E && Args[I] == "-Xclang" &&
+  (Args[I + 1] == "-load" || Args[I + 1] == "-plugin" ||
+   llvm::StringRef(Args[I + 1]).startswith("-plugin-arg-") ||
+   Args[I + 1] == "-add-plugin") &&
+  Args[I + 2] == "-Xclang") {
+I += 3;
+continue;
+  }
+  AdjustedArgs.push_back(Args[I]);
+}
+return AdjustedArgs;
+  };
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -450,6 +450,37 @@
   EXPECT_TRUE(HasFlag("-w"));
 }
 
+// Check getClangStripPluginsAdjuster strips plugin related args.
+TEST(ClangToolTest, StripPluginsAdjuster) {
+  FixedCompilationDatabase Compilations(
+  "/", {"-Xclang", "-add-plugin", "-Xclang", "random-plugin"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+  [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [&FinalArgs](const std::string &Flag) {
+return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
+   FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("-Xclang"));
+  EXPECT_FALSE(HasFlag("-add-plugin"));
+  EXPECT_FALSE(HasFlag("-random-plugin"));
+}
+
 namespace {
 /// Find a target name such that looking for it in TargetRegistry by that name
 /// returns the same target. We expect that there is at least one target
Index: include/clang/Tooling/ArgumentsAdjusters.h
===
--- include/clang/Tooling/ArgumentsAdjusters.h
+++ include/clang/Tooling/ArgumentsAdjusters.h
@@ -61,6 +61,10 @@
 const char *Extra,
 ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
 
+/// Gets an argument adjuster which strips plugin related command line
+/// arguments.
+ArgumentsAdjuster getStripPluginsAdjuster();
+
 /// Gets an argument adjuster which adjusts the arguments in sequence
 /// with the \p First adjuster and then with the \p Second one.
 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,


Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -108,5 +108,27 @@
   };
 }
 
+ArgumentsAdjuster getStripPluginsAdjuster() {
+  return [](const CommandLineArguments &Args, StringRef /*unused*/) {
+CommandLineArguments AdjustedArgs;
+for (size_t I = 0, E = Args.size(); I != E; I++) {
+  // According to https://clang.llvm.org/docs/ClangPlugins.html
+  // plugin arguments are in the form:
+  // -Xclang {-load, -plugin, -plugin-arg-, -add-plugin}
+  // -Xclang 
+  if (I + 4 < E && Args[I] == "-Xclang" &&
+  (Args[I + 1] == "-load" || Args[I + 1] == "-plugin" ||
+   llvm::StringRef(Args[I + 1]).startswith("-plugin-arg-") ||
+   Args[I + 1] == "-add-plugin") &&
+  Args[I + 2] == "-Xclang") {
+I += 3;
+continue;
+  }
+  AdjustedArgs.push_back(Args[I]);
+}
+return AdjustedArgs;
+  };
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest

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

2019-01-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:9825
+if (Result.isSigned() && !DstSigned) {
+  Overflow = Result < 0 || Result.ugt(DstMax);
+} else if (Result.isUnsigned() && DstSigned) {

The `Result < 0` is more clearly expressed as `Result.isNegative()` I think.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1499
+  IsNegFractional, NegResult,
+  Builder.CreateAShr(Result, SrcScale - DstScale, "downscale"));
+} else {

I think this block can be simplified significantly by simply rounding up before 
conversion. So, something like:
```
%lt = icmp slt %val, 0
%rounded = add %val, lowBits(Scale)
%sel = select %lt, %rounded, %val
... rescale/resize ...
```




Comment at: clang/lib/Sema/SemaChecking.cpp:11096
+}
+  }
 }

Seems like a lot of logic in these blocks is duplicated from the code in 
ExprConstant.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56900



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


Re: r351457 - TLS: Respect visibility for thread_local variables on Darwin (PR40327)

2019-01-18 Thread Hans Wennborg via cfe-commits
Merged to the 8.0 branch in r351533. Please let me know if there are
any further commits for this issue.

Thanks,
Hans

On Thu, Jan 17, 2019 at 6:57 PM Vlad Tsyrklevich via cfe-commits
 wrote:
>
> Author: vlad.tsyrklevich
> Date: Thu Jan 17 09:53:45 2019
> New Revision: 351457
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351457&view=rev
> Log:
> TLS: Respect visibility for thread_local variables on Darwin (PR40327)
>
> Summary:
> Teach clang to mark thread wrappers for thread_local variables with
> hidden visibility when the original variable is marked with hidden
> visibility. This is necessary on Darwin which exposes the thread wrapper
> instead of the thread variable. The thread wrapper would previously
> always be created with default visibility unless it had
> linkonce*/weak_odr linkage.
>
> Reviewers: rjmccall
>
> Reviewed By: rjmccall
>
> Differential Revision: https://reviews.llvm.org/D56818
>
> Added:
> cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
> Modified:
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
>
> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=351457&r1=351456&r2=351457&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Jan 17 09:53:45 2019
> @@ -2463,10 +2463,12 @@ ItaniumCXXABI::getOrCreateThreadLocalWra
>  CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Wrapper);
>
>// Always resolve references to the wrapper at link time.
> -  if (!Wrapper->hasLocalLinkage() && !(isThreadWrapperReplaceable(VD, CGM) &&
> -  !llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) &&
> -  !llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage(
> -Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility);
> +  if (!Wrapper->hasLocalLinkage())
> +if (!isThreadWrapperReplaceable(VD, CGM) ||
> +llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) ||
> +llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage()) ||
> +VD->getVisibility() == HiddenVisibility)
> +  Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility);
>
>if (isThreadWrapperReplaceable(VD, CGM)) {
>  Wrapper->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
>
> Added: cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp?rev=351457&view=auto
> ==
> --- cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp Thu Jan 17 
> 09:53:45 2019
> @@ -0,0 +1,17 @@
> +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | 
> FileCheck --check-prefix=LINUX %s
> +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple 
> x86_64-apple-darwin12 | FileCheck --check-prefix=DARWIN %s
> +
> +// Regression test for PR40327
> +
> +// LINUX: @default_tls = thread_local global i32
> +// LINUX: @hidden_tls = hidden thread_local global i32
> +// LINUX: define weak_odr hidden i32* @_ZTW11default_tls()
> +// LINUX: define weak_odr hidden i32* @_ZTW10hidden_tls()
> +//
> +// DARWIN: @default_tls = internal thread_local global i32
> +// DARWIN: @hidden_tls = internal thread_local global i32
> +// DARWIN: define cxx_fast_tlscc i32* @_ZTW11default_tls()
> +// DARWIN: define hidden cxx_fast_tlscc i32* @_ZTW10hidden_tls()
> +
> +__attribute__((visibility("default"))) thread_local int default_tls;
> +__attribute__((visibility("hidden"))) thread_local int hidden_tls;
>
> Modified: cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp?rev=351457&r1=351456&r2=351457&view=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp Thu Jan 17 09:53:45 2019
> @@ -318,7 +318,7 @@ void set_anon_i() {
>  // CHECK-NOT: call void @[[V_M_INIT]]()
>
>
> -// LIUNX: define weak_odr hidden i32* @_ZTW1a() {
> +// LINUX: define weak_odr hidden i32* @_ZTW1a()
>  // DARWIN: define cxx_fast_tlscc i32* @_ZTW1a()
>  // LINUX:   call void @_ZTH1a()
>  // DARWIN: call cxx_fast_tlscc void @_ZTH1a()
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56752: [ASTDump] Mark BlockDecls which capture this with a tag

2019-01-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 182475.
steveire added a comment.

Rebase


Repository:
  rC Clang

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

https://reviews.llvm.org/D56752

Files:
  lib/AST/ASTDumper.cpp
  test/AST/ast-dump-decl.mm


Index: test/AST/ast-dump-decl.mm
===
--- test/AST/ast-dump-decl.mm
+++ test/AST/ast-dump-decl.mm
@@ -39,8 +39,7 @@
 // CHECK-NEXT:   cleanup Block
 // CHECK-NEXT:   CallExpr {{.*}}  'void'
 // CHECK-NEXT: BlockExpr {{.*}}  'void (^)()'
-// CHECK-NEXT:   BlockDecl {{.*}}  col:5
-// CHECK-NEXT: capture this
+// CHECK-NEXT:   BlockDecl {{.*}}  col:5 captures_this
 // CHECK-NEXT: CompoundStmt {{.*}} 
 // CHECK-NEXT:   CXXMemberCallExpr {{.*}}  'void'
 // CHECK-NEXT: MemberExpr {{.*}}  '' ->yada
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -1379,12 +1379,12 @@
   if (D->isVariadic())
 OS << " variadic";
 
+  if (D->capturesCXXThis())
+OS << " captures_this";
+
   for (auto I : D->parameters())
 dumpDecl(I);
 
-  if (D->capturesCXXThis())
-dumpChild([=]{ OS << "capture this"; });
-
   for (const auto &I : D->captures())
 Visit(I);
   dumpStmt(D->getBody());


Index: test/AST/ast-dump-decl.mm
===
--- test/AST/ast-dump-decl.mm
+++ test/AST/ast-dump-decl.mm
@@ -39,8 +39,7 @@
 // CHECK-NEXT:   cleanup Block
 // CHECK-NEXT:   CallExpr {{.*}}  'void'
 // CHECK-NEXT: BlockExpr {{.*}}  'void (^)()'
-// CHECK-NEXT:   BlockDecl {{.*}}  col:5
-// CHECK-NEXT: capture this
+// CHECK-NEXT:   BlockDecl {{.*}}  col:5 captures_this
 // CHECK-NEXT: CompoundStmt {{.*}} 
 // CHECK-NEXT:   CXXMemberCallExpr {{.*}}  'void'
 // CHECK-NEXT: MemberExpr {{.*}}  '' ->yada
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -1379,12 +1379,12 @@
   if (D->isVariadic())
 OS << " variadic";
 
+  if (D->capturesCXXThis())
+OS << " captures_this";
+
   for (auto I : D->parameters())
 dumpDecl(I);
 
-  if (D->capturesCXXThis())
-dumpChild([=]{ OS << "capture this"; });
-
   for (const auto &I : D->captures())
 Visit(I);
   dumpStmt(D->getBody());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56753: [ASTDump] Mark null params with a tag rather than a child node

2019-01-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 182476.
steveire marked an inline comment as done.
steveire added a comment.

Update


Repository:
  rC Clang

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

https://reviews.llvm.org/D56753

Files:
  lib/AST/ASTDumper.cpp


Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -633,13 +633,19 @@
 }
   }
 
+  // Since NumParams comes from the FunctionProtoType of the
+  // FunctionDecl and the Params are set later, it is possible
+  // for a dump during debugging to encounter a FunctionDecl
+  // that has been created but hasn't been assigned
+  // ParmVarDecls yet.
+  if (!D->param_empty() && !D->param_begin())
+OS << " >";
+
   if (const auto *FTSI = D->getTemplateSpecializationInfo())
 dumpTemplateArgumentList(*FTSI->TemplateArguments);
 
-  if (!D->param_begin() && D->getNumParams())
-dumpChild([=] { OS << ">"; });
-  else
-for (const ParmVarDecl *Parameter : D->parameters())
+  if (D->param_begin())
+for (const auto *Parameter : D->parameters())
   dumpDecl(Parameter);
 
   if (const auto *C = dyn_cast(D))


Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -633,13 +633,19 @@
 }
   }
 
+  // Since NumParams comes from the FunctionProtoType of the
+  // FunctionDecl and the Params are set later, it is possible
+  // for a dump during debugging to encounter a FunctionDecl
+  // that has been created but hasn't been assigned
+  // ParmVarDecls yet.
+  if (!D->param_empty() && !D->param_begin())
+OS << " >";
+
   if (const auto *FTSI = D->getTemplateSpecializationInfo())
 dumpTemplateArgumentList(*FTSI->TemplateArguments);
 
-  if (!D->param_begin() && D->getNumParams())
-dumpChild([=] { OS << ">"; });
-  else
-for (const ParmVarDecl *Parameter : D->parameters())
+  if (D->param_begin())
+for (const auto *Parameter : D->parameters())
   dumpDecl(Parameter);
 
   if (const auto *C = dyn_cast(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r351459 - [ObjC] Follow-up r350768 and allow the use of unavailable methods that are

2019-01-18 Thread Hans Wennborg via cfe-commits
Merged in r351535. Please let me know if there are any more issues in this area.

Also, do you want to write something for r350768 and this in the release notes?

On Thu, Jan 17, 2019 at 7:22 PM Alex L  wrote:
>
> Hi Hans,
>
> Could you please cherry-pick this change into the release branch?
>
> Cheers,
> Alex
>
> On Thu, 17 Jan 2019 at 10:16, Alex Lorenz via cfe-commits 
>  wrote:
>>
>> Author: arphaman
>> Date: Thu Jan 17 10:12:45 2019
>> New Revision: 351459
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=351459&view=rev
>> Log:
>> [ObjC] Follow-up r350768 and allow the use of unavailable methods that are
>> declared in a parent class from within the @implementation context
>>
>> This commit extends r350768 and allows the use of methods marked as 
>> unavailable
>> that are declared in a parent class/category from within the @implementation 
>> of
>> the class where the method is marked as unavailable.
>> This allows users to call init that's marked as unavailable even if they 
>> don't
>> define it.
>>
>> rdar://47134898
>>
>> Differential Revision: https://reviews.llvm.org/D56816
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
>> cfe/trunk/test/SemaObjC/infer-availability-from-init.m
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=351459&r1=351458&r2=351459&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jan 17 10:12:45 2019
>> @@ -7365,13 +7365,11 @@ ShouldDiagnoseAvailabilityInContext(Sema
>>  return true;
>>  } else if (K == AR_Unavailable) {
>>// It is perfectly fine to refer to an 'unavailable' Objective-C 
>> method
>> -  // when it's actually defined and is referenced from within the
>> -  // @implementation itself. In this context, we interpret unavailable 
>> as a
>> -  // form of access control.
>> +  // when it is referenced from within the @implementation itself. In 
>> this
>> +  // context, we interpret unavailable as a form of access control.
>>if (const auto *MD = dyn_cast(OffendingDecl)) {
>>  if (const auto *Impl = dyn_cast(C)) {
>> -  if (MD->getClassInterface() == Impl->getClassInterface() &&
>> -  MD->isDefined())
>> +  if (MD->getClassInterface() == Impl->getClassInterface())
>>  return true;
>>  }
>>}
>>
>> Modified: cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m?rev=351459&r1=351458&r2=351459&view=diff
>> ==
>> --- cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m (original)
>> +++ cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m Thu Jan 17 
>> 10:12:45 2019
>> @@ -5,13 +5,24 @@
>>  + (instancetype)new;
>>  + (instancetype)alloc;
>>
>> +- (void)declaredInSuper;
>> +
>> +@end
>> +
>> +@interface NSObject (Category)
>> +
>> +- (void)declaredInSuperCategory;
>> +
>>  @end
>>
>>  @interface Sub: NSObject
>>
>>  - (instancetype)init __attribute__((unavailable)); // expected-note 4 
>> {{'init' has been explicitly marked unavailable here}}
>>
>> -- (void)notImplemented __attribute__((unavailable)); // expected-note 
>> {{'notImplemented' has been explicitly marked unavailable here}}
>> +- (void)notImplemented __attribute__((unavailable));
>> +
>> +- (void)declaredInSuper __attribute__((unavailable));
>> +- (void)declaredInSuperCategory __attribute__((unavailable));
>>
>>  @end
>>
>> @@ -34,7 +45,14 @@
>>  }
>>
>>  - (void)reportUseOfUnimplemented {
>> -  [self notImplemented]; // expected-error {{'notImplemented' is 
>> unavailable}}
>> +  [self notImplemented];
>> +}
>> +
>> +- (void)allowSuperCallUsingSelf {
>> +  [self declaredInSuper];
>> +  [[Sub alloc] declaredInSuper];
>> +  [self declaredInSuperCategory];
>> +  [[Sub alloc] declaredInSuperCategory];
>>  }
>>
>>  @end
>>
>> Modified: cfe/trunk/test/SemaObjC/infer-availability-from-init.m
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/infer-availability-from-init.m?rev=351459&r1=351458&r2=351459&view=diff
>> ==
>> --- cfe/trunk/test/SemaObjC/infer-availability-from-init.m (original)
>> +++ cfe/trunk/test/SemaObjC/infer-availability-from-init.m Thu Jan 17 
>> 10:12:45 2019
>> @@ -47,12 +47,12 @@ void usenotmyobject() {
>>  }
>>
>>  @interface FromSelf : NSObject
>> --(instancetype)init __attribute__((unavailable)); // expected-note {{'init' 
>> has been explicitly marked unavailable here}}
>> +-(instancetype)init __attribute__((unavailable));
>>  +(FromSelf*)another_one;
>>  @end
>>
>>  @implementation FromSel

[PATCH] D56829: Move decl context dumping to TextNodeDumper

2019-01-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 182478.
steveire added a comment.

Update


Repository:
  rC Clang

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

https://reviews.llvm.org/D56829

Files:
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -256,6 +256,17 @@
   if (const FunctionDecl *FD = dyn_cast(D))
 if (FD->isConstexpr())
   OS << " constexpr";
+
+  if (!isa(*D)) {
+auto MD = dyn_cast(D);
+if (!MD || !MD->isThisDeclarationADefinition()) {
+  auto DC = dyn_cast(D);
+  if (DC && DC->hasExternalLexicalStorage()) {
+ColorScope Color(OS, ShowColors, UndeserializedColor);
+OS << " ";
+  }
+}
+  }
 }
 
 void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -355,18 +355,8 @@
 }
 
 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
-  if (!DC)
-return;
-
   for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
 dumpDecl(D);
-
-  if (DC->hasExternalLexicalStorage()) {
-dumpChild([=] {
-  ColorScope Color(OS, ShowColors, UndeserializedColor);
-  OS << "";
-});
-  }
 }
 
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
@@ -514,10 +504,7 @@
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D)) {
   auto DC = dyn_cast(D);
-  if (DC &&
-  (DC->hasExternalLexicalStorage() ||
-   (Deserialize ? DC->decls_begin() != DC->decls_end()
-: DC->noload_decls_begin() != DC->noload_decls_end(
+  if (DC)
 dumpDeclContext(DC);
 }
   });
@@ -1243,12 +1230,11 @@
   if (D->isVariadic())
 OS << " variadic";
 
-  if (D->isThisDeclarationADefinition()) {
+  if (isa(D) && D->isThisDeclarationADefinition())
 dumpDeclContext(D);
-  } else {
+  else
 for (const ParmVarDecl *Parameter : D->parameters())
   dumpDecl(Parameter);
-  }
 
   if (D->hasBody())
 dumpStmt(D->getBody());


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -256,6 +256,17 @@
   if (const FunctionDecl *FD = dyn_cast(D))
 if (FD->isConstexpr())
   OS << " constexpr";
+
+  if (!isa(*D)) {
+auto MD = dyn_cast(D);
+if (!MD || !MD->isThisDeclarationADefinition()) {
+  auto DC = dyn_cast(D);
+  if (DC && DC->hasExternalLexicalStorage()) {
+ColorScope Color(OS, ShowColors, UndeserializedColor);
+OS << " ";
+  }
+}
+  }
 }
 
 void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -355,18 +355,8 @@
 }
 
 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
-  if (!DC)
-return;
-
   for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
 dumpDecl(D);
-
-  if (DC->hasExternalLexicalStorage()) {
-dumpChild([=] {
-  ColorScope Color(OS, ShowColors, UndeserializedColor);
-  OS << "";
-});
-  }
 }
 
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
@@ -514,10 +504,7 @@
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D)) {
   auto DC = dyn_cast(D);
-  if (DC &&
-  (DC->hasExternalLexicalStorage() ||
-   (Deserialize ? DC->decls_begin() != DC->decls_end()
-: DC->noload_decls_begin() != DC->noload_decls_end(
+  if (DC)
 dumpDeclContext(DC);
 }
   });
@@ -1243,12 +1230,11 @@
   if (D->isVariadic())
 OS << " variadic";
 
-  if (D->isThisDeclarationADefinition()) {
+  if (isa(D) && D->isThisDeclarationADefinition())
 dumpDeclContext(D);
-  } else {
+  else
 for (const ParmVarDecl *Parameter : D->parameters())
   dumpDecl(Parameter);
-  }
 
   if (D->hasBody())
 dumpStmt(D->getBody());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r351463 - [Documentation] Add a chapter about Clang-tidy integrations.

2019-01-18 Thread Hans Wennborg via cfe-commits
Merged to 8.0 along with the follow-ups in r351538.

On Thu, Jan 17, 2019 at 7:35 PM Eugene Zelenko via cfe-commits
 wrote:
>
> Author: eugenezelenko
> Date: Thu Jan 17 10:31:34 2019
> New Revision: 351463
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351463&view=rev
> Log:
> [Documentation] Add a chapter about Clang-tidy integrations.
>
> Patch by Marina Kalashina.
>
> Differential Revision: https://reviews.llvm.org/D54945
>
> Added:
> clang-tools-extra/trunk/docs/clang-tidy/Contributing.rst
> clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/index.rst
>
> Added: clang-tools-extra/trunk/docs/clang-tidy/Contributing.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/Contributing.rst?rev=351463&view=auto
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/Contributing.rst (added)
> +++ clang-tools-extra/trunk/docs/clang-tidy/Contributing.rst Thu Jan 17 
> 10:31:34 2019
> @@ -0,0 +1,507 @@
> +
> +Getting Involved
> +
> +
> +:program:`clang-tidy` has several own checks and can run Clang static 
> analyzer
> +checks, but its power is in the ability to easily write custom checks.
> +
> +Checks are organized in modules, which can be linked into 
> :program:`clang-tidy`
> +with minimal or no code changes in :program:`clang-tidy`.
> +
> +Checks can plug into the analysis on the preprocessor level using 
> `PPCallbacks`_
> +or on the AST level using `AST Matchers`_. When an error is found, checks can
> +report them in a way similar to how Clang diagnostics work. A fix-it hint 
> can be
> +attached to a diagnostic message.
> +
> +The interface provided by :program:`clang-tidy` makes it easy to write useful
> +and precise checks in just a few lines of code. If you have an idea for a 
> good
> +check, the rest of this document explains how to do this.
> +
> +There are a few tools particularly useful when developing clang-tidy checks:
> +  * ``add_new_check.py`` is a script to automate the process of adding a new
> +check, it will create the check, update the CMake file and create a test;
> +  * ``rename_check.py`` does what the script name suggests, renames an 
> existing
> +check;
> +  * :program:`clang-query` is invaluable for interactive prototyping of AST
> +matchers and exploration of the Clang AST;
> +  * `clang-check`_ with the ``-ast-dump`` (and optionally 
> ``-ast-dump-filter``)
> +provides a convenient way to dump AST of a C++ program.
> +
> +If CMake is configured with ``CLANG_ENABLE_STATIC_ANALYZER``,
> +:program:`clang-tidy` will not be built with support for the
> +``clang-analyzer-*`` checks or the ``mpi-*`` checks.
> +
> +
> +.. _AST Matchers: http://clang.llvm.org/docs/LibASTMatchers.html
> +.. _PPCallbacks: http://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html
> +.. _clang-check: http://clang.llvm.org/docs/ClangCheck.html
> +
> +
> +Choosing the Right Place for your Check
> +---
> +
> +If you have an idea of a check, you should decide whether it should be
> +implemented as a:
> +
> ++ *Clang diagnostic*: if the check is generic enough, targets code patterns 
> that
> +  most probably are bugs (rather than style or readability issues), can be
> +  implemented effectively and with extremely low false positive rate, it may
> +  make a good Clang diagnostic.
> +
> ++ *Clang static analyzer check*: if the check requires some sort of control 
> flow
> +  analysis, it should probably be implemented as a static analyzer check.
> +
> ++ *clang-tidy check* is a good choice for linter-style checks, checks that 
> are
> +  related to a certain coding style, checks that address code readability, 
> etc.
> +
> +
> +Preparing your Workspace
> +
> +
> +If you are new to LLVM development, you should read the `Getting Started with
> +the LLVM System`_, `Using Clang Tools`_ and `How To Setup Tooling For LLVM`_
> +documents to check out and build LLVM, Clang and Clang Extra Tools with 
> CMake.
> +
> +Once you are done, change to the ``llvm/tools/clang/tools/extra`` directory, 
> and
> +let's start!
> +
> +.. _Getting Started with the LLVM System: 
> http://llvm.org/docs/GettingStarted.html
> +.. _Using Clang Tools: http://clang.llvm.org/docs/ClangTools.html
> +
> +
> +The Directory Structure
> +---
> +
> +:program:`clang-tidy` source code resides in the
> +``llvm/tools/clang/tools/extra`` directory and is structured as follows:
> +
> +::
> +
> +  clang-tidy/   # Clang-tidy core.
> +  |-- ClangTidy.h   # Interfaces for users and checks.
> +  |-- ClangTidyModule.h # Interface for clang-tidy modules.
> +  |-- ClangTidyModuleRegistry.h # Interface for registering of modules.
> + ...
> +  |-- google/   # Google clang-tidy module.

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

2019-01-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 182479.
kadircet added a comment.

- Use getStripPluginsAdjuster and move manipulations into OverlayCDB


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56841

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -65,7 +65,7 @@
 };
 
 TEST_F(OverlayCDBTest, GetCompileCommand) {
-  OverlayCDB CDB(Base.get());
+  OverlayCDB CDB(Base.get(), {}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
 Base->getCompileCommand(testPath("foo.cc")));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
@@ -85,7 +85,7 @@
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
-  OverlayCDB CDB(nullptr, {"-DA=6"});
+  OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -10,6 +10,7 @@
 #include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
@@ -1037,6 +1038,28 @@
 }
 #endif
 
+TEST_F(ClangdVFSTest, FlagsWithPlugins) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {
+  "-Xclang",
+  "-add-plugin",
+  "-Xclang",
+  "random-plugin",
+  };
+  OverlayCDB OCDB(&CDB);
+  ClangdServer Server(OCDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  const auto SourceContents = "int main() { return 0; }";
+  FS.Files[FooCpp] = FooCpp;
+  Server.addDocument(FooCpp, SourceContents);
+  auto Result = dumpASTWithoutMemoryLocs(Server, FooCpp);
+  EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  EXPECT_NE(Result, "");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -76,7 +76,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return &MSS; });
 
   tooling::CompileCommand Cmd;
@@ -113,7 +113,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return &MSS; });
 
   tooling::CompileCommand Cmd;
@@ -168,7 +168,7 @@
   // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -178,7 +178,7 @@
 
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -224,7 +224,7 @@
   Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -262,7 +262,7 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex Idx(
-  Context::empty(), "", FS, CDB, [&](llvm::StringRef) { return &MSS; },
+  Context::empty(), FS, CDB, [&](llvm::StringRef) { return &MSS; },

[PATCH] D56852: [AArch64] Use LLU for 64-bit crc32 arguments

2019-01-18 Thread Sam Parker via Phabricator via cfe-commits
samparker updated this revision to Diff 182481.
samparker added a comment.

Updated wsr, rsr and rbit


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

https://reviews.llvm.org/D56852

Files:
  include/clang/Basic/BuiltinsAArch64.def
  test/CodeGen/arm64-crc32.c
  test/CodeGen/builtins-arm64.c

Index: test/CodeGen/builtins-arm64.c
===
--- test/CodeGen/builtins-arm64.c
+++ test/CodeGen/builtins-arm64.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+#include 
 
 void f0(void *a, void *b) {
 	__clear_cache(a,b);
@@ -55,7 +57,7 @@
   return __builtin_arm_rsr("1:2:3:4:5");
 }
 
-unsigned long rsr64() {
+uint64_t rsr64() {
   // CHECK: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
   return __builtin_arm_rsr64("1:2:3:4:5");
 }
@@ -72,7 +74,7 @@
   __builtin_arm_wsr("1:2:3:4:5", v);
 }
 
-void wsr64(unsigned long v) {
+void wsr64(uint64_t v) {
   // CHECK: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %v)
   __builtin_arm_wsr64("1:2:3:4:5", v);
 }
Index: test/CodeGen/arm64-crc32.c
===
--- test/CodeGen/arm64-crc32.c
+++ test/CodeGen/arm64-crc32.c
@@ -1,54 +1,57 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu \
 // RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows \
+// RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+#include 
 
-int crc32b(int a, char b)
+uint32_t crc32b(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32b(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32b(i32 %a, i32 [[T0]])
 }
 
-int crc32cb(int a, char b)
+uint32_t crc32cb(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32cb(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32cb(i32 %a, i32 [[T0]])
 }
 
-int crc32h(int a, short b)
+uint32_t crc32h(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32h(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32h(i32 %a, i32 [[T0]])
 }
 
-int crc32ch(int a, short b)
+uint32_t crc32ch(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32ch(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32ch(i32 %a, i32 [[T0]])
 }
 
-int crc32w(int a, int b)
+uint32_t crc32w(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32w(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32w(i32 %a, i32 %b)
 }
 
-int crc32cw(int a, int b)
+uint32_t crc32cw(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32cw(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cw(i32 %a, i32 %b)
 }
 
-int crc32d(int a, long b)
+uint32_t crc32d(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32d(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32x(i32 %a, i64 %b)
 }
 
-int crc32cd(int a, long b)
+uint32_t crc32cd(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32cd(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cx(i32 %a, i64 %b)
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -33,7 +33,7 @@
 
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
-BUILTIN(__builtin_arm_rbit64, "LUiLUi", "nc")
+BUILTIN(__builtin_arm_rbit64, "LLUiLLUi", "nc")
 
 // HINT
 BUILTIN(__builtin_arm_nop, "v", "")
@@ -50,8 +50,8 @@
 BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc")
 BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc")
 BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc")
-BUILTIN(__builtin_arm_crc32d, "UiUiLUi", "nc")
-BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
+BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc")
+BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc")
 
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
@@ -63,10 +63,10 @@
 
 // System Registers
 BUILTIN(__builtin_arm_rsr, "UicC*", "nc")
-BUILTIN(__builtin_arm_rsr64, "LUicC*", "nc")
+BUILTIN(__builtin_arm_rsr64, "LLUicC*", "nc")
 BUILTIN(__builtin_arm_rsrp, "v*cC*", "nc")
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
-BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
+BUILTIN(__builtin_arm_wsr64, "vcC*LLUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
 // MSVC
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56829: Move decl context dumping to TextNodeDumper

2019-01-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 182482.
steveire added a comment.

Update


Repository:
  rC Clang

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

https://reviews.llvm.org/D56829

Files:
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -256,6 +256,17 @@
   if (const FunctionDecl *FD = dyn_cast(D))
 if (FD->isConstexpr())
   OS << " constexpr";
+
+  if (!isa(*D)) {
+const auto *MD = dyn_cast(D);
+if (!MD || !MD->isThisDeclarationADefinition()) {
+  const auto *DC = dyn_cast(D);
+  if (DC && DC->hasExternalLexicalStorage()) {
+ColorScope Color(OS, ShowColors, UndeserializedColor);
+OS << " ";
+  }
+}
+  }
 }
 
 void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -355,18 +355,8 @@
 }
 
 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
-  if (!DC)
-return;
-
   for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
 dumpDecl(D);
-
-  if (DC->hasExternalLexicalStorage()) {
-dumpChild([=] {
-  ColorScope Color(OS, ShowColors, UndeserializedColor);
-  OS << "";
-});
-  }
 }
 
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
@@ -513,11 +503,7 @@
 
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D)) {
-  auto DC = dyn_cast(D);
-  if (DC &&
-  (DC->hasExternalLexicalStorage() ||
-   (Deserialize ? DC->decls_begin() != DC->decls_end()
-: DC->noload_decls_begin() != DC->noload_decls_end(
+  if (const auto *DC = dyn_cast(D))
 dumpDeclContext(DC);
 }
   });
@@ -1243,12 +1229,11 @@
   if (D->isVariadic())
 OS << " variadic";
 
-  if (D->isThisDeclarationADefinition()) {
+  if (D->isThisDeclarationADefinition())
 dumpDeclContext(D);
-  } else {
+  else
 for (const ParmVarDecl *Parameter : D->parameters())
   dumpDecl(Parameter);
-  }
 
   if (D->hasBody())
 dumpStmt(D->getBody());


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -256,6 +256,17 @@
   if (const FunctionDecl *FD = dyn_cast(D))
 if (FD->isConstexpr())
   OS << " constexpr";
+
+  if (!isa(*D)) {
+const auto *MD = dyn_cast(D);
+if (!MD || !MD->isThisDeclarationADefinition()) {
+  const auto *DC = dyn_cast(D);
+  if (DC && DC->hasExternalLexicalStorage()) {
+ColorScope Color(OS, ShowColors, UndeserializedColor);
+OS << " ";
+  }
+}
+  }
 }
 
 void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -355,18 +355,8 @@
 }
 
 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
-  if (!DC)
-return;
-
   for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
 dumpDecl(D);
-
-  if (DC->hasExternalLexicalStorage()) {
-dumpChild([=] {
-  ColorScope Color(OS, ShowColors, UndeserializedColor);
-  OS << "";
-});
-  }
 }
 
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
@@ -513,11 +503,7 @@
 
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D)) {
-  auto DC = dyn_cast(D);
-  if (DC &&
-  (DC->hasExternalLexicalStorage() ||
-   (Deserialize ? DC->decls_begin() != DC->decls_end()
-: DC->noload_decls_begin() != DC->noload_decls_end(
+  if (const auto *DC = dyn_cast(D))
 dumpDeclContext(DC);
 }
   });
@@ -1243,12 +1229,11 @@
   if (D->isVariadic())
 OS << " variadic";
 
-  if (D->isThisDeclarationADefinition()) {
+  if (D->isThisDeclarationADefinition())
 dumpDeclContext(D);
-  } else {
+  else
 for (const ParmVarDecl *Parameter : D->parameters())
   dumpDecl(Parameter);
-  }
 
   if (D->hasBody())
 dumpStmt(D->getBody());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56902: [clang-tidy] Use getStripPluginsAdjuster

2019-01-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: alexfh.
Herald added subscribers: cfe-commits, xazax.hun.

See rC351531  for the introduction of 
getStripPluginsAdjuster.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56902

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -529,24 +529,8 @@
 return AdjustedArgs;
   };
 
-  // Remove plugins arguments.
-  ArgumentsAdjuster PluginArgumentsRemover =
-  [](const CommandLineArguments &Args, StringRef Filename) {
-CommandLineArguments AdjustedArgs;
-for (size_t I = 0, E = Args.size(); I < E; ++I) {
-  if (I + 4 < Args.size() && Args[I] == "-Xclang" &&
-  (Args[I + 1] == "-load" || Args[I + 1] == "-add-plugin" ||
-   StringRef(Args[I + 1]).startswith("-plugin-arg-")) &&
-  Args[I + 2] == "-Xclang") {
-I += 3;
-  } else
-AdjustedArgs.push_back(Args[I]);
-}
-return AdjustedArgs;
-  };
-
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
-  Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
   Context.setEnableProfiling(EnableCheckProfile);
   Context.setProfileStoragePrefix(StoreCheckProfile);
 


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -529,24 +529,8 @@
 return AdjustedArgs;
   };
 
-  // Remove plugins arguments.
-  ArgumentsAdjuster PluginArgumentsRemover =
-  [](const CommandLineArguments &Args, StringRef Filename) {
-CommandLineArguments AdjustedArgs;
-for (size_t I = 0, E = Args.size(); I < E; ++I) {
-  if (I + 4 < Args.size() && Args[I] == "-Xclang" &&
-  (Args[I + 1] == "-load" || Args[I + 1] == "-add-plugin" ||
-   StringRef(Args[I + 1]).startswith("-plugin-arg-")) &&
-  Args[I + 2] == "-Xclang") {
-I += 3;
-  } else
-AdjustedArgs.push_back(Args[I]);
-}
-return AdjustedArgs;
-  };
-
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
-  Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
   Context.setEnableProfiling(EnableCheckProfile);
   Context.setProfileStoragePrefix(StoreCheckProfile);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351540 - [analyzer] Unbreak building of SymbolReaperTest true BUILD_SHARED_LIBS=True

2019-01-18 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Fri Jan 18 02:13:07 2019
New Revision: 351540

URL: http://llvm.org/viewvc/llvm-project?rev=351540&view=rev
Log:
[analyzer] Unbreak building of SymbolReaperTest true BUILD_SHARED_LIBS=True

Extra dependencies need to be listed for StaticAnalysisTests in order for
linking to succeed when BUILD_SHARED_LIBS=True.


Modified:
cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt

Modified: cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt?rev=351540&r1=351539&r2=351540&view=diff
==
--- cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt (original)
+++ cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt Fri Jan 18 02:13:07 2019
@@ -12,6 +12,9 @@ target_link_libraries(StaticAnalysisTest
   PRIVATE
   clangBasic
   clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangCrossTU
   clangFrontend
   clangSerialization
   clangStaticAnalyzerCore


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


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

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

This enables clangd to intercept compiler diagnostics and attach fixes (e.g. by
querying index). This patch adds missing includes for incomplete types e.g.
member access into class with only forward declaration. This would allow adding
missing includes for user-typed symbol names that are missing declarations
(e.g. typos) in the future.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56903

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IncludeFixerTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -49,6 +49,9 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  // Index to use when building AST.
+  const SymbolIndex *ExternalIndex = nullptr;
+
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -36,6 +36,7 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
+  Inputs.Index = ExternalIndex;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -38,8 +38,9 @@
 class TUSchedulerTests : public ::testing::Test {
 protected:
   ParseInputs getInputs(PathRef File, std::string Contents) {
-return ParseInputs{*CDB.getCompileCommand(File),
-   buildTestFS(Files, Timestamps), std::move(Contents)};
+return ParseInputs(*CDB.getCompileCommand(File),
+   buildTestFS(Files, Timestamps), std::move(Contents),
+   /*Index=*/nullptr);
   }
 
   void updateWithCallback(TUScheduler &S, PathRef File,
Index: unittests/clangd/IncludeFixerTests.cpp
===
--- /dev/null
+++ unittests/clangd/IncludeFixerTests.cpp
@@ -0,0 +1,78 @@
+//===-- ClangdUnitTests.cpp - ClangdUnit tests --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "IncludeFixer.h"
+#include "TestIndex.h"
+#include "TestTU.h"
+#include "index/MemIndex.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::UnorderedElementsAre;
+
+testing::Matcher WithFix(testing::Matcher FixMatcher) {
+  return Field(&Diag::Fixes, ElementsAre(FixMatcher));
+}
+
+MATCHER_P2(Diag, Range, Message,
+   "Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
+  return arg.Range == Range && arg.Message == Message;
+}
+
+MATCHER_P3(Fix, Range, Replacement, Message,
+   "Fix " + llvm::to_string(Range) + " => " +
+   testing::PrintToString(Replacement) + " = [" + Message + "]") {
+  return arg.Message == Message && arg.Edits.size() == 1 &&
+ arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
+}
+
+TEST(IncludeFixerTest, IncompleteType) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+  class X;
+}
+class Y : $base[[public ns::X]] {};
+int main() {
+  ns::X *x;
+  x$access[[->]]f();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  Symbol Sym = symbol("ns::X");
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.CanonicalDeclaration.FileURI = "unittest:///x.h";
+  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
+
+  SymbolSlab::Builder Slab;
+  Slab.insert(Sym);
+  auto Index = MemIndex::build(std::move(Slab).build(), RefSlab());
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(

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

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

just a few nits




Comment at: clangd/GlobalCompilationDatabase.cpp:23
+
+void AdjustArguments(tooling::CompileCommand &Cmd,
+ const std::string &ResourceDir) {

naming NIT: use `adjustArguments`



Comment at: clangd/GlobalCompilationDatabase.cpp:24
+void AdjustArguments(tooling::CompileCommand &Cmd,
+ const std::string &ResourceDir) {
+  // Strip plugin related command line arguments. Clangd does

NIT: use `StringRef`



Comment at: clangd/GlobalCompilationDatabase.cpp:136
+: Base(Base),
+  ResourceDir(ResourceDir ? *ResourceDir : getStandardResourceDir()),
+  FallbackFlags(std::move(FallbackFlags)) {

NIT: avoid an unnecessary copy: `ResourceDir ? std::move(*ResourceDir) : …`


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56841



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


Re: r351495 - Make integral-o-pointer conversions in SFINAE illegal.

2019-01-18 Thread Peter Smith via cfe-commits
Hello Erich,

The test added in this commit is failing on the Arm and Hexagon
builders. I think that this is because the expected type "long" in the
warning text is "int" on these platforms (possibly other 32-bit host
platforms).

The raw output from an Arm machine is:
llvm-project/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp:5:5: warning:
incompatible integer to pointer conversion assigning to 'int *' from
'int'; take the address with &
  a -= b; // expected-warning {{incompatible integer to pointer
conversion assigning to 'int *' from 'long'}}
^  ~
   &

Could you take a look and update the test?

Thanks in advance

Peter

On Thu, 17 Jan 2019 at 23:14, Erich Keane via cfe-commits
 wrote:
>
> Author: erichkeane
> Date: Thu Jan 17 15:11:15 2019
> New Revision: 351495
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351495&view=rev
> Log:
> Make integral-o-pointer conversions in SFINAE illegal.
>
> As reported in PR40362, allowing the conversion from an integral to a
> pointer type (despite being illegal in the C++ standard) will cause
> surprsing results when testing for certain behaviors in SFINAE.  This
> patch converts the error to a SFINAE Error and adds a test to ensure
> that it is still a warning in non-SFINAE but an error in it.
>
> Change-Id: I1f475637fa4d83217ae37dc6b5dbf653e118fae4
>
> Added:
> cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp   (with props)
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351495&r1=351494&r2=351495&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 15:11:15 
> 2019
> @@ -6817,7 +6817,7 @@ def ext_typecheck_convert_int_pointer :
>"; take the address with &|"
>"; remove *|"
>"; remove &}3">,
> -  InGroup;
> +  InGroup, SFINAEFailure;
>  def ext_typecheck_convert_pointer_void_func : Extension<
>"%select{%diff{assigning to $ from $|assigning to different types}0,1"
>"|%diff{passing $ to parameter of type $|"
>
> Added: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp?rev=351495&view=auto
> ==
> --- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (added)
> +++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp Thu Jan 17 15:11:15 2019
> @@ -0,0 +1,22 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17
> +
> +void foo(int* a, int *b) {
> +  a -= b; // expected-warning {{incompatible integer to pointer conversion 
> assigning to 'int *' from 'long'}}
> +}
> +
> +template T declval();
> +struct true_type { static const bool value = true; };
> +struct false_type { static const bool value = false; };
> +template struct select { using type = T; };
> +template struct select { using type = 
> U; };
> +
> +
> +template
> +typename select<(sizeof(declval() -= declval(), 1) != 1), true_type, 
> false_type>::type test(...);
> +template false_type test(...);
> +
> +template
> +static const auto has_minus_assign = decltype(test())::value;
> +
> +static_assert(has_minus_assign, "failed"); // expected-error 
> {{static_assert failed due to requirement 'has_minus_assign' "failed"}}
>
> Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> --
> svn:keywords = "Author Date Id Rev URL"
>
> Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> --
> svn:mime-type = text/plain
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2019-01-18 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D35068#1361902 , @Szelethus wrote:

> Edit: it doesn't, but CMake is mostly a C project and it does!


CMake really isn't a C project if you look at what language it actually uses - 
the C files come from tests and system utilities such as ZIP being 
reimplemented.
And as far as I've seen with my recent endeavours, Clang has problems with 
parsing and building CMake (however all these errors relate to some very niche 
standard library memory size related stuff not being there where it wants them).


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

https://reviews.llvm.org/D35068



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


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

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

- Address comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56841

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -65,7 +65,7 @@
 };
 
 TEST_F(OverlayCDBTest, GetCompileCommand) {
-  OverlayCDB CDB(Base.get());
+  OverlayCDB CDB(Base.get(), {}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
 Base->getCompileCommand(testPath("foo.cc")));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
@@ -85,7 +85,7 @@
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
-  OverlayCDB CDB(nullptr, {"-DA=6"});
+  OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -10,6 +10,7 @@
 #include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
@@ -1037,6 +1038,28 @@
 }
 #endif
 
+TEST_F(ClangdVFSTest, FlagsWithPlugins) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {
+  "-Xclang",
+  "-add-plugin",
+  "-Xclang",
+  "random-plugin",
+  };
+  OverlayCDB OCDB(&CDB);
+  ClangdServer Server(OCDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  const auto SourceContents = "int main() { return 0; }";
+  FS.Files[FooCpp] = FooCpp;
+  Server.addDocument(FooCpp, SourceContents);
+  auto Result = dumpASTWithoutMemoryLocs(Server, FooCpp);
+  EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  EXPECT_NE(Result, "");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -76,7 +76,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return &MSS; });
 
   tooling::CompileCommand Cmd;
@@ -113,7 +113,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return &MSS; });
 
   tooling::CompileCommand Cmd;
@@ -168,7 +168,7 @@
   // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -178,7 +178,7 @@
 
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -224,7 +224,7 @@
   Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -262,7 +262,7 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex Idx(
-  Context::empty(), "", FS, CDB, [&](llvm::StringRef) { return &MSS; },
+  Context::empty(), FS, CDB, [&](llvm::StringRef) { return &MSS; },
   

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

2019-01-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
+void AdjustArguments(tooling::CompileCommand &Cmd,
+ const std::string &ResourceDir) {
+  // Strip plugin related command line arguments. Clangd does

ilya-biryukov wrote:
> NIT: use `StringRef`
Need a string for the concatenation below, when pushing to vector. Otherwise we 
get a Twine


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56841



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


[PATCH] D56735: [OpenCL] Fix overloading ranking rules to work correctly for address space conversions

2019-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351546: [OpenCL] Fix overloading ranking rules for addrspace 
conversions. (authored by stulova, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56735?vs=182245&id=182491#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56735

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -4019,9 +4019,12 @@
 // to unwrap. This essentially mimics what
 // IsQualificationConversion does, but here we're checking for a
 // strict subset of qualifiers.
-if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
+if (T1.getQualifiers().withoutObjCLifetime() ==
+T2.getQualifiers().withoutObjCLifetime())
   // The qualifiers are the same, so this doesn't tell us anything
   // about how the sequences rank.
+  // ObjC ownership quals are omitted above as they interfere with
+  // the ARC overload rule.
   ;
 else if (T2.isMoreQualifiedThan(T1)) {
   // T1 has fewer qualifiers, so it could be the better sequence.
Index: cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
===
--- cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
+++ cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+
+// expected-no-diagnostics
+
+struct RetGlob {
+  int dummy;
+};
+
+struct RetGen {
+  char dummy;
+};
+
+RetGlob foo(const __global int *);
+RetGen foo(const __generic int *);
+
+void kernel k() {
+  __global int *ArgGlob;
+  __generic int *ArgGen;
+  __local int *ArgLoc;
+  RetGlob TestGlob = foo(ArgGlob);
+  RetGen TestGen = foo(ArgGen);
+  TestGen = foo(ArgLoc);
+}


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -4019,9 +4019,12 @@
 // to unwrap. This essentially mimics what
 // IsQualificationConversion does, but here we're checking for a
 // strict subset of qualifiers.
-if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
+if (T1.getQualifiers().withoutObjCLifetime() ==
+T2.getQualifiers().withoutObjCLifetime())
   // The qualifiers are the same, so this doesn't tell us anything
   // about how the sequences rank.
+  // ObjC ownership quals are omitted above as they interfere with
+  // the ARC overload rule.
   ;
 else if (T2.isMoreQualifiedThan(T1)) {
   // T1 has fewer qualifiers, so it could be the better sequence.
Index: cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
===
--- cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
+++ cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+
+// expected-no-diagnostics
+
+struct RetGlob {
+  int dummy;
+};
+
+struct RetGen {
+  char dummy;
+};
+
+RetGlob foo(const __global int *);
+RetGen foo(const __generic int *);
+
+void kernel k() {
+  __global int *ArgGlob;
+  __generic int *ArgGen;
+  __local int *ArgLoc;
+  RetGlob TestGlob = foo(ArgGlob);
+  RetGen TestGen = foo(ArgGen);
+  TestGen = foo(ArgLoc);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351546 - [OpenCL] Fix overloading ranking rules for addrspace conversions.

2019-01-18 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Fri Jan 18 03:38:16 2019
New Revision: 351546

URL: http://llvm.org/viewvc/llvm-project?rev=351546&view=rev
Log:
[OpenCL] Fix overloading ranking rules for addrspace conversions.

Extend ranking to work with address spaces correctly when
resolving overloads.

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


Added:
cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=351546&r1=351545&r2=351546&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jan 18 03:38:16 2019
@@ -4019,9 +4019,12 @@ CompareQualificationConversions(Sema &S,
 // to unwrap. This essentially mimics what
 // IsQualificationConversion does, but here we're checking for a
 // strict subset of qualifiers.
-if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
+if (T1.getQualifiers().withoutObjCLifetime() ==
+T2.getQualifiers().withoutObjCLifetime())
   // The qualifiers are the same, so this doesn't tell us anything
   // about how the sequences rank.
+  // ObjC ownership quals are omitted above as they interfere with
+  // the ARC overload rule.
   ;
 else if (T2.isMoreQualifiedThan(T1)) {
   // T1 has fewer qualifiers, so it could be the better sequence.

Added: cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl?rev=351546&view=auto
==
--- cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl (added)
+++ cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl Fri Jan 18 
03:38:16 2019
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+
+// expected-no-diagnostics
+
+struct RetGlob {
+  int dummy;
+};
+
+struct RetGen {
+  char dummy;
+};
+
+RetGlob foo(const __global int *);
+RetGen foo(const __generic int *);
+
+void kernel k() {
+  __global int *ArgGlob;
+  __generic int *ArgGen;
+  __local int *ArgLoc;
+  RetGlob TestGlob = foo(ArgGlob);
+  RetGen TestGen = foo(ArgGen);
+  TestGen = foo(ArgLoc);
+}


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


[PATCH] D54141: [clang-tidy] add deduplication support for run-clang-tidy.py

2019-01-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> LLVM is very chatty as well, I don't consider LLVM to be a bad code-base. 
> Take readability-braces-around-statements for example.

Do we need a llvm-elide-braces-for-small-statements?

This would make a great pre-review check


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54141



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


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

2019-01-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 182496.
Anastasia added a comment.

Added a comment explaining when multiple address spaces are diagnosed.


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

https://reviews.llvm.org/D55850

Files:
  include/clang/AST/Type.h
  include/clang/Sema/ParsedAttr.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/method-overload-address-space.cl
  test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  test/SemaOpenCLCXX/method-overload-address-space.cl

Index: test/SemaOpenCLCXX/method-overload-address-space.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/method-overload-address-space.cl
@@ -0,0 +1,20 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+
+struct C {
+  void m1() __local __local; //expected-warning{{multiple identical address spaces specified for type}}
+  //expected-note@-1{{candidate function}}
+  void m1() __global;
+  //expected-note@-1{{candidate function}}
+  void m2() __global __local; //expected-error{{multiple address spaces specified for type}}
+};
+
+__global C c_glob;
+
+__kernel void bar() {
+  __local C c_loc;
+  C c_priv;
+
+  c_glob.m1();
+  c_loc.m1();
+  c_priv.m1(); //expected-error{{no matching member function for call to 'm1'}}
+}
Index: test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
@@ -0,0 +1,18 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+
+struct C {
+  auto fGlob() __global -> decltype(this);
+  auto fGen() -> decltype(this);
+  auto fErr() __global __local -> decltype(this); //expected-error{{multiple address spaces specified for type}}
+};
+
+void bar(__local C*);
+// expected-note@-1{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka '__global C *')), parameter type must be '__local C *'}}
+// expected-note@-2{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka 'C *')), parameter type must be '__local C *'}}
+
+__global C Glob;
+void foo(){
+bar(Glob.fGlob()); // expected-error{{no matching function for call to 'bar'}}
+// FIXME: AS of 'this' below should be correctly deduced to generic
+bar(Glob.fGen()); // expected-error{{no matching function for call to 'bar'}}
+}
Index: test/CodeGenOpenCLCXX/method-overload-address-space.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/method-overload-address-space.cl
@@ -0,0 +1,35 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct C {
+  void foo() __local;
+  void foo() __global;
+  void foo();
+  void bar();
+};
+
+__global C c1;
+
+__kernel void k() {
+  __local C c2;
+  C c3;
+  __global C &c_ref = c1;
+  __global C *c_ptr;
+
+  // CHECK: call void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c1.foo();
+  // CHECK: call void @_ZNU3AS31C3fooEv(%struct.C addrspace(3)*
+  c2.foo();
+  // CHECK: call void @_ZNU3AS41C3fooEv(%struct.C addrspace(4)*
+  c3.foo();
+  // CHECK: call void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c_ptr->foo();
+  // CHECK: void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c_ref.foo();
+
+  // CHECK: call void @_ZNU3AS41C3barEv(%struct.C addrspace(4)* addrspacecast (%struct.C addrspace(1)* @c1 to %struct.C addrspace(4)*))
+  c1.bar();
+  //FIXME: Doesn't compile yet
+  //c_ptr->bar();
+  // CHECK: call void @_ZNU3AS41C3barEv(%struct.C addrspace(4)* addrspacecast (%struct.C addrspace(1)* @c1 to %struct.C addrspace(4)*))
+  c_ref.bar();
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3916,6 +3916,25 @@
   llvm_unreachable("unknown NullabilityKind");
 }
 
+// Diagnose whether this is a case with the multiple addr spaces.
+// Returns true if this is an invalid case.
+// ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified
+// by qualifiers for two or more different address spaces."
+static bool DiagnoseMultipleAddrSpaceAttributes(Sema &S, LangAS ASOld,
+LangAS ASNew,
+SourceLocation AttrLoc) {
+  if (ASOld != LangAS::Default) {
+if (ASOld != ASNew) {
+  S.Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
+  return true;
+}
+// Emit a warning if they are identical; it's likely unintended.
+S.Diag(AttrLoc,
+   diag::warn_attribute_address_multiple_identical_qualifiers);
+  }
+  return false;
+}
+
 static TypeSourceInfo *
 GetTypeSourceInfoForDeclarator(TypeProcessingState &State,
QualType T, TypeSourceInfo *ReturnTypeInfo

[PATCH] D56836: [mips] Include whole lpthread when using both -pthread and -static

2019-01-18 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji added a comment.

@atanasyan That looks good. I tried to make an equivalent for the Makefile

  --- SingleSource/UnitTests/C++11/Makefile (revision 351547)
  +++ SingleSource/UnitTests/C++11/Makefile (working copy)
  @@ -4,6 +4,11 @@
   
   CPPFLAGS += -std=c++11 -pthread
   
  +ifeq (-static, $(findstring -static, $(TARGET_FLAGS)))
  +#PROGRAMS_TO_SKIP += stdthreadbug
  +LDFLAGS += -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
  +endif
  +
   ifdef BENCHMARKING_ONLY
   PROGRAMS_TO_SKIP += stdthreadbug
   endif

As an option, we can provide necessary flags for the test to finish 
successfully instead of not testing it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56836



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


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

2019-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This looks really good, everything else is pretty superficial I think.

I think we'll want to add one lit test for the whole two-step tweak workflow, 
as well as TestTU/annotation-based unit-tests for each tweak.
As this patch has no actual tweaks in it, we can work out the details when 
landing the first one.




Comment at: clangd/ClangdLSPServer.cpp:38
+/// Transforms a tweak into a code action that would apply it if executed.
+CodeAction toCodeAction(const Tweak &T, const URIForFile &File,
+Range Selection) {

comment: tweak must have been successfully prepared?



Comment at: clangd/ClangdLSPServer.cpp:43
+  CA.kind = CodeAction::REFACTOR_KIND;
+  // This action requires an expensive second stage, we only run it if
+  // the user actually chooses the action. So we reply with a command to

Comment should be more tentative (calculating edits *may* be expensive) since 
we don't have the immediate-edit optimization yet.
Decent place for a FIXME or comment regarding the optimization too.



Comment at: clangd/ClangdServer.h:208
+  /// Enumerate the code tweaks available to the user at a specified point.
+  void enumerateCodeTweaks(PathRef File, Range Sel,
+Callback>> CB);

The returned `Tweak` object contains references to the AST, which may be 
dangling, so it's not actually safe to use.
It would be nice to allow callers to either directly apply a returned tweak 
(with progress saved) or to apply one "later" by name, but the way that 
transactions work in ClangdServer only the latter is really possible.

So I'd suggest this should return vector>, which makes it 
clear(ish) how this relates to `applyCodeTweak`



Comment at: clangd/ClangdServer.h:208
+  /// Enumerate the code tweaks available to the user at a specified point.
+  void enumerateCodeTweaks(PathRef File, Range Sel,
+Callback>> CB);

sammccall wrote:
> The returned `Tweak` object contains references to the AST, which may be 
> dangling, so it's not actually safe to use.
> It would be nice to allow callers to either directly apply a returned tweak 
> (with progress saved) or to apply one "later" by name, but the way that 
> transactions work in ClangdServer only the latter is really possible.
> 
> So I'd suggest this should return vector>, which makes 
> it clear(ish) how this relates to `applyCodeTweak`
`enumerateTweaks`?



Comment at: clangd/ClangdServer.h:212
+  /// Apply the code tweak with a specified \p ID.
+  void applyCodeTweak(PathRef File, Range Sel, TweakID ID,
+  Callback CB);

`tweak`? It's a verb...



Comment at: clangd/Protocol.cpp:426
+const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_CODE_ACTION =
+"clangd.applyCodeAction";
+

tweak



Comment at: clangd/Protocol.h:635
 
+struct CodeActionArgs {
+  URIForFile file;

TweakArgs?



Comment at: clangd/Protocol.h:637
+  URIForFile file;
+  std::string actionId;
+  Range selection;

"tweakId" or just "id"



Comment at: clangd/Protocol.h:655
+  // Command to apply the code action. Uses CodeActionArgs as argument.
+  const static llvm::StringLiteral CLANGD_APPLY_CODE_ACTION;
 

CLANGD_TWEAK_COMMAND



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

Not convinced about this helper function.
 - much of it is just a passthrough to struct initialization. I think the code 
calling it would be clearer if it was initialising the fields one-by one
 - the only part that's not passthrough is already a function call with a clear 
name, calling it seems reasonable
 - I'm not sure it makes sense to have the Range -> SourceLocation conversion 
in this file, but the Tweak -> CodeAction conversion outside this file (and not 
unit-testable). There's an argument to be make to keep this file independent of 
LSP protocol structs, but I think that argument applies equally to this 
function.



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

sammccall wrote:
> Not convinced about this helper function.
>  - much of it is just a passthrough to struct initialization. I think the 
> code calling it would be clearer if it was initialising the fields one-by one
>  - the only part that's not passthrough is already a function call with a 
> clear name, calling it seems reasonable
>  - I'm not sure it makes sense to have the Range -> SourceLocation conversion

[PATCH] D56878: [mips] Add '-mrelax-pic-calls', '-mno-relax-pic-calls'

2019-01-18 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM with a nit.




Comment at: lib/Driver/ToolChains/Clang.cpp:1720
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back(Args.MakeArgString("-mips-jalr-reloc=0"));
+}

It's not necessary to call the `MakeArgString` here. You can write just 
`CmdArgs.push_back("-mips-jalr-reloc=0");`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56878



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


[PATCH] D56836: [mips] Include whole lpthread when using both -pthread and -static

2019-01-18 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

In D56836#1362967 , @abeserminji wrote:

> As an option, we can provide necessary flags for the test to finish 
> successfully instead of not testing it.


Agreed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56836



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


[PATCH] D56905: [libunwind] [SjLj] Don't use __declspec(thread) in MinGW mode

2019-01-18 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: mclow.lists, EricWF, ldionne, compnerd, smeenai, rnk.
Herald added a subscriber: libcxx-commits.
mstorsjo edited the summary of this revision.

GCC and Clang in MinGW mode don't support `__declspec(thread)`, which after 
expanding macros ends up as `__attribute__((thread))`. Use the GCC specific 
attribute `__thread` instead (the next one in the chain of alternatives).


Repository:
  rUNW libunwind

https://reviews.llvm.org/D56905

Files:
  src/Unwind-sjlj.c


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -52,7 +52,7 @@
 #else
 # if __STDC_VERSION__ >= 201112L
 #  define _LIBUNWIND_THREAD_LOCAL _Thread_local
-# elif defined(_WIN32)
+# elif defined(_MSC_VER)
 #  define _LIBUNWIND_THREAD_LOCAL __declspec(thread)
 # elif defined(__GNUC__) || defined(__clang__)
 #  define _LIBUNWIND_THREAD_LOCAL __thread


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -52,7 +52,7 @@
 #else
 # if __STDC_VERSION__ >= 201112L
 #  define _LIBUNWIND_THREAD_LOCAL _Thread_local
-# elif defined(_WIN32)
+# elif defined(_MSC_VER)
 #  define _LIBUNWIND_THREAD_LOCAL __declspec(thread)
 # elif defined(__GNUC__) || defined(__clang__)
 #  define _LIBUNWIND_THREAD_LOCAL __thread
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56752: [ASTDump] Mark BlockDecls which capture this with a tag

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

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D56752



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


Re: r232680 - MS ABI: Don't try to emit VF/VB-Tables for extern class templates

2019-01-18 Thread Nico Weber via cfe-commits
(-old cfe-commits, +new cfe-commits)

On Fri, Jan 18, 2019 at 8:21 AM Nico Weber  wrote:

> I found this comment useful, but from your reply it sounds like it's no
> longer true:
>
> -  // We must indicate which VFTable is larger to support linking
> between
> -  // translation units which do and do not have RTTI data.  The
> largest
> -  // VFTable contains the RTTI data; translation units which
> reference
> -  // the smaller VFTable always reference it relative to the first
> -  // virtual method.
>
> If it's no longer true, why do we still call
> setSelectionKind(llvm::Comdat::Largest)?
>
> On Thu, Jan 17, 2019 at 5:09 PM David Majnemer 
> wrote:
>
>> Yes, the comments don't look like they were relevant after this change.
>>
>> On Sat, Jan 12, 2019 at 4:52 PM Nico Weber  wrote:
>>
>>> This removed two of the comments you had added in
>>> https://reviews.llvm.org/rL212142 -- was that intentional?
>>>
>>> On Wed, Mar 18, 2015 at 6:08 PM David Majnemer 
>>> wrote:
>>>
 Author: majnemer
 Date: Wed Mar 18 17:04:43 2015
 New Revision: 232680

 URL: http://llvm.org/viewvc/llvm-project?rev=232680&view=rev
 Log:
 MS ABI: Don't try to emit VF/VB-Tables for extern class templates

 There will be an explicit template instantiation in another translation
 unit which will provide the definition of the VF/VB-Tables.

 This fixes PR22932.

 Modified:
 cfe/trunk/lib/AST/VTableBuilder.cpp
 cfe/trunk/lib/CodeGen/CGVTables.cpp
 cfe/trunk/lib/CodeGen/CodeGenModule.cpp
 cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
 cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
 cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

 Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=232680&r1=232679&r2=232680&view=diff

 ==
 --- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
 +++ cfe/trunk/lib/AST/VTableBuilder.cpp Wed Mar 18 17:04:43 2015
 @@ -2589,7 +2589,9 @@ public:
  // Only include the RTTI component if we know that we will provide
 a
  // definition of the vftable.
  HasRTTIComponent = Context.getLangOpts().RTTIData &&
 -   !MostDerivedClass->hasAttr();
 +   !MostDerivedClass->hasAttr() &&
 +
  MostDerivedClass->getTemplateSpecializationKind() !=
 +   TSK_ExplicitInstantiationDeclaration;

  LayoutVFTable();


 Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=232680&r1=232679&r2=232680&view=diff

 ==
 --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Mar 18 17:04:43 2015
 @@ -743,7 +743,7 @@ CodeGenModule::getVTableLinkage(const CX
  return DiscardableODRLinkage;

case TSK_ExplicitInstantiationDeclaration:
 -llvm_unreachable("Should not have been asked to emit this");
 +return llvm::GlobalVariable::ExternalLinkage;

case TSK_ExplicitInstantiationDefinition:
  return NonDiscardableODRLinkage;

 Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=232680&r1=232679&r2=232680&view=diff

 ==
 --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Mar 18 17:04:43 2015
 @@ -1851,7 +1851,8 @@ CodeGenModule::CreateOrReplaceCXXRuntime
  OldGV->eraseFromParent();
}

 -  if (supportsCOMDAT() && GV->isWeakForLinker())
 +  if (supportsCOMDAT() && GV->isWeakForLinker() &&
 +  !GV->hasAvailableExternallyLinkage())
  GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

return GV;

 Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=232680&r1=232679&r2=232680&view=diff

 ==
 --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
 +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Mar 18 17:04:43 2015
 @@ -1487,102 +1487,97 @@ llvm::GlobalVariable *MicrosoftCXXABI::g
  #endif
}

 -  for (size_t J = 0, F = VFPtrs.size(); J != F; ++J) {
 -if (VFPtrs[J]->FullOffsetInMDC != VPtrOffset)
 -  continue;
 -SmallString<256> VFTableName;
 -mangleVFTableName(getMangle

[PATCH] D56902: [clang-tidy] Use getStripPluginsAdjuster

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

LG


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56902



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


[PATCH] D56753: [ASTDump] Mark null params with a tag rather than a child node

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

With bracket and comment changes, LGTM. No need for tests on this one because 
the scenario changed can only occur during debugging.




Comment at: lib/AST/ASTDumper.cpp:636
 
+  // Since NumParams comes from the FunctionProtoType of the
+  // FunctionDecl and the Params are set later, it is possible

Re-flow comments to 80-col.



Comment at: lib/AST/ASTDumper.cpp:642
+  if (!D->param_empty() && !D->param_begin())
+OS << " >";
+

Let's make this `<<>>` with three brackets instead of two.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56753



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


RE: r351495 - Make integral-o-pointer conversions in SFINAE illegal.

2019-01-18 Thread Keane, Erich via cfe-commits
Thanks for the heads up!  Looking now.

-Original Message-
From: Peter Smith [mailto:peter.sm...@linaro.org] 
Sent: Friday, January 18, 2019 2:33 AM
To: Keane, Erich 
Cc: cfe-commits cfe 
Subject: Re: r351495 - Make integral-o-pointer conversions in SFINAE illegal.

Hello Erich,

The test added in this commit is failing on the Arm and Hexagon builders. I 
think that this is because the expected type "long" in the warning text is 
"int" on these platforms (possibly other 32-bit host platforms).

The raw output from an Arm machine is:
llvm-project/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp:5:5: warning:
incompatible integer to pointer conversion assigning to 'int *' from 'int'; 
take the address with &
  a -= b; // expected-warning {{incompatible integer to pointer conversion 
assigning to 'int *' from 'long'}}
^  ~
   &

Could you take a look and update the test?

Thanks in advance

Peter

On Thu, 17 Jan 2019 at 23:14, Erich Keane via cfe-commits 
 wrote:
>
> Author: erichkeane
> Date: Thu Jan 17 15:11:15 2019
> New Revision: 351495
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351495&view=rev
> Log:
> Make integral-o-pointer conversions in SFINAE illegal.
>
> As reported in PR40362, allowing the conversion from an integral to a 
> pointer type (despite being illegal in the C++ standard) will cause 
> surprsing results when testing for certain behaviors in SFINAE.  This 
> patch converts the error to a SFINAE Error and adds a test to ensure 
> that it is still a warning in non-SFINAE but an error in it.
>
> Change-Id: I1f475637fa4d83217ae37dc6b5dbf653e118fae4
>
> Added:
> cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp   (with props)
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticSemaKinds.td?rev=351495&r1=351494&r2=351495&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 
> +++ 15:11:15 2019
> @@ -6817,7 +6817,7 @@ def ext_typecheck_convert_int_pointer :
>"; take the address with &|"
>"; remove *|"
>"; remove &}3">,
> -  InGroup;
> +  InGroup, SFINAEFailure;
>  def ext_typecheck_convert_pointer_void_func : Extension<
>"%select{%diff{assigning to $ from $|assigning to different types}0,1"
>"|%diff{passing $ to parameter of type $|"
>
> Added: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/int-ptr-cas
> t-SFINAE.cpp?rev=351495&view=auto 
> ==
> 
> --- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (added)
> +++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp Thu Jan 17 15:11:15 
> +++ 2019
> @@ -0,0 +1,22 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 
> +-fsyntax-only -verify %s -std=c++17
> +
> +void foo(int* a, int *b) {
> +  a -= b; // expected-warning {{incompatible integer to pointer 
> +conversion assigning to 'int *' from 'long'}} }
> +
> +template T declval();
> +struct true_type { static const bool value = true; }; struct 
> +false_type { static const bool value = false; }; template +typename T, typename U> struct select { using type = T; }; 
> +template struct select { using 
> +type = U; };
> +
> +
> +template
> +typename select<(sizeof(declval() -= declval(), 1) != 1), 
> +true_type, false_type>::type test(...); template 
> +false_type test(...);
> +
> +template
> +static const auto has_minus_assign = decltype(test())::value;
> +
> +static_assert(has_minus_assign, "failed"); // expected-error 
> +{{static_assert failed due to requirement 'has_minus_assign' 
> +"failed"}}
>
> Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> --
> svn:keywords = "Author Date Id Rev URL"
>
> Propchange: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
> --
> svn:mime-type = text/plain
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I believe there is some sort of memory leak in the `run-clang-tidy` or so. I 
had similar experience :)
Take this with a grain of salt, as I don't recall all details: 
`run-clang-tidy.py` just takes all output from clang-tidy and prints it. A lot 
is redundant due to the include-horror in c++. After I implemented 
deduplication (not in tree, but here https://reviews.llvm.org/D54141) things 
got better. You don't need to run it over the whole of LLVM, but can take a 
subset, too. Maybe `lib/` or `tools/clang/lib`. Note that `run-clang-tidy.py` 
reads in the compilation database and matches your path as regex against it. So 
`lib/` includes all libs (clang, llvm, ...).

> In the meantime I might need some help: I tried running the check on LLVM 
> last weekend using the run-clang-tidy.py file. The script eventually crashed 
> with a segmentation fault (after 1.5 days, running on CentOS 7, 30GiB RAM) 
> with no modifications of the source tree. I ran again and exported the fixes, 
> but again, python failed to merge the yaml files and crashed (probably 
> because it went out of memory). After manual merging, I ran 
> clang-apply-replacements and it took a while, but then I also had zero 
> modifications on my LLVM working copy. clang-apply-replacements reported a 
> few overlapping refactorings and missing files, but that's it. What am I 
> doing wrong?

Overlapping can not be resolved, but interesting it occurs. Maybe in headers? 
Each TU (~ .cpp-file) will emit transformations. If they are identical they are 
merged, but if not there is a collision which can not be resolved. Maybe there 
is something going on with macros, ... that make the same header included twice 
not equivalent or so?

Try to run it over a subset first and then think about the issues. Trying other 
projects is certainly a good idea as well.

> And btw, is there an easy way to get a compilation database on Windows?

No windows-user, but cmake creates one with `CMAKE_EXPORT_COMPILECOMMANDS=ON` 
that you need to pass in somewhere somehow :)




Comment at: clang-tidy/modernize/UseTrailingReturnCheck.cpp:162
+  functionDecl(unless(anyOf(hasTrailingReturn(), returns(voidType()),
+returns(autoType()), cxxConversionDecl(),
+cxxMethodDecl(isImplicit()

bernhardmgruber wrote:
> JonasToth wrote:
> > Shouldn't you include `returns(decltypeType())` as well?
> good question! i have a unit test of the form `decltype(auto) f();` and it 
> seems to be already excluded by `returns(autoType())`. but i could add your 
> suggestion as well to make it more explicit that (for now) we will not 
> rewrite functions returning `decltype(auto)`.
There should be a difference between `decltype(auto)` and 
`decltype(some_expression)`. I will check your tests and suggest something 
there.



Comment at: test/clang-tidy/modernize-use-trailing-return.cpp:269
+auto l1 = [](int arg) {};
+auto l2 = [](int arg) -> double {};

bernhardmgruber wrote:
> JonasToth wrote:
> > These tests are missing the great template fun :)
> > 
> > Lets start with those two examples:
> > 
> > ```
> > template 
> > [[maybe_unused]] typename Container::value_type const volatile&& 
> > myFunnyFunction(Container& C) noexcept;
> > ```
> > 
> > and
> > 
> > ```
> > #define MAYBE_UNUSED_MACRO [[maybe_unused]]
> > template 
> > MAYBE_UNUSED_MACRO typename Container::value_type const volatile** const 
> > myFunnyFunction(Container& C) noexcept;
> > ```
> > 
> > Its not necessarily nice code, but I am sure something like this is 
> > somewhere in boost for example ;)
> You remind me of Jason Turner at CppCon 2018 who said, we should pick a toy 
> project, for which we are sure we can handle it, because complexity will 
> manifest itself in the details. This is exactly what is happening now.
> 
> Thank you for input, I added it to my tests!
Templates made me sad often, after i "finished" my checks and ran them over 
projects ;)
Sometimes it is almost impossible to fix very weird (and uncommon) things. But 
its better to find such cases early and work around them.



Comment at: test/clang-tidy/modernize-use-trailing-return.cpp:116
+
+// TODO: not matched by the AST matcher
+//decltype(auto) e6();

Is this still the case? That should be doable with the matchers, if you have a 
specific question i can look at it and try to help.

Here would be a good place to test the different `decltype`s.

```
decltype(auto) foo0() { return 1 + 2; } // should be the same as ...
auto foo1() { return 1 + 2; } // this, BUT ...
decltype(1 + 2) foo2() { return 1 + 2; } // should be something else
```
The matching for all three of them should be done differently.


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

https://reviews.llvm.org/D56160



___
cfe-commits mailing li

r351550 - Fix test failure from r351495

2019-01-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jan 18 05:58:10 2019
New Revision: 351550

URL: http://llvm.org/viewvc/llvm-project?rev=351550&view=rev
Log:
Fix test failure from r351495

The test has problems due to some platforms having a different type for
ptrdiff_t, so the error message is different.  The error message doesn't
matter to the test for anything other than an incompatible intger to
pointer conversion, so this patch removes the integral type from the
expected message.

Change-Id: I80e786f9b80268163813774bbf25a9ca25b6c60c

Modified:
cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp

Modified: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp?rev=351550&r1=351549&r2=351550&view=diff
==
--- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp (original)
+++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp Fri Jan 18 05:58:10 2019
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17
 
 void foo(int* a, int *b) {
-  a -= b; // expected-warning {{incompatible integer to pointer conversion 
assigning to 'int *' from 'long'}}
+  a -= b; // expected-warning {{incompatible integer to pointer conversion 
assigning to 'int *' from}}
 }
 
 template T declval();


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


[PATCH] D54141: [clang-tidy] add deduplication support for run-clang-tidy.py

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D54141#1362924 , @MyDeveloperDay 
wrote:

> > LLVM is very chatty as well, I don't consider LLVM to be a bad code-base. 
> > Take readability-braces-around-statements for example.
>
> Do we need a llvm-elide-braces-for-small-statements?
>
> This would make a great pre-review check


IMHO wouldn't hurt. It could even be a readability, one. But we need general 
thought on how to deal with conflicting checks, in this case especially.
Maybe we could extend the `readability-braces-around-statements` check with its 
`AntiCheck` and make it configurable. Therefore collision cant be emitted?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54141



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


[PATCH] D56879: [Sema] Suppress a warning about a forward-declared fixed enum in C mode

2019-01-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/fixed-enum.c:4
 // RUN: %clang_cc1 -Weverything -xobjective-c -DOBJC -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s

Can you add a RUN line with `-pedantic` to ensure that we still warn on the 
forward declare of the enum even when it's fixed?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56879



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


[PATCH] D56892: Add a priority field to availability attributes to prioritize explicit attributes from declaration over attributes from '#pragma clang attribute'

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

I think the documentation for the attribute should be updated to explain this 
new behavior, otherwise this will be a very inexplicable feature to users.

One question I have is: will this feature also be needed by other attributes? 
This seems like a somewhat general problem between explicit attributes, 
implicit attributes, and attributes added via the pragma. It might not be worth 
generalizing yet, but I'm curious to know whether we'll need this for things 
like visibility and type_visibility as well.




Comment at: include/clang/Sema/Sema.h:2467
+  /// already has an availability attribute with a lower priority for the
+  /// specified platform.
+  enum AvailabilityPriority : int {

We should have a comment somewhere (perhaps here) that makes it clear that the 
priorities we calculate and store on the semantic attribute object are not 
expected to match values in this enumeration, but instead be treated as a plain 
integer value. This enumeration is just giving a name to some of the addends 
used to calculate that value.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56892



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


[PATCH] D56751: [ASTDump] Mark variadic declarations with a tag instead of child node

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

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D56751



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


[PATCH] D56829: Move decl context dumping to TextNodeDumper

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

LGTM aside from the testing situation -- so long as the tests come out without 
changes, this is good to go. If there is a change in test behavior, let's do 
another round of review just to verify everyone's happy with the behavioral 
change.




Comment at: lib/AST/ASTDumper.cpp:1232
 
-  if (D->isThisDeclarationADefinition()) {
+  if (D->isThisDeclarationADefinition())
 dumpDeclContext(D);

Since this is just formatting changes unrelated to the patch, feel free to 
revert and commit separately for commit hygiene.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56829



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


[PATCH] D56909: [clang-format] Fix line parsing for noexcept lambdas

2019-01-18 Thread Marcus Hultman via Phabricator via cfe-commits
hultman created this revision.
hultman added reviewers: benhamilton, jolesiak, klimek, Wizard.
Herald added a subscriber: cfe-commits.

> $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" 
> |clang-format



  int c = [b]() mutable noexcept {
return [&b] { return b++; }();
  }
  ();

with patch:

> $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" 
> |bin/clang-format

  int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();


Repository:
  rC Clang

https://reviews.llvm.org/D56909

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11723,6 +11723,8 @@
 
 TEST_F(FormatTest, FormatsLambdas) {
   verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); 
}();\n");
+  verifyFormat(
+  "int c = [b]() mutable noexcept { return [&b] { return b++; }(); 
}();\n");
   verifyFormat("int c = [&] { [=] { return b++; }(); }();\n");
   verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n");
   verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); 
}();\n");
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1419,6 +1419,7 @@
 case tok::numeric_constant:
 case tok::coloncolon:
 case tok::kw_mutable:
+case tok::kw_noexcept:
   nextToken();
   break;
 case tok::arrow:


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11723,6 +11723,8 @@
 
 TEST_F(FormatTest, FormatsLambdas) {
   verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); }();\n");
+  verifyFormat(
+  "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();\n");
   verifyFormat("int c = [&] { [=] { return b++; }(); }();\n");
   verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n");
   verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n");
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1419,6 +1419,7 @@
 case tok::numeric_constant:
 case tok::coloncolon:
 case tok::kw_mutable:
+case tok::kw_noexcept:
   nextToken();
   break;
 case tok::arrow:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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



Comment at: clangd/ClangdServer.cpp:339
+  return CB(llvm::createStringError(llvm::inconvertibleErrorCode(),
+"could not create action context"));
+CB(prepareTweaks(*Inputs));

(action context?)



Comment at: clangd/ClangdServer.cpp:363
+  return CB(A.takeError());
+return CB((*A)->apply(*Inputs));
+  };

we should `format::cleanUpAroundReplacements`... fine to leave this as a FIXME



Comment at: clangd/refactor/Tweak.h:45
+/// The path of an active document the action was invoked in.
+llvm::StringRef File;
+/// The text of the active document.

Hmm, maybe we should drop this until we know how cross-file tweaks will work?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56267



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


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

2019-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Cool! Adopting this one as the simplest tweak for "how should tweaks do X" 
questions.

This depends on helpers not (yet) present in this patch, so not commenting on 
them now.

Need unit tests for tweaks. Something like this should work:

  Annotations Test(R"cpp(void foo() {
[[if]] (1) { return; } else { continue; }
  })cpp");
  auto AST = TestTU(Test.code()).build();
  auto Sel = Tweak::Selection::create(Test.Code(), AST, Test.range());
  auto T = prepareTweak("SwapIfBranches", Sel);
  ASSERT_TRUE(T) << T.takeError();
  auto Edits = T.apply(Sel);
  ASSERT_TRUE(Edits) << Edits.takeError();
  auto After = applyAllReplacements(Test.code(), *Edits);
  EXPECT_EQ(After, R"cpp(void foo() {
if (1) { continue; } else { return; }
  })cpp");

Probably want to wrap it up into a table driven test once we have a few.




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

The before/after is useful, we should probably have it for all tweaks if 
possible.
It'd also be useful to notate where the cursor can be to trigger the action. 
Partly because it forces us to consider this!

e.g. (not sure if this actually matches the logic you want, just an example)
```
Before:
  if (foo) { return 10; } else { continue; }
  ^^   ^
After:
  ...
```



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

I think prepare() should just verify:
 - cursor is in the right place
 - else statement exists and isn't an else if
 - both branches are compound statements (for now)
 - (maybe) relevant locations (if keyword, else keyword, braces) are not macro 
expansions
and then record the relevant source locations (or just the IfStmt*)

We may be able to get away with doing all the work in `prepare()`, but it's not 
a good model for future tweaks. (And it is at least somewhat wasteful on a hot 
path).



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

(Mostly this is food for thought for later - we shouldn't try to solve 
everything in this patch)

Two efficiency problems here:
 - doing one traversal per tweak is wasteful (when we have >1 tweaks, but worth 
at least *thinking* about)
 - traversing the entire AST rather than just the nodes over the cursor is bad 
news (though "over the cursor" may not be trivial to define)

Idea for how to "framework" this problem away:
Add `vector SelectedNodes` to the inputs, the idea being that 
this is the stack from the narrowest `Expr` under the cursor to the 
`TranslationUnitDecl` at the top.
This can be produced by a RecursiveASTVisitor (that either traverses the whole 
AST, or just the bits under the cursor if that's simple enough).
Tweaks would iterate over the nodes from narrowest to broadest, deciding 
whether to select this node for processing, continue iterating, or bail out.

Matching in checks are then pretty easy to write, we haven't removed too much 
flexibility in flow control, and it's pretty hard to write a slow check.

There are some complications:
 - we need access to parents somehow (e.g. consider the case of adding NS 
qualifiers, we want to match on names but then traverse up to the containing 
declrefexpr to get the nested namespace loc)
 - the interesting nodes may be a tree rather than a stack, because nodes 
overlap in the source. We could store a postorder traversal... but this makes 
e.g. "bail out when you hit a functiondecl" harder - you probably want to bail 
out of the current branch only.
 - things get complicated when we think about macros - depending on the 
semantics we want, it may be hard for the framework to prune parts of the tree 
that aren't under the cursor withouth traversing the whole AST.



Comment at: clangd/refactor/tweaks/SwapIfBranches.cpp:84
+  // to avoid changing semantics of the code (i.e. dangling else).
+  if (!llvm::dyn_cast_or_null(If->getThen()) ||
+  !llvm::dyn_cast_or_null(If->getElse()))

isa


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56611



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


r351559 - Clang side support for @cc assembly operands.

2019-01-18 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Fri Jan 18 07:57:23 2019
New Revision: 351559

URL: http://llvm.org/viewvc/llvm-project?rev=351559&view=rev
Log:
Clang side support for @cc assembly operands.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=351559&r1=351558&r2=351559&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Fri Jan 18 07:57:23 2019
@@ -1554,6 +1554,42 @@ bool X86TargetInfo::validateCpuIs(String
   .Default(false);
 }
 
+
+static unsigned matchAsmCCConstraint(const char *&Name) {
+ auto RV = llvm::StringSwitch(Name)
+   .Case("@cca",  4)
+   .Case("@ccae", 5)
+   .Case("@ccb",  4)
+   .Case("@ccbe", 5)
+   .Case("@ccc",  4)
+   .Case("@cce",  4)
+   .Case("@ccz",  4)
+   .Case("@ccg",  4)
+   .Case("@ccge", 4)
+   .Case("@ccl",  4)
+   .Case("@ccle", 5)
+   .Case("@ccna", 5)
+   .Case("@ccnae",6)
+   .Case("@ccnb", 5)
+   .Case("@ccnbe",6)
+   .Case("@ccnc", 5)
+   .Case("@ccne", 5)
+   .Case("@ccnz", 5)
+   .Case("@ccng", 5)
+   .Case("@ccnge",6)
+   .Case("@ccnl", 5)
+   .Case("@ccnle",6)
+   .Case("@ccno", 5)
+   .Case("@ccnp", 5)
+   .Case("@ccns", 5)
+   .Case("@cco",  4)
+   .Case("@ccp",  4)
+   .Case("@ccs",  4)
+   .Default(0);
+ return RV;
+}
+
+
 bool X86TargetInfo::validateAsmConstraint(
 const char *&Name, TargetInfo::ConstraintInfo &Info) const {
   switch (*Name) {
@@ -1636,6 +1672,14 @@ bool X86TargetInfo::validateAsmConstrain
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
+  case '@':
+// CC condition changes.
+if (auto Len = matchAsmCCConstraint(Name)) {
+  Name+=Len-1;
+  Info.setAllowsRegister();
+  return true;
+}
+return false;
   }
 }
 
@@ -1705,8 +1749,16 @@ bool X86TargetInfo::validateOperandSize(
   return true;
 }
 
+//niravd
 std::string X86TargetInfo::convertConstraint(const char *&Constraint) const {
   switch (*Constraint) {
+case '@':
+if (auto Len = matchAsmCCConstraint(Constraint)) {
+  std::string Converted = "{" + std::string(Constraint, Len) + "}";
+  Constraint+=Len-1;
+  return Converted;
+}
+break;
   case 'a':
 return std::string("{ax}");
   case 'b':


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


[PATCH] D54324: [AST] Store the value of CharacterLiteral in the bit-fields of Stmt if possible

2019-01-18 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno abandoned this revision.
riccibruno added a comment.

This is not worth doing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54324



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


r351561 - Revert "Clang side support for @cc assembly operands."

2019-01-18 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Fri Jan 18 08:03:08 2019
New Revision: 351561

URL: http://llvm.org/viewvc/llvm-project?rev=351561&view=rev
Log:
Revert "Clang side support for @cc assembly operands."

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=351561&r1=351560&r2=351561&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Fri Jan 18 08:03:08 2019
@@ -1554,42 +1554,6 @@ bool X86TargetInfo::validateCpuIs(String
   .Default(false);
 }
 
-
-static unsigned matchAsmCCConstraint(const char *&Name) {
- auto RV = llvm::StringSwitch(Name)
-   .Case("@cca",  4)
-   .Case("@ccae", 5)
-   .Case("@ccb",  4)
-   .Case("@ccbe", 5)
-   .Case("@ccc",  4)
-   .Case("@cce",  4)
-   .Case("@ccz",  4)
-   .Case("@ccg",  4)
-   .Case("@ccge", 4)
-   .Case("@ccl",  4)
-   .Case("@ccle", 5)
-   .Case("@ccna", 5)
-   .Case("@ccnae",6)
-   .Case("@ccnb", 5)
-   .Case("@ccnbe",6)
-   .Case("@ccnc", 5)
-   .Case("@ccne", 5)
-   .Case("@ccnz", 5)
-   .Case("@ccng", 5)
-   .Case("@ccnge",6)
-   .Case("@ccnl", 5)
-   .Case("@ccnle",6)
-   .Case("@ccno", 5)
-   .Case("@ccnp", 5)
-   .Case("@ccns", 5)
-   .Case("@cco",  4)
-   .Case("@ccp",  4)
-   .Case("@ccs",  4)
-   .Default(0);
- return RV;
-}
-
-
 bool X86TargetInfo::validateAsmConstraint(
 const char *&Name, TargetInfo::ConstraintInfo &Info) const {
   switch (*Name) {
@@ -1672,14 +1636,6 @@ bool X86TargetInfo::validateAsmConstrain
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
-  case '@':
-// CC condition changes.
-if (auto Len = matchAsmCCConstraint(Name)) {
-  Name+=Len-1;
-  Info.setAllowsRegister();
-  return true;
-}
-return false;
   }
 }
 
@@ -1749,16 +1705,8 @@ bool X86TargetInfo::validateOperandSize(
   return true;
 }
 
-//niravd
 std::string X86TargetInfo::convertConstraint(const char *&Constraint) const {
   switch (*Constraint) {
-case '@':
-if (auto Len = matchAsmCCConstraint(Constraint)) {
-  std::string Converted = "{" + std::string(Constraint, Len) + "}";
-  Constraint+=Len-1;
-  return Converted;
-}
-break;
   case 'a':
 return std::string("{ax}");
   case 'b':


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


[PATCH] D56915: [clangd] Make background index less chatty

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

It is producing too much input in non-verbose mode,
i.e. a message per indexed file


https://reviews.llvm.org/D56915

Files:
  clang-tools-extra/clangd/index/Background.cpp


Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -398,7 +398,7 @@
 DigestsSnapshot = IndexedFileDigests;
   }
 
-  log("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
+  vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
   ParseInputs Inputs;
   Inputs.FS = std::move(FS);
   Inputs.FS->setCurrentWorkingDirectory(Cmd.Directory);


Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -398,7 +398,7 @@
 DigestsSnapshot = IndexedFileDigests;
   }
 
-  log("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
+  vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
   ParseInputs Inputs;
   Inputs.FS = std::move(FS);
   Inputs.FS->setCurrentWorkingDirectory(Cmd.Directory);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, ioeric, 
ilya-biryukov.

With ObjCPropertyDecl, ASTNode.OrigD can be a ObjCPropertyImplDecl
which is not a NamedDecl, leading to a crash since the code
incorrectly assumes ASTNode.OrigD will always be a NamedDecl.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56916

Files:
  clangd/index/SymbolCollector.cpp


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -369,6 +369,10 @@
   if (!ID)
 return true;
 
+  // ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  if (!isa(ASTNode.OrigD))
+return true;
   const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -369,6 +369,10 @@
   if (!ID)
 return true;
 
+  // ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  if (!isa(ASTNode.OrigD))
+return true;
   const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56868: Add -fextern-visibility for -cc1

2019-01-18 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 182528.
scott.linder retitled this revision from "Add -fset-visibility-for-decls for 
-cc1" to "Add -fextern-visibility for -cc1".
scott.linder added a comment.

Update the -cc1 option name and docs; also update the LangOpt and docs.


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

https://reviews.llvm.org/D56868

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChains/AMDGPU.cpp
  lib/Driver/ToolChains/HIP.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/set-visibility-for-decls.c
  test/Driver/amdgpu-visibility.cl
  test/Driver/hip-toolchain-no-rdc.hip
  test/Driver/hip-toolchain-rdc.hip

Index: test/Driver/hip-toolchain-rdc.hip
===
--- test/Driver/hip-toolchain-rdc.hip
+++ test/Driver/hip-toolchain-rdc.hip
@@ -12,10 +12,11 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s
 
-// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden"
+// CHECK-SAME: "-fextern-visibility"
 // CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
@@ -23,6 +24,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden"
+// CHECK-SAME: "-fextern-visibility"
 // CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
Index: test/Driver/hip-toolchain-no-rdc.hip
===
--- test/Driver/hip-toolchain-no-rdc.hip
+++ test/Driver/hip-toolchain-no-rdc.hip
@@ -20,6 +20,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fextern-visibility"
 // CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
@@ -47,6 +48,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fextern-visibility"
 // CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
@@ -89,6 +91,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fextern-visibility"
 // CHECK-SAME: {{.*}} "-o" [[B_BC_803:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
@@ -116,6 +119,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fextern-visibility"
 // CHECK-SAME: {{.*}} "-o" [[B_BC_900:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC]]
 
Index: test/Driver/amdgpu-visibility.cl
===
--- test/Driver/amdgpu-visibility.cl
+++ test/Driver/amdgpu-visibility.cl
@@ -2,6 +2,14 @@
 // RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm -fvisibility=protected  %s 2>&1 | FileCheck -check-prefix=OVERRIDE-PROTECTED  %s
 // RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm -fvisibility-ms-compat  %s 2>&1 | FileCheck -check-prefix=OVERRIDE-MS  %s
 
-// DEFAULT: "-fvisibility" "hidden"
+// DEFAULT-DAG: "-fvisibility" "hidden"
+// DEFAULT-DAG: "-fextern-visibility"
+
+// OVERRIDE-PROTECTED-NOT: "-fextern-visibility"
 // OVERRIDE-PROTECTED: "-fvisibility" "protected"
-// OVERRIDE-MS:  "-fvisibility" "hidden" "-ftype-visibility" "default"
+// OVERRIDE-PROTECTED-NOT: "-fextern-visibility"
+
+// OVERRIDE-MS-NOT: "-fextern-visibility"
+// OVERRIDE-MS-DAG: "-fvisibility" "hidden"
+// OVERRIDE-MS-DAG: "-ftype-visibility" "default"
+// OVERRIDE-MS-NOT: "-fextern-visibility"
Index: test/CodeGen/set-visibility-for-decls.c
===
--- /dev/null
+++ test/CodeGen/set-visibility-for-decls.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -std=c11 -triple=x86_64-pc-linux -fvisibility hidden -fextern-visibility -emit-llvm -o - | FileCheck --check-prefix=CHECK-HIDDEN %s
+// RUN: %clang_cc1 %s -std=c11 -triple=x86_64-pc-linux -fvisibilit

Re: r351540 - [analyzer] Unbreak building of SymbolReaperTest true BUILD_SHARED_LIBS=True

2019-01-18 Thread Artem Dergachev via cfe-commits

Thanks!!!

On 1/18/19 2:13 AM, Alex Bradbury via cfe-commits wrote:

Author: asb
Date: Fri Jan 18 02:13:07 2019
New Revision: 351540

URL: http://llvm.org/viewvc/llvm-project?rev=351540&view=rev
Log:
[analyzer] Unbreak building of SymbolReaperTest true BUILD_SHARED_LIBS=True

Extra dependencies need to be listed for StaticAnalysisTests in order for
linking to succeed when BUILD_SHARED_LIBS=True.


Modified:
 cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt

Modified: cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt?rev=351540&r1=351539&r2=351540&view=diff
==
--- cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt (original)
+++ cfe/trunk/unittests/StaticAnalyzer/CMakeLists.txt Fri Jan 18 02:13:07 2019
@@ -12,6 +12,9 @@ target_link_libraries(StaticAnalysisTest
PRIVATE
clangBasic
clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangCrossTU
clangFrontend
clangSerialization
clangStaticAnalyzerCore


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


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


[PATCH] D56871: [AMDGPU] Require at least protected visibility for certain symbols

2019-01-18 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 182532.
scott.linder added a comment.

Update option name


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

https://reviews.llvm.org/D56871

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/visibility.cl

Index: test/CodeGenOpenCL/visibility.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/visibility.cl
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=cl2.0 -fextern-visibility -fvisibility default -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-DEFAULT %s
+// RUN: %clang_cc1 -std=cl2.0 -fextern-visibility -fvisibility protected -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-PROTECTED %s
+// RUN: %clang_cc1 -std=cl2.0 -fextern-visibility -fvisibility hidden -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-HIDDEN %s
+
+// REQUIRES: amdgpu-registered-target
+
+// FVIS-DEFAULT:  @glob = local_unnamed_addr
+// FVIS-PROTECTED: @glob = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob = hidden local_unnamed_addr
+int glob = 0;
+// FVIS-DEFAULT:  @glob_hidden = hidden local_unnamed_addr
+// FVIS-PROTECTED: @glob_hidden = hidden local_unnamed_addr
+// FVIS-HIDDEN: @glob_hidden = hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) int glob_hidden = 0;
+// FVIS-DEFAULT:  @glob_protected = protected local_unnamed_addr
+// FVIS-PROTECTED: @glob_protected = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob_protected = protected local_unnamed_addr
+__attribute__((visibility("protected"))) int glob_protected = 0;
+// FVIS-DEFAULT:  @glob_default = local_unnamed_addr
+// FVIS-PROTECTED: @glob_default = local_unnamed_addr
+// FVIS-HIDDEN: @glob_default = local_unnamed_addr
+__attribute__((visibility("default"))) int glob_default = 0;
+
+// FVIS-DEFAULT:  @ext = external local_unnamed_addr
+// FVIS-PROTECTED: @ext = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext = external hidden local_unnamed_addr
+extern int ext;
+// FVIS-DEFAULT:  @ext_hidden = external hidden local_unnamed_addr
+// FVIS-PROTECTED: @ext_hidden = external hidden local_unnamed_addr
+// FVIS-HIDDEN: @ext_hidden = external hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) extern int ext_hidden;
+// FVIS-DEFAULT:  @ext_protected = external protected local_unnamed_addr
+// FVIS-PROTECTED: @ext_protected = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext_protected = external protected local_unnamed_addr
+__attribute__((visibility("protected"))) extern int ext_protected;
+// FVIS-DEFAULT:  @ext_default = external local_unnamed_addr
+// FVIS-PROTECTED: @ext_default = external local_unnamed_addr
+// FVIS-HIDDEN: @ext_default = external local_unnamed_addr
+__attribute__((visibility("default"))) extern int ext_default;
+
+// FVIS-DEFAULT: define amdgpu_kernel void @kern()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern()
+kernel void kern() {}
+// FVIS-DEFAULT: define protected amdgpu_kernel void @kern_hidden()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern_hidden()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern_hidden()
+__attribute__((visibility("hidden"))) kernel void kern_hidden() {}
+// FVIS-DEFAULT: define protected amdgpu_kernel void @kern_protected()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern_protected()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern_protected()
+__attribute__((visibility("protected"))) kernel void kern_protected() {}
+// FVIS-DEFAULT: define amdgpu_kernel void @kern_default()
+// FVIS-PROTECTED: define amdgpu_kernel void @kern_default()
+// FVIS-HIDDEN: define amdgpu_kernel void @kern_default()
+__attribute__((visibility("default"))) kernel void kern_default() {}
+
+// FVIS-DEFAULT: define void @func()
+// FVIS-PROTECTED: define protected void @func()
+// FVIS-HIDDEN: define hidden void @func()
+void func() {}
+// FVIS-DEFAULT: define hidden void @func_hidden()
+// FVIS-PROTECTED: define hidden void @func_hidden()
+// FVIS-HIDDEN: define hidden void @func_hidden()
+__attribute__((visibility("hidden"))) void func_hidden() {}
+// FVIS-DEFAULT: define protected void @func_protected()
+// FVIS-PROTECTED: define protected void @func_protected()
+// FVIS-HIDDEN: define protected void @func_protected()
+__attribute__((visibility("protected"))) void func_protected() {}
+// FVIS-DEFAULT: define void @func_default()
+// FVIS-PROTECTED: define void @func_default()
+// FVIS-HIDDEN: define void @func_default()
+__attribute__((visibility("default"))) void func_default() {}
+
+void use() {
+glob = ext + ext_hidden + ext_protected + ext_default;
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp

[PATCH] D56917: [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, sammccall, rsmith.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: george.karpenkov.

This patch adds two unit-tests that are the result of reducing a crashing TU
when running ExprMutAnalyzer over it. They are added only to ensure the 
regression
that has been fixed with https://reviews.llvm.org/D56444 don't creep back.


Repository:
  rC Clang

https://reviews.llvm.org/D56917

Files:
  unittests/Analysis/ExprMutationAnalyzerTest.cpp


Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1109,4 +1109,48 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailure11) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  a&& forward(a & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "_Fp d;"
+  "template  __bind(_Fp f, e &&) : d(forward(f)) {}"
+  "};"
+  "template  void bind(_Fp f, h && g) {"
+  "__bind<_Fp>(f, g);"
+  "}"
+  "template  void async(i f, j && g) {"
+  "bind(f, g);"
+  "}"
+  "}"
+  "void k() {"
+  "int x = 42;"
+  "std::async([] {}, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang


Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1109,4 +1109,48 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailure11) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  a&& forward(a & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "_Fp d;"
+  "template  __bind(_Fp f, e &&) : d(forward(f)) {}"
+  "};"
+  "template  void bind(_Fp f, h && g) {"
+  "__bind<_Fp>(f, g);"
+  "}"
+  "template  void async(i f, j && g) {"
+  "bind(f, g);"
+  "}"
+  "}"
+  "void k() {"
+  "int x = 42;"
+  "std::async([] {}, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.cpp:363
+  return CB(A.takeError());
+return CB((*A)->apply(*Inputs));
+  };

sammccall wrote:
> we should `format::cleanUpAroundReplacements`... fine to leave this as a FIXME
Added a FIXME. We probably want a helper that does this, to reuse in tests and 
`ClangdServer`.



Comment at: clangd/ClangdServer.h:212
+  /// Apply the code tweak with a specified \p ID.
+  void applyCodeTweak(PathRef File, Range Sel, TweakID ID,
+  Callback CB);

sammccall wrote:
> `tweak`? It's a verb...
That's too short for my taste, I went with `applyTweak` and it also feels 
helpful if we don't switch between a verb and a noun to keep clear a parallel 
between a `Tweak` returned by `enumerateTweaks` and a tweak applied in 
`applyTweak`.

Let me know if you feel strongly about this :-)



Comment at: clangd/Protocol.cpp:426
+const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_CODE_ACTION =
+"clangd.applyCodeAction";
+

sammccall wrote:
> tweak
Used `applyTweak` for symmetry with `applyFix` (and other reasons mentioned in 
the comments for `ClangdServer::tweak`)



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

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



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

sammccall wrote:
> nit: one of my lessons from clang-tidy is that mapping between IDs and 
> implementations is annoying.
> Since IDs are 1:1 with classes, can we just require this to be the class name?
> 
> (If you wanted, I think you could adapt REGISTER_TWEAK so that it goes inside 
> the class defn, and then it could provide the override of id() itself)
That would mean no two tweaks are allowed to have the same class name. This is 
probably fine, but somewhat contradicts C++, which would solve it with 
namespaces.
To be fair, there's a simple trick to grep for the id to find its class, so I'd 
keep as is.

If we choose to adapt `REGISTER_TWEAK`, that would mean we force everyone to 
put their tweaks **only** in `.cpp` files. That creates arbitrary restrictions 
on how one should write a check and I'm somewhat opposed to this. But happy to 
reconsider if you feel strongly about this.


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

https://reviews.llvm.org/D56267



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


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

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

- Update comments
- Return an ID+Title instead of a Tweak object
- Rename codeAction -> tweak everywhere
- Remove Tweak::Selection::File
- Return Expected instead of Optional
- Add a FIXME to apply the formatter on top of the actions


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

https://reviews.llvm.org/D56267

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

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

[clang-tools-extra] r351563 - [clangd] Make background index less chatty

2019-01-18 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Jan 18 09:04:26 2019
New Revision: 351563

URL: http://llvm.org/viewvc/llvm-project?rev=351563&view=rev
Log:
[clangd] Make background index less chatty

Summary:
It is producing too much input in non-verbose mode,
i.e. a message per indexed file

Reviewers: sammccall, kadircet

Reviewed By: sammccall

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

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

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

Modified: clang-tools-extra/trunk/clangd/index/Background.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=351563&r1=351562&r2=351563&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Background.cpp Fri Jan 18 09:04:26 2019
@@ -398,7 +398,7 @@ llvm::Error BackgroundIndex::index(tooli
 DigestsSnapshot = IndexedFileDigests;
   }
 
-  log("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
+  vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
   ParseInputs Inputs;
   Inputs.FS = std::move(FS);
   Inputs.FS->setCurrentWorkingDirectory(Cmd.Directory);


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


[PATCH] D56915: [clangd] Make background index less chatty

2019-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351563: [clangd] Make background index less chatty (authored 
by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56915?vs=182523&id=182535#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56915

Files:
  clang-tools-extra/trunk/clangd/index/Background.cpp


Index: clang-tools-extra/trunk/clangd/index/Background.cpp
===
--- clang-tools-extra/trunk/clangd/index/Background.cpp
+++ clang-tools-extra/trunk/clangd/index/Background.cpp
@@ -398,7 +398,7 @@
 DigestsSnapshot = IndexedFileDigests;
   }
 
-  log("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
+  vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
   ParseInputs Inputs;
   Inputs.FS = std::move(FS);
   Inputs.FS->setCurrentWorkingDirectory(Cmd.Directory);


Index: clang-tools-extra/trunk/clangd/index/Background.cpp
===
--- clang-tools-extra/trunk/clangd/index/Background.cpp
+++ clang-tools-extra/trunk/clangd/index/Background.cpp
@@ -398,7 +398,7 @@
 DigestsSnapshot = IndexedFileDigests;
   }
 
-  log("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
+  vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
   ParseInputs Inputs;
   Inputs.FS = std::move(FS);
   Inputs.FS->setCurrentWorkingDirectory(Cmd.Directory);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56918: [clang-tidy] add reproducer for PR39949 into test-suite

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: alexfh, aaron.ballman, hokein, hwright.
Herald added subscribers: cfe-commits, xazax.hun.

The underlying issue is fixed in https://reviews.llvm.org/D56444
and this test ensures the issue does not creep back into our
code-base.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56918

Files:
  test/clang-tidy/abseil-upgrade-duration-conversions.cpp


Index: test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===
--- test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -430,3 +430,36 @@
   factoryTemplateAndMacro>();
   TemplateFactoryInMacro(ConvertibleTo());
 }
+
+// This is a reduced test-case for PR39949 and manifested in this check.
+namespace std {
+template 
+_Tp declval();
+
+template 
+struct __res {
+  template 
+  static decltype(declval<_Functor>()(_Args()...)) _S_test(int);
+
+  template 
+  static void _S_test(...);
+
+  typedef decltype(_S_test<_ArgTypes...>(0)) type;
+};
+
+template 
+struct function;
+
+template 
+struct function {
+  template ::type>
+  function(_Functor) {}
+};
+} // namespace std
+
+typedef std::function F;
+
+F foo() {
+  return F([] {});
+}


Index: test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===
--- test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -430,3 +430,36 @@
   factoryTemplateAndMacro>();
   TemplateFactoryInMacro(ConvertibleTo());
 }
+
+// This is a reduced test-case for PR39949 and manifested in this check.
+namespace std {
+template 
+_Tp declval();
+
+template 
+struct __res {
+  template 
+  static decltype(declval<_Functor>()(_Args()...)) _S_test(int);
+
+  template 
+  static void _S_test(...);
+
+  typedef decltype(_S_test<_ArgTypes...>(0)) type;
+};
+
+template 
+struct function;
+
+template 
+struct function {
+  template ::type>
+  function(_Functor) {}
+};
+} // namespace std
+
+typedef std::function F;
+
+F foo() {
+  return F([] {});
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351565 - [clang][slh] add Clang attr no_speculative_load_hardening

2019-01-18 Thread Zola Bridges via cfe-commits
Author: zbrid
Date: Fri Jan 18 09:20:46 2019
New Revision: 351565

URL: http://llvm.org/viewvc/llvm-project?rev=351565&view=rev
Log:
[clang][slh] add Clang attr no_speculative_load_hardening

Summary:
This attribute will allow users to opt specific functions out of
speculative load hardening. This compliments the Clang attribute
named speculative_load_hardening. When this attribute or the attribute
speculative_load_hardening is used in combination with the flags
-mno-speculative-load-hardening or -mspeculative-load-hardening,
the function level attribute will override the default during LLVM IR
generation. For example, in the case, where the flag opposes the
function attribute, the function attribute will take precendence.
The sticky inlining behavior of the speculative_load_hardening attribute
may cause a function with the no_speculative_load_hardening attribute
to be tagged with the speculative_load_hardening tag in
subsequent compiler phases which is desired behavior since the
speculative_load_hardening LLVM attribute is designed to be maximally
conservative.

If both attributes are specified for a function, then an error will be
thrown.

Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman

Subscribers: llvm-commits

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

Added:
cfe/trunk/test/CodeGenCXX/attr-speculative-load-hardening.cpp
cfe/trunk/test/CodeGenObjC/attr-speculative-load-hardening.m
cfe/trunk/test/SemaCXX/attr-no-speculative-load-hardening.cpp
Removed:
cfe/trunk/test/CodeGen/attr-speculative-load-hardening.cpp
cfe/trunk/test/CodeGen/attr-speculative-load-hardening.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/test/SemaCXX/attr-speculative-load-hardening.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=351565&r1=351564&r2=351565&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jan 18 09:20:46 2019
@@ -3149,6 +3149,12 @@ def SpeculativeLoadHardening : Inheritab
   let Documentation = [SpeculativeLoadHardeningDocs];
 }
 
+def NoSpeculativeLoadHardening : InheritableAttr {
+  let Spellings = [Clang<"no_speculative_load_hardening">];
+  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
+  let Documentation = [NoSpeculativeLoadHardeningDocs];
+}
+
 def Uninitialized : InheritableAttr {
   let Spellings = [Clang<"uninitialized", 0>];
   let Subjects = SubjectList<[LocalVar]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=351565&r1=351564&r2=351565&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Jan 18 09:20:46 2019
@@ -3822,7 +3822,8 @@ def SpeculativeLoadHardeningDocs : Docum
   This attribute can be applied to a function declaration in order to indicate
   that `Speculative Load Hardening 
`_
   should be enabled for the function body. This can also be applied to a method
-  in Objective C.
+  in Objective C. This attribute will take precedence over the command line 
flag in
+  the case where `-mno-speculative-load-hardening 
`_
 is specified.
 
   Speculative Load Hardening is a best-effort mitigation against
   information leak attacks that make use of control flow
@@ -3840,6 +3841,42 @@ def SpeculativeLoadHardeningDocs : Docum
   }];
 }
 
+def NoSpeculativeLoadHardeningDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+  This attribute can be applied to a function declaration in order to indicate
+  that `Speculative Load Hardening 
`_
+  is *not* needed for the function body. This can also be applied to a method
+  in Objective C. This attribute will take precedence over the command line 
flag in
+  the case where `-mspeculative-load-hardening 
`_
 is specified.
+
+  Warning: This attribute may not prevent Speculative Load Hardening from being
+  enabled for a function which inlines a function that has the
+  'speculative_load_hardening' attribute. This is intended to provide a
+  maximally conservative model where the code that is marked with the
+  'speculative_

[PATCH] D54909: [clang][slh] add Clang attr no_speculative_load_hardening

2019-01-18 Thread Zola Bridges via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351565: [clang][slh] add Clang attr 
no_speculative_load_hardening (authored by zbrid, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54909?vs=182060&id=182539#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54909

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-speculative-load-hardening.cpp
  test/CodeGen/attr-speculative-load-hardening.m
  test/CodeGenCXX/attr-speculative-load-hardening.cpp
  test/CodeGenObjC/attr-speculative-load-hardening.m
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/attr-no-speculative-load-hardening.cpp
  test/SemaCXX/attr-speculative-load-hardening.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1793,8 +1793,6 @@
 if (CodeGenOpts.Backchain)
   FuncAttrs.addAttribute("backchain");
 
-// FIXME: The interaction of this attribute with the SLH command line flag
-// has not been determined.
 if (CodeGenOpts.SpeculativeLoadHardening)
   FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
   }
@@ -1864,8 +1862,6 @@
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
-if (TargetDecl->hasAttr())
-  FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
   AddAttributesFromFunctionProtoType(
@@ -1910,6 +1906,16 @@
 
   ConstructDefaultFnAttrList(Name, HasOptnone, AttrOnCallSite, FuncAttrs);
 
+  // This must run after constructing the default function attribute list
+  // to ensure that the speculative load hardening attribute is removed
+  // in the case where the -mspeculative-load-hardening flag was passed.
+  if (TargetDecl) {
+if (TargetDecl->hasAttr())
+  FuncAttrs.removeAttribute(llvm::Attribute::SpeculativeLoadHardening);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
+  }
+
   if (CodeGenOpts.EnableSegmentedStacks &&
   !(TargetDecl && TargetDecl->hasAttr()))
 FuncAttrs.addAttribute("split-stack");
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2489,6 +2489,10 @@
   else if (const auto *UA = dyn_cast(Attr))
 NewAttr = S.mergeUuidAttr(D, UA->getRange(), AttrSpellingListIndex,
   UA->getGuid());
+  else if (const auto *SLHA = dyn_cast(Attr))
+NewAttr = S.mergeSpeculativeLoadHardeningAttr(D, *SLHA);
+  else if (const auto *SLHA = dyn_cast(Attr))
+NewAttr = S.mergeNoSpeculativeLoadHardeningAttr(D, *SLHA);
   else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
 NewAttr = cast(Attr->clone(S.Context));
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4157,6 +4157,15 @@
   return ::new (Context) MinSizeAttr(Range, Context, AttrSpellingListIndex);
 }
 
+NoSpeculativeLoadHardeningAttr *Sema::mergeNoSpeculativeLoadHardeningAttr(
+Decl *D, const NoSpeculativeLoadHardeningAttr &AL) {
+  if (checkAttrMutualExclusion(*this, D, AL))
+return nullptr;
+
+  return ::new (Context) NoSpeculativeLoadHardeningAttr(
+  AL.getRange(), Context, AL.getSpellingListIndex());
+}
+
 OptimizeNoneAttr *Sema::mergeOptimizeNoneAttr(Decl *D, SourceRange Range,
   unsigned AttrSpellingListIndex) {
   if (AlwaysInlineAttr *Inline = D->getAttr()) {
@@ -4177,6 +4186,15 @@
   AttrSpellingListIndex);
 }
 
+SpeculativeLoadHardeningAttr *Sema::mergeSpeculativeLoadHardeningAttr(
+Decl *D, const SpeculativeLoadHardeningAttr &AL) {
+  if (checkAttrMutualExclusion(*this, D, AL))
+return nullptr;
+
+  return ::new (Context) SpeculativeLoadHardeningAttr(
+  AL.getRange(), Context, AL.getSpellingListIndex());
+}
+
 static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   if (checkAttrMutualExclusion(S, D, AL))
 return;
@@ -6618,7 +6636,13 @@
 handleSectionAttr(S, D, AL);
 break;
   case ParsedAttr::AT_SpeculativeLoadHardening:
-handleSimpleAttribute(S, D, AL);
+handleSimpleAttributeWithExclusions(S, D,
+AL);
+break;
+  case ParsedAttr::AT_NoSpeculativeLoadHardening:
+handleSimpleAttributeWithExclusions(S, D, AL);
  

Re: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

2019-01-18 Thread Jordan Rupprecht via cfe-commits
Hi Craig,
We're seeing issues building a few other things now; notably this part in
opencv:
https://github.com/opencv/opencv/blob/master/modules/core/src/system.cpp#L422
#ifdef _XCR_XFEATURE_ENABLED_MASK // requires immintrin.h
xcr0 = (int)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
=> error: '__builtin_ia32_xgetbv' needs target feature xsave
We can workaround by building with -mavx... but we also have code running
on non-avx machines that pull in this dependency. (It likely doesn't
actually *use* the code, but still depends on it compiling as a transitive
dep).
Is there a more accurate preprocessor macro (e.g. one that says if xsave is
available) we could use to selectively disable this?

There are similar breakages here:
https://chromium.googlesource.com/aosp/platform/external/libchrome/+/master/base/cpu.cc#82
https://github.com/google/sling/blob/master/third_party/jit/cpu.cc#L58
Advice there too would be appreciated, if possible :)

On Wed, Jan 16, 2019 at 3:00 PM Craig Topper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ctopper
> Date: Wed Jan 16 14:56:25 2019
> New Revision: 351391
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351391&view=rev
> Log:
> Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"
>
> V8 has been fixed now.
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/immintrin.h
> cfe/trunk/lib/Headers/intrin.h
> cfe/trunk/lib/Headers/xsaveintrin.h
> cfe/trunk/test/CodeGen/builtins-x86.c
> cfe/trunk/test/CodeGen/x86_32-xsave.c
> cfe/trunk/test/CodeGen/x86_64-xsave.c
> cfe/trunk/test/Headers/ms-intrin.cpp
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351391&r1=351390&r2=351391&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jan 16 14:56:25 2019
> @@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
>  // XSAVE
>  TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
> +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
> +TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h",
> ALL_MS_LANGUAGES, "")
> +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
> +TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h",
> ALL_MS_LANGUAGES, "")
>  TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
>  TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
>  TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351391&r1=351390&r2=351391&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jan 16 14:56:25 2019
> @@ -9833,7 +9833,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>case X86::BI__builtin_ia32_xsavec:
>case X86::BI__builtin_ia32_xsavec64:
>case X86::BI__builtin_ia32_xsaves:
> -  case X86::BI__builtin_ia32_xsaves64: {
> +  case X86::BI__builtin_ia32_xsaves64:
> +  case X86::BI__builtin_ia32_xsetbv:
> +  case X86::BI_xsetbv: {
>  Intrinsic::ID ID;
>  #define INTRINSIC_X86_XSAVE_ID(NAME) \
>  case X86::BI__builtin_ia32_##NAME: \
> @@ -9853,6 +9855,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  INTRINSIC_X86_XSAVE_ID(xsavec64);
>  INTRINSIC_X86_XSAVE_ID(xsaves);
>  INTRINSIC_X86_XSAVE_ID(xsaves64);
> +INTRINSIC_X86_XSAVE_ID(xsetbv);
> +case X86::BI_xsetbv:
> +  ID = Intrinsic::x86_xsetbv;
> +  break;
>  }
>  #undef INTRINSIC_X86_XSAVE_ID
>  Value *Mhi = Builder.CreateTrunc(
> @@ -9862,6 +9868,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  Ops.push_back(Mlo);
>  return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
>}
> +  case X86::BI__builtin_ia32_xgetbv:
> +  case X86::BI_xgetbv:
> +return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv),
> Ops);
>case X86::BI__builtin_ia32_storedqudi128_mask:
>case X86::BI__builtin_ia32_storedqusi128_mask:
>case X86::BI__builtin_ia32_storedquhi128_mask:
>
> Modified: cfe/trunk/lib/Headers/immintrin.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=351391&r1=351390&r2=351391&view=diff
>
> ==
> --- cfe/trunk/lib/Headers/immintrin.h (original)
> +++ cfe/trunk/lib/Headers/immintrin.h Wed Jan 16 14:56:25 2019
> @@ -378,9 +378,8 @@ _storebe_i64(void * __P, long long __D)
>  #include 
>  #endif
>
> -#if !de

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

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

- Move to the monorepo
- Move out the source code helpers (they're now in swap-if-branches)


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

https://reviews.llvm.org/D56610

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

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

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

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

- Move source code helpers to this patch


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

https://reviews.llvm.org/D56611

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

Index: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -0,0 +1,119 @@
+//===--- SwapIfBranches.cpp --*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Swaps the 'then' and 'else' branch of the if statement.
+/// Before:
+///   if (foo) { return 10; } else { continue; }
+/// After:
+///   if (foo) { continue; } else { return 10; }
+class SwapIfBranches : public Tweak {
+public:
+  TweakID id() const override {
+return llvm::StringLiteral("swap-if-branches");
+  }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  tooling::Replacements Result;
+};
+REGISTER_TWEAK(SwapIfBranches);
+
+class FindIfUnderCursor : public RecursiveASTVisitor {
+public:
+  FindIfUnderCursor(ASTContext &Ctx, SourceLocation CursorLoc, IfStmt *&Result)
+  : Ctx(Ctx), CursorLoc(CursorLoc), Result(Result) {}
+
+  bool VisitIfStmt(IfStmt *If) {
+auto R = toHalfOpenFileRange(Ctx.getSourceManager(), Ctx.getLangOpts(),
+ SourceRange(If->getIfLoc()));
+if (!R)
+  return true;
+if (!halfOpenRangeContains(Ctx.getSourceManager(), *R, CursorLoc))
+  return true;
+Result = If;
+return false;
+  }
+
+private:
+  ASTContext &Ctx;
+  SourceLocation CursorLoc;
+  IfStmt *&Result;
+};
+} // namespace
+
+bool SwapIfBranches::prepare(const Selection &Inputs) {
+
+  auto &Ctx = Inputs.AST.getASTContext();
+  auto &SrcMgr = Ctx.getSourceManager();
+  IfStmt *If = nullptr;
+  FindIfUnderCursor(Ctx, Inputs.Cursor, If).TraverseAST(Ctx);
+  if (!If)
+return false;
+
+  // avoid dealing with single-statement brances, they require careful handling
+  // to avoid changing semantics of the code (i.e. dangling else).
+  if (!llvm::dyn_cast_or_null(If->getThen()) ||
+  !llvm::dyn_cast_or_null(If->getElse()))
+return false;
+
+  auto ThenRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getThen()->getSourceRange());
+  if (!ThenRng)
+return false;
+  auto ElseRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getElse()->getSourceRange());
+  if (!ElseRng)
+return false;
+
+  llvm::StringRef ThenCode = toSourceCode(SrcMgr, *ThenRng);
+  llvm::StringRef ElseCode = toSourceCode(SrcMgr, *ElseRng);
+
+  if (auto Err = Result.add(tooling::Replacement(SrcMgr, ThenRng->getBegin(),
+ ThenCode.size(), ElseCode))) {
+llvm::consumeError(std::move(Err));
+return false;
+  }
+  if (auto Err = Result.add(tooling::Replacement(SrcMgr, ElseRng->getBegin(),
+ ElseCode.size(), ThenCode))) {
+llvm::consumeError(std::move(Err));
+return false;
+  }
+  return true;
+}
+
+Expected SwapIfBranches::apply(const Selection &Inputs) {
+  return Result;
+}
+
+std::string SwapIfBranches::title() const { return "Swap if branches"; }
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -9,4 +9,5 @@
 # clangd/tool/CMakeLists.txt for an example.
 add_clang_library(clangDaemonTweaks OBJECT
   QualifyName.cpp
+  SwapIfBranches.cpp
   )
Index: clang-tools-extra/clangd/SourceCode.h
===

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

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

- Move to the monorepo


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

https://reviews.llvm.org/D56612

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

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

r351568 - [X86] Only define _XCR_XFEATURE_ENABLED_MASK in xsaveintrin.h when _MSC_VER is defined. Remove from intrin.h.

2019-01-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Jan 18 09:51:51 2019
New Revision: 351568

URL: http://llvm.org/viewvc/llvm-project?rev=351568&view=rev
Log:
[X86] Only define _XCR_XFEATURE_ENABLED_MASK in xsaveintrin.h when _MSC_VER is 
defined. Remove from intrin.h.

I think this was my intention when I added it xsaveintrin.h

Modified:
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xsaveintrin.h

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=351568&r1=351567&r2=351568&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Fri Jan 18 09:51:51 2019
@@ -200,7 +200,6 @@ __attribute__((__deprecated__("use other
 _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
-#define _XCR_XFEATURE_ENABLED_MASK 0
 
 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
 #ifdef __x86_64__

Modified: cfe/trunk/lib/Headers/xsaveintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xsaveintrin.h?rev=351568&r1=351567&r2=351568&view=diff
==
--- cfe/trunk/lib/Headers/xsaveintrin.h (original)
+++ cfe/trunk/lib/Headers/xsaveintrin.h Fri Jan 18 09:51:51 2019
@@ -28,7 +28,7 @@
 #ifndef __XSAVEINTRIN_H
 #define __XSAVEINTRIN_H
 
-#ifndef _MSC_VER
+#ifdef _MSC_VER
 #define _XCR_XFEATURE_ENABLED_MASK 0
 #endif
 


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


[PATCH] D56879: [Sema] Suppress a warning about a forward-declared fixed enum in C mode

2019-01-18 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 182548.
erik.pilkington marked an inline comment as done.
erik.pilkington added a comment.

Add a `-pedantic` RUN line.


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

https://reviews.llvm.org/D56879

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/fixed-enum.c


Index: clang/test/Sema/fixed-enum.c
===
--- clang/test/Sema/fixed-enum.c
+++ clang/test/Sema/fixed-enum.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -Weverything -xc++ -std=c++03 -DCXX03 -verify %s
 // RUN: %clang_cc1 -Weverything -xobjective-c -DOBJC -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
 
 enum X : int {e};
@@ -10,9 +11,29 @@
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
 #elif defined(OBJC)
-// expected-no-diagnostics
+// No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
 #elif defined(MS)
 // expected-warning@-10{{enumeration types with a fixed underlying type are a 
Microsoft extension}}
 #endif
+
+// Don't warn about the forward declaration in any language mode.
+enum Fwd : int;
+enum Fwd : int { e2 };
+#ifndef OBJC
+// expected-warning@-3 {{enumeration types with a fixed underlying type}}
+// expected-warning@-3 {{enumeration types with a fixed underlying type}}
+#endif
+
+// Always error on the incompatible redeclaration.
+enum BadFwd : int;
+#ifndef OBJC
+// expected-warning@-2 {{enumeration types with a fixed underlying type}}
+#endif
+// expected-note@-4 {{previous declaration is here}}
+enum BadFwd : char { e3 };
+#ifndef OBJC
+// expected-warning@-2 {{enumeration types with a fixed underlying type}}
+#endif
+// expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14743,8 +14743,7 @@
 // If this is an undefined enum, warn.
 if (TUK != TUK_Definition && !Invalid) {
   TagDecl *Def;
-  if (IsFixed && (getLangOpts().CPlusPlus11 || getLangOpts().ObjC) &&
-  cast(New)->isFixed()) {
+  if (IsFixed && cast(New)->isFixed()) {
 // C++0x: 7.2p2: opaque-enum-declaration.
 // Conflicts are diagnosed above. Do nothing.
   }


Index: clang/test/Sema/fixed-enum.c
===
--- clang/test/Sema/fixed-enum.c
+++ clang/test/Sema/fixed-enum.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -Weverything -xc++ -std=c++03 -DCXX03 -verify %s
 // RUN: %clang_cc1 -Weverything -xobjective-c -DOBJC -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
 
 enum X : int {e};
@@ -10,9 +11,29 @@
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a C++11 extension}}
 #elif defined(OBJC)
-// expected-no-diagnostics
+// No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a Clang extension}}
 #elif defined(MS)
 // expected-warning@-10{{enumeration types with a fixed underlying type are a Microsoft extension}}
 #endif
+
+// Don't warn about the forward declaration in any language mode.
+enum Fwd : int;
+enum Fwd : int { e2 };
+#ifndef OBJC
+// expected-warning@-3 {{enumeration types with a fixed underlying type}}
+// expected-warning@-3 {{enumeration types with a fixed underlying type}}
+#endif
+
+// Always error on the incompatible redeclaration.
+enum BadFwd : int;
+#ifndef OBJC
+// expected-warning@-2 {{enumeration types with a fixed underlying type}}
+#endif
+// expected-note@-4 {{previous declaration is here}}
+enum BadFwd : char { e3 };
+#ifndef OBJC
+// expected-warning@-2 {{enumeration types with a fixed underlying type}}
+#endif
+// expected-error@-4 {{enumeration redeclared with different underlying type 'char' (was 'int')}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14743,8 +14743,7 @@
 // If this is an undefined enum, warn.
 if (TUK != TUK_Definition && !Invalid) {
   TagDecl *Def;
-  if (IsFixed && (getLangOpts().CPlusPlus11 || getLangOpts().ObjC) &&
-  cast(New)->isFixed()) {
+  if (IsFixed && cast(New)->isFixed()) {
 // C++0x: 7.2p2: opaque-enum-declaration.
 // Conflicts are diagnosed above. Do nothing.
   }
___
cfe-commits ma

RE: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

2019-01-18 Thread Topper, Craig via cfe-commits
I just committed a change to go back to only definining 
_XCR_XFEATURE_ENABLED_MASK when clang is in MSVC compatibility mode. I don’t 
think I meant to define it outside of that since it doesn’t appear gcc does.

For the other two files, I assume you’re getting a collision of names similar 
to what Benjamin Kramer reported on V8?

From: Jordan Rupprecht [mailto:ruppre...@google.com]
Sent: Friday, January 18, 2019 9:30 AM
To: Topper, Craig 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on 
non-windows platforms"

Hi Craig,
We're seeing issues building a few other things now; notably this part in 
opencv: 
https://github.com/opencv/opencv/blob/master/modules/core/src/system.cpp#L422
#ifdef _XCR_XFEATURE_ENABLED_MASK // requires immintrin.h
xcr0 = (int)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
=> error: '__builtin_ia32_xgetbv' needs target feature xsave
We can workaround by building with -mavx... but we also have code running on 
non-avx machines that pull in this dependency. (It likely doesn't actually 
*use* the code, but still depends on it compiling as a transitive dep).
Is there a more accurate preprocessor macro (e.g. one that says if xsave is 
available) we could use to selectively disable this?

There are similar breakages here:
https://chromium.googlesource.com/aosp/platform/external/libchrome/+/master/base/cpu.cc#82
https://github.com/google/sling/blob/master/third_party/jit/cpu.cc#L58
Advice there too would be appreciated, if possible :)

On Wed, Jan 16, 2019 at 3:00 PM Craig Topper via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: ctopper
Date: Wed Jan 16 14:56:25 2019
New Revision: 351391

URL: http://llvm.org/viewvc/llvm-project?rev=351391&view=rev
Log:
Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

V8 has been fixed now.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xsaveintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/x86_32-xsave.c
cfe/trunk/test/CodeGen/x86_64-xsave.c
cfe/trunk/test/Headers/ms-intrin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351391&r1=351390&r2=351391&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jan 16 14:56:25 2019
@@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
 // XSAVE
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
+TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h", ALL_MS_LANGUAGES, 
"")
+TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
+TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
 TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
 TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351391&r1=351390&r2=351391&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jan 16 14:56:25 2019
@@ -9833,7 +9833,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_xsavec:
   case X86::BI__builtin_ia32_xsavec64:
   case X86::BI__builtin_ia32_xsaves:
-  case X86::BI__builtin_ia32_xsaves64: {
+  case X86::BI__builtin_ia32_xsaves64:
+  case X86::BI__builtin_ia32_xsetbv:
+  case X86::BI_xsetbv: {
 Intrinsic::ID ID;
 #define INTRINSIC_X86_XSAVE_ID(NAME) \
 case X86::BI__builtin_ia32_##NAME: \
@@ -9853,6 +9855,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 INTRINSIC_X86_XSAVE_ID(xsavec64);
 INTRINSIC_X86_XSAVE_ID(xsaves);
 INTRINSIC_X86_XSAVE_ID(xsaves64);
+INTRINSIC_X86_XSAVE_ID(xsetbv);
+case X86::BI_xsetbv:
+  ID = Intrinsic::x86_xsetbv;
+  break;
 }
 #undef INTRINSIC_X86_XSAVE_ID
 Value *Mhi = Builder.CreateTrunc(
@@ -9862,6 +9868,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops.push_back(Mlo);
 return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
   }
+  case X86::BI__builtin_ia32_xgetbv:
+  case X86::BI_xgetbv:
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);
   case X86::BI__builtin_ia32_storedqudi128_mask:
   case X86::BI__builtin_ia32_storedqusi128_mask:
   case X86::BI__builtin_ia32_storedquhi128_mask:

Modified: cfe/trunk/lib/Headers/immi

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

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Is this for something like `add const`? 
If yes, there is clang-tidy effort on that, see https://reviews.llvm.org/D54943 
and https://reviews.llvm.org/D54395 for a similar effort. Would be best to 
share the code instead of reinventing it :)


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

https://reviews.llvm.org/D56610



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


[PATCH] D56868: Add -fextern-visibility for -cc1

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

I'm sorry to keep jerking you around, but let's spell out the flag a bit more: 
`-fapply-global-visibility-to-externs`.  No reason not to be totally clear 
here.  Thank you for updating the fields and descriptions, those all look good 
now.


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

https://reviews.llvm.org/D56868



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


[PATCH] D54141: [clang-tidy] add deduplication support for run-clang-tidy.py

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

In D54141#1289980 , @hokein wrote:

> >> If you're suggesting proceeding with this regex based solution, I
> > 
> > don't think that's a good idea. Why commit a hack which people will object 
> > to ever removing? Just see if we can do the right thing instead.
>
> +1, my main concern is the complexity of the patch and maintenance burden of 
> the python script.


I think these are reasonable concerns and to a degree I share them. At the same 
time, I worry we may be leaving useful functionality behind in favor of 
functionality that doesn't exist and doesn't appear to be moving forward. If we 
were to move forward with this patch, nothing prevents us from surfacing it 
more naturally later when we have the infrastructure in place for the better 
solution, correct?

>> At the moment clang-apply-replacements is called at the end of an clang-tidy 
>> run in run-clang-tidy.py That means we produce ~GBs of Yaml first, to then 
>> emit ~10MBs worth of it.
> 
> That's why I suggest using some sort of other space-efficient formats to 
> store the fixes. My intuition is that the final deduplicated result shouldn't 
> be too large (even for YAML), because 1) no duplication 2) these are **actual 
> diagnostics** in code, a healthy codebase shouldn't contain lots of problem 
> 3) you have mentioned that you use it for small projects :)

Re: #2, I don't think that assertion is true in practice. I expect there are 
plenty of projects that contain a lot of clang-tidy diagnostics, especially 
given that clang-tidy checks tend to have higher false positive rates. Even if 
clang-tidy checks were not so chatty, "shouldn't" and "don't" are very 
different measurements.

I'm not suggesting to plow full-steam-ahead with this patch or that the 
concerns raised here are invalid, but at the same time, I think it does solve a 
real problem and it would be a shame to lose a workable solution because 
something better might be possible. If work is taking place to actually 
implement that something better, then that's a different matter of course. I 
get the impression though that "something better" is an extensive amount of 
work compared to what's in front of us; am I misunderstanding?

In D54141#1291509 , @JonasToth wrote:

> My opinion is, that we should put as much of the deduplication into 
> clang-tidy itself and not rely on tools like run-clang-tidy.py if we can.


Strong +1. TBH, I was unaware people used run-clang-tidy.py. ;-)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54141



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


[PATCH] D55868: [Fixed Point Arithmetic] Fixed Point Addition Constant Expression Evaluation

2019-01-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55868



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


[PATCH] D56918: [clang-tidy] add reproducer for PR39949 into test-suite

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

LGTM, thank you for the extra test coverage!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56918



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


[clang-tools-extra] r351569 - [clang-tidy] add reproducer for PR39949 into test-suite

2019-01-18 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Fri Jan 18 10:03:11 2019
New Revision: 351569

URL: http://llvm.org/viewvc/llvm-project?rev=351569&view=rev
Log:
[clang-tidy] add reproducer for PR39949 into test-suite

Summary:
The underlying issue is fixed in https://reviews.llvm.org/D56444
and this test ensures the issue does not creep back into our
code-base.

Reviewers: alexfh, aaron.ballman, hokein, hwright

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

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

Modified:

clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp?rev=351569&r1=351568&r2=351569&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp 
Fri Jan 18 10:03:11 2019
@@ -430,3 +430,36 @@ void factoryInMacros() {
   factoryTemplateAndMacro>();
   TemplateFactoryInMacro(ConvertibleTo());
 }
+
+// This is a reduced test-case for PR39949 and manifested in this check.
+namespace std {
+template 
+_Tp declval();
+
+template 
+struct __res {
+  template 
+  static decltype(declval<_Functor>()(_Args()...)) _S_test(int);
+
+  template 
+  static void _S_test(...);
+
+  typedef decltype(_S_test<_ArgTypes...>(0)) type;
+};
+
+template 
+struct function;
+
+template 
+struct function {
+  template ::type>
+  function(_Functor) {}
+};
+} // namespace std
+
+typedef std::function F;
+
+F foo() {
+  return F([] {});
+}


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


Re: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

2019-01-18 Thread Jordan Rupprecht via cfe-commits
Thanks! I'll rebuild clang from trunk and give it another try.
Yes, for the second two, I think it should be a more straightforward fix a
la https://chromium-review.googlesource.com/c/v8/v8/+/1414858

On Fri, Jan 18, 2019 at 9:58 AM Topper, Craig 
wrote:

> I just committed a change to go back to only definining 
> _XCR_XFEATURE_ENABLED_MASK
> when clang is in MSVC compatibility mode. I don’t think I meant to define
> it outside of that since it doesn’t appear gcc does.
>
>
>
> For the other two files, I assume you’re getting a collision of names
> similar to what Benjamin Kramer reported on V8?
>
>
>
> *From:* Jordan Rupprecht [mailto:ruppre...@google.com]
> *Sent:* Friday, January 18, 2019 9:30 AM
> *To:* Topper, Craig 
> *Cc:* cfe-commits@lists.llvm.org
> *Subject:* Re: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on
> non-windows platforms"
>
>
>
> Hi Craig,
>
> We're seeing issues building a few other things now; notably this part in
> opencv:
> https://github.com/opencv/opencv/blob/master/modules/core/src/system.cpp#L422
>
> #ifdef _XCR_XFEATURE_ENABLED_MASK // requires immintrin.h
>
> xcr0 = (int)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
>
> => error: '__builtin_ia32_xgetbv' needs target feature xsave
>
> We can workaround by building with -mavx... but we also have code running
> on non-avx machines that pull in this dependency. (It likely doesn't
> actually *use* the code, but still depends on it compiling as a transitive
> dep).
>
> Is there a more accurate preprocessor macro (e.g. one that says if xsave
> is available) we could use to selectively disable this?
>
>
>
> There are similar breakages here:
>
>
> https://chromium.googlesource.com/aosp/platform/external/libchrome/+/master/base/cpu.cc#82
>
> https://github.com/google/sling/blob/master/third_party/jit/cpu.cc#L58
>
> Advice there too would be appreciated, if possible :)
>
>
>
> On Wed, Jan 16, 2019 at 3:00 PM Craig Topper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ctopper
> Date: Wed Jan 16 14:56:25 2019
> New Revision: 351391
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351391&view=rev
> Log:
> Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"
>
> V8 has been fixed now.
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/immintrin.h
> cfe/trunk/lib/Headers/intrin.h
> cfe/trunk/lib/Headers/xsaveintrin.h
> cfe/trunk/test/CodeGen/builtins-x86.c
> cfe/trunk/test/CodeGen/x86_32-xsave.c
> cfe/trunk/test/CodeGen/x86_64-xsave.c
> cfe/trunk/test/Headers/ms-intrin.cpp
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351391&r1=351390&r2=351391&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jan 16 14:56:25 2019
> @@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
>  // XSAVE
>  TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
> +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
> +TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h",
> ALL_MS_LANGUAGES, "")
> +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
> +TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h",
> ALL_MS_LANGUAGES, "")
>  TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
>  TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
>  TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351391&r1=351390&r2=351391&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jan 16 14:56:25 2019
> @@ -9833,7 +9833,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>case X86::BI__builtin_ia32_xsavec:
>case X86::BI__builtin_ia32_xsavec64:
>case X86::BI__builtin_ia32_xsaves:
> -  case X86::BI__builtin_ia32_xsaves64: {
> +  case X86::BI__builtin_ia32_xsaves64:
> +  case X86::BI__builtin_ia32_xsetbv:
> +  case X86::BI_xsetbv: {
>  Intrinsic::ID ID;
>  #define INTRINSIC_X86_XSAVE_ID(NAME) \
>  case X86::BI__builtin_ia32_##NAME: \
> @@ -9853,6 +9855,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  INTRINSIC_X86_XSAVE_ID(xsavec64);
>  INTRINSIC_X86_XSAVE_ID(xsaves);
>  INTRINSIC_X86_XSAVE_ID(xsaves64);
> +INTRINSIC_X86_XSAVE_ID(xsetbv);
> +case X86::BI_xsetbv:
> +  ID = Intrinsic::x86_xsetbv;
> +  break;
>  }
>  #undef INTRINSIC_X86_XSAVE_ID
>  Value *Mhi = Builder

[PATCH] D56918: [clang-tidy] add reproducer for PR39949 into test-suite

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351569: [clang-tidy] add reproducer for PR39949 into 
test-suite (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56918

Files:
  
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -430,3 +430,36 @@
   factoryTemplateAndMacro>();
   TemplateFactoryInMacro(ConvertibleTo());
 }
+
+// This is a reduced test-case for PR39949 and manifested in this check.
+namespace std {
+template 
+_Tp declval();
+
+template 
+struct __res {
+  template 
+  static decltype(declval<_Functor>()(_Args()...)) _S_test(int);
+
+  template 
+  static void _S_test(...);
+
+  typedef decltype(_S_test<_ArgTypes...>(0)) type;
+};
+
+template 
+struct function;
+
+template 
+struct function {
+  template ::type>
+  function(_Functor) {}
+};
+} // namespace std
+
+typedef std::function F;
+
+F foo() {
+  return F([] {});
+}


Index: clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -430,3 +430,36 @@
   factoryTemplateAndMacro>();
   TemplateFactoryInMacro(ConvertibleTo());
 }
+
+// This is a reduced test-case for PR39949 and manifested in this check.
+namespace std {
+template 
+_Tp declval();
+
+template 
+struct __res {
+  template 
+  static decltype(declval<_Functor>()(_Args()...)) _S_test(int);
+
+  template 
+  static void _S_test(...);
+
+  typedef decltype(_S_test<_ArgTypes...>(0)) type;
+};
+
+template 
+struct function;
+
+template 
+struct function {
+  template ::type>
+  function(_Functor) {}
+};
+} // namespace std
+
+typedef std::function F;
+
+F foo() {
+  return F([] {});
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

2019-01-18 Thread Jordan Rupprecht via cfe-commits
Confirmed that opencv builds now, thanks :)

On Fri, Jan 18, 2019 at 10:05 AM Jordan Rupprecht 
wrote:

> Thanks! I'll rebuild clang from trunk and give it another try.
> Yes, for the second two, I think it should be a more straightforward fix a
> la https://chromium-review.googlesource.com/c/v8/v8/+/1414858
>
> On Fri, Jan 18, 2019 at 9:58 AM Topper, Craig 
> wrote:
>
>> I just committed a change to go back to only definining 
>> _XCR_XFEATURE_ENABLED_MASK
>> when clang is in MSVC compatibility mode. I don’t think I meant to define
>> it outside of that since it doesn’t appear gcc does.
>>
>>
>>
>> For the other two files, I assume you’re getting a collision of names
>> similar to what Benjamin Kramer reported on V8?
>>
>>
>>
>> *From:* Jordan Rupprecht [mailto:ruppre...@google.com]
>> *Sent:* Friday, January 18, 2019 9:30 AM
>> *To:* Topper, Craig 
>> *Cc:* cfe-commits@lists.llvm.org
>> *Subject:* Re: r351391 - Recommit r351160 "[X86] Make _xgetbv/_xsetbv on
>> non-windows platforms"
>>
>>
>>
>> Hi Craig,
>>
>> We're seeing issues building a few other things now; notably this part in
>> opencv:
>> https://github.com/opencv/opencv/blob/master/modules/core/src/system.cpp#L422
>>
>> #ifdef _XCR_XFEATURE_ENABLED_MASK // requires immintrin.h
>>
>> xcr0 = (int)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
>>
>> => error: '__builtin_ia32_xgetbv' needs target feature xsave
>>
>> We can workaround by building with -mavx... but we also have code running
>> on non-avx machines that pull in this dependency. (It likely doesn't
>> actually *use* the code, but still depends on it compiling as a transitive
>> dep).
>>
>> Is there a more accurate preprocessor macro (e.g. one that says if xsave
>> is available) we could use to selectively disable this?
>>
>>
>>
>> There are similar breakages here:
>>
>>
>> https://chromium.googlesource.com/aosp/platform/external/libchrome/+/master/base/cpu.cc#82
>>
>> https://github.com/google/sling/blob/master/third_party/jit/cpu.cc#L58
>>
>> Advice there too would be appreciated, if possible :)
>>
>>
>>
>> On Wed, Jan 16, 2019 at 3:00 PM Craig Topper via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: ctopper
>> Date: Wed Jan 16 14:56:25 2019
>> New Revision: 351391
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=351391&view=rev
>> Log:
>> Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"
>>
>> V8 has been fixed now.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> cfe/trunk/lib/Headers/immintrin.h
>> cfe/trunk/lib/Headers/intrin.h
>> cfe/trunk/lib/Headers/xsaveintrin.h
>> cfe/trunk/test/CodeGen/builtins-x86.c
>> cfe/trunk/test/CodeGen/x86_32-xsave.c
>> cfe/trunk/test/CodeGen/x86_64-xsave.c
>> cfe/trunk/test/Headers/ms-intrin.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351391&r1=351390&r2=351391&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jan 16 14:56:25 2019
>> @@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
>>  // XSAVE
>>  TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
>>  TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
>> +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
>> +TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h",
>> ALL_MS_LANGUAGES, "")
>> +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
>> +TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h",
>> ALL_MS_LANGUAGES, "")
>>  TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
>>  TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
>>  TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")
>>
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351391&r1=351390&r2=351391&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jan 16 14:56:25 2019
>> @@ -9833,7 +9833,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>>case X86::BI__builtin_ia32_xsavec:
>>case X86::BI__builtin_ia32_xsavec64:
>>case X86::BI__builtin_ia32_xsaves:
>> -  case X86::BI__builtin_ia32_xsaves64: {
>> +  case X86::BI__builtin_ia32_xsaves64:
>> +  case X86::BI__builtin_ia32_xsetbv:
>> +  case X86::BI_xsetbv: {
>>  Intrinsic::ID ID;
>>  #define INTRINSIC_X86_XSAVE_ID(NAME) \
>>  case X86::BI__builtin_ia32_##NAME: \
>> @@ -9853,6 +9855,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>>  INTRINSIC_X86_XSAVE_ID(xsavec64);
>>  INTRINSIC_X86_XSAVE_ID(xsa

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

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

- Add tests.


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

https://reviews.llvm.org/D56611

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

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

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

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

In D56610#1363408 , @JonasToth wrote:

> Is this for something like `add const`? 
>  If yes, there is clang-tidy effort on that, see 
> https://reviews.llvm.org/D54943 and https://reviews.llvm.org/D54395 for a 
> similar effort. Would be best to share the code instead of reinventing it :)


No, this action is not about adding a type qualifier (like `const` or 
`volatile`), it adds a namespace qualifier, e.g.

  using namespace std;
  
  vector foo; // --> std::vector foo;

Moreover, it's just an example to illustrate how one could write a simple 
action like that in clangd.


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

https://reviews.llvm.org/D56610



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


[PATCH] D56733: [OPENMP] update release note for implemented OMP 5.0 features

2019-01-18 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 marked 2 inline comments as done.
kkwli0 added inline comments.



Comment at: docs/OpenMPSupport.rst:62
+  
+- Simplified code generation for distribute and parallel in SPMD mode.
+

gtbercea wrote:
> Simplified SPMD code generation for `distribute parallel for` when the new 
> default schedules are applicable.
Will update the sentence.


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

https://reviews.llvm.org/D56733



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


[PATCH] D56733: [OPENMP] update release note for implemented OMP 5.0 features

2019-01-18 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 updated this revision to Diff 182556.
kkwli0 marked an inline comment as done.
kkwli0 added a comment.

Addressed reviewer's comment.


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

https://reviews.llvm.org/D56733

Files:
  docs/OpenMPSupport.rst
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -133,7 +133,36 @@
 OpenMP Support in Clang
 --
 
-- ...
+- OpenMP 5.0 features
+
+  - Support relational-op != (not-equal) as one of the canonical forms of random
+access iterator.
+  - Added support for mapping of the lambdas in target regions.
+  - Added parsing/sema analysis for the requires directive.
+  - Support nested declare target directives.
+  - Make the `this` pointer implicitly mapped as `map(this[:1])`.
+  - Added the `close` *map-type-modifier*.
+
+- Various bugfixes and improvements.
+
+New features supported for Cuda devices:
+
+- Added support for the reductions across the teams.
+
+- Extended number of constructs that can be executed in SPMD mode.
+
+- Fixed support for lastprivate/reduction variables in SPMD constructs.
+
+- New collapse clause scheme to avoid expensive remainder operations.
+
+- New default schedule for distribute and parallel constructs.
+
+- Simplified code generation for distribute and parallel in SPMD mode.
+
+- Flag (``-fopenmp_optimistic_collapse``) for user to limit collapsed
+  loop counter width when safe to do so.
+
+- General performance improvement.
 
 CUDA Support in Clang
 -
Index: docs/OpenMPSupport.rst
===
--- docs/OpenMPSupport.rst
+++ docs/OpenMPSupport.rst
@@ -17,60 +17,50 @@
 OpenMP Support
 ==
 
-Clang fully supports OpenMP 4.5. Clang supports offloading to X86_64, AArch64,
-PPC64[LE] and has `basic support for Cuda devices`_.
-
-Standalone directives
-=
-
-* #pragma omp [for] simd: :good:`Complete`.
-
-* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
-  analysis + generation of special attributes for X86 target, but still
-  missing the LLVM pass for vectorization.
-
-* #pragma omp taskloop [simd]: :good:`Complete`.
-
-* #pragma omp target [enter|exit] data: :good:`Complete`.
-
-* #pragma omp target update: :good:`Complete`.
-
-* #pragma omp target: :good:`Complete`.
+Clang supports the following OpenMP 5.0 features
 
-* #pragma omp declare target: :good:`Complete`.
+* The `reduction`-based clauses in the `task` and `target`-based directives.
 
-* #pragma omp teams: :good:`Complete`.
+* Support relational-op != (not-equal) as one of the canonical forms of random
+  access iterator.
 
-* #pragma omp distribute [simd]: :good:`Complete`.
+* Support for mapping of the lambdas in target regions.
 
-* #pragma omp distribute parallel for [simd]: :good:`Complete`.
+* Parsing/sema analysis for the requires directive.
 
-Combined directives
-===
+* Nested declare target directives.
 
-* #pragma omp parallel for simd: :good:`Complete`.
+* Make the `this` pointer implicitly mapped as `map(this[:1])`.
 
-* #pragma omp target parallel: :good:`Complete`.
+* The `close` *map-type-modifier*.
 
-* #pragma omp target parallel for [simd]: :good:`Complete`.
-
-* #pragma omp target simd: :good:`Complete`.
-
-* #pragma omp target teams: :good:`Complete`.
-
-* #pragma omp teams distribute [simd]: :good:`Complete`.
-
-* #pragma omp target teams distribute [simd]: :good:`Complete`.
-
-* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
-
-* #pragma omp target teams distribute parallel for [simd]: :good:`Complete`.
+Clang fully supports OpenMP 4.5. Clang supports offloading to X86_64, AArch64,
+PPC64[LE] and has `basic support for Cuda devices`_.
 
-Clang does not support any constructs/updates from OpenMP 5.0 except
-for `reduction`-based clauses in the `task` and `target`-based directives.
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
 
 In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools
-Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS.
+Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS.
+
+General improvements
+
+- New collapse clause scheme to avoid expensive remainder operations.
+  Compute loop index variables after collapsing a loop nest via the
+  collapse clause by replacing the expensive remainder operation with
+  multiplications and additions.
+
+- The default schedules for the `distribute` and `for` constructs in a
+  parallel region and in SPMD mode have changed to ensure coalesced
+  accesses. For the `distribute` construct, a static schedule is used
+ 

[PATCH] D56916: Fix crash due to ObjCPropertyDecl

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

Thanks for fixing this.
Quick LGTM to fix a crash, albeit a fews NITs.




Comment at: clangd/index/SymbolCollector.cpp:372
 
+  // ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.

Could you please leave a FIXME mentioning objc properties are not indexed 
properly here?



Comment at: clangd/index/SymbolCollector.cpp:374
+  // not a NamedDecl.
+  if (!isa(ASTNode.OrigD))
+return true;

Maybe use `llvm_dyn_cast` and check for null? (To avoid double-cast)



Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916



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


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

2019-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
+void AdjustArguments(tooling::CompileCommand &Cmd,
+ const std::string &ResourceDir) {
+  // Strip plugin related command line arguments. Clangd does

kadircet wrote:
> ilya-biryukov wrote:
> > NIT: use `StringRef`
> Need a string for the concatenation below, when pushing to vector. Otherwise 
> we get a Twine
Why not call `.str()` on a Twine?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56841



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


[PATCH] D56868: Add -fapply-global-visibility-to-externs for -cc1

2019-01-18 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 182559.
scott.linder retitled this revision from "Add -fextern-visibility for -cc1" to 
"Add -fapply-global-visibility-to-externs for -cc1".
scott.linder added a comment.

No worries, I agree that we don't gain much with a shorter flag here; explicit 
seems preferable.


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

https://reviews.llvm.org/D56868

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChains/AMDGPU.cpp
  lib/Driver/ToolChains/HIP.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/set-visibility-for-decls.c
  test/Driver/amdgpu-visibility.cl
  test/Driver/hip-toolchain-no-rdc.hip
  test/Driver/hip-toolchain-rdc.hip

Index: test/Driver/hip-toolchain-rdc.hip
===
--- test/Driver/hip-toolchain-rdc.hip
+++ test/Driver/hip-toolchain-rdc.hip
@@ -12,10 +12,11 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s
 
-// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden"
+// CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
@@ -23,6 +24,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fvisibility" "hidden"
+// CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
Index: test/Driver/hip-toolchain-no-rdc.hip
===
--- test/Driver/hip-toolchain-no-rdc.hip
+++ test/Driver/hip-toolchain-no-rdc.hip
@@ -20,6 +20,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
@@ -47,6 +48,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
@@ -89,6 +91,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: {{.*}} "-o" [[B_BC_803:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
@@ -116,6 +119,7 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: {{.*}} "-o" [[B_BC_900:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC]]
 
Index: test/Driver/amdgpu-visibility.cl
===
--- test/Driver/amdgpu-visibility.cl
+++ test/Driver/amdgpu-visibility.cl
@@ -2,6 +2,14 @@
 // RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm -fvisibility=protected  %s 2>&1 | FileCheck -check-prefix=OVERRIDE-PROTECTED  %s
 // RUN: %clang -### -target amdgcn-amd-amdhsa -x cl -c -emit-llvm -fvisibility-ms-compat  %s 2>&1 | FileCheck -check-prefix=OVERRIDE-MS  %s
 
-// DEFAULT: "-fvisibility" "hidden"
+// DEFAULT-DAG: "-fvisibility" "hidden"
+// DEFAULT-DAG: "-fapply-global-visibility-to-externs"
+
+// OVERRIDE-PROTECTED-NOT: "-fapply-global-visibility-to-externs"
 // OVERRIDE-PROTECTED: "-fvisibility" "protected"
-// OVERRIDE-MS:  "-fvisibility" "hidden" "-ftype-visibility" "default"
+// OVERRIDE-PROTECTED-NOT: "-fapply-global-visibility-to-externs"
+
+// OVERRIDE-MS-NOT: "-fapply-global-visibility-to-externs"
+// OVERRIDE-MS-DAG: "-fvisibility" "hidden"
+// OVERRIDE-MS-DAG: "-ftype-visibility" "default"
+// OVERRIDE-MS-NOT: "-fapply-global-visibility-to-externs"
Index: test/CodeGen/set-visibility-for-decls.c
===
--- /dev/null
+++ test/CodeGen/set-visibility-for-decls.c
@@ -0,0 +1,42 @@

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

2019-01-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D56610#1363461 , @ilya-biryukov 
wrote:

> In D56610#1363408 , @JonasToth wrote:
>
> > Is this for something like `add const`? 
> >  If yes, there is clang-tidy effort on that, see 
> > https://reviews.llvm.org/D54943 and https://reviews.llvm.org/D54395 for a 
> > similar effort. Would be best to share the code instead of reinventing it :)
>
>
> No, this action is not about adding a type qualifier (like `const` or 
> `volatile`), it adds a namespace qualifier, e.g.
>
>   using namespace std;
>  
>   vector foo; // --> std::vector foo;
>
>
> Moreover, it's just an example to illustrate how one could write a simple 
> action like that in clangd.


I see, nvmd then :)


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

https://reviews.llvm.org/D56610



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


[PATCH] D56871: [AMDGPU] Require at least protected visibility for certain symbols

2019-01-18 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 182561.
scott.linder added a comment.

Update option name


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

https://reviews.llvm.org/D56871

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/visibility.cl

Index: test/CodeGenOpenCL/visibility.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/visibility.cl
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility default -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-DEFAULT %s
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility protected -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-PROTECTED %s
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility hidden -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-HIDDEN %s
+
+// REQUIRES: amdgpu-registered-target
+
+// FVIS-DEFAULT:  @glob = local_unnamed_addr
+// FVIS-PROTECTED: @glob = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob = hidden local_unnamed_addr
+int glob = 0;
+// FVIS-DEFAULT:  @glob_hidden = hidden local_unnamed_addr
+// FVIS-PROTECTED: @glob_hidden = hidden local_unnamed_addr
+// FVIS-HIDDEN: @glob_hidden = hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) int glob_hidden = 0;
+// FVIS-DEFAULT:  @glob_protected = protected local_unnamed_addr
+// FVIS-PROTECTED: @glob_protected = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob_protected = protected local_unnamed_addr
+__attribute__((visibility("protected"))) int glob_protected = 0;
+// FVIS-DEFAULT:  @glob_default = local_unnamed_addr
+// FVIS-PROTECTED: @glob_default = local_unnamed_addr
+// FVIS-HIDDEN: @glob_default = local_unnamed_addr
+__attribute__((visibility("default"))) int glob_default = 0;
+
+// FVIS-DEFAULT:  @ext = external local_unnamed_addr
+// FVIS-PROTECTED: @ext = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext = external hidden local_unnamed_addr
+extern int ext;
+// FVIS-DEFAULT:  @ext_hidden = external hidden local_unnamed_addr
+// FVIS-PROTECTED: @ext_hidden = external hidden local_unnamed_addr
+// FVIS-HIDDEN: @ext_hidden = external hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) extern int ext_hidden;
+// FVIS-DEFAULT:  @ext_protected = external protected local_unnamed_addr
+// FVIS-PROTECTED: @ext_protected = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext_protected = external protected local_unnamed_addr
+__attribute__((visibility("protected"))) extern int ext_protected;
+// FVIS-DEFAULT:  @ext_default = external local_unnamed_addr
+// FVIS-PROTECTED: @ext_default = external local_unnamed_addr
+// FVIS-HIDDEN: @ext_default = external local_unnamed_addr
+__attribute__((visibility("default"))) extern int ext_default;
+
+// FVIS-DEFAULT: define amdgpu_kernel void @kern()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern()
+kernel void kern() {}
+// FVIS-DEFAULT: define protected amdgpu_kernel void @kern_hidden()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern_hidden()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern_hidden()
+__attribute__((visibility("hidden"))) kernel void kern_hidden() {}
+// FVIS-DEFAULT: define protected amdgpu_kernel void @kern_protected()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern_protected()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern_protected()
+__attribute__((visibility("protected"))) kernel void kern_protected() {}
+// FVIS-DEFAULT: define amdgpu_kernel void @kern_default()
+// FVIS-PROTECTED: define amdgpu_kernel void @kern_default()
+// FVIS-HIDDEN: define amdgpu_kernel void @kern_default()
+__attribute__((visibility("default"))) kernel void kern_default() {}
+
+// FVIS-DEFAULT: define void @func()
+// FVIS-PROTECTED: define protected void @func()
+// FVIS-HIDDEN: define hidden void @func()
+void func() {}
+// FVIS-DEFAULT: define hidden void @func_hidden()
+// FVIS-PROTECTED: define hidden void @func_hidden()
+// FVIS-HIDDEN: define hidden void @func_hidden()
+__attribute__((visibility("hidden"))) void func_hidden() {}
+// FVIS-DEFAULT: define protected void @func_protected()
+// FVIS-PROTECTED: define protected void @func_protected()
+// FVIS-HIDDEN: define protected void @func_protected()
+__attribute__((visibility("protected"))) void func_protected() {}
+// FVIS-DEFAULT: define void @func_default()
+// FVIS-PROTECTED: define void @func_default()
+// FVIS-HIDDEN: define void @func_default()
+__attribute__((visibility("default"))) void func_default() {}
+
+void use() {
+glob = ext + ext_hidden + ext_protected + ext_default;
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/Co

[PATCH] D56733: [OPENMP] update release note for implemented OMP 5.0 features

2019-01-18 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea accepted this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

Thanks for the update!

LG


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

https://reviews.llvm.org/D56733



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


r351573 - [clang] Change to range-based invocation of llvm::sort

2019-01-18 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Fri Jan 18 10:45:26 2019
New Revision: 351573

URL: http://llvm.org/viewvc/llvm-project?rev=351573&view=rev
Log:
[clang] Change to range-based invocation of llvm::sort

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=351573&r1=351572&r2=351573&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan 18 10:45:26 2019
@@ -1868,7 +1868,7 @@ static void sortJavaImports(const Format
 JavaImportGroups.push_back(
 findJavaImportGroup(Style, Imports[i].Identifier));
   }
-  llvm::sort(Indices.begin(), Indices.end(), [&](unsigned LHSI, unsigned RHSI) 
{
+  llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
 // Negating IsStatic to push static imports above non-static imports.
 return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
Imports[LHSI].Identifier) <


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


[PATCH] D56852: [AArch64] Use LL for 64-bit arguments

2019-01-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: test/CodeGen/builtins-arm64.c:2
 // RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm 
-o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows -disable-O0-optnone -S -emit-llvm 
-o - %s | opt -S -mem2reg | FileCheck %s
+#include 

"-S" is redundant.


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

https://reviews.llvm.org/D56852



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


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

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

- FIXME and dyn_cast


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56916

Files:
  clangd/index/SymbolCollector.cpp


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


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


[PATCH] D56868: Add -fapply-global-visibility-to-externs for -cc1

2019-01-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, I appreciate you bearing with me on this.  LGTM.


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

https://reviews.llvm.org/D56868



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


[PATCH] D56905: [libunwind] [SjLj] Don't use __declspec(thread) in MinGW mode

2019-01-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D56905



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


[PATCH] D56879: [Sema] Suppress a warning about a forward-declared fixed enum in C mode

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

LGTM!




Comment at: clang/test/Sema/fixed-enum.c:4
 // RUN: %clang_cc1 -Weverything -xobjective-c -DOBJC -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s

aaron.ballman wrote:
> Can you add a RUN line with `-pedantic` to ensure that we still warn on the 
> forward declare of the enum even when it's fixed?
This was meant to say "don't warn" but I see you figured that out. :-)


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

https://reviews.llvm.org/D56879



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


Re: r351514 - [analyzer] Introduce proper diagnostic for freeing unowned object

2019-01-18 Thread George Karpenkov via cfe-commits
OK thanks - I’ll fix it.

> On Jan 18, 2019, at 12:47 AM, Vlad Tsyrklevich  wrote:
> 
> Hi, I've reverted r351508-351514 as they were causing MSan failures on the 
> sanitizer bots. It looks like isLeak is not initialized by one of the 
> RefCountReport constructors and it is not immediately obvious to me what an 
> appropriate value for it is. You can observe the failures here 
> ,
>  they look like the following:
> FAIL: Clang :: Analysis/inlining/path-notes.m (525 of 13800)
>  TEST 'Clang :: Analysis/inlining/path-notes.m' FAILED 
> 
> Script:
> --
> : 'RUN: at line 1';   
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang -cc1 
> -internal-isystem 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
>  -nostdsysteminc -analyze -analyzer-constraints=range 
> -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount 
> -analyzer-output=text -analyzer-config suppress-null-return-paths=false 
> -fblocks -verify 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/path-notes.m
> : 'RUN: at line 2';   
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang -cc1 
> -internal-isystem 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
>  -nostdsysteminc -analyze -analyzer-constraints=range 
> -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount 
> -analyzer-output=plist-multi-file -analyzer-config 
> suppress-null-return-paths=false -fblocks 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/path-notes.m
>  -o 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Analysis/inlining/Output/path-notes.m.tmp.plist
> : 'RUN: at line 3';   cat 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Analysis/inlining/Output/path-notes.m.tmp.plist
>  | diff -u -w -I "/" -I ".:" -I "version" 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.m.plist
>  -
> --
> Exit Code: 77
> 
> Command Output (stderr):
> --
> ==93612==WARNING: MemorySanitizer: use-of-uninitialized-value
> #0 0xa0635a8 in 
> clang::ento::retaincountchecker::RefCountReport::getRanges() 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h:65:9
> #1 0xa18bb67 in 
> clang::ento::BugReporterVisitor::getDefaultEndPath(clang::ento::BugReporterContext&,
>  clang::ento::ExplodedNode const*, clang::ento::BugReport&) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:176:27
> #2 0xa05cf02 in 
> clang::ento::retaincountchecker::RefCountReportVisitor::getEndPath(clang::ento::BugReporterContext&,
>  clang::ento::ExplodedNode const*, clang::ento::BugReport&) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:681:10
> #3 0xa15b9aa in generateVisitorsDiagnostics(clang::ento::BugReport*, 
> clang::ento::ExplodedNode const*, clang::ento::BugReporterContext&) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2564:29
> #4 0xa1429dc in findValidReport 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2621:9
> #5 0xa1429dc in 
> clang::ento::GRBugReporter::generatePathDiagnostics(llvm::ArrayRef,
>  llvm::ArrayRef&) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2670
> #6 0xa14f991 in 
> clang::ento::BugReporter::generateDiagnosticForConsumerMap(clang::ento::BugReport*,
>  llvm::ArrayRef, 
> llvm::ArrayRef) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3092:5
> #7 0xa13cbc1 in 
> clang::ento::BugReporter::FlushReport(clang::ento::BugReportEquivClass&) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2948:7
> #8 0xa13a171 in clang::ento::BugReporter::FlushReports() 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2254:5
> #9 0x99e9463 in RunPathSensitiveChecks 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:752:24
> #10 0x99e9463 in (anonymous 
> namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, 
> clang::ento::ExprEngine::InliningModes, llvm::DenseSet llvm::DenseMapInfo >*) 
> /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisCon

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

2019-01-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, LGTM.


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

https://reviews.llvm.org/D55850



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


r351575 - Revert "Fix failing MSan bots"

2019-01-18 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Jan 18 11:24:55 2019
New Revision: 351575

URL: http://llvm.org/viewvc/llvm-project?rev=351575&view=rev
Log:
Revert "Fix failing MSan bots"

This reverts commit 2cedaaef383d8d6142046074ffebc2bb5a914778.

Revert with a fix.

Added:
cfe/trunk/test/Analysis/os_object_base.h
cfe/trunk/test/Analysis/os_smart_ptr.h
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

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

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

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

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
cfe/trunk/test/Analysis/test-separate-retaincount.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=351575&r1=351574&r2=351575&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Fri 
Jan 18 11:24:55 2019
@@ -95,7 +95,7 @@ protected:
   friend class BugReportEquivClass;
   friend class BugReporter;
 
-  BugType& BT;
+  const BugType& BT;
   const Decl *DeclWithIssue = nullptr;
   std::string ShortDescription;
   std::string Description;
@@ -164,15 +164,15 @@ private:
   void popInterestingSymbolsAndRegions();
 
 public:
-  BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode)
+  BugReport(const BugType& bt, StringRef desc, const ExplodedNode *errornode)
   : BT(bt), Description(desc), ErrorNode(errornode) {}
 
-  BugReport(BugType& bt, StringRef shortDesc, StringRef desc,
+  BugReport(const BugType& bt, StringRef shortDesc, StringRef desc,
 const ExplodedNode *errornode)
   : BT(bt), ShortDescription(shortDesc), Description(desc),
 ErrorNode(errornode) {}
 
-  BugReport(BugType &bt, StringRef desc, PathDiagnosticLocation l)
+  BugReport(const BugType &bt, StringRef desc, PathDiagnosticLocation l)
   : BT(bt), Description(desc), Location(l) {}
 
   /// Create a BugReport with a custom uniqueing location.
@@ -190,7 +190,7 @@ public:
   virtual ~BugReport();
 
   const BugType& getBugType() const { return BT; }
-  BugType& getBugType() { return BT; }
+  //BugType& getBugType() { return BT; }
 
   /// True when the report has an execution path associated with it.
   ///
@@ -481,7 +481,7 @@ public:
 return {};
   }
 
-  void Register(BugType *BT);
+  void Register(const BugType *BT);
 
   /// Add the given report to the set of reports tracked by BugReporter.
   ///

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h?rev=351575&r1=351574&r2=351575&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h Fri Jan 
18 11:24:55 2019
@@ -38,12 +38,14 @@ private:
   virtual void anchor();
 
 public:
-  BugType(CheckName Check, StringRef Name, StringRef Cat)
+  BugType(CheckName Check, StringRef Name, StringRef Cat,
+  bool SuppressOnSink=false)
   : Check(Check), Name(Name), Category(Cat), Checker(nullptr),
-SuppressOnSink(false) {}
-  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
+SuppressOnSink(SuppressOnSink) {}
+  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat,
+  bool SuppressOnSink=false)
   : Check(Checker->getCheckName()), Name(Name), Category(Cat),
-Checker(Checker), SuppressOnSink(false) {}
+Checker(Checker), SuppressOnSink(SuppressOnSink) {}
   virtual ~BugType() = default;
 
   StringRef getName() const { return Name; }
@@ -64,7 +66,6 @@ public:
   ///  type should be suppressed if the end node of the report is 
post-dominated
   ///  by a sink node.
   bool isSuppressOnS

[PATCH] D56924: Handle ObjCCategoryDecl class extensions for print

2019-01-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
Herald added a subscriber: cfe-commits.

Since class extensions do not have a name, (class extension) is
used instead.


Repository:
  rC Clang

https://reviews.llvm.org/D56924

Files:
  lib/AST/Decl.cpp


Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1605,6 +1605,11 @@
 OS << *ED;
   else
 continue;
+} else if (const auto *CD = dyn_cast(DC)) {
+  if (CD->IsClassExtension())
+ OS << "(class extension)";
+  else
+OS << *CD;
 } else {
   OS << *cast(DC);
 }


Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1605,6 +1605,11 @@
 OS << *ED;
   else
 continue;
+} else if (const auto *CD = dyn_cast(DC)) {
+  if (CD->IsClassExtension())
+ OS << "(class extension)";
+  else
+OS << *CD;
 } else {
   OS << *cast(DC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351576 - [NFC] Fix wParentheses warning in ASTContext getFixedPointSemantics

2019-01-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jan 18 11:31:54 2019
New Revision: 351576

URL: http://llvm.org/viewvc/llvm-project?rev=351576&view=rev
Log:
[NFC] Fix wParentheses warning in ASTContext getFixedPointSemantics

Change-Id: I862f00a548236872fe24f7da8eb2bf7917e123ff

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

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=351576&r1=351575&r2=351576&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jan 18 11:31:54 2019
@@ -10485,9 +10485,9 @@ unsigned char ASTContext::getFixedPointI
 }
 
 FixedPointSemantics ASTContext::getFixedPointSemantics(QualType Ty) const {
-  assert(Ty->isFixedPointType() ||
- Ty->isIntegerType() && "Can only get the fixed point semantics for a "
-"fixed point or integer type.");
+  assert((Ty->isFixedPointType() || Ty->isIntegerType()) &&
+ "Can only get the fixed point semantics for a "
+ "fixed point or integer type.");
   if (Ty->isIntegerType())
 return FixedPointSemantics::GetIntegerSemantics(getIntWidth(Ty),
 Ty->isSignedIntegerType());


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


  1   2   >