[PATCH] D40065: [libcxx] [test] Change (void)s to TEST_IGNORE_NODISCARD as requested by Eric.

2017-11-15 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal created this revision.

Added the TEST_IGNORE_NODISCARD macro to `test_macros.h`.
grep test/std for (void) casts that look like they're suppressing [[nodiscard]] 
and change them to TEST_IGNORE_NODISCARD.


https://reviews.llvm.org/D40065

Files:
  test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp
  test/std/containers/associative/map/map.access/at.pass.cpp
  test/std/containers/associative/map/map.ops/count1.fail.cpp
  test/std/containers/associative/map/map.ops/count2.fail.cpp
  test/std/containers/associative/map/map.ops/count3.fail.cpp
  test/std/containers/associative/map/map.ops/equal_range1.fail.cpp
  test/std/containers/associative/map/map.ops/equal_range2.fail.cpp
  test/std/containers/associative/map/map.ops/equal_range3.fail.cpp
  test/std/containers/associative/map/map.ops/find1.fail.cpp
  test/std/containers/associative/map/map.ops/find2.fail.cpp
  test/std/containers/associative/map/map.ops/find3.fail.cpp
  test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp
  test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp
  test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp
  test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp
  test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp
  test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp
  test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
  
test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/types.pass.cpp
  
test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/types.pass.cpp
  test/std/iterators/iterator.range/begin-end.fail.cpp
  test/std/iterators/iterators.general/gcc_workaround.pass.cpp
  
test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
  test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
  test/std/re/re.alg/re.alg.search/grep.pass.cpp
  test/std/re/re.grammar/excessive_brace_count.pass.cpp
  test/std/strings/basic.string/string.access/at.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
  test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp
  test/std/utilities/any/any.nonmembers/make_any.pass.cpp
  
test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
  
test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp
  test/std/utilities/tu

[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

ABataev wrote:
> Hahnfeld wrote:
> > rjmccall wrote:
> > > Hahnfeld wrote:
> > > > rjmccall wrote:
> > > > > Hahnfeld wrote:
> > > > > > rjmccall wrote:
> > > > > > > ABataev wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > The way you've written this makes it sound like 
> > > > > > > > > > > > > > > "does the target support VLAs?", but the actual 
> > > > > > > > > > > > > > > semantic checks treat it as "do OpenMP devices on 
> > > > > > > > > > > > > > > this target support VLAs?"  Maybe there should be 
> > > > > > > > > > > > > > > a more specific way to query things about OpenMP 
> > > > > > > > > > > > > > > devices instead of setting a global flag for the 
> > > > > > > > > > > > > > > target?
> > > > > > > > > > > > > > Actually, the NVPTX and SPIR targets never support 
> > > > > > > > > > > > > > VLAs. So I felt like it would be more correct to 
> > > > > > > > > > > > > > make this a global property of the target.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > The difference is that the other programming models 
> > > > > > > > > > > > > > (OpenCL and CUDA) error out immediatelyand 
> > > > > > > > > > > > > > regardless of the target because this limitation is 
> > > > > > > > > > > > > > reflected in the standards that disallow VLAs (see 
> > > > > > > > > > > > > > SemaType.cpp). For OpenMP we might have target 
> > > > > > > > > > > > > > devices that support VLA so we shouldn't error out 
> > > > > > > > > > > > > > for those.
> > > > > > > > > > > > > If you want to make it a global property of the 
> > > > > > > > > > > > > target, that's fine, but then I don't understand why 
> > > > > > > > > > > > > your diagnostic only fires when 
> > > > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > > > That is because of how OpenMP offloading works and how 
> > > > > > > > > > > > it is implemented in Clang. Consider the following 
> > > > > > > > > > > > snippet from the added test case:
> > > > > > > > > > > > ```lang=c
> > > > > > > > > > > > int vla[arg];
> > > > > > > > > > > > 
> > > > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > > > {
> > > > > > > > > > > >// more code here...
> > > > > > > > > > > > }
> > > > > > > > > > > > ```
> > > > > > > > > > > > 
> > > > > > > > > > > > Clang will take the following steps to compile this 
> > > > > > > > > > > > into a working binary for a GPU:
> > > > > > > > > > > > 1. Parse and (semantically) analyze the code as-is for 
> > > > > > > > > > > > the host and produce LLVM Bitcode.
> > > > > > > > > > > > 2. Parse and analyze again the code as-is and generate 
> > > > > > > > > > > > code for the offloading target, the GPU in this case.
> > > > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary and 
> > > > > > > > > > > > embed target binary from 3.
> > > > > > > > > > > > 
> > > > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the complete 
> > > > > > > > > > > > source code is analyzed. So to not throw errors for the 
> > > > > > > > > > > > host code, we have to make sure that we are actually 
> > > > > > > > > > > > generating code for the target device. This is either 
> > > > > > > > > > > > in a `target` directive or in a `declare target` region.
> > > > > > > > > > > > Note that this is quite similar to what CUDA does, only 
> > > > > > > > > > > > they have `CUDADiagIfDeviceCode` for this logic. If you 
> > > > > > > > > > > > want me to add something of that kind for OpenMP target 
> > > > > > > > > > > > devices, I'm fine with that. However for the given 
> > > > > > > > > > > > case, it's a bit different because this error should 
> > > > > > > > > > > > only be thrown for target devices that don't support 
> > > > > > > > > > > > VLAs...
> > > > > > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > > > > > re-Sema'ed from scratch for the target?  Which means you 
> > > > > > > > > > > need to avoid generating errors about things in the outer 
> > > > > > > > > > > translation unit that aren't part of the target directive 
> > > > > > > > > > > that you actually want to compile.  I would've expected 
> > > > > > > > > > > there to be some existing mechanism for that, to be 
> > > > > > > > > > > honest, as opposed to explicitly trying to suppress 
> > > > > > > > > > > target-specific diagnostics one by one.
> > > > > > > > > > Yes, that is my understanding. For

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

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

LGTM with a few nits, I'd like to see whether @benhamilton has comments before 
committing it.




Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:4
+google-objc-avoid-throwing-exception
+===
+

nit: remove the extra  `===`



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:10
+The corresponding style guide rule:
+http://go/objc-style#Avoid_Throwing_Exceptions

Use the public link: 
http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions



Comment at: test/clang-tidy/google-objc-avoid-throwing-exception.m:11
+@end
+

nit: remove the empty line.


https://reviews.llvm.org/D40058



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


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 122986.
sammccall added a comment.

Trim memory usage and add comments.


https://reviews.llvm.org/D40060

Files:
  clangd/CMakeLists.txt
  clangd/FuzzyMatch.cpp
  clangd/FuzzyMatch.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FuzzyMatchTests.cpp

Index: unittests/clangd/FuzzyMatchTests.cpp
===
--- /dev/null
+++ unittests/clangd/FuzzyMatchTests.cpp
@@ -0,0 +1,130 @@
+//===-- FuzzyMatchTests.cpp - String fuzzy matcher tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using namespace llvm;
+using testing::Not;
+
+struct MatchesMatcher : public testing::MatcherInterface {
+  StringRef Candidate;
+  MatchesMatcher(StringRef Candidate) : Candidate(Candidate) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+*OS << "Matches '" << Candidate.str() << "'";
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+auto Result = Matcher.match(Candidate);
+Matcher.dumpLast(*OS << "\n");
+return !!Result;
+  }
+};
+
+// Accepts patterns that match a given word.
+// Dumps the debug tables on match failure.
+testing::Matcher matches(StringRef Word) {
+  return testing::MakeMatcher(new MatchesMatcher(Word));
+}
+
+TEST(FuzzyMatch, Matches) {
+  EXPECT_THAT("u_p", matches("unique_ptr"));
+  EXPECT_THAT("up", matches("unique_ptr"));
+  EXPECT_THAT("uq", matches("unique_ptr"));
+  EXPECT_THAT("qp", Not(matches("unique_ptr")));
+  EXPECT_THAT("log", Not(matches("SVGFEMorphologyElement")));
+}
+
+struct RankMatcher : public testing::MatcherInterface {
+  std::vector RankedStrings;
+  RankMatcher(std::initializer_list RankedStrings)
+  : RankedStrings(RankedStrings) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+*OS << "Ranks strings in order: ["
+<< join(RankedStrings.begin(), RankedStrings.end(), ", ") << "]";
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+StringRef LastString;
+Optional LastScore;
+bool Ok = true;
+for (StringRef Str : RankedStrings) {
+  auto Score = Matcher.match(Str);
+  if (!Score) {
+*OS << "\nDoesn't match '" << Str.str() << "'";
+Matcher.dumpLast(*OS << "\n");
+Ok = false;
+  } else if (LastScore && *LastScore < *Score) {
+*OS << "\nRanks '" << Str.str() << "'=" << *Score << " above '"
+<< LastString.str() << "'=" << *LastScore;
+Matcher.dumpLast(*OS << "\n");
+Matcher.match(LastString);
+Matcher.dumpLast(*OS << "\n");
+Ok = false;
+  }
+  LastString = Str;
+  LastScore = Score;
+}
+return Ok;
+  }
+};
+
+// Accepts patterns that match all the strings and rank them in the given order.
+// Dumps the debug tables on match failure.
+template  testing::Matcher ranks(T... RankedStrings) {
+  return testing::MakeMatcher(new RankMatcher{RankedStrings...});
+}
+
+TEST(FuzzyMatch, Ranking) {
+  EXPECT_THAT("eb", ranks("emplace_back", "embed"));
+  EXPECT_THAT("cons", ranks("console", "Console", "ArrayBufferConstructor"));
+  EXPECT_THAT("foo", ranks("foo", "Foo"));
+  EXPECT_THAT("onMess", ranks("onMessage", "onmessage", "onThisMegaEscapes"));
+  EXPECT_THAT("CC", ranks("CamelCase", "camelCase"));
+  EXPECT_THAT("cC", ranks("camelCase", "CamelCase"));
+  EXPECT_THAT("p", ranks("parse", "posix", "pafdsa", "path", "p"));
+  EXPECT_THAT("pa", ranks("parse", "path", "pafdsa"));
+  EXPECT_THAT("log", ranks("log", "ScrollLogicalPosition"));
+  EXPECT_THAT("e", ranks("else", "AbstractElement"));
+  EXPECT_THAT("workbench.sideb",
+  ranks("workbench.sideBar.location",
+"workbench.editor.defaultSideBySideLayout"));
+  EXPECT_THAT("editor.r", ranks("editor.renderControlCharacter",
+"editor.overviewRulerlanes",
+"diffEditor.renderSideBySide"));
+  EXPECT_THAT("-mo", ranks("-moz-columns", "-ms-ime-mode"));
+  EXPECT_THAT("convertModelPosition",
+  ranks("convertModelPositionToViewPosition",
+"co

r318286 - [clang] Expose orderedString from CodeCompletionResult. NFC

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 01:15:06 2017
New Revision: 318286

URL: http://llvm.org/viewvc/llvm-project?rev=318286&view=rev
Log:
[clang] Expose orderedString from CodeCompletionResult. NFC

Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=318286&r1=318285&r2=318286&view=diff
==
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Wed Nov 15 01:15:06 2017
@@ -777,6 +777,12 @@ public:
CodeCompletionTUInfo &CCTUInfo,
bool IncludeBriefComments);
 
+  /// \brief Retrieve the name that should be used to order a result.
+  ///
+  /// If the name needs to be constructed as a string, that string will be
+  /// saved into Saved and the returned StringRef will refer to it.
+  StringRef getOrderedName(std::string &Saved) const;
+
 private:
   void computeCursorKindAndAvailability(bool Accessible = true);
 };

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=318286&r1=318285&r2=318286&view=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Nov 15 01:15:06 2017
@@ -613,24 +613,20 @@ void CodeCompletionResult::computeCursor
 ///
 /// If the name needs to be constructed as a string, that string will be
 /// saved into Saved and the returned StringRef will refer to it.
-static StringRef getOrderedName(const CodeCompletionResult &R,
-std::string &Saved) {
-  switch (R.Kind) {
-case CodeCompletionResult::RK_Keyword:
-  return R.Keyword;
-  
-case CodeCompletionResult::RK_Pattern:
-  return R.Pattern->getTypedText();
-  
-case CodeCompletionResult::RK_Macro:
-  return R.Macro->getName();
-  
-case CodeCompletionResult::RK_Declaration:
+StringRef CodeCompletionResult::getOrderedName(std::string &Saved) const {
+  switch (Kind) {
+case RK_Keyword:
+  return Keyword;
+case RK_Pattern:
+  return Pattern->getTypedText();
+case RK_Macro:
+  return Macro->getName();
+case RK_Declaration:
   // Handle declarations below.
   break;
   }
   
-  DeclarationName Name = R.Declaration->getDeclName();
+  DeclarationName Name = Declaration->getDeclName();
   
   // If the name is a simple identifier (by far the common case), or a
   // zero-argument selector, just return a reference to that identifier.
@@ -648,8 +644,8 @@ static StringRef getOrderedName(const Co
 bool clang::operator<(const CodeCompletionResult &X, 
   const CodeCompletionResult &Y) {
   std::string XSaved, YSaved;
-  StringRef XStr = getOrderedName(X, XSaved);
-  StringRef YStr = getOrderedName(Y, YSaved);
+  StringRef XStr = X.getOrderedName(XSaved);
+  StringRef YStr = Y.getOrderedName(YSaved);
   int cmp = XStr.compare_lower(YStr);
   if (cmp)
 return cmp < 0;


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


[clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 01:16:29 2017
New Revision: 318287

URL: http://llvm.org/viewvc/llvm-project?rev=318287&view=rev
Log:
[clangd] Support returning a limited number of completion results.

Summary:
All results are scored, we only process CodeCompletionStrings for the winners.
We now return CompletionList rather than CompletionItem[] (both are valid).
sortText is now based on CodeCompletionResult::orderedName (mostly the same).

This is the first clangd-only completion option, so plumbing changed.
It requires a small clangd patch (exposing CodeCompletionResult::orderedName).

(This can't usefully be enabled yet: we don't support server-side filtering)

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/test/clangd/authority-less-uri.test
clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
clang-tools-extra/trunk/test/clangd/completion-priorities.test
clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
clang-tools-extra/trunk/test/clangd/completion-snippet.test
clang-tools-extra/trunk/test/clangd/completion.test
clang-tools-extra/trunk/test/clangd/protocol.test
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=318287&r1=318286&r2=318287&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15 01:16:29 2017
@@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
 }
 
 void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams &Params) {
-  auto Items = Server
-   .codeComplete(Params.textDocument.uri.file,
- Position{Params.position.line,
-  Params.position.character})
-   .get() // FIXME(ibiryukov): This could be made async if we
-  // had an API that would allow to attach callbacks to
-  // futures returned by ClangdServer.
-   .Value;
-  C.reply(json::ary(Items));
+  auto List = Server
+  .codeComplete(
+  Params.textDocument.uri.file,
+  Position{Params.position.line, 
Params.position.character})
+  .get() // FIXME(ibiryukov): This could be made async if we
+ // had an API that would allow to attach callbacks to
+ // futures returned by ClangdServer.
+  .Value;
+  C.reply(List);
 }
 
 void ClangdLSPServer::onSignatureHelp(Ctx C,

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=318287&r1=318286&r2=318287&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29 2017
@@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
  std::move(TaggedFS));
 }
 
-std::future>>
+std::future>
 ClangdServer::codeComplete(PathRef File, Position Pos,
llvm::Optional OverridenContents,
IntrusiveRefCntPtr *UsedFS) {
-  using ResultType = Tagged>;
+  using ResultType = Tagged;
 
   std::promise ResultPromise;
 
@@ -242,11 +242,10 @@ ClangdServer::codeComplete(PathRef File,
 }
 
 void ClangdServer::codeComplete(
-UniqueFunction>)> Callback,
-PathRef File, Position Pos, llvm::Optional OverridenContents,
+UniqueFunction)> Callback, PathRef File,
+Position Pos, llvm::Optional OverridenContents,
 IntrusiveRefCntPtr *UsedFS) {
-  using CallbackType =
-  UniqueFunction>)>;
+  using CallbackType = UniqueFunction)>;
 
   std::string Contents;
   if (OverridenContents) {
@@ -283,7 +282,7 @@ void ClangdServer::codeComplete(
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 
-std::vector Result = clangd::codeComplete(
+CompletionList Result = clangd::codeComplete(
 File, Resources->getCompileCommand(),
 Preamble ? &Preamble->Preamble : nullptr, Contents, Pos,
 Tagg

[PATCH] D39852: [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318287: [clangd] Support returning a limited number of 
completion results. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D39852?vs=122342&id=122987#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39852

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/test/clangd/authority-less-uri.test
  clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
  clang-tools-extra/trunk/test/clangd/completion-priorities.test
  clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
  clang-tools-extra/trunk/test/clangd/completion-snippet.test
  clang-tools-extra/trunk/test/clangd/completion.test
  clang-tools-extra/trunk/test/clangd/protocol.test
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/test/clangd/protocol.test
===
--- clang-tools-extra/trunk/test/clangd/protocol.test
+++ clang-tools-extra/trunk/test/clangd/protocol.test
@@ -31,14 +31,17 @@
 #
 #  CHECK:  "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 
 X-Test: Testing
 Content-Type: application/vscode-jsonrpc; charset-utf-8
@@ -57,14 +60,17 @@
 #
 #  CHECK:  "id": 3,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
 
 Content-Type: application/vscode-jsonrpc; charset-utf-8
@@ -83,14 +89,17 @@
 #
 #  CHECK:  "id": 5,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 Content-Length: 1024
 
 {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
Index: clang-tools-extra/trunk/test/clangd/completion-priorities.test
===
--- clang-tools-extra/trunk/test/clangd/completion-priorities.test
+++ clang-tools-extra/trunk/test/clangd/completion-priorities.test
@@ -15,69 +15,74 @@
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":12,"character":8}}}
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "void",
-# CHECK-NEXT:  "filterText": "priv",
-# CHECK-NEXT:  "insertText": "priv",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "priv()",
-# CHECK-NEXT:  "sortText": "34priv"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail":

[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-11-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: include/clang/Sema/TemplateInstCallback.h:44
+template 
+void initialize(TemplateInstantiationCallbackPtrs& Callbacks_, const Sema 
&TheSema)
+{

Nit: this file should be clang formatted, it does not follow the LLVM  style. 
(This also applies to some other changes.)  Also, I would prefer to remove the 
trailing underscore from parameter names. 


https://reviews.llvm.org/D5767



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


[PATCH] D40068: Implement more accurate penalty & trade-offs while breaking protruding tokens.

2017-11-15 Thread Manuel Klimek via Phabricator via cfe-commits
klimek created this revision.

This is a counter-proposal to https://reviews.llvm.org/D33589.


https://reviews.llvm.org/D40068

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestComments.cpp

Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -2078,6 +2078,22 @@
"   // longsec\n",
getLLVMStyleWithColumns(20)));
 
+  // Simple case that correctly handles reflow in parameter lists.
+  EXPECT_EQ("a = f(/* long\n"
+"   * long long\n"
+"   */\n"
+"  a);",
+format("a = f(/* long long\n* long\n*/ a);",
+   getLLVMStyleWithColumns(22)));
+  // Tricky case that has fewer lines if we reflow the comment, ending up with
+  // fewer lines.
+  EXPECT_EQ("a = f(/* loong\n"
+"   * long long\n"
+"   */\n"
+"  a);",
+format("a = f(/* loong long\n* long\n*/ a);",
+   getLLVMStyleWithColumns(22)));
+
   // Keep empty comment lines.
   EXPECT_EQ("/**/", format(" /**/", getLLVMStyleWithColumns(20)));
   EXPECT_EQ("/* */", format(" /* */", getLLVMStyleWithColumns(20)));
@@ -2426,53 +2442,50 @@
 
 TEST_F(FormatTestComments, BreaksAfterMultilineBlockCommentsInParamLists) {
   EXPECT_EQ("a = f(/* long\n"
-" long\n"
-"   */\n"
+" long */\n"
 "  a);",
-format("a = f(/* long long */ a);", getLLVMStyleWithColumns(15)));
+format("a = f(/* long long */ a);", getLLVMStyleWithColumns(16)));
 
   EXPECT_EQ("a = f(/* long\n"
 " long\n"
 "   */\n"
 "  a);",
 format("a = f(/* long\n"
" long\n"
"   */a);",
-   getLLVMStyleWithColumns(15)));
+   getLLVMStyleWithColumns(16)));
 
   EXPECT_EQ("a = f(/* long\n"
 " long\n"
 "   */\n"
 "  a);",
 format("a = f(/* long\n"
" long\n"
"   */ a);",
-   getLLVMStyleWithColumns(15)));
+   getLLVMStyleWithColumns(16)));
 
   EXPECT_EQ("a = f(/* long\n"
 " long\n"
 "   */\n"
 "  (1 + 1));",
 format("a = f(/* long\n"
" long\n"
"   */ (1 + 1));",
-   getLLVMStyleWithColumns(15)));
+   getLLVMStyleWithColumns(16)));
 
   EXPECT_EQ(
   "a = f(a,\n"
   "  /* long\n"
-  " long\n"
-  "   */\n"
+  " long */\n"
   "  b);",
-  format("a = f(a, /* long long */ b);", getLLVMStyleWithColumns(15)));
+  format("a = f(a, /* long long */ b);", getLLVMStyleWithColumns(16)));
 
   EXPECT_EQ(
   "a = f(a,\n"
   "  /* long\n"
-  " long\n"
-  "   */\n"
+  " long */\n"
   "  (1 + 1));",
-  format("a = f(a, /* long long */ (1 + 1));", getLLVMStyleWithColumns(15)));
+  format("a = f(a, /* long long */ (1 + 1));", getLLVMStyleWithColumns(16)));
 }
 
 TEST_F(FormatTestComments, IndentLineCommentsInStartOfBlockAtEndOfFile) {
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8002,9 +8002,9 @@
 "\"f\");",
 format("someFunction1234567890(\"aaabbbcccdddeeefff\");",
getLLVMStyleWithColumns(24)));
-  EXPECT_EQ("someFunction(\"aaabbbcc \"\n"
-" \"ddde \"\n"
-" \"efff\");",
+  EXPECT_EQ("someFunction(\n"
+"\"aaabbbcc ddde \"\n"
+"\"efff\");",
 format("someFunction(\"aaabbbcc ddde efff\");",
getLLVMStyleWithColumns(25)));
   EXPECT_EQ("someFunction(\"aaabbbccc \"\n"
@@ -8023,10 +8023,9 @@
 "  int i;",
 format("#define A string s = \"1234567890\"; int i;",
getLLVMStyleWithColumns(20)));
-  // FIXME: Put additional penalties on breaking at non-whitespace locations.
-  EXPECT_EQ("someFunction(\"aaabbbcc \"\n"
-" \"dddeeeff\"\n"
-" \"f\");",
+  EXPECT_EQ("someFunction(\n"
+"\"aaabbbcc \"\n"
+"\"dddeeefff\");",
 format("someFunction(\"aaabbbcc dddeeefff\");",
getLLVMStyleWithColumns(25)));
 }
@@ -9895,6 +9894,106 @@
   EXPECT_EQ("#pragma option -C -A", format("#pragmaoption

[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.h:289
+  llvm::Expected>
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
+

rwols wrote:
> ilya-biryukov wrote:
> > Why do we accept `Code` as a parameter here instead of getting it 
> > internally?
> > 
> > Maybe we should consider moving this method out of `ClangdServer`? Its 
> > signature looks pretty self-contained now.
> There are a couple intertwined problems:
> 
> 1. replacementsToEdits wants llvm::StringRef Code
> 2. ClangdServer::formatCode wants llvm::StringRef Code
> 3. ClangdServer::getDocument returns an std::string
> 
> So yes, in principle you can call getDocument when you need it for 
> replacementsToEdits, and you can let formatCode itself call getDocument for 
> clang::format::getStyle. But then we create two copies of the document 
> contents for one LSP request.
> 
> If getDocument returned an llvm::StringRef, I'd probably vote for removing 
> the Code argument everywhere and call getDocument as needed.
Oh, I see. Calling `getDocument` twice does not really make sense.  
Maybe we could move a call to `replacementsToEdits` into `formatOnFile` and 
make it return `vector`?  Seems to be solving both problems.

We could've made `getDocument` return `StringRef`, but we'd have to be more 
careful to ensure it's actually copied when we're scheduling async operations, 
worth a separate review.


https://reviews.llvm.org/D39430



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-11-15 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

I think this patch doesn't handle a couple of cases that I'd like to see 
handled. A counter-proposal with different trade-offs is in 
https://reviews.llvm.org/D40068.


https://reviews.llvm.org/D33589



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


[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2017-11-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D38171#909346, @leanil wrote:

> In https://reviews.llvm.org/D38171#901427, @xazax.hun wrote:
>
> > One problem to think about when we add all clang-diagnostic as "first or 
> > second" class citizen, `checkes=*` might now enable all the warnings which 
> > make no sense and might be surprising to the users. What do you think?
>
>
> This is a good point. Should I insert ",-clang-diagnostic*" after any 
> (positive) * ?


@alexfh do you have some thoughts on this?


https://reviews.llvm.org/D38171



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


[PATCH] D39962: [libcxx] Fix current_exception test on Windows.

2017-11-15 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin updated this revision to Diff 122998.
halyavin added a comment.

Add lower bound too.


https://reviews.llvm.org/D39962

Files:
  
test/std/language.support/support.exception/propagation/current_exception.pass.cpp

Index: test/std/language.support/support.exception/propagation/current_exception.pass.cpp
===
--- test/std/language.support/support.exception/propagation/current_exception.pass.cpp
+++ test/std/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -7,10 +7,6 @@
 //
 //===--===//
 
-// This test needs to be rewritten for the Windows exception_ptr semantics
-// which copy the exception each time the exception_ptr is copied.
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // UNSUPPORTED: libcpp-no-exceptions
 // 
 
@@ -51,6 +47,22 @@
 }
 assert(A::constructed == 0);
 {
+try 
+{
+throw A();
+assert(false);
+}
+catch(...)
+{
+std::exception_ptr p = std::current_exception();
+int constructed_before = A::constructed;
+std::exception_ptr p2 = p;
+assert(A::constructed == constructed_before);
+assert(p == p2);
+}
+}
+assert(A::constructed == 0);
+{
 std::exception_ptr p2;
 try
 {
@@ -61,11 +73,10 @@
 catch (...)
 {
 std::exception_ptr p = std::current_exception();
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 assert(p != nullptr);
 p2 = std::current_exception();
-assert(A::constructed == 1);
-assert(p == p2);
+assert(1 <= A::constructed && A::constructed <= 3);
 }
 assert(A::constructed == 1);
 }
@@ -81,11 +92,10 @@
 catch (A&)
 {
 std::exception_ptr p = std::current_exception();
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 assert(p != nullptr);
 p2 = std::current_exception();
-assert(A::constructed == 1);
-assert(p == p2);
+assert(1 <= A::constructed && A::constructed <= 3);
 }
 assert(A::constructed == 1);
 }
@@ -101,11 +111,10 @@
 catch (A)
 {
 std::exception_ptr p = std::current_exception();
-assert(A::constructed == 2);
+assert(2 <= A::constructed && A::constructed <= 3);
 assert(p != nullptr);
 p2 = std::current_exception();
-assert(A::constructed == 2);
-assert(p == p2);
+assert(2 <= A::constructed && A::constructed <= 4);
 }
 assert(A::constructed == 1);
 }
@@ -148,7 +157,7 @@
 try
 {
 std::exception_ptr p = std::current_exception();
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 assert(p != nullptr);
 throw;
 assert(false);
@@ -181,7 +190,7 @@
 catch (...)
 {
 std::exception_ptr p = std::current_exception();
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 assert(p != nullptr);
 }
 assert(A::constructed == 1);
@@ -210,7 +219,7 @@
 assert(A::constructed == 1);
 }
 std::exception_ptr p = std::current_exception();
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 assert(p != nullptr);
 }
 assert(A::constructed == 0);
@@ -263,9 +272,9 @@
 catch (...)
 {
 p = std::current_exception();
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 }
-assert(A::constructed == 1);
+assert(1 <= A::constructed && A::constructed <= 2);
 }
 assert(A::constructed == 1);
 assert(p != nullptr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39955: [Driver] Add command-line flags for the new TBAA metadata format

2017-11-15 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Adding a (temporary) flag for the new format would help with updating tests 
that depend on the shape of TBAA metadata. There are lots of them and I guess 
some change frequently so we may want to address this in a few patches. That 
would also reduce the pressure on those who are in process of preparing new 
patches. So yes, if we can live with both the formats for some time, then that 
would make the transition easier for all concerned.

Will remove the clang option from the patch. We don't need it indeed. Thanks 
for pointing out.


Repository:
  rL LLVM

https://reviews.llvm.org/D39955



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


[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

As discussed, we should probably bundle together some related options into 
structs to make plumbing easier. Not a blocker here though.

If these options are pure-data, I think it's OK if some layers end up with 
access to other layers' options.




Comment at: clangd/ClangdUnit.cpp:238
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, Buffer.get());
+Preamble->AddImplicitPreamble(*CI, /*ref*/ VFS, Buffer.get());
   } else {

ref is still here :-)



Comment at: clangd/tool/ClangdMain.cpp:48
 
+static llvm::cl::opt StorePreamblesInMemory(
+"in-memory-pchs",

Couple of questions about the flag syntax:
 - I wonder about the granularity - if we had another temp storage (indexes?), 
would we want another flag or something shared like `-in-memory-storage`
 - Having this as a bool seems confusing compared to 
`-pch-storage={memory/disk}`. (We could also overload such a flag to allow 
setting the location, but nobody's asked for that yet)


https://reviews.llvm.org/D39843



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


[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-15 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:206
+  std::unique_ptr Storage;
+  if (InMemStorage) {
+OS = llvm::make_unique(*InMemStorage);

ilya-biryukov wrote:
> klimek wrote:
> > It looks like we should pass in the output stream, not the storage?
> We're not actually using the `Storage` variable, it's a leftover from 
> previous versions. Removed it.
> 
> Or did you mean that we should pass in the output stream directly to 
> `PrecompilePreambleAction`'s constructor?
Yes, I'm generally looking at things that might be better to decide at a higher 
abstraction level and pass in, rather than having switches for behavior (like 
InMemStorage) all over the place. Generally, I think we should have a storage 
(PCHStorage sounds like it was the right abstraction, but perhaps that one 
currently has a bad name) and the things dealing with that storage shouldn't 
care whether it's in memory or on the file system.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:490
   PreprocessorOpts.DisablePCHValidation = true;
+  if (Storage.getKind() == PCHStorage::Kind::TempFile) {
+const TempPCHFile &PCHFile = Storage.asFile();

ilya-biryukov wrote:
> klimek wrote:
> > This looks a bit like we should push it into the PCHStorage.
> I've extracted a function here to make the code read simpler.
> However, I placed it directly into the `PrecompiledPreamble` instead of 
> `PCHStorage` to keep `PCHStorage` responsible for just one thing: managing 
> the `variant`-like union.
It being called PCHStorage makes it sound like it handles the abstraction for 
how the preamble is stored. Given that the variant-like union is basically an 
interface with an implementation switch, I think all switching on it is also 
the responsibility of that class. Otherwise we'd need another abstraction on 
top of it?


https://reviews.llvm.org/D39842



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


[PATCH] D40068: Implement more accurate penalty & trade-offs while breaking protruding tokens.

2017-11-15 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1517
 ReflowInProgress = SplitBefore.first != StringRef::npos;
+DEBUG(if (ReflowInProgress) llvm::dbgs() << "  Reflowing.\n");
 TailOffset =

I'd rather
```
DEBUG({
  if (ReflowInProgress)
llvm::dbgs() << "  Reflowing.\n";
});
```



Comment at: unittests/Format/FormatTest.cpp:8007
+"\"aaabbbcc ddde \"\n"
+"\"efff\");",
 format("someFunction(\"aaabbbcc ddde efff\");",

Why did the string got on a newline here?



Comment at: unittests/Format/FormatTestComments.cpp:2447
 "  a);",
-format("a = f(/* long long */ a);", getLLVMStyleWithColumns(15)));
+format("a = f(/* long long */ a);", getLLVMStyleWithColumns(16)));
 

Please also leave the old test case, which is about the `*/` just going over 
the column limit if not put on a newline.



Comment at: unittests/Format/FormatTestComments.cpp:2456
"   */a);",
-   getLLVMStyleWithColumns(15)));
+   getLLVMStyleWithColumns(16)));
 

Why change `15` to `16`? The same for the subsequent cases.



Comment at: unittests/Format/FormatTestComments.cpp:2481
   "  b);",
-  format("a = f(a, /* long long */ b);", getLLVMStyleWithColumns(15)));
+  format("a = f(a, /* long long */ b);", getLLVMStyleWithColumns(16)));
 

Please also leave the old test case, which is about the `*/` just going over 
the column limit if not put on a newline.



Comment at: unittests/Format/FormatTestComments.cpp:2488
   "  (1 + 1));",
-  format("a = f(a, /* long long */ (1 + 1));", 
getLLVMStyleWithColumns(15)));
+  format("a = f(a, /* long long */ (1 + 1));", 
getLLVMStyleWithColumns(16)));
 }

Please also leave the old test case, which is about the `*/` just going over 
the column limit if not put on a newline.


https://reviews.llvm.org/D40068



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


r318290 - [OpenCL] Fix code generation of function-scope constant samplers.

2017-11-15 Thread Alexey Bader via cfe-commits
Author: bader
Date: Wed Nov 15 03:38:17 2017
New Revision: 318290

URL: http://llvm.org/viewvc/llvm-project?rev=318290&view=rev
Log:
[OpenCL] Fix code generation of function-scope constant samplers.

Summary:
Constant samplers are handled as static variables and clang's code generation
library, which leads to llvm::unreachable. We bypass emitting sampler variable
as static since it's translated to a function call later.

Reviewers: yaxunl, Anastasia

Reviewed By: yaxunl, Anastasia

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenOpenCL/sampler.cl
cfe/trunk/test/SemaOpenCL/sampler_t.cl

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=318290&r1=318289&r2=318290&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Nov 15 03:38:17 2017
@@ -162,6 +162,10 @@ void CodeGenFunction::EmitVarDecl(const
   // needs to be emitted like a static variable, e.g. a function-scope
   // variable in constant address space in OpenCL.
   if (D.getStorageDuration() != SD_Automatic) {
+// Static sampler variables translated to function calls.
+if (D.getType()->isSamplerT())
+  return;
+
 llvm::GlobalValue::LinkageTypes Linkage =
 CGM.getLLVMLinkageVarDefinition(&D, /*isConstant=*/false);
 

Modified: cfe/trunk/test/CodeGenOpenCL/sampler.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/sampler.cl?rev=318290&r1=318289&r2=318290&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/sampler.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/sampler.cl Wed Nov 15 03:38:17 2017
@@ -20,6 +20,8 @@
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 // CHECK-NOT: glb_smp
 
+int get_sampler_initializer(void);
+
 void fnc4smp(sampler_t s) {}
 // CHECK: define spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* %
 
@@ -58,4 +60,20 @@ kernel void foo(sampler_t smp_par) {
   fnc4smp(5);
   // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 5)
   // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* 
[[SAMP]])
+
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  fnc4smp(const_smp);
+   // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]]
+  fnc4smp(const_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]]
+  // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* 
[[SAMP]])
+
+  constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  fnc4smp(constant_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* 
[[SAMP]])
+
+  // TODO: enable sampler initialization with non-constant integer.
+  //const sampler_t const_smp_func_init = get_sampler_initializer();
 }

Modified: cfe/trunk/test/SemaOpenCL/sampler_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/sampler_t.cl?rev=318290&r1=318289&r2=318290&view=diff
==
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/sampler_t.cl Wed Nov 15 03:38:17 2017
@@ -46,36 +46,11 @@ const constant sampler_t glb_smp11 = CLK
 
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the 
__local and __global address space qualifiers}}
-  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
-  const sampler_t const_smp2;
-  const sampler_t const_smp3 = const_smp;
-  const sampler_t const_smp4 = f();
   const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const 
sampler_t' with an expression of incompatible type 'float'}}
   const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t 
initialization requires 32-bit integer, not 'long long'}}
 
-  foo(glb_smp);
-  foo(glb_smp2);
-  foo(glb_smp3);
-  foo(glb_smp4);
-  foo(glb_smp5);
-  foo(glb_smp6);
-  foo(glb_smp7);
-  foo(glb_smp8);
-  foo(glb_smp9);
-  foo(smp);
-  foo(sampler_str.smp);
-  foo(const_smp);
-  foo(const_smp2);
-  foo(const_smp3);
-  foo(const_smp4);
-  foo(const_smp5);
-  foo(const_smp6);
-  foo(argsmp);
-  foo(5);
   

[PATCH] D34342: [OpenCL] Fix code generation of function-scope constant samplers.

2017-11-15 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318290: [OpenCL] Fix code generation of function-scope 
constant samplers. (authored by bader).

Repository:
  rL LLVM

https://reviews.llvm.org/D34342

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/test/CodeGenOpenCL/sampler.cl
  cfe/trunk/test/SemaOpenCL/sampler_t.cl


Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -162,6 +162,10 @@
   // needs to be emitted like a static variable, e.g. a function-scope
   // variable in constant address space in OpenCL.
   if (D.getStorageDuration() != SD_Automatic) {
+// Static sampler variables translated to function calls.
+if (D.getType()->isSamplerT())
+  return;
+
 llvm::GlobalValue::LinkageTypes Linkage =
 CGM.getLLVMLinkageVarDefinition(&D, /*isConstant=*/false);
 
Index: cfe/trunk/test/CodeGenOpenCL/sampler.cl
===
--- cfe/trunk/test/CodeGenOpenCL/sampler.cl
+++ cfe/trunk/test/CodeGenOpenCL/sampler.cl
@@ -20,6 +20,8 @@
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 // CHECK-NOT: glb_smp
 
+int get_sampler_initializer(void);
+
 void fnc4smp(sampler_t s) {}
 // CHECK: define spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* %
 
@@ -58,4 +60,20 @@
   fnc4smp(5);
   // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 5)
   // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* 
[[SAMP]])
+
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  fnc4smp(const_smp);
+   // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]]
+  fnc4smp(const_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]]
+  // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* 
[[SAMP]])
+
+  constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  fnc4smp(constant_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* 
[[SAMP]])
+
+  // TODO: enable sampler initialization with non-constant integer.
+  //const sampler_t const_smp_func_init = get_sampler_initializer();
 }
Index: cfe/trunk/test/SemaOpenCL/sampler_t.cl
===
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl
+++ cfe/trunk/test/SemaOpenCL/sampler_t.cl
@@ -46,36 +46,11 @@
 
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the 
__local and __global address space qualifiers}}
-  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
-  const sampler_t const_smp2;
-  const sampler_t const_smp3 = const_smp;
-  const sampler_t const_smp4 = f();
   const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const 
sampler_t' with an expression of incompatible type 'float'}}
   const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t 
initialization requires 32-bit integer, not 'long long'}}
 
-  foo(glb_smp);
-  foo(glb_smp2);
-  foo(glb_smp3);
-  foo(glb_smp4);
-  foo(glb_smp5);
-  foo(glb_smp6);
-  foo(glb_smp7);
-  foo(glb_smp8);
-  foo(glb_smp9);
-  foo(smp);
-  foo(sampler_str.smp);
-  foo(const_smp);
-  foo(const_smp2);
-  foo(const_smp3);
-  foo(const_smp4);
-  foo(const_smp5);
-  foo(const_smp6);
-  foo(argsmp);
-  foo(5);
   foo(5.0f); // expected-error {{passing 'float' to parameter of incompatible 
type 'sampler_t'}}
-  sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 
'sampler_t' type is invalid in OpenCL}}
-  foo(sa[0]);
-  foo(bad());
+  sampler_t sa[] = {argsmp, glb_smp}; // expected-error {{array of 'sampler_t' 
type is invalid in OpenCL}}
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is 
invalid in OpenCL}}


Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -162,6 +162,10 @@
   // needs to be emitted like a static variable, e.g. a function-scope
   // variable in constant address space in OpenCL.
   if (D.getStorageDuration() != SD_Automatic) {
+// Static sampler variables translated to function calls.
+if (D.getType()->isSamplerT())
+  return;
+
 llvm::GlobalValue:

r318292 - [libclang] Fix cursors for in-class initializer of field declarations

2017-11-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Nov 15 04:20:41 2017
New Revision: 318292

URL: http://llvm.org/viewvc/llvm-project?rev=318292&view=rev
Log:
[libclang] Fix cursors for in-class initializer of field declarations

Fixes PR33745.

Patch by Nikolai Kosjar!

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

Modified:
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=318292&r1=318291&r2=318292&view=diff
==
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Wed Nov 15 04:20:41 2017
@@ -152,6 +152,11 @@ void f_dynamic_noexcept_none() throw();
 void f_dynamic_noexcept() throw(int);
 void f_dynamic_noexcept_any() throw(...);
 
+enum EnumType { Enumerator };
+struct Z {
+EnumType e = Enumerator;
+};
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck 
-check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen 
(}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -275,3 +280,6 @@ void f_dynamic_noexcept_any() throw(...)
 // CHECK-FORRANGE: 141:18 DeclRefExpr=coll:140:20 Extent=[141:18 - 141:22] 
Spelling=coll ([141:18 - 141:22])
 // CHECK-FORRANGE: 142:11 DeclRefExpr=lv:141:13 Extent=[142:11 - 142:13] 
Spelling=lv ([142:11 - 142:13])
 
+// RUN: c-index-test -cursor-at=%s:157:18 -std=c++11 %s | FileCheck 
-check-prefix=CHECK-INCLASSINITIALIZER %s
+// CHECK-INCLASSINITIALIZER: 157:18 DeclRefExpr=Enumerator:155:17 
Extent=[157:18 - 157:28] Spelling=Enumerator ([157:18 - 157:28])
+

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=318292&r1=318291&r2=318292&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Nov 15 04:20:41 2017
@@ -877,6 +877,9 @@ bool CursorVisitor::VisitFieldDecl(Field
   if (Expr *BitWidth = D->getBitWidth())
 return Visit(MakeCXCursor(BitWidth, StmtParent, TU, RegionOfInterest));
 
+  if (Expr *Init = D->getInClassInitializer())
+return Visit(MakeCXCursor(Init, StmtParent, TU, RegionOfInterest));
+
   return false;
 }
 


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


[PATCH] D40071: [libcxx] Implement exception_ptr on Windows without msvcprt.dll

2017-11-15 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin created this revision.
Herald added a reviewer: EricWF.

This change removes dependency on Microsoft STL implementation but adds 
dependency on VC runtime implementation. We will need to evolve and add 
#ifdef's to this code as new versions of Visual Studio runtime will come out.

Tested on x86 and x64, llvm clang 5.0, Visual Studio 2015 runtime.


https://reviews.llvm.org/D40071

Files:
  include/exception
  src/support/runtime/exception_pointer_msvc.ipp

Index: src/support/runtime/exception_pointer_msvc.ipp
===
--- src/support/runtime/exception_pointer_msvc.ipp
+++ src/support/runtime/exception_pointer_msvc.ipp
@@ -8,84 +8,237 @@
 //
 //===--===//
 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include  // For RtlPcToFileHeader function
 
-#if !defined(_CRTIMP2_PURE)
-#define _CRTIMP2_PURE __declspec(dllimport)
+struct EHCatchableType {
+  uint32_t properties;
+  int32_t type_info;
+  uint32_t non_virtual_adjustment;
+  uint32_t offset_to_virtual_base_ptr;
+  uint32_t virtual_base_table_index;
+  uint32_t size;
+  int32_t copy_function;
+};
+
+struct EHCatchableTypeArray {
+  uint32_t catchable_types;
+  // It is variable size but we only need the first element of this array
+  int32_t array_of_catchable_types[1];
+};
+
+struct EHThrowInfo {
+  uint32_t attributes;
+  int32_t unwind;
+  int32_t forward_compat;
+  int32_t catchable_type_array;
+};
+
+struct EHParameters {
+  uint32_t magic_number;
+  void* exception_object;
+  EHThrowInfo* throw_info;
+#ifdef _M_AMD64
+  uintptr_t throw_image_base;
 #endif
+};
 
-#if !defined(__CLRCALL_PURE_OR_CDECL)
-#define __CLRCALL_PURE_OR_CDECL __cdecl
+struct EHExceptionRecord {
+  uint32_t exception_code;
+  uint32_t exception_flags;
+  void* exception_record;
+  void* exception_address;
+  uint32_t number_of_parameters;
+  EHParameters parameters;
+};
+
+// defined in vcruntime.dll
+extern "C" EHExceptionRecord** __current_exception();
+
+// This is internal compiler definition for MSVC but not for clang.
+// We use our own EHThrowInfo because _ThrowInfo doesn't match actual
+// compiler-generated structures in 64-bit mode.
+#ifdef __clang__
+struct _ThrowInfo;
+// defined in vcruntime.dll
+_LIBCPP_NORETURN extern "C" void __stdcall _CxxThrowException(
+void* __exc, _ThrowInfo* __throw_info);
 #endif
 
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(void*,
-  const void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
-__ExceptionPtrAssign(void*, const void*);
-_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
-__ExceptionPtrCompare(const void*, const void*);
-_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
-__ExceptionPtrToBool(const void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrSwap(void*, void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
-__ExceptionPtrCurrentException(void*);
-[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
-__ExceptionPtrRethrow(const void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
-__ExceptionPtrCopyException(void*, const void*, const void*);
+namespace {
+struct ExceptionPtr {
+  void* exception_object;
+  const EHThrowInfo* throw_info;
+  std::atomic counter;
+#ifdef _M_AMD64
+  PVOID image_base;
+#endif
+  template 
+  T convert(int32_t offset) {
+#ifdef _M_AMD64
+uintptr_t value = reinterpret_cast(image_base) +
+  static_cast(offset);
+#else
+uintptr_t value = static_cast(offset);
+#endif
+T res;
+static_assert(
+sizeof(value) == sizeof(res),
+"Can only convert to pointers or pointers to member functions");
+memcpy(&res, &value, sizeof(value));
+return res;
+  }
 
-namespace std {
+  void copy(void* dst, const void* src, const EHCatchableType* exc_type) {
+struct Temp {};
+constexpr uint32_t virtual_base = 4;
+if (exc_type->copy_function == 0) {
+  memcpy(dst, src, exc_type->size);
+} else if (exc_type->properties & virtual_base) {
+  auto copy_constructor =
+  convert(exc_type->copy_function);
+  ((Temp*)dst->*copy_constructor)(src, 1);
+} else {
+  auto copy_constructor =
+  convert(exc_type->copy_function);
+  ((Temp*)dst->*copy_constructor)(src);
+}
+  }
 
-exception_ptr::exception_ptr() _NOEXCEPT { __ExceptionPtrCreate(this); }
-exception_ptr::exception_ptr(nullptr_t) _NOEXCEPT { __ExceptionPtrCreate(this); }
+  EHCatchableType* exception_type() {
+return convert(
+convert(throw_info->catchable_type_array)
+->array_of_catchable_types[0]);
+  }
 
-exception_ptr::exception_ptr(const exception_ptr& __other) _NOEXCEPT {
-  __ExceptionPtrCopy(this, &__other);
-}
-exception_ptr& exception_ptr::op

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

2017-11-15 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 123015.
hamzasood added a comment.

Resolved merge conflicts from the last month of changes 
(`unittests/AST/StmtPrinterTest.cpp` and `lib/AST/DeclCXX.cpp`)


https://reviews.llvm.org/D36527

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

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -823,7 +823,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2";>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: unittests/Tooling/TestVisitor.h
===
--- unittests/Tooling/TestVisitor.h
+++ unittests/Tooling/TestVisitor.h
@@ -44,6 +44,8 @@
 Lang_CXX98,
 Lang_CXX11,
 Lang_CXX14,
+Lang_CXX17,
+Lang_CXX2a,
 Lang_OBJC,
 Lang_OBJCXX11,
 Lang_CXX = Lang_CXX98
@@ -60,6 +62,8 @@
   case Lang_CXX98: Args.push_back("-std=c++98"); break;
   case Lang_CXX11: Args.push_back("-std=c++11"); break;
   case Lang_CXX14: Args.push_back("-std=c++14"); break;
+  case Lang_CXX17: Args.push_back("-std=c++17"); break;
+  case Lang_CXX2a: Args.push_back("-std=c++2a"); break;
   case Lang_OBJC:
 Args.push_back("-ObjC");
 Args.push_back("-fobjc-runtime=macosx-10.12.0");
Index: unittests/Tooling/RecursiveASTVisitorTest.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ unittests/Tooling/RecursiveASTVisitorTest.cpp
@@ -79,6 +79,41 @@
   LambdaDefaultCaptureVisitor::Lang_CXX11));
 }
 
+// Matches (optional) explicit template parameters.
+class LambdaTemplateParametersVisitor
+  : public ExpectedLocationVisitor {
+public:
+  bool shouldVisitImplicitCode() const { return false; }
+
+  bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+  bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+  bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, VisitsLambdaExplicitTemplateParameters) {
+  LambdaTemplateParametersVisitor Visitor;
+  Visitor.ExpectMatch("T",  2, 15);
+  Visitor.ExpectMatch("I",  2, 24);
+  Visitor.ExpectMatch("TT", 2, 31);
+  EXPECT_TRUE(Visitor.runOver(
+  "void f() { \n"
+  "  auto l = [] class TT>(auto p) { }; \n"
+  "}",
+  LambdaTemplateParametersVisitor::Lang_CXX2a));
+}
+
 // Checks for lambda classes that are not marked as implicitly-generated.
 // (There should be none.)
 class ClassVisitor : public ExpectedLocationVisitor {
Index: unittests/AST/StmtPrinterTest.cpp
===
--- unittests/AST/StmtPrinterTest.cpp
+++ unittests/AST/StmtPrinterTest.cpp
@@ -106,78 +106,73 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedStmtCXX98Matches(StringRef Code, const StatementMatcher &NodeMatch,
-StringRef ExpectedPrinted) {
-  std::vector Args;
-  Args.push_back("-std=c++98");
-  Args.push_back("-Wno-unused-value");
-  return PrintedStmtMatches(Code, Args, NodeMatch, ExpectedPrinted);
-}
-
-::testing::AssertionResult PrintedStmtCXX98Matches(
-  StringRef Code,
-  StringRef ContainingFunction,
-  StringRef ExpectedPrinted) {
-  std::vector Args;
-  Args.push_back("-std=c++98");
-  Args.push_back("-Wno-unused-value");
-  return PrintedStmtMatches(Code,
-Args,
-functionDecl(hasName(Contain

[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-15 Thread Ilya Palachev via Phabricator via cfe-commits
ilya-palachev created this revision.
Herald added subscribers: szepet, xazax.hun.

Current CFG is built in non-deterministic order due to the fact that indirect 
goto labels' declarations (LabelDecl's) are stored in the llvm::SmallSet 
container. LabelDecl's are pointers, whose order is not deterministic by 
design, and llvm::SmallSet sorts them by their non-deterministic addresses 
after "small" container is exceeded. This leads to non-deterministic processing 
of the elements of the
container.

The fix is to use llvm::SmallSetVector, which is deterministic by design.

The introduced test case was creduce'd from Android5 source file.

The test file contains 100 runs, in order to make the testing stable: different 
PLIST's are generated in 20% and 80% cases, correspondingly.


Repository:
  rL LLVM

https://reviews.llvm.org/D40073

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/diagnostics/goto-label-determinism.cpp

Index: test/Analysis/diagnostics/goto-label-determinism.cpp
===
--- /dev/null
+++ test/Analysis/diagnostics/goto-label-determinism.cpp
@@ -0,0 +1,254 @@
+// RUN: %clang_analyze_cc1 -triple arm-unknown-linux-gnueabi -w -analyzer-checker=debug.ExprInspection %s -verify
+// RUN: for i in {1..100}; do %clang_analyze_cc1 -triple arm-unknown-linux-gnueabi -w -analyzer-checker=debug.ExprInspection -analyzer-config max-nodes=10433 %s -analyzer-output=plist-multi-file -o %t.${i}.plist; done ; for i in {1..100}; do FileCheck --input-file=%t.${i}.plist %s; done ; if [ `md5sum %t.*.plist | awk '{print $1}' | sort -u | wc -l` -gt 1 ] ; then exit 1 ; fi
+
+int f();
+void clang_analyzer_warnIfReached();
+struct A {
+  void **t;
+  int recursion() {
+&&L1;
+&&L2;
+&&L3;
+&&L4;
+&&L5;
+&&L6;
+&&L7;
+&&L8;
+&&L9;
+  L1:
+f() > recursion();
+  L2:
+goto *t[f()];
+  L3:
+clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}};
+  L4:
+  L5:
+  L6:
+  L7:
+  L8:
+  L9:
+return 0;
+  }
+};
+
+// CHECK: diagnostics
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   path
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line9
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line9
+// CHECK-NEXT:   col6
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col6
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col6
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line21
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line21
+// CHECK-NEXT:   col8
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+

[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-15 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: test/Analysis/diagnostics/goto-label-determinism.cpp:2
+// RUN: %clang_analyze_cc1 -triple arm-unknown-linux-gnueabi -w 
-analyzer-checker=debug.ExprInspection %s -verify
+// RUN: for i in {1..100}; do %clang_analyze_cc1 -triple 
arm-unknown-linux-gnueabi -w -analyzer-checker=debug.ExprInspection 
-analyzer-config max-nodes=10433 %s -analyzer-output=plist-multi-file -o 
%t.${i}.plist; done ; for i in {1..100}; do FileCheck 
--input-file=%t.${i}.plist %s; done ; if [ `md5sum %t.*.plist | awk '{print 
$1}' | sort -u | wc -l` -gt 1 ] ; then exit 1 ; fi
+

This will not work on Windows. However, I don't know the common way of writing 
tests for determinism. Any ideas?


Repository:
  rL LLVM

https://reviews.llvm.org/D40073



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


[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-15 Thread Ilya Palachev via Phabricator via cfe-commits
ilya-palachev updated this revision to Diff 123016.
ilya-palachev added a comment.

Slightly changed the number of max-nodes, since previous one was maximum 
possible on my local branch, and it doesn't work for upstream. The behavior 
with number 500 seems more stable. With it, we have 4 different types of 
PLIST's being generated: 14, 54, 8 and 24 times, correspondingly.


Repository:
  rL LLVM

https://reviews.llvm.org/D40073

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/diagnostics/goto-label-determinism.cpp

Index: test/Analysis/diagnostics/goto-label-determinism.cpp
===
--- /dev/null
+++ test/Analysis/diagnostics/goto-label-determinism.cpp
@@ -0,0 +1,254 @@
+// RUN: %clang_analyze_cc1 -triple arm-unknown-linux-gnueabi -w -analyzer-checker=debug.ExprInspection %s -verify
+// RUN: for i in {1..100}; do %clang_analyze_cc1 -triple arm-unknown-linux-gnueabi -w -analyzer-checker=debug.ExprInspection -analyzer-config max-nodes=500 %s -analyzer-output=plist-multi-file -o %t.${i}.plist; done ; for i in {1..100}; do FileCheck --input-file=%t.${i}.plist %s; done ; if [ `md5sum %t.*.plist | awk '{print $1}' | sort -u | wc -l` -gt 1 ] ; then exit 1 ; fi
+
+int f();
+void clang_analyzer_warnIfReached();
+struct A {
+  void **t;
+  int recursion() {
+&&L1;
+&&L2;
+&&L3;
+&&L4;
+&&L5;
+&&L6;
+&&L7;
+&&L8;
+&&L9;
+  L1:
+f() > recursion();
+  L2:
+goto *t[f()];
+  L3:
+clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}};
+  L4:
+  L5:
+  L6:
+  L7:
+  L8:
+  L9:
+return 0;
+  }
+};
+
+// CHECK: diagnostics
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   path
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line9
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line9
+// CHECK-NEXT:   col6
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col6
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line17
+// CHECK-NEXT:   col6
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line19
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line21
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line21
+// CHECK-NEXT:   col8
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line21
+// CHECK-NEXT:   col5
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line21
+// CHECK-NEXT:   col8
+// CHECK-NEXT:   file0
+// CHECK-NEXT:

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

2017-11-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:382
+DescFile<"CheckSecuritySyntaxOnly.cpp">;
+  def DeprecatedBufferHandling : Checker<"DeprecatedBufferHandling">,
+HelpText<"Warn on uses of deprecated buffer manipulating functions">,

koldaniel wrote:
> xazax.hun wrote:
> > I do not like the naming of these two checks, It feels like one of them 
> > warns for a subset of the other, however, it is not the case.
> > What about removing the "deprecated" part from the first check? 
> Both checker warns if a buffer handling function is deprecated 
> (DeprecatedOrUnsafeBufferHandling calls DeprecatedBufferHandling), but the 
> DeprecatedOrUnsafeBufferHandling checker also warns if a function is not only 
> deprecated but unsafe (i.e. writes a buffer without size restrictions) too.
I see. Maybe it would be better to make them disjoint? Also, I think it is not 
a good user experience to get two warnings for the same function call.  


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] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-11-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The unconstrained rearrangements for `+`/`-`/`==`/`!=` are definitely good to 
go regardless of anything else.

Within the checker, we propose to manually simplify both `$x - N < $x` and `$x 
+ N > $x` to true (where N is positive), because in general this is unsound 
(due to potential overflows), but for iterator position symbols this is **the** 
intended behavior (if `container.end() + N` overflows, it's even worse than a 
regular past-end access).

For the rest of the cases (`>`/`<` with mixed symbols), we propose to delay the 
decision for now. For now simply admit that the solver is not awesome. If we 
had a perfect solver, we wouldn't have to rearrange anything, so the root cause 
of the problem is in the solver, and we shouldn't be fixing it on the checker 
side. If, before turning the checker on by default, we prove through evaluation 
that this shortcoming of the solver is indeed a bigger problem for this checker 
than for the rest of the analyzer, and is also the biggest problem with the 
checker, we can still come up with something (eg. the already-existing max/4 
approach). But let's delay this until we see how bad this part of the problem 
actually is.


https://reviews.llvm.org/D35109



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-11-15 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Thank you for your respone! However, I think you (not you, Artem, but you three 
at Apple) do not really understand that I need to compare A+m to B+n not only 
because of the iterator range checking, but also in later parts. So your 
proposal means that I am not allowed to fix the shortcomings of the constraint 
solver neither in the engine nor in the checker. Maybe part 2 of the iterator 
checkers patch will work, but then we will restart the whole dispute at a later 
part.

As I mentioned, I need these comparisons in a lot of places, not only in range 
checking. This is the core part of my solution. It is primarily needed for 
invalidation, which is the most solid part. The latest version (not part 10, 
but a fixed version of the whole chekcer set) finds only 5 false positives for 
invalidated iterator access, which I could further reduce by adding more 
detailed simulation of insertion and erasement.

So still the options are to fix it in the checker or fix it in the engine (the 
max/4 or the type extension solution), but leaving it unfixed is not an option. 
I am open to any solution, but only full solutions and no partial solutions, 
because they will not help us enough.


https://reviews.llvm.org/D35109



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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8858
+  else
+NeededArgGPRs = 1;
+

efriedma wrote:
> It looks like the ABI says there's a special rule for varargs here?
You're right, I neglected vararg calls. Now addressed and test cases added. The 
difference is only observable on RV64 I believe (as we only use the GPR 
tracking to decide whether an argument should be extended or not, and the 
argument promotion rules mean you'll never see signext/zeroext on varargs in 
RV32).



Comment at: lib/CodeGen/TargetInfo.cpp:8914
+Address RISCVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const {
+  CharUnits SlotSize = CharUnits::fromQuantity(XLen / 8);

efriedma wrote:
> The type of va_list and the behavior of va_arg should be documented in the 
> ABI doc... but apparently it's missing at the moment?  (I mean, this is the 
> obvious implementation from what is mentioned, but it would be nice to see 
> something more explicit.)
I've started an attempt to better document things 
https://github.com/riscv/riscv-elf-psabi-doc/pull/60



Comment at: test/CodeGen/riscv32-abi.c:118
+// single 2*xlen-sized argument, to ensure that alignment can be maintained if
+// it spills to the stack
+

efriedma wrote:
> Please clarify this comment; the ABI doc doesn't say anything about aligning 
> arguments whose alignment is 2✕XLEN, except in the case of varargs.
I've corrected the comment to say "if passed on the stack" and submitted a PR 
to clarify the ABI doc https://github.com/riscv/riscv-elf-psabi-doc/pull/59


https://reviews.llvm.org/D40023



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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 123020.
asb marked an inline comment as done.
asb added a comment.

Updated to address review comments. I've added some extra test coverage that 
demonstrates that argument lowering happens the same once registers are 
exhausted, as well as more coverage around varargs. Also updated to properly 
handle the "aligned register pair" rule for variadic arguments, and added tests 
for this.


https://reviews.llvm.org/D40023

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/riscv32-abi.c
  test/CodeGen/riscv64-abi.c
  test/Driver/riscv32-toolchain.c
  test/Driver/riscv64-toolchain.c

Index: test/Driver/riscv64-toolchain.c
===
--- test/Driver/riscv64-toolchain.c
+++ test/Driver/riscv64-toolchain.c
@@ -42,3 +42,50 @@
 
 // CHECK: @align_vl = global i32 8
 int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: define zeroext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: define signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: define signext i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: define signext i32 @check_wchar_t()
+int check_wchar_t() { return 0; }
+
+// CHECK: define i64 @check_long()
+long check_long() { return 0; }
+
+// CHECK: define i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: define zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: define zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: define signext i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: define i64 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: define i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: define i64 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: define float @check_float()
+float check_float() { return 0; }
+
+// CHECK: define double @check_double()
+double check_double() { return 0; }
+
+// CHECK: define fp128 @check_longdouble()
+long double check_longdouble() { return 0; }
Index: test/Driver/riscv32-toolchain.c
===
--- test/Driver/riscv32-toolchain.c
+++ test/Driver/riscv32-toolchain.c
@@ -42,3 +42,50 @@
 
 // CHECK: @align_vl = global i32 4
 int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: zeroext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: define signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: define i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: define i32 @check_wchar_t()
+int check_wchar_t() { return 0; }
+
+// CHECK: define i32 @check_long()
+long check_long() { return 0; }
+
+// CHECK: define i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: define zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: define zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: define i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: define i32 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: define i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: define i32 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: define float @check_float()
+float check_float() { return 0; }
+
+// CHECK: define double @check_double()
+double check_double() { return 0; }
+
+// CHECK: define fp128 @check_longdouble()
+long double check_longdouble() { return 0; }
Index: test/CodeGen/riscv64-abi.c
===
--- /dev/null
+++ test/CodeGen/riscv64-abi.c
@@ -0,0 +1,406 @@
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s
+
+#include 
+#include 
+
+// CHECK-LABEL: define void @f_void()
+void f_void(void) {}
+
+// Scalar arguments and return values smaller than the word size are extended
+// according to the sign of their type, up to 32 bits
+
+// CHECK-LABEL: define signext i8 @f_scalar_1(i8 signext %x)
+int8_t f_scalar_1(int8_t x) { return x; }
+
+// CHECK-LABEL: define zeroext i8 @f_scalar_2(i8 zeroext %x)
+uint8_t f_scalar_2(uint8_t x) { return x; }
+
+// CHECK-LABEL: define signext i32 @f_scalar_3(i32 signext %x)
+uint32_t f_scalar_3(int32_t x) { return x; }
+
+// CHECK-LABEL: define i64 @f_scalar_4(i64 %x)
+int64_t f_scalar_4(int64_t x) { return x; }
+
+// CHECK-LABEL: define float @f_fp_scalar_1(float %x)
+float f_fp_scalar_1(float x) { return x; }
+
+// CHECK-LABEL: define double @f_fp_scalar_2(double %x)
+double f_fp_scalar_2(double x) { return x; }
+
+// CHECK-LABEL: define fp128 @f_fp_scalar_3(fp128 %x)
+long double f_fp_scalar_3(long double x) { return x; }
+
+// Aggregates <= 2*xlen may be passed in registers, so will be coerced to
+// integer arguments. The rules for

[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

rjmccall wrote:
> ABataev wrote:
> > Hahnfeld wrote:
> > > rjmccall wrote:
> > > > Hahnfeld wrote:
> > > > > rjmccall wrote:
> > > > > > Hahnfeld wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > > The way you've written this makes it sound like 
> > > > > > > > > > > > > > > > "does the target support VLAs?", but the actual 
> > > > > > > > > > > > > > > > semantic checks treat it as "do OpenMP devices 
> > > > > > > > > > > > > > > > on this target support VLAs?"  Maybe there 
> > > > > > > > > > > > > > > > should be a more specific way to query things 
> > > > > > > > > > > > > > > > about OpenMP devices instead of setting a 
> > > > > > > > > > > > > > > > global flag for the target?
> > > > > > > > > > > > > > > Actually, the NVPTX and SPIR targets never 
> > > > > > > > > > > > > > > support VLAs. So I felt like it would be more 
> > > > > > > > > > > > > > > correct to make this a global property of the 
> > > > > > > > > > > > > > > target.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > The difference is that the other programming 
> > > > > > > > > > > > > > > models (OpenCL and CUDA) error out immediatelyand 
> > > > > > > > > > > > > > > regardless of the target because this limitation 
> > > > > > > > > > > > > > > is reflected in the standards that disallow VLAs 
> > > > > > > > > > > > > > > (see SemaType.cpp). For OpenMP we might have 
> > > > > > > > > > > > > > > target devices that support VLA so we shouldn't 
> > > > > > > > > > > > > > > error out for those.
> > > > > > > > > > > > > > If you want to make it a global property of the 
> > > > > > > > > > > > > > target, that's fine, but then I don't understand 
> > > > > > > > > > > > > > why your diagnostic only fires when 
> > > > > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > > > > That is because of how OpenMP offloading works and 
> > > > > > > > > > > > > how it is implemented in Clang. Consider the 
> > > > > > > > > > > > > following snippet from the added test case:
> > > > > > > > > > > > > ```lang=c
> > > > > > > > > > > > > int vla[arg];
> > > > > > > > > > > > > 
> > > > > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > > > > {
> > > > > > > > > > > > >// more code here...
> > > > > > > > > > > > > }
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Clang will take the following steps to compile this 
> > > > > > > > > > > > > into a working binary for a GPU:
> > > > > > > > > > > > > 1. Parse and (semantically) analyze the code as-is 
> > > > > > > > > > > > > for the host and produce LLVM Bitcode.
> > > > > > > > > > > > > 2. Parse and analyze again the code as-is and 
> > > > > > > > > > > > > generate code for the offloading target, the GPU in 
> > > > > > > > > > > > > this case.
> > > > > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary 
> > > > > > > > > > > > > and embed target binary from 3.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the 
> > > > > > > > > > > > > complete source code is analyzed. So to not throw 
> > > > > > > > > > > > > errors for the host code, we have to make sure that 
> > > > > > > > > > > > > we are actually generating code for the target 
> > > > > > > > > > > > > device. This is either in a `target` directive or in 
> > > > > > > > > > > > > a `declare target` region.
> > > > > > > > > > > > > Note that this is quite similar to what CUDA does, 
> > > > > > > > > > > > > only they have `CUDADiagIfDeviceCode` for this logic. 
> > > > > > > > > > > > > If you want me to add something of that kind for 
> > > > > > > > > > > > > OpenMP target devices, I'm fine with that. However 
> > > > > > > > > > > > > for the given case, it's a bit different because this 
> > > > > > > > > > > > > error should only be thrown for target devices that 
> > > > > > > > > > > > > don't support VLAs...
> > > > > > > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > > > > > > re-Sema'ed from scratch for the target?  Which means 
> > > > > > > > > > > > you need to avoid generating errors about things in the 
> > > > > > > > > > > > outer translation unit that aren't part of the target 
> > > > > > > > > > > > directive that you actually want to compile.  I 
> > > > > > > > > > > > would'v

[PATCH] D39730: Enabling constructor code completion

2017-11-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple added a comment.

Sorry, what do you mean by "this works in the body of the class"?

Definition of constructor inside class definition has been working even before:

struct foo {

  foo();
  f

};

Do you mean that a test shall be added in order to check that it still works?


https://reviews.llvm.org/D39730



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


[PATCH] D39812: [Driver, CodeGen] pass through and apply -fassociative-math

2017-11-15 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

Ping.


https://reviews.llvm.org/D39812



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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

> Mips is the only other implementer of shouldSignExtUnsignedType but is 
> unaffected, as unlike classifyArgumentType, classifyReturnType will not 
> extend i32 values (@sdardis: is this a bug?).

I believe this is an oversight that is addressed in the backend. The MIPS64 
backend treats 'trunc i64 %x to i32' as '(SLL (EXTRACT_SUBREG GPR64:$src, 
sub_32), 0)', which is required to match MIPS32 arithmetic works on MIPS64.

I will take a longer look at this issue.

Thanks.


https://reviews.llvm.org/D40023



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


[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:206
+  std::unique_ptr Storage;
+  if (InMemStorage) {
+OS = llvm::make_unique(*InMemStorage);

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > It looks like we should pass in the output stream, not the storage?
> > We're not actually using the `Storage` variable, it's a leftover from 
> > previous versions. Removed it.
> > 
> > Or did you mean that we should pass in the output stream directly to 
> > `PrecompilePreambleAction`'s constructor?
> Yes, I'm generally looking at things that might be better to decide at a 
> higher abstraction level and pass in, rather than having switches for 
> behavior (like InMemStorage) all over the place. Generally, I think we should 
> have a storage (PCHStorage sounds like it was the right abstraction, but 
> perhaps that one currently has a bad name) and the things dealing with that 
> storage shouldn't care whether it's in memory or on the file system.
It's a bit easier to share code with `GeneratePCHAction` this way in a way that 
would obviously works (as we call the same functions at the same points in the 
compilation pipeline, that is in `CreateASTConsumer`). 

`PCHStorage` is not a public interface and `PrecompiledPreamble` is exactly the 
interface that let's you use it without caring whether PCHs are stored in 
memory or on disk. It also feels ok for it to have the storage-dependent code 
as part of its own implementation.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:490
   PreprocessorOpts.DisablePCHValidation = true;
+  if (Storage.getKind() == PCHStorage::Kind::TempFile) {
+const TempPCHFile &PCHFile = Storage.asFile();

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > This looks a bit like we should push it into the PCHStorage.
> > I've extracted a function here to make the code read simpler.
> > However, I placed it directly into the `PrecompiledPreamble` instead of 
> > `PCHStorage` to keep `PCHStorage` responsible for just one thing: managing 
> > the `variant`-like union.
> It being called PCHStorage makes it sound like it handles the abstraction for 
> how the preamble is stored. Given that the variant-like union is basically an 
> interface with an implementation switch, I think all switching on it is also 
> the responsibility of that class. Otherwise we'd need another abstraction on 
> top of it?
Abstraction on top of it is `PrecompiledPreamble` itself. And `PCHStorage` is 
just an implementation detail.
Does that sound reasonable?


https://reviews.llvm.org/D39842



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton requested changes to this revision.
benhamilton added a comment.
This revision now requires changes to proceed.

Almost there.




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp:22
+void AvoidThrowingObjcExceptionCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
+}

It looks like we also need to catch (no pun intended :) people who invoke the 
following class methods:

```
+[NSException raise:format:]
+[NSException raise:format:arguments:]
```

We actually have a few places that use these:

http://google3/googlemac/iPhone/Maps/SDK/Maps/GMSServices.mm?l=412&rcl=174266104
http://google3/googlemac/iPhone/Bigtop/Source/Actions/ActionHandler.m?l=1942&rcl=174353485
http://google3/googlemac/iPhone/Applecrisp/Sketchy/Classes/Sketchy/SketchyLib/SketchyApplicationContext.mm?l=398&rcl=175173348




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp:30
+  diag(MatchedStmt->getThrowLoc(),
+   "avoid using @throw to handle Objective-C exceptions");
+}

Suggested wording:

"Pass in NSError ** instead of using @throw to indicate Objective-C errors"



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjcExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

Naming nit-pick: We are currently using `ObjC`, not `Objc`.



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:21-22
+/// The check is to find usage of @throw invocation in Objective-C code.
+/// We should avoid using @throw for Objective-C exceptions according to
+/// Google Objective-C Style Guide.
+///

Grammar nit:

according to Google Objective-C Style Guide -> according to the Google 
Objective-C Style Guide



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:26
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/google-objc-avoid-throwing-exception.html
+class AvoidThrowingObjcExceptionCheck : public ClangTidyCheck {
+ public:

`Objc` -> `ObjC`




Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6-7
+
+This check finds @throw usages in Objective-C files. According to Google's 
Objective-C
+Guide, we should not use @throw to handle exceptions.
+

How about:

This check finds @throw usages in Objective-C files. [For the same reasons as 
the Google C++ style 
guide](https://google.github.io/styleguide/cppguide.html#Exceptions), we 
[prefer not throwing exceptions from Objective-C 
code](http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions).

Instead, prefer passing in `NSError **` and return `BOOL` to indicate success 
or failure. A counterexample:

```lang=objectivec
- (void)readFile {
  if ([self isError]) {
@throw [NSException exceptionWithName:...];
  }
}
```

Instead, returning an error via `NSError **` is preferred:

```lang=objectivec
- (BOOL)readFileWithError:(NSError **)error {
  if ([self isError]) {
*error = [NSError errorWithDomain:...];
return NO;
  }
  return YES;
}
```




Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:10
+The corresponding style guide rule:
+http://go/objc-style#Avoid_Throwing_Exceptions

hokein wrote:
> Use the public link: 
> http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
+1


https://reviews.llvm.org/D40058



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


[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-11-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 123027.
jdenny added a comment.

1. Capitalized some of the new local variables according to coding standards.

2. Rebased on master/trunk fetched today.


https://reviews.llvm.org/D39694

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticOptions.h
  include/clang/Driver/CC1Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp
  test/Frontend/verify-prefixes.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-constant-enum-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.cpp
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence -x c++ %s
 
 unsigned uvalue(void);
 signed int svalue(void);
@@ -13,13 +13,8 @@
 void TFunc() {
   // Make sure that we do warn for normal variables in template functions !
   unsigned char c = svalue();
-#ifdef TEST
   if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
   return;
-#else
-  if (c < 0)
-  return;
-#endif
 
   if (c < macro(0))
   return;
@@ -39,7 +34,8 @@
 
   unsigned un = uvalue();
 
-#ifdef TEST
+  // silence-no-diagnostics
+
   if (un == 0)
   return 0;
   if (un != 0)
@@ -91,65 +87,10 @@
   return 0;
   if (0UL >= un)
   return 0;
-#else
-// expected-no-diagnostics
-  if (un == 0)
-  return 0;
-  if (un != 0)
-  return 0;
-  if (un < 0)
-  return 0;
-  if (un <= 0)
-  return 0;
-  if (un > 0)
-  return 0;
-  if (un >= 0)
-  return 0;
-
-  if (0 == un)
-  return 0;
-  if (0 != un)
-  return 0;
-  if (0 < un)
-  return 0;
-  if (0 <= un)
-  return 0;
-  if (0 > un)
-  return 0;
-  if (0 >= un)
-  return 0;
-
-  if (un == 0UL)
-  return 0;
-  if (un != 0UL)
-  return 0;
-  if (un < 0UL)
-  return 0;
-  if (un <= 0UL)
-  return 0;
-  if (un > 0UL)
-  return 0;
-  if (un >= 0UL)
-  return 0;
-
-  if (0UL == un)
-  return 0;
-  if (0UL != un)
-  return 0;
-  if (0UL < un)
-  return 0;
-  if (0UL <= un)
-  return 0;
-  if (0UL > un)
-  return 0;
-  if (0UL >= un)
-  return 0;
-#endif
 
 
   signed int a = svalue();
 
-#ifdef TEST
   if (a == 0)
   return 0;
   if (a != 0)
@@ -201,60 +142,6 @@
   return 0;
   if (0UL >= a)
   return 0;
-#else
-// expected-no-diagnostics
-  if (a == 0)
-  return 0;
-  if (a != 0)
-  return 0;
-  if (a < 0)
-  return 0;
-  if (a <= 0)
-  return 0;
-  if (a > 0)
-  return 0;
-  if (a >= 0)
-  return 0;
-
-  if (0 == a)
-  return 0;
-  if (0 != a)
-  return 0;
-  if (0 < a)
-  return 0;
-  if (0 <= a)
-  return 0;
-  if (0 > a)
-  return 0;
-  if (0 >= a)
-  return 0;
-
-  if (a == 0UL)
-  return 0;
-  if (a != 0UL)
-  return 0;
-  if (a < 0UL)
-  return 0;
-  if (a <= 0UL)
-  return 0;
-  if (a > 0UL)
-  return 0;
-  if (a >= 0UL)
-  return 0;
-
-  if (0UL == a)
-  return 0;
-  if (0UL != a)
-  return 0;
-  if (0UL < a)
-  return 0;
-  if (0UL <= a)
-  return 0;
-  if (0UL > a)
-  return 0;
-  if (0UL >= a)
-  return 0;
-#endif
 
 
   float fl = 0;
Index: test/Sema/tautological-unsigned-enum-zero-compare.cpp
===
--- test/Sema/tautological-unsigned-enum-zero-compare.cpp
+++ test/Sema/tautological-unsigned-enum-zero-compare.cpp
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSILENCE -Wno-tautological-unsigned-enum-zero-compare -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only \
+// RUN:-verify=unsigned,unsigned-signed,expected %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN:-verify=unsigned-signed,signed-silence,expected %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN:-Wno-tautol

[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.cpp:238
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, Buffer.get());
+Preamble->AddImplicitPreamble(*CI, /*ref*/ VFS, Buffer.get());
   } else {

sammccall wrote:
> ref is still here :-)
Thx. Missed that. Removed.



Comment at: clangd/tool/ClangdMain.cpp:48
 
+static llvm::cl::opt StorePreamblesInMemory(
+"in-memory-pchs",

sammccall wrote:
> Couple of questions about the flag syntax:
>  - I wonder about the granularity - if we had another temp storage 
> (indexes?), would we want another flag or something shared like 
> `-in-memory-storage`
>  - Having this as a bool seems confusing compared to 
> `-pch-storage={memory/disk}`. (We could also overload such a flag to allow 
> setting the location, but nobody's asked for that yet)
  - Indexes are fundamentally different because we actually want to persist 
them across multiple sessions. But I see your point. I'd go with another flag 
for greater flexibility. We do want clangd work great by-default, so those 
flags are mostly for people who know what they're doing and can figure out 
which flags they want to change and why. Maybe I'm not right, though, and 
people would want those kinds of switches.
  - Totally like the `-pch-storage={memory/disk}`  more, updated the change 
accordingly.




https://reviews.llvm.org/D39843



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjcExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

benhamilton wrote:
> Naming nit-pick: We are currently using `ObjC`, not `Objc`.
We also need to rename the file name. 



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6-7
+
+This check finds @throw usages in Objective-C files. According to Google's 
Objective-C
+Guide, we should not use @throw to handle exceptions.
+

benhamilton wrote:
> How about:
> 
> This check finds @throw usages in Objective-C files. [For the same reasons as 
> the Google C++ style 
> guide](https://google.github.io/styleguide/cppguide.html#Exceptions), we 
> [prefer not throwing exceptions from Objective-C 
> code](http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions).
> 
> Instead, prefer passing in `NSError **` and return `BOOL` to indicate success 
> or failure. A counterexample:
> 
> ```lang=objectivec
> - (void)readFile {
>   if ([self isError]) {
> @throw [NSException exceptionWithName:...];
>   }
> }
> ```
> 
> Instead, returning an error via `NSError **` is preferred:
> 
> ```lang=objectivec
> - (BOOL)readFileWithError:(NSError **)error {
>   if ([self isError]) {
> *error = [NSError errorWithDomain:...];
> return NO;
>   }
>   return YES;
> }
> ```
> 
+1 on an illustrated sample :)


https://reviews.llvm.org/D40058



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


r318304 - ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in headers

2017-11-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Nov 15 08:52:12 2017
New Revision: 318304

URL: http://llvm.org/viewvc/llvm-project?rev=318304&view=rev
Log:
ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in 
headers

Internal linkage variables ODR referenced from inline functions create
ODR violations (the same inline function ends up having different
definitions in each TU, since it references different variables - rather
than one definition).

This also happens to break modular code generation - so this is the last
fix to allow clang to compile with modular code generation.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=318304&r1=318303&r2=318304&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Nov 15 08:52:12 2017
@@ -178,7 +178,7 @@ inline internal::TrueMatcher anything()
 /// \endcode
 /// decl(hasDeclContext(translationUnitDecl()))
 ///   matches "int X", but not "int Y".
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 translationUnitDecl;
 
 /// \brief Matches typedef declarations.
@@ -190,7 +190,8 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// typedefDecl()
 ///   matches "typedef int X", but not "using Y = int"
-const internal::VariadicDynCastAllOfMatcher typedefDecl;
+extern const internal::VariadicDynCastAllOfMatcher
+typedefDecl;
 
 /// \brief Matches typedef name declarations.
 ///
@@ -201,7 +202,7 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// typedefNameDecl()
 ///   matches "typedef int X" and "using Y = int"
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 typedefNameDecl;
 
 /// \brief Matches type alias declarations.
@@ -213,7 +214,8 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// typeAliasDecl()
 ///   matches "using Y = int", but not "typedef int X"
-const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
+extern const internal::VariadicDynCastAllOfMatcher
+typeAliasDecl;
 
 /// \brief Matches type alias template declarations.
 ///
@@ -222,7 +224,7 @@ const internal::VariadicDynCastAllOfMatc
 ///   template 
 ///   using Y = X;
 /// \endcode
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 typeAliasTemplateDecl;
 
 /// \brief Matches AST nodes that were expanded within the main-file.
@@ -313,7 +315,7 @@ AST_POLYMORPHIC_MATCHER_P(isExpansionInF
 /// friend X;
 ///   };
 /// \endcode
-const internal::VariadicAllOfMatcher decl;
+extern const internal::VariadicAllOfMatcher decl;
 
 /// \brief Matches a declaration of a linkage specification.
 ///
@@ -323,7 +325,7 @@ const internal::VariadicAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 linkageSpecDecl;
 
 /// \brief Matches a declaration of anything that could have a name.
@@ -337,7 +339,7 @@ const internal::VariadicDynCastAllOfMatc
 /// } U;
 ///   };
 /// \endcode
-const internal::VariadicDynCastAllOfMatcher namedDecl;
+extern const internal::VariadicDynCastAllOfMatcher namedDecl;
 
 /// \brief Matches a declaration of label.
 ///
@@ -348,7 +350,7 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// labelDecl()
 ///   matches 'FOO:'
-const internal::VariadicDynCastAllOfMatcher labelDecl;
+extern const internal::VariadicDynCastAllOfMatcher labelDecl;
 
 /// \brief Matches a declaration of a namespace.
 ///
@@ -359,7 +361,8 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// namespaceDecl()
 ///   matches "namespace {}" and "namespace test {}"
-const internal::VariadicDynCastAllOfMatcher namespaceDecl;
+extern const internal::VariadicDynCastAllOfMatcher
+namespaceDecl;
 
 /// \brief Matches a declaration of a namespace alias.
 ///
@@ -370,7 +373,7 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// namespaceAliasDecl()
 ///   matches "namespace alias" but not "namespace test"
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 namespaceAliasDecl;
 
 /// \brief Matches class, struct, and union declarations.
@@ -382,9 +385,7 @@ const internal::VariadicDynCastAllOfMatc
 ///   struct S {};
 ///   union U {};
 /// \endcode
-const internal::VariadicDynCastAllOfMatcher<
-  Decl,
-  RecordDecl> recordDecl;
+extern const internal::VariadicDynCastAllOfMatcher 
recordDecl;
 
 /// \brief Matches C++ class declarations.
 ///
@@ -393,9 +394,8 @@ const internal::VariadicDynCastAllOfMatc
 ///   class X;
 ///   template class Z {};
 /// \endcode
-const internal::VariadicDynCastAllOfMatcher<
-  Decl,
-  CXXRecordDecl> cxxRecordDecl;
+exter

r318309 - BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Nov 15 09:11:53 2017
New Revision: 318309

URL: http://llvm.org/viewvc/llvm-project?rev=318309&view=rev
Log:
BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on 
the target (PR35174)

In the PR, Clang ended up in a situation where it tried to mangle the
__float128 type, which isn't supported when targetingt MSVC, because
Clang instantiated a variable template with that type when searching for
a conversion to use in an arithmetic expression.

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

Added:
cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=318309&r1=318308&r2=318309&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 15 09:11:53 2017
@@ -7615,53 +7615,62 @@ class BuiltinOperatorOverloadBuilder {
   SmallVectorImpl &CandidateTypes;
   OverloadCandidateSet &CandidateSet;
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  static constexpr int ArithmeticTypesCap = 24;
+  SmallVector ArithmeticTypes;
+
+  // Define some indices used to iterate over the arithemetic types in
+  // ArithmeticTypes.  The "promoted arithmetic types" are the arithmetic
   // types are that preserved by promotion (C++ [over.built]p2).
-  static const unsigned FirstIntegralType = 4;
-  static const unsigned LastIntegralType = 21;
-  static const unsigned FirstPromotedIntegralType = 4,
-LastPromotedIntegralType = 12;
-  static const unsigned FirstPromotedArithmeticType = 0,
-LastPromotedArithmeticType = 12;
-  static const unsigned NumArithmeticTypes = 21;
-
-  /// \brief Get the canonical type for a given arithmetic type index.
-  CanQualType getArithmeticType(unsigned index) {
-assert(index < NumArithmeticTypes);
-static CanQualType ASTContext::* const
-  ArithmeticTypes[NumArithmeticTypes] = {
-  // Start of promoted types.
-  &ASTContext::FloatTy,
-  &ASTContext::DoubleTy,
-  &ASTContext::LongDoubleTy,
-  &ASTContext::Float128Ty,
-
-  // Start of integral types.
-  &ASTContext::IntTy,
-  &ASTContext::LongTy,
-  &ASTContext::LongLongTy,
-  &ASTContext::Int128Ty,
-  &ASTContext::UnsignedIntTy,
-  &ASTContext::UnsignedLongTy,
-  &ASTContext::UnsignedLongLongTy,
-  &ASTContext::UnsignedInt128Ty,
-  // End of promoted types.
-
-  &ASTContext::BoolTy,
-  &ASTContext::CharTy,
-  &ASTContext::WCharTy,
-  &ASTContext::Char16Ty,
-  &ASTContext::Char32Ty,
-  &ASTContext::SignedCharTy,
-  &ASTContext::ShortTy,
-  &ASTContext::UnsignedCharTy,
-  &ASTContext::UnsignedShortTy,
-  // End of integral types.
-  // FIXME: What about complex? What about half?
-};
-return S.Context.*ArithmeticTypes[index];
+  unsigned FirstIntegralType,
+   LastIntegralType;
+  unsigned FirstPromotedIntegralType,
+   LastPromotedIntegralType;
+  unsigned FirstPromotedArithmeticType,
+   LastPromotedArithmeticType;
+  unsigned NumArithmeticTypes;
+
+  void InitArithmeticTypes() {
+// Start of promoted types.
+FirstPromotedArithmeticType = 0;
+ArithmeticTypes.push_back(S.Context.FloatTy);
+ArithmeticTypes.push_back(S.Context.DoubleTy);
+ArithmeticTypes.push_back(S.Context.LongDoubleTy);
+if (S.Context.getTargetInfo().hasFloat128Type())
+  ArithmeticTypes.push_back(S.Context.Float128Ty);
+
+// Start of integral types.
+FirstIntegralType = ArithmeticTypes.size();
+FirstPromotedIntegralType = ArithmeticTypes.size();
+ArithmeticTypes.push_back(S.Context.IntTy);
+ArithmeticTypes.push_back(S.Context.LongTy);
+ArithmeticTypes.push_back(S.Context.LongLongTy);
+if (S.Context.getTargetInfo().hasInt128Type())
+  ArithmeticTypes.push_back(S.Context.Int128Ty);
+ArithmeticTypes.push_back(S.Context.UnsignedIntTy);
+ArithmeticTypes.push_back(S.Context.UnsignedLongTy);
+ArithmeticTypes.push_back(S.Context.UnsignedLongLongTy);
+if (S.Context.getTargetInfo().hasInt128Type())
+  ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty);
+LastPromotedIntegralType = ArithmeticTypes.size();
+LastPromotedArithmeticType = ArithmeticTypes.size();
+// End of promoted types.
+
+ArithmeticTypes.push_back(S.Context.BoolTy);
+ArithmeticTypes.push_back(S.Context.CharTy);
+ArithmeticTypes.push_back(S.Context.WCharTy);
+ArithmeticTypes.push_back(S.Context.Char16Ty);
+ArithmeticTypes.push_back(S.Context.Char32Ty);
+ArithmeticTypes.push_back(S.Context.SignedCharTy);
+ArithmeticTypes.

[PATCH] D39579: BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:7618
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  SmallVector ArithmeticTypes;
+

rsmith wrote:
> Can we do better than a magic number here? I don't like that getting this 
> wrong will lead to a silent performance change. (Can we at least assert 
> `isSmall()` below or something?)
It turns out `isSmall()` isn't public, so I can't use that directly, but I've 
added a constant for the capacity and an assert against that.

I don't actually know if there's any good reason for `isSmall()` to not be 
public. If you agree, I can follow up and just use that.


https://reviews.llvm.org/D39579



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


[PATCH] D39579: BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-15 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318309: BuiltinOperatorOverloadBuilder: Don't consider types 
that are unavailable on… (authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D39579?vs=121824&id=123041#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39579

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp

Index: cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
===
--- cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
+++ cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 -DMS %s
+
+template  struct enable_if {};
+template<> struct enable_if { typedef void type; };
+
+template  struct is_same { static constexpr bool value = false; };
+template  struct is_same { static constexpr bool value = true; };
+
+
+
+
+struct S {
+  // The only numeric types S can be converted to is __int128 and __float128.
+  template ::value ||
+  is_same::value ||
+  is_same::value)>::type>
+  operator T() { return T(); }
+};
+
+void f() {
+#ifdef MS
+  // When targeting Win32, __float128 and __int128 do not exist, so the S
+  // object cannot be converted to anything usable in the expression.
+  // expected-error@+2{{invalid operands to binary expression ('S' and 'double')}}
+#endif
+  double d = S() + 1.0;
+#ifndef MS
+  // expected-error@-2{{use of overloaded operator '+' is ambiguous}}
+  // expected-note@-3 36{{built-in candidate operator+}}
+#endif
+}
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -7615,53 +7615,62 @@
   SmallVectorImpl &CandidateTypes;
   OverloadCandidateSet &CandidateSet;
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  static constexpr int ArithmeticTypesCap = 24;
+  SmallVector ArithmeticTypes;
+
+  // Define some indices used to iterate over the arithemetic types in
+  // ArithmeticTypes.  The "promoted arithmetic types" are the arithmetic
   // types are that preserved by promotion (C++ [over.built]p2).
-  static const unsigned FirstIntegralType = 4;
-  static const unsigned LastIntegralType = 21;
-  static const unsigned FirstPromotedIntegralType = 4,
-LastPromotedIntegralType = 12;
-  static const unsigned FirstPromotedArithmeticType = 0,
-LastPromotedArithmeticType = 12;
-  static const unsigned NumArithmeticTypes = 21;
-
-  /// \brief Get the canonical type for a given arithmetic type index.
-  CanQualType getArithmeticType(unsigned index) {
-assert(index < NumArithmeticTypes);
-static CanQualType ASTContext::* const
-  ArithmeticTypes[NumArithmeticTypes] = {
-  // Start of promoted types.
-  &ASTContext::FloatTy,
-  &ASTContext::DoubleTy,
-  &ASTContext::LongDoubleTy,
-  &ASTContext::Float128Ty,
-
-  // Start of integral types.
-  &ASTContext::IntTy,
-  &ASTContext::LongTy,
-  &ASTContext::LongLongTy,
-  &ASTContext::Int128Ty,
-  &ASTContext::UnsignedIntTy,
-  &ASTContext::UnsignedLongTy,
-  &ASTContext::UnsignedLongLongTy,
-  &ASTContext::UnsignedInt128Ty,
-  // End of promoted types.
-
-  &ASTContext::BoolTy,
-  &ASTContext::CharTy,
-  &ASTContext::WCharTy,
-  &ASTContext::Char16Ty,
-  &ASTContext::Char32Ty,
-  &ASTContext::SignedCharTy,
-  &ASTContext::ShortTy,
-  &ASTContext::UnsignedCharTy,
-  &ASTContext::UnsignedShortTy,
-  // End of integral types.
-  // FIXME: What about complex? What about half?
-};
-return S.Context.*ArithmeticTypes[index];
+  unsigned FirstIntegralType,
+   LastIntegralType;
+  unsigned FirstPromotedIntegralType,
+   LastPromotedIntegralType;
+  unsigned FirstPromotedArithmeticType,
+   LastPromotedArithmeticType;
+  unsigned NumArithmeticTypes;
+
+  void InitArithmeticTypes() {
+// Start of promoted types.
+FirstPromotedArithmeticType = 0;
+ArithmeticTypes.push_back(S.Context.FloatTy);
+ArithmeticTypes.push_back(S.Context.DoubleTy);
+ArithmeticTypes.push_back(S.Context.LongDoubleTy);
+if (S.Context.getTargetInfo().hasFloat128Type())
+  ArithmeticTypes.push_back(S.Context.Float128Ty);
+
+// Start of integral types.
+FirstIntegralType = ArithmeticTypes.size();
+FirstPromotedIntegralType = ArithmeticTypes.size();
+ArithmeticTypes.push_back(S.Context.IntTy);
+   

[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

2017-11-15 Thread Cameron via Phabricator via cfe-commits
cameron314 updated this revision to Diff 123044.
cameron314 added a comment.

Fully rebased, with a test.


https://reviews.llvm.org/D20124

Files:
  include/clang/Lex/PreprocessingRecord.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/Module.h
  lib/Lex/PPDirectives.cpp
  lib/Lex/PreprocessingRecord.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/libclang/LibclangTest.cpp

Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -572,3 +572,52 @@
   EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU));
   DisplayDiagnostics();
 }
+
+TEST_F(LibclangReparseTest, PreprocessorSkippedRanges) {
+  std::string Header = "header.h", Main = "main.cpp";
+  WriteFile(Header,
+"#ifdef MANGOS\n"
+"printf(\"mmm\");\n"
+"#endif");
+  WriteFile(Main,
+"#include \"header.h\"\n"
+"#ifdef KIWIS\n"
+"printf(\"mmm!!\");\n"
+"#endif");
+
+  unsigned flags = TUFlags |
+CXTranslationUnit_PrecompiledPreamble;//|
+  //CXTranslationUnit_CreatePreambleOnFirstParse;
+  for (int i = 0; i != 5; ++i) {
+if (i == 0) {
+  // first parse
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0,
+   nullptr, 0, flags);
+}
+else {
+  // reparse
+  ASSERT_TRUE(ReparseTU(0, nullptr /* No unsaved files. */));
+}
+
+CXSourceRangeList *Ranges = clang_getAllSkippedRanges(ClangTU);
+EXPECT_EQ(2U, Ranges->count);
+
+CXSourceLocation cxl;
+unsigned line;
+cxl = clang_getRangeStart(Ranges->ranges[0]);
+clang_getSpellingLocation(cxl, nullptr, &line, nullptr, nullptr);
+EXPECT_EQ(1U, line);
+cxl = clang_getRangeEnd(Ranges->ranges[0]);
+clang_getSpellingLocation(cxl, nullptr, &line, nullptr, nullptr);
+EXPECT_EQ(3U, line);
+
+cxl = clang_getRangeStart(Ranges->ranges[1]);
+clang_getSpellingLocation(cxl, nullptr, &line, nullptr, nullptr);
+EXPECT_EQ(2U, line);
+cxl = clang_getRangeEnd(Ranges->ranges[1]);
+clang_getSpellingLocation(cxl, nullptr, &line, nullptr, nullptr);
+EXPECT_EQ(4U, line);
+
+clang_disposeSourceRangeList(Ranges);
+  }
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1104,6 +1104,7 @@
   RECORD(UNUSED_FILESCOPED_DECLS);
   RECORD(PPD_ENTITIES_OFFSETS);
   RECORD(VTABLE_USES);
+  RECORD(PPD_SKIPPED_RANGES);
   RECORD(REFERENCED_SELECTOR_POOL);
   RECORD(TU_UPDATE_LEXICAL);
   RECORD(SEMA_DECL_REFS);
@@ -2725,6 +2726,26 @@
 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
   bytes(PreprocessedEntityOffsets));
   }
+
+  // Write the skipped region table for the preprocessing record.
+  ArrayRef SkippedRanges = PPRec.getSkippedRanges();
+  if (SkippedRanges.size() > 0) {
+std::vector SerializedSkippedRanges;
+SerializedSkippedRanges.reserve(SkippedRanges.size());
+for (auto const& Range : SkippedRanges)
+  SerializedSkippedRanges.emplace_back(Range);
+
+using namespace llvm;
+auto Abbrev = std::make_shared();
+Abbrev->Add(BitCodeAbbrevOp(PPD_SKIPPED_RANGES));
+Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
+unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
+
+Record.clear();
+Record.push_back(PPD_SKIPPED_RANGES);
+Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev, Record,
+  bytes(SerializedSkippedRanges));
+  }
 }
 
 unsigned ASTWriter::getLocalOrImportedSubmoduleID(Module *Mod) {
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3214,6 +3214,24 @@
   break;
 }
 
+case PPD_SKIPPED_RANGES: {
+  F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange*)Blob.data();
+  assert(Blob.size() % sizeof(PPSkippedRange) == 0);
+  F.NumPreprocessedSkippedRanges = Blob.size() / sizeof(PPSkippedRange);
+
+  if (!PP.getPreprocessingRecord())
+PP.createPreprocessingRecord();
+  if (!PP.getPreprocessingRecord()->getExternalSource())
+PP.getPreprocessingRecord()->SetExternalSource(*this);
+  F.BasePreprocessedSkippedRangeID = PP.getPreprocessingRecord()
+  ->allocateSkippedRanges(F.NumPreprocessedSkippedRanges);
+  
+  if (F.NumPreprocessedSkippedRanges > 0)
+GlobalSkippedRangeMap.insert(
+std::make_pair(F.BasePreprocessedSkippedRangeID, &F));
+  break;
+}
+
 case DECL_UPDATE_OFFSETS:
   if (Record.size() % 2 != 0) {
 Error("invalid DECL_UPDATE_OFFSETS block in AST file");
@@ -5379,6 +5397,20 @@
  Mod.FileSo

[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 123035.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Removed /*ref*/.
- Changed the command-line flag: it's -pch-storage now instead of 
-in-memory-pchs.
- Actually pass the StoreInMemory flag to PrecompiledPreamble::Build.
- Fixed a new usage of ClangdServer after rebase (In ClangdTests).


https://reviews.llvm.org/D39843

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/tool/ClangdMain.cpp
  test/clangd/completion.test
  test/clangd/diagnostics-preamble.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -332,6 +332,7 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+/*StorePreamblesInMemory=*/true,
 clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
@@ -396,6 +397,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -442,6 +444,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -490,7 +493,9 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -524,7 +529,9 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   // Just a random gcc version string
@@ -573,7 +580,9 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
@@ -641,6 +650,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -701,7 +711,8 @@
   clangd::CodeCompleteOptions Opts;
   Opts.Limit = 2;
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  Opts, EmptyLogger::getInstance());
+  /*StorePreamblesInMemory=*/true, Opts,
+  EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   FS.Files[FooCpp] = "";
@@ -796,7 +807,8 @@
 
   auto TestWithOpts = [&](clangd::CodeCompleteOptions Opts) {
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-Opts, EmptyLogger::getInstance());
+/*StorePreamblesInMemory=*/true, Opts,
+EmptyLogger::getInstance());
 // No need to sync reparses here as there are no asserts on diagnostics (or
 // other async operations).
 Server.addDocument(FooCpp, GlobalCompletion.Text);
@@ -989,6 +1001,7 @@
   {
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, get

[PATCH] D40089: [clangd] Make completion scores use 0-1 floats internally.

2017-11-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

This scale is much easier to mix with other signals, such as fuzzy match 
strength.
Mostly NFC, but it does reorder some low-priority items that get folded 
together at a score of 0 (see completion-qualifiers.test).
Removed the exact sortText from the testcases, because it's the ranking that we 
want to test.


https://reviews.llvm.org/D40089

Files:
  clangd/ClangdUnit.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-items-kinds.test
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test

Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -39,7 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 7,
 # CHECK-NEXT:"label": "fake::",
-# CHECK-NEXT:"sortText": "75fake"
+# CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
 
@@ -68,7 +68,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 7,
 # CHECK-NEXT:"label": "fake::",
-# CHECK-NEXT:"sortText": "75fake"
+# CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
@@ -97,7 +97,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 7,
 # CHECK-NEXT:"label": "fake::",
-# CHECK-NEXT:"sortText": "75fake"
+# CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
 Content-Length: 1024
Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -24,51 +24,51 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "a",
-# CHECK-NEXT:  "sortText": "35a"
+# CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "bb",
 # CHECK-NEXT:  "insertText": "bb",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "bb",
-# CHECK-NEXT:  "sortText": "35bb"
+# CHECK-NEXT:  "sortText": "{{.*}}bb"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "ccc",
 # CHECK-NEXT:  "insertText": "ccc",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "ccc",
-# CHECK-NEXT:  "sortText": "35ccc"
+# CHECK-NEXT:  "sortText": "{{.*}}ccc"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "f",
 # CHECK-NEXT:  "insertText": "f",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 2,
 # CHECK-NEXT:  "label": "f(int i, const float f) const",
-# CHECK-NEXT:  "sortText": "35f"
+# CHECK-NEXT:  "sortText": "{{.*}}f"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "filterText": "fake",
 # CHECK-NEXT:  "insertText": "fake",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 7,
 # CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
+# CHECK-NEXT:  "sortText": "{{.*}}fake"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "fake &",
 # CHECK-NEXT:  "filterText": "operator=",
 # CHECK-NEXT:  "insertText": "operator=",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 2,
 # CHECK-NEXT:  "label": "operator=(const fake &)",
-# CHECK-NEXT:  "sortText": "79operator="
+# CHECK-NEXT:  "sortText": "{{.*}}operator="
 # CHECK-NEXT:},
 # FIXME: Why do some buildbots show an extra operator==(fake&&) here?
 #  CHECK:{
@@ -78,7 +78,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 4,
 # CHECK-NEXT:  "label": "~fake()",
-# CHECK-NEXT:  "sortText": "79~fake"
+# CHECK-NEXT:  "sortText": "{{.*}}~fake"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 Content-Length: 148
@@ -96,60 +96,60 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "a",
-# CHECK-NEXT:  "sortText": "35a"
+# CHECK-NEXT:  "sortText": "{{.*}}"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "bb",
 # CHECK-NEXT:  "insertText": "bb",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "bb",
-# CHECK-NEXT:  "sortText": "35bb"
+# CHECK-NEXT:  "sortText": "{{.*}}"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",

[libcxx] r318313 - Clean up the tests for free data(), size() and empty()

2017-11-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 15 09:47:09 2017
New Revision: 318313

URL: http://llvm.org/viewvc/llvm-project?rev=318313&view=rev
Log:
Clean up the tests for free data(), size() and empty()

Modified:
libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp
libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp
libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp

Modified: libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp?rev=318313&r1=318312&r2=318313&view=diff
==
--- libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp Wed Nov 15 
09:47:09 2017
@@ -7,51 +7,54 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
 // 
 // template  constexpr auto data(C& c) -> decltype(c.data()); 
  // C++17
 // template  constexpr auto data(const C& c) -> decltype(c.data());   
  // C++17
 // template  constexpr T* data(T (&array)[N]) noexcept; 
  // C++17
 // template  constexpr const E* data(initializer_list il) 
noexcept;  // C++17
 
-#include "test_macros.h"
-
-#if TEST_STD_VER <= 14
-int main () {}
-#else
-
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template
 void test_const_container( const C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::data(c)   == c.data());
 }
 
 template
 void test_const_container( const std::initializer_list& c )
 {
+ASSERT_NOEXCEPT(std::data(c));
 assert ( std::data(c)   == c.begin());
 }
 
 template
 void test_container( C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::data(c)   == c.data());
 }
 
 template
 void test_container( std::initializer_list& c)
 {
+ASSERT_NOEXCEPT(std::data(c));
 assert ( std::data(c)   == c.begin());
 }
 
 template
 void test_const_array( const T (&array)[Sz] )
 {
+ASSERT_NOEXCEPT(std::data(array));
 assert ( std::data(array) == &array[0]);
 }
 
@@ -72,5 +75,3 @@ int main()
 static constexpr int arrA [] { 1, 2, 3 };
 test_const_array ( arrA );
 }
-
-#endif

Modified: libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp?rev=318313&r1=318312&r2=318313&view=diff
==
--- libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp Wed Nov 
15 09:47:09 2017
@@ -7,17 +7,13 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
 // 
 // template  constexpr auto empty(const C& c) -> decltype(c.empty()); 
  // C++17
 // template  constexpr bool empty(const T (&array)[N]) 
noexcept;  // C++17
 // template  constexpr bool empty(initializer_list il) noexcept;   
  // C++17
 
-#include "test_macros.h"
-
-#if TEST_STD_VER <= 14
-int main () {}
-#else
-
 #include 
 #include 
 #include 
@@ -25,9 +21,12 @@ int main () {}
 #include 
 #include 
 
+#include "test_macros.h"
+
 template
 void test_const_container( const C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::empty(c)   == c.empty());
 }
 
@@ -40,18 +39,21 @@ void test_const_container( const std::in
 template
 void test_container( C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::empty(c)   == c.empty());
 }
 
 template
 void test_container( std::initializer_list& c )
 {
+ASSERT_NOEXCEPT(std::empty(c));
 assert ( std::empty(c)   == (c.size() == 0));
 }
 
 template
 void test_const_array( const T (&array)[Sz] )
 {
+ASSERT_NOEXCEPT(std::empty(array));
 assert (!std::empty(array));
 }
 
@@ -75,5 +77,3 @@ int main()
 static constexpr int arrA [] { 1, 2, 3 };
 test_const_array ( arrA );
 }
-
-#endif

Modified: libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp?rev=318313&r1=318312&r2=318313&view=diff
==
--- libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp Wed Nov 15 
09:47:09 2017
@@ -7,16 +7,12 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
 // 
 // template  constexpr auto size(

r318314 - Try to fix test/SemaCXX/deleted-operator.cpp after r318309

2017-11-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Nov 15 09:47:58 2017
New Revision: 318314

URL: http://llvm.org/viewvc/llvm-project?rev=318314&view=rev
Log:
Try to fix test/SemaCXX/deleted-operator.cpp after r318309

The number of 'built-in candidate' notes now varies since __float128 may
or may not be a candidate depending on the target.

Modified:
cfe/trunk/test/SemaCXX/deleted-operator.cpp

Modified: cfe/trunk/test/SemaCXX/deleted-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-operator.cpp?rev=318314&r1=318313&r2=318314&view=diff
==
--- cfe/trunk/test/SemaCXX/deleted-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/deleted-operator.cpp Wed Nov 15 09:47:58 2017
@@ -8,8 +8,8 @@ struct PR10757 {
 int PR10757f() {
   PR10757 a1;
   // FIXME: We get a ridiculous number of "built-in candidate" notes here...
-  if(~a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 8 {{built-in candidate}}
-  if(a1==a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 144 {{built-in candidate}}
+  if(~a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 6-8 {{built-in candidate}}
+  if(a1==a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 1-144 {{built-in candidate}}
 }
 
 struct DelOpDel {


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


[PATCH] D39730: Enabling constructor code completion

2017-11-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D39730#926108, @jkorous-apple wrote:

> Sorry, what do you mean by "this works in the body of the class"?
>
> Definition of constructor inside class definition has been working even 
> before:
>
>   struct foo {
> foo();
> f
>   };
>   
>
> Do you mean that a test shall be added in order to check that it still works?


You're right, but we don't actually code-complete constructor in this case, but 
the struct name. I suppose we don't need to complete the constructor here, but 
we do need the destructor, i.e.:

  struct foo {
  ~
  };


https://reviews.llvm.org/D39730



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


[clang-tools-extra] r318316 - [clangd] Fix time units in clangd performance trace

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 09:53:46 2017
New Revision: 318316

URL: http://llvm.org/viewvc/llvm-project?rev=318316&view=rev
Log:
[clangd] Fix time units in clangd performance trace

Modified:
clang-tools-extra/trunk/clangd/Trace.cpp

Modified: clang-tools-extra/trunk/clangd/Trace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Trace.cpp?rev=318316&r1=318315&r2=318316&view=diff
==
--- clang-tools-extra/trunk/clangd/Trace.cpp (original)
+++ clang-tools-extra/trunk/clangd/Trace.cpp Wed Nov 15 09:53:46 2017
@@ -74,7 +74,7 @@ private:
 
   double timestamp() {
 using namespace std::chrono;
-return duration(system_clock::now() - Start).count();
+return duration(system_clock::now() - Start).count();
   }
 
   std::mutex Mu;


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


[clang-tools-extra] r318317 - [clangd] clang-format the source code. NFC.

2017-11-15 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Nov 15 10:04:56 2017
New Revision: 318317

URL: http://llvm.org/viewvc/llvm-project?rev=318317&view=rev
Log:
[clangd] clang-format the source code. NFC.

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=318317&r1=318316&r2=318317&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15 10:04:56 2017
@@ -132,9 +132,8 @@ void ClangdLSPServer::onRename(Ctx C, Re
   auto File = Params.textDocument.uri.file;
   auto Replacements = Server.rename(File, Params.position, Params.newName);
   if (!Replacements) {
-C.replyError(
-ErrorCode::InternalError,
-llvm::toString(Replacements.takeError()));
+C.replyError(ErrorCode::InternalError,
+ llvm::toString(Replacements.takeError()));
 return;
   }
   std::string Code = Server.getDocument(File);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=318317&r1=318316&r2=318317&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 10:04:56 2017
@@ -9,11 +9,11 @@
 
 #include "ClangdServer.h"
 #include "clang/Format/Format.h"
-#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
-#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=318317&r1=318316&r2=318317&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Wed Nov 15 10:04:56 
2017
@@ -66,13 +66,15 @@ void RequestContext::reply(json::Expr &&
   });
 }
 
-void RequestContext::replyError(ErrorCode code, const llvm::StringRef 
&Message) {
+void RequestContext::replyError(ErrorCode code,
+const llvm::StringRef &Message) {
   Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", static_cast(code)}, {"message", 
Message}}},
+{"error",
+ json::obj{{"code", static_cast(code)}, {"message", Message}}},
 });
   }
 }

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=318317&r1=318316&r2=318317&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Wed Nov 15 10:04:56 2017
@@ -1094,7 +1094,7 @@ RenameParams::parse(llvm::yaml::MappingN
 
 if (KeyValue == "textDocument") {
   auto *Value =
-dyn_cast_or_null(NextKeyValue.getValue());
+  dyn_cast_or_null(NextKeyValue.getValue());
   if (!Value)
 continue;
   auto *Map = dyn_cast(Value);

Modified: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp?rev=318317&r1=318316&r2=318317&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp Wed Nov 15 
10:04:56 2017
@@ -94,20 +94,18 @@ TEST(JSONExprTests, PrettyPrinting) {
   }
 })";
 
-  EXPECT_EQ(
-  str,
-  sp(obj{
-  {"empty_object", obj{}},
-  {"empty_array", {}},
-  {"full_array", {1, nullptr}},
-  {"full_object",
-   obj{
-   {"nested_array",
-{obj{
-{"property", "value"},
-}}},
-   }},
-  }));
+  EX

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:683
+  if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
 

Please define `__ARM_DWARF_EH__` if dwarf is enabled on arm, see D39533, as I 
commented earlier. (Sorry, I forgot about it and thought it was fixed already.)


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


RE: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Robinson, Paul via cfe-commits
Hi Sam,
It looks like llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast has been
failing a couple of clangd tests ever since this went in.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13517

Please fix or revert ASAP when bots go red.  Failures like this interfere
with our CI process.

Thanks,
--paulr
PS4 code owner


> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Sam McCall via cfe-commits
> Sent: Wednesday, November 15, 2017 1:16 AM
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r318287 - [clangd] Support returning a
> limited number of completion results.
> 
> Author: sammccall
> Date: Wed Nov 15 01:16:29 2017
> New Revision: 318287
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=318287&view=rev
> Log:
> [clangd] Support returning a limited number of completion results.
> 
> Summary:
> All results are scored, we only process CodeCompletionStrings for the
> winners.
> We now return CompletionList rather than CompletionItem[] (both are
> valid).
> sortText is now based on CodeCompletionResult::orderedName (mostly the
> same).
> 
> This is the first clangd-only completion option, so plumbing changed.
> It requires a small clangd patch (exposing
> CodeCompletionResult::orderedName).
> 
> (This can't usefully be enabled yet: we don't support server-side
> filtering)
> 
> Reviewers: ilya-biryukov
> 
> Subscribers: cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D39852
> 
> Modified:
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.h
> clang-tools-extra/trunk/clangd/ClangdUnit.cpp
> clang-tools-extra/trunk/clangd/ClangdUnit.h
> clang-tools-extra/trunk/clangd/Protocol.cpp
> clang-tools-extra/trunk/clangd/Protocol.h
> clang-tools-extra/trunk/test/clangd/authority-less-uri.test
> clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
> clang-tools-extra/trunk/test/clangd/completion-priorities.test
> clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
> clang-tools-extra/trunk/test/clangd/completion-snippet.test
> clang-tools-extra/trunk/test/clangd/completion.test
> clang-tools-extra/trunk/test/clangd/protocol.test
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> 
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/ClangdLSPServer.cpp?rev=318287&r1=318286&r2=318287&view
> =diff
> ==
> 
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15 01:16:29
> 2017
> @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
>  }
> 
>  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
> &Params) {
> -  auto Items = Server
> -   .codeComplete(Params.textDocument.uri.file,
> - Position{Params.position.line,
> -  Params.position.character})
> -   .get() // FIXME(ibiryukov): This could be made async
> if we
> -  // had an API that would allow to attach
> callbacks to
> -  // futures returned by ClangdServer.
> -   .Value;
> -  C.reply(json::ary(Items));
> +  auto List = Server
> +  .codeComplete(
> +  Params.textDocument.uri.file,
> +  Position{Params.position.line,
> Params.position.character})
> +  .get() // FIXME(ibiryukov): This could be made async if
> we
> + // had an API that would allow to attach
> callbacks to
> + // futures returned by ClangdServer.
> +  .Value;
> +  C.reply(List);
>  }
> 
>  void ClangdLSPServer::onSignatureHelp(Ctx C,
> 
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/ClangdServer.cpp?rev=318287&r1=318286&r2=318287&view=di
> ff
> ==
> 
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
> 2017
> @@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
>   std::move(TaggedFS));
>  }
> 
> -std::future>>
> +std::future>
>  ClangdServer::codeComplete(PathRef File, Position Pos,
> llvm::Optional OverridenContents,
> IntrusiveRefCntPtr *UsedFS) {
> -  using ResultType = Tagged>;
> +  using ResultType = Tagged;
> 
>std::promise ResultPromise;
> 
> @@ -242,11 +242,10 @@ ClangdServ

[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:13
+
+#include 
+#include 

Including  is forbidden by our coding standard. However, it doesn't 
appear to be used in the source file, either.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:41
+  switchStmt(hasCondition(allOf(
+  // Match on switch statements that have either bitfield or 
integer
+  // condition.

either bitfield or integer condition -> either a bit-field or an integer 
condition



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:43
+  // condition.
+  // The ordering in 'anyOf()' is important, since the last
+  // condition is the most general.

since -> because

Also, drop the comma.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:48
+hasDescendant(declRefExpr().bind("non-enum-condition"))),
+  // 'unless()' must be the last match here and must be binded,
+  // otherwise the matcher does not work correctly.

binded -> bound



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:54
+
+  /// This option is noisy, therefore matching is configurable.
+  if (WarnOnMissingElse) {

Don't use doxygen comments here.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:63
+
+namespace {
+unsigned countCaseLabels(const SwitchStmt *Switch) {

Our usual preference is to make these methods static rather than put them in an 
anonymous namespace (types go into anonymous namespaces, however).



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:80
+
+  return Bits > 0 && DiscreteValues <= 1
+ ? std::numeric_limits::max()

This logic does not make sense to me -- the goal is to test for overflow, which 
can be done solely by looking at the value of `Bits` and the size of 
`std::size_t`. The current logic appears to return 1 if `Bits == 0` and will 
only return the max value if the wraparound happens to precisely create the 
value 0 or 1. I'd replace with:
```
return Bits >= std::numeric_limits::digits() ? 
std::numeric_limits::max() : static_cast(1) << Bits;
```



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:84
+}
+/// Get the number of different values for the Type T, that is switched on.
+///

How about: Get the number of possible values that can be switched on for the 
type T



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:91-92
+  // Context.getTypeSize(T) returns the number of bits T uses.
+  // Calculates the number of discrete values that are representable by this
+  // type.
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))

I don't think this comment adds value.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:94
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))
+: twoPow(0ul);
+}

No need for the `ul` suffix -- the type will undergo implicit conversion with 
or without the suffix.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:94
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))
+: twoPow(0ul);
+}

aaron.ballman wrote:
> No need for the `ul` suffix -- the type will undergo implicit conversion with 
> or without the suffix.
Why call toPow instead of just returning the value `1` directly?



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:102
+diag(ElseIfWithoutElse->getLocStart(),
+ "potential uncovered codepath; add an ending else branch");
+return;

potential uncovered codepath -> potentially uncovered code path
branch -> statement



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:131
+const SwitchStmt *Switch) {
+  const unsigned CaseCount = countCaseLabels(Switch);
+  assert(CaseCount > 0 && "Switch statementt with supposedly one default "

No need to make this `const` (we only do that for reference and pointer types, 
not other local variable or parameter types). Here and elsewhere.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:132
+  const unsigned CaseCount = countCaseLabels(Switch);
+  assert(CaseCount > 0 && "Switch statementt with supposedly one default "
+  "branch did not contain any case labels");

statementt -> statement



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:138
+ ? "degenerated switch with default label only"
+ : "switch could be b

Re: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Galina Kistanova via cfe-commits
Hello Sam,

One of tests is failing on
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/20638

Please have a look?

Thanks

Galina

...

Failing Tests (1):
Clang Tools :: clangd/completion.test


On Wed, Nov 15, 2017 at 1:16 AM, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Wed Nov 15 01:16:29 2017
> New Revision: 318287
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318287&view=rev
> Log:
> [clangd] Support returning a limited number of completion results.
>
> Summary:
> All results are scored, we only process CodeCompletionStrings for the
> winners.
> We now return CompletionList rather than CompletionItem[] (both are valid).
> sortText is now based on CodeCompletionResult::orderedName (mostly the
> same).
>
> This is the first clangd-only completion option, so plumbing changed.
> It requires a small clangd patch (exposing CodeCompletionResult::
> orderedName).
>
> (This can't usefully be enabled yet: we don't support server-side
> filtering)
>
> Reviewers: ilya-biryukov
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D39852
>
> Modified:
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.h
> clang-tools-extra/trunk/clangd/ClangdUnit.cpp
> clang-tools-extra/trunk/clangd/ClangdUnit.h
> clang-tools-extra/trunk/clangd/Protocol.cpp
> clang-tools-extra/trunk/clangd/Protocol.h
> clang-tools-extra/trunk/test/clangd/authority-less-uri.test
> clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
> clang-tools-extra/trunk/test/clangd/completion-priorities.test
> clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
> clang-tools-extra/trunk/test/clangd/completion-snippet.test
> clang-tools-extra/trunk/test/clangd/completion.test
> clang-tools-extra/trunk/test/clangd/protocol.test
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdLSPServer.cpp?rev=318287&r1=318286&r2=318287&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15
> 01:16:29 2017
> @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
>  }
>
>  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
> &Params) {
> -  auto Items = Server
> -   .codeComplete(Params.textDocument.uri.file,
> - Position{Params.position.line,
> -  Params.position.character})
> -   .get() // FIXME(ibiryukov): This could be made async
> if we
> -  // had an API that would allow to attach
> callbacks to
> -  // futures returned by ClangdServer.
> -   .Value;
> -  C.reply(json::ary(Items));
> +  auto List = Server
> +  .codeComplete(
> +  Params.textDocument.uri.file,
> +  Position{Params.position.line,
> Params.position.character})
> +  .get() // FIXME(ibiryukov): This could be made async if
> we
> + // had an API that would allow to attach
> callbacks to
> + // futures returned by ClangdServer.
> +  .Value;
> +  C.reply(List);
>  }
>
>  void ClangdLSPServer::onSignatureHelp(Ctx C,
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.cpp?rev=318287&r1=318286&r2=318287&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
> 2017
> @@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
>   std::move(TaggedFS));
>  }
>
> -std::future>>
> +std::future>
>  ClangdServer::codeComplete(PathRef File, Position Pos,
> llvm::Optional OverridenContents,
> IntrusiveRefCntPtr *UsedFS) {
> -  using ResultType = Tagged>;
> +  using ResultType = Tagged;
>
>std::promise ResultPromise;
>
> @@ -242,11 +242,10 @@ ClangdServer::codeComplete(PathRef File,
>  }
>
>  void ClangdServer::codeComplete(
> -UniqueFunction>)> Callback,
> -PathRef File, Position Pos, llvm::Optional
> OverridenContents,
> +UniqueFunction)> Callback, PathRef File,
> +Position Pos, llvm::Optional OverridenContents,
>  IntrusiveRefCntPtr *UsedFS) {
> -  using CallbackType =
> -  UniqueFunction>)>;
> +  u

[PATCH] D39955: [Driver] Add command-line flags for the new TBAA metadata format

2017-11-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  I'm fine with living with both formats as long as we're not exposing 
this as a feature.


Repository:
  rL LLVM

https://reviews.llvm.org/D39955



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


Re: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Galina Kistanova via cfe-commits
Also at least one more builder is affected:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13517

Thanks

Galina

On Wed, Nov 15, 2017 at 10:54 AM, Galina Kistanova 
wrote:

> Hello Sam,
>
> One of tests is failing on
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-ubuntu-fast/builds/20638
>
> Please have a look?
>
> Thanks
>
> Galina
>
> ...
>
> Failing Tests (1):
> Clang Tools :: clangd/completion.test
>
>
> On Wed, Nov 15, 2017 at 1:16 AM, Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Wed Nov 15 01:16:29 2017
>> New Revision: 318287
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318287&view=rev
>> Log:
>> [clangd] Support returning a limited number of completion results.
>>
>> Summary:
>> All results are scored, we only process CodeCompletionStrings for the
>> winners.
>> We now return CompletionList rather than CompletionItem[] (both are
>> valid).
>> sortText is now based on CodeCompletionResult::orderedName (mostly the
>> same).
>>
>> This is the first clangd-only completion option, so plumbing changed.
>> It requires a small clangd patch (exposing CodeCompletionResult::orderedN
>> ame).
>>
>> (This can't usefully be enabled yet: we don't support server-side
>> filtering)
>>
>> Reviewers: ilya-biryukov
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D39852
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> clang-tools-extra/trunk/clangd/ClangdServer.h
>> clang-tools-extra/trunk/clangd/ClangdUnit.cpp
>> clang-tools-extra/trunk/clangd/ClangdUnit.h
>> clang-tools-extra/trunk/clangd/Protocol.cpp
>> clang-tools-extra/trunk/clangd/Protocol.h
>> clang-tools-extra/trunk/test/clangd/authority-less-uri.test
>> clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
>> clang-tools-extra/trunk/test/clangd/completion-priorities.test
>> clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
>> clang-tools-extra/trunk/test/clangd/completion-snippet.test
>> clang-tools-extra/trunk/test/clangd/completion.test
>> clang-tools-extra/trunk/test/clangd/protocol.test
>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdLSPServer.cpp?rev=318287&r1=318286&r2=318287&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15
>> 01:16:29 2017
>> @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
>>  }
>>
>>  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
>> &Params) {
>> -  auto Items = Server
>> -   .codeComplete(Params.textDocument.uri.file,
>> - Position{Params.position.line,
>> -  Params.position.character})
>> -   .get() // FIXME(ibiryukov): This could be made async
>> if we
>> -  // had an API that would allow to attach
>> callbacks to
>> -  // futures returned by ClangdServer.
>> -   .Value;
>> -  C.reply(json::ary(Items));
>> +  auto List = Server
>> +  .codeComplete(
>> +  Params.textDocument.uri.file,
>> +  Position{Params.position.line,
>> Params.position.character})
>> +  .get() // FIXME(ibiryukov): This could be made async
>> if we
>> + // had an API that would allow to attach
>> callbacks to
>> + // futures returned by ClangdServer.
>> +  .Value;
>> +  C.reply(List);
>>  }
>>
>>  void ClangdLSPServer::onSignatureHelp(Ctx C,
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.cpp?rev=318287&r1=318286&r2=318287&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
>> 2017
>> @@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
>>   std::move(TaggedFS));
>>  }
>>
>> -std::future>>
>> +std::future>
>>  ClangdServer::codeComplete(PathRef File, Position Pos,
>> llvm::Optional OverridenContents,
>> IntrusiveRefCntPtr *UsedFS)
>> {
>> -  using ResultType = Tagged>;
>> +  using ResultType = Tagged;
>>
>>std::promise ResultPromise;
>>
>> @@ -242,11 +242,10 @@ ClangdServer::codeComplet

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rsmith, aaron.ballman.
aaron.ballman added a comment.

I think the new wording is a bit more clear, in general.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1595-1597
+def err_member_function_call_other : Error<
+  "cannot initialize object parameter of type %0 with an expression "
+  "of type %1">;

I don't think this diagnostic needs to be moved and renamed; the old name was 
more clear than "other" on the new name.



Comment at: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp:22-24
+  void lvalue() &; // expected-note 2 {{'lvalue' declared here}}
+  void const_lvalue() const&;
+  void rvalue() &&; // expected-note {{'rvalue' declared here}}

Can you add examples that cover the other diagnostic wordings as well 
(volatile, restrict, combinations, etc)?


https://reviews.llvm.org/D39937



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


Re: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Sam McCall via cfe-commits
Sorry about these - I've finally understood what's going on.
It looks like the PS4 has a different default --std, which probably doesn't
make sense for clangd. I'll override it.

On Wed, Nov 15, 2017 at 7:49 PM, Robinson, Paul 
wrote:

> Hi Sam,
> It looks like llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast has been
> failing a couple of clangd tests ever since this went in.
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/13517
>
> Please fix or revert ASAP when bots go red.  Failures like this interfere
> with our CI process.
>
> Thanks,
> --paulr
> PS4 code owner
>
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Sam McCall via cfe-commits
> > Sent: Wednesday, November 15, 2017 1:16 AM
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r318287 - [clangd] Support returning a
> > limited number of completion results.
> >
> > Author: sammccall
> > Date: Wed Nov 15 01:16:29 2017
> > New Revision: 318287
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=318287&view=rev
> > Log:
> > [clangd] Support returning a limited number of completion results.
> >
> > Summary:
> > All results are scored, we only process CodeCompletionStrings for the
> > winners.
> > We now return CompletionList rather than CompletionItem[] (both are
> > valid).
> > sortText is now based on CodeCompletionResult::orderedName (mostly the
> > same).
> >
> > This is the first clangd-only completion option, so plumbing changed.
> > It requires a small clangd patch (exposing
> > CodeCompletionResult::orderedName).
> >
> > (This can't usefully be enabled yet: we don't support server-side
> > filtering)
> >
> > Reviewers: ilya-biryukov
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D39852
> >
> > Modified:
> > clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> > clang-tools-extra/trunk/clangd/ClangdServer.cpp
> > clang-tools-extra/trunk/clangd/ClangdServer.h
> > clang-tools-extra/trunk/clangd/ClangdUnit.cpp
> > clang-tools-extra/trunk/clangd/ClangdUnit.h
> > clang-tools-extra/trunk/clangd/Protocol.cpp
> > clang-tools-extra/trunk/clangd/Protocol.h
> > clang-tools-extra/trunk/test/clangd/authority-less-uri.test
> > clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
> > clang-tools-extra/trunk/test/clangd/completion-priorities.test
> > clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
> > clang-tools-extra/trunk/test/clangd/completion-snippet.test
> > clang-tools-extra/trunk/test/clangd/completion.test
> > clang-tools-extra/trunk/test/clangd/protocol.test
> > clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> >
> > Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/ClangdLSPServer.cpp?rev=318287&r1=318286&r2=318287&
> view
> > =diff
> > 
> ==
> > 
> > --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> > +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15
> 01:16:29
> > 2017
> > @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
> >  }
> >
> >  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
> > &Params) {
> > -  auto Items = Server
> > -   .codeComplete(Params.textDocument.uri.file,
> > - Position{Params.position.line,
> > -  Params.position.character})
> > -   .get() // FIXME(ibiryukov): This could be made async
> > if we
> > -  // had an API that would allow to attach
> > callbacks to
> > -  // futures returned by ClangdServer.
> > -   .Value;
> > -  C.reply(json::ary(Items));
> > +  auto List = Server
> > +  .codeComplete(
> > +  Params.textDocument.uri.file,
> > +  Position{Params.position.line,
> > Params.position.character})
> > +  .get() // FIXME(ibiryukov): This could be made async
> if
> > we
> > + // had an API that would allow to attach
> > callbacks to
> > + // futures returned by ClangdServer.
> > +  .Value;
> > +  C.reply(List);
> >  }
> >
> >  void ClangdLSPServer::onSignatureHelp(Ctx C,
> >
> > Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/ClangdServer.cpp?rev=318287&
> r1=318286&r2=318287&view=di
> > ff
> > 
> ==
> > 
> > --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> > +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
> > 2017
> >

[libcxx] r318325 - [test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

2017-11-15 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Wed Nov 15 11:14:45 2017
New Revision: 318325

URL: http://llvm.org/viewvc/llvm-project?rev=318325&view=rev
Log:
[test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

Differential Revision: D39221

Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp?rev=318325&r1=318324&r2=318325&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -36,7 +36,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int unsized_delete_called = 0;
 int unsized_delete_nothrow_called = 0;

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp?rev=318325&r1=318324&r2=318325&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -38,7 +38,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp?rev=318325&r1=318324&r2=318325&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp?rev=318325&r1=318324&r2=318325&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -34,7 +34,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std:

[PATCH] D39221: [libcxx] [test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

2017-11-15 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318325: [test] Alignment must be > 
__STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D39221?vs=119990&id=123062#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39221

Files:
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int unsized_delete_called = 0;
 int unsized_delete_nothrow_called = 0;
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
@@ -24,7 +24,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
===

[PATCH] D40093: Split x86 "Processor" info into its own def file.

2017-11-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

A first step toward removing the repetition of
features/CPU info in the x86 target info, this
patch pulls all the processor information out into
its own .def file.


https://reviews.llvm.org/D40093

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h

Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -95,178 +95,8 @@
   /// loosely correspond to the options passed to '-march' or '-mtune' flags.
   enum CPUKind {
 CK_Generic,
-
-/// \name i386
-/// i386-generation processors.
-//@{
-CK_i386,
-//@}
-
-/// \name i486
-/// i486-generation processors.
-//@{
-CK_i486,
-CK_WinChipC6,
-CK_WinChip2,
-CK_C3,
-//@}
-
-/// \name i586
-/// i586-generation processors, P5 microarchitecture based.
-//@{
-CK_i586,
-CK_Pentium,
-CK_PentiumMMX,
-//@}
-
-/// \name i686
-/// i686-generation processors, P6 / Pentium M microarchitecture based.
-//@{
-CK_PentiumPro,
-CK_Pentium2,
-CK_Pentium3,
-CK_PentiumM,
-CK_C3_2,
-
-/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
-/// Clang however has some logic to support this.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Yonah,
-//@}
-
-/// \name Netburst
-/// Netburst microarchitecture based processors.
-//@{
-CK_Pentium4,
-CK_Prescott,
-CK_Nocona,
-//@}
-
-/// \name Core
-/// Core microarchitecture based processors.
-//@{
-CK_Core2,
-
-/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
-/// codename which GCC no longer accepts as an option to -march, but Clang
-/// has some logic for recognizing it.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Penryn,
-//@}
-
-/// \name Atom
-/// Atom processors
-//@{
-CK_Bonnell,
-CK_Silvermont,
-CK_Goldmont,
-//@}
-
-/// \name Nehalem
-/// Nehalem microarchitecture based processors.
-CK_Nehalem,
-
-/// \name Westmere
-/// Westmere microarchitecture based processors.
-CK_Westmere,
-
-/// \name Sandy Bridge
-/// Sandy Bridge microarchitecture based processors.
-CK_SandyBridge,
-
-/// \name Ivy Bridge
-/// Ivy Bridge microarchitecture based processors.
-CK_IvyBridge,
-
-/// \name Haswell
-/// Haswell microarchitecture based processors.
-CK_Haswell,
-
-/// \name Broadwell
-/// Broadwell microarchitecture based processors.
-CK_Broadwell,
-
-/// \name Skylake Client
-/// Skylake client microarchitecture based processors.
-CK_SkylakeClient,
-
-/// \name Skylake Server
-/// Skylake server microarchitecture based processors.
-CK_SkylakeServer,
-
-/// \name Cannonlake Client
-/// Cannonlake client microarchitecture based processors.
-CK_Cannonlake,
-
-/// \name Knights Landing
-/// Knights Landing processor.
-CK_KNL,
-
-/// \name Knights Mill
-/// Knights Mill processor.
-CK_KNM,
-
-/// \name Lakemont
-/// Lakemont microarchitecture based processors.
-CK_Lakemont,
-
-/// \name K6
-/// K6 architecture processors.
-//@{
-CK_K6,
-CK_K6_2,
-CK_K6_3,
-//@}
-
-/// \name K7
-/// K7 architecture processors.
-//@{
-CK_Athlon,
-CK_AthlonXP,
-//@}
-
-/// \name K8
-/// K8 architecture processors.
-//@{
-CK_K8,
-CK_K8SSE3,
-CK_AMDFAM10,
-//@}
-
-/// \name Bobcat
-/// Bobcat architecture processors.
-//@{
-CK_BTVER1,
-CK_BTVER2,
-//@}
-
-/// \name Bulldozer
-/// Bulldozer architecture processors.
-//@{
-CK_BDVER1,
-CK_BDVER2,
-CK_BDVER3,
-CK_BDVER4,
-//@}
-
-/// \name zen
-/// Zen architecture processors.
-//@{
-CK_ZNVER1,
-//@}
-
-/// This specification is deprecated and will be removed in the future.
-/// Users should prefer \see CK_K8.
-// FIXME: Warn on this when the CPU is set to it.
-//@{
-CK_x86_64,
-//@}
-
-/// \name Geode
-/// Geode processors.
-//@{
-CK_Geode
-//@}
+#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
+#include "clang/Basic/X86Target.def"
   } CPU = CK_Generic;
 
   bool checkCPUKind(CPUKind Kind) const;
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -1504,121 +1504,19 @@
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  case CK_PentiumMMX:
-  case CK_PentiumPro:
-  case CK_Pentium2:
-  case CK_Pentium3:
-  case CK_PentiumM:
-  case CK_Yonah:
-  case CK_C3_2:
-  case

[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8913
+  }
+  return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
+}

The spec says "Aggregates larger than 2✕XLEN bits are passed by reference and 
are replaced in the argument list with the address".  That's not byval.


https://reviews.llvm.org/D40023



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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-15 Thread Volodymyr Sapsai via cfe-commits
On Nov 12, 2017, at 12:37, Reimar Döffinger  wrote:
> 
> On Thu, Nov 09, 2017 at 05:37:32PM -0800, Volodymyr Sapsai wrote:
>> On Nov 9, 2017, at 12:13, Reimar Döffinger  wrote:
>>> 
>>> Hello!
>>> 
>>> On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote:
 Thanks for the patch, Reimar. Can you please add tests to ensure this 
 functionality doesn’t regress? As null character is required by the 
 standard (27.7.2.3p21), a good starting point seems to be
 test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
 test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
>>> 
>>> New patch attached, though I went the lazy way of just adding one case.
>>> Not sure that's "good enough" - in principle I think it should be.
>> I think it makes sense to cover wchar_t as well. And I think it would be 
>> useful to test the case with specified delimiter too. Most likely 
>> implementation should be reused for the case with explicit delimiter and 
>> default new line delimiter. But I prefer not to rely on this assumption and 
>> test explicitly.
> 
> Well, it was rather trivial to do anyway, so done.
Thanks for adding more tests.

>>> More tricky would be to add a test for the _LIBCPP_NO_EXCEPTIONS case,
>>> is there any code testing that at all?
>> According to tests, exceptions are tested in various ways. Let me find how 
>> to configure the build to run tests in these modes.
> 
> There aren't many references to that mode, and I am not sure
> running in a separate mode would make for a good test anyway.
> Maybe not how it should done, but for now I added a separate file
> that just defines _LIBCPP_NO_EXCEPTIONS before the includes.
> <0001-Ensure-std-istream-getline-always-0-terminates-strin.patch>

libc++ can be built with exceptions enabled or disabled (see 
LIBCXX_ENABLE_EXCEPTIONS 
)
 and we need to support both configurations. The problem with your 
_LIBCPP_NO_EXCEPTIONS approach is that it won't work when exceptions are 
disabled. Various exception-related tests are usually guarded with 
TEST_HAS_NO_EXCEPTIONS macro defined in “test_macros.h”. You can check other 
tests for examples of TEST_HAS_NO_EXCEPTIONS usage, I had in mind something like

#ifndef TEST_HAS_NO_EXCEPTIONS
{
testbuf sb(" ");
std::istream is(&sb);
char s[5] = "test";
is.exceptions(std::istream::eofbit | std::istream::badbit);
try
{
is.getline(s, 5);
assert(false);
}
catch (std::ios_base::failure&)
{
}
assert( is.eof());
assert( is.fail());
assert(std::string(s) == " ");
assert(is.gcount() == 1);
}
#endif

Non-empty `sb` allows to test null-termination at correct place in array; 
initializing `s` with “test” avoids spurious correct values in memory; 
try-catch block and badbit are to make it more obvious we are testing code path 
throwing an exception.___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r318327 - [clangd] Try to unbreak tests on PS4 by targeting PC explicitly

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 11:38:09 2017
New Revision: 318327

URL: http://llvm.org/viewvc/llvm-project?rev=318327&view=rev
Log:
[clangd] Try to unbreak tests on PS4 by targeting PC explicitly

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=318327&r1=318326&r2=318327&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov 15 
11:38:09 2017
@@ -31,7 +31,11 @@ static void addExtraFlags(tooling::Compi
 }
 
 tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
-  std::vector CommandLine{"clang", "-fsyntax-only", File.str()};
+  // We don't specify --std because we want to infer it from the filename.
+  // We force PC because PS4 will change --std from under us.
+  // FIXME: there must be a more principled way to do this!
+  std::vector CommandLine{
+  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File), CommandLine,
  /*Output=*/"");


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


Re: [clang-tools-extra] r318327 - [clangd] Try to unbreak tests on PS4 by targeting PC explicitly

2017-11-15 Thread Alex L via cfe-commits
This doesn't seem like a good permanent solution (as Paul pointed out -std
will change in the future). Will you be able to avoid this in the future?

On 15 November 2017 at 11:38, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Wed Nov 15 11:38:09 2017
> New Revision: 318327
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318327&view=rev
> Log:
> [clangd] Try to unbreak tests on PS4 by targeting PC explicitly
>
> Modified:
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>
> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/
> GlobalCompilationDatabase.cpp?rev=318327&r1=318326&r2=318327&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> (original)
> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov
> 15 11:38:09 2017
> @@ -31,7 +31,11 @@ static void addExtraFlags(tooling::Compi
>  }
>
>  tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
> -  std::vector CommandLine{"clang", "-fsyntax-only",
> File.str()};
> +  // We don't specify --std because we want to infer it from the filename.
> +  // We force PC because PS4 will change --std from under us.
> +  // FIXME: there must be a more principled way to do this!
> +  std::vector CommandLine{
> +  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown", File.str()};
>return tooling::CompileCommand(llvm::sys::path::parent_path(File),
>   llvm::sys::path::filename(File),
> CommandLine,
>   /*Output=*/"");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r318327 - [clangd] Try to unbreak tests on PS4 by targeting PC explicitly

2017-11-15 Thread Sam McCall via cfe-commits
On Wed, Nov 15, 2017 at 8:43 PM, Alex L  wrote:

> This doesn't seem like a good permanent solution (as Paul pointed out -std
> will change in the future).
>
Right, clearly not :-) It's a temporary fix to get the tests to pass.
Reverting the patch isn't that useful because it only masks the problem
(our testcases already include hacks around this)

Will you be able to avoid this in the future?
>
Ideally we would make most of the tests independent of the default --std,
probably by pinning it to something specific.
Then we'd just need one explicit test that we have the right default
behavior, which would be updated when the default changes.

I can do some work on this, but I could use some advice from people more
familiar with lit testing patterns. (Mostly this all seems like an argument
for unit-testing instead, to me :-)

On 15 November 2017 at 11:38, Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Wed Nov 15 11:38:09 2017
>> New Revision: 318327
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318327&view=rev
>> Log:
>> [clangd] Try to unbreak tests on PS4 by targeting PC explicitly
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/GlobalCompilationDatabase.cpp?rev=318327&r1=318326&
>> r2=318327&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>> (original)
>> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov
>> 15 11:38:09 2017
>> @@ -31,7 +31,11 @@ static void addExtraFlags(tooling::Compi
>>  }
>>
>>  tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
>> -  std::vector CommandLine{"clang", "-fsyntax-only",
>> File.str()};
>> +  // We don't specify --std because we want to infer it from the
>> filename.
>> +  // We force PC because PS4 will change --std from under us.
>> +  // FIXME: there must be a more principled way to do this!
>> +  std::vector CommandLine{
>> +  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown",
>> File.str()};
>>return tooling::CompileCommand(llvm::sys::path::parent_path(File),
>>   llvm::sys::path::filename(File),
>> CommandLine,
>>   /*Output=*/"");
>>
>>
>> ___
>> 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] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-15 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1595-1597
+def err_member_function_call_other : Error<
+  "cannot initialize object parameter of type %0 with an expression "
+  "of type %1">;

aaron.ballman wrote:
> I don't think this diagnostic needs to be moved and renamed; the old name was 
> more clear than "other" on the new name.
How about `_bad_type`? I was hoping to give these all similar names since they 
happen during the same implicit conversion. Also, while "implicit object 
parameter" is technically a correct name, it seems to be not very commonly used 
and would confuse users. Though it's also valuable for the diagnostic id to be 
similar to the actual text...


https://reviews.llvm.org/D39937



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


[libcxx] r318328 - More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in string, string_view, and the free function std::empty(). Removed tabs from , which is why th

2017-11-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 15 12:02:27 2017
New Revision: 318328

URL: http://llvm.org/viewvc/llvm-project?rev=318328&view=rev
Log:
More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in 
string, string_view, and the free function std::empty(). Removed tabs from 
, which is why the diff is so big.

Added:
libcxx/trunk/test/std/iterators/iterator.container/empty.array.fail.cpp
libcxx/trunk/test/std/iterators/iterator.container/empty.container.fail.cpp

libcxx/trunk/test/std/iterators/iterator.container/empty.initializer_list.fail.cpp
libcxx/trunk/test/std/strings/basic.string/string.capacity/empty.fail.cpp

libcxx/trunk/test/std/strings/string.view/string.view.capacity/empty.fail.cpp
Modified:
libcxx/trunk/include/iterator
libcxx/trunk/include/string
libcxx/trunk/include/string_view
libcxx/trunk/test/std/strings/basic.string/string.capacity/empty.pass.cpp

libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=318328&r1=318327&r2=318328&view=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed Nov 15 12:02:27 2017
@@ -1791,30 +1791,39 @@ end(const _Cp& __c)
 
 #if _LIBCPP_STD_VER > 14
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr auto size(const _Cont& __c) -> decltype(__c.size()) { return 
__c.size(); }
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr auto empty(const _Cont& __c) -> decltype(__c.empty()) { return 
__c.empty(); }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() 
== 0; }
 
 template  constexpr
+inline _LIBCPP_INLINE_VISIBILITY
 auto data(_Cont& __c) -> decltype(__c.data()) { return __c.data(); }
 
 template  constexpr
+inline _LIBCPP_INLINE_VISIBILITY
 auto data(const _Cont& __c) -> decltype(__c.data()) { return __c.data(); }
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return 
__il.begin(); }
 #endif
 

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=318328&r1=318327&r2=318328&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Nov 15 12:02:27 2017
@@ -608,7 +608,7 @@ struct __libcpp_string_gets_noexcept_ite
 
 template 
 struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT(
-   ( is_convertible 
>::value &&
+( is_convertible >::value &&
  !is_convertible::value)) {};
 
 #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
@@ -901,7 +901,8 @@ public:
 void shrink_to_fit() _NOEXCEPT {reserve();}
 _LIBCPP_INLINE_VISIBILITY
 void clear() _NOEXCEPT;
-_LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 
0;}
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+bool empty() const _NOEXCEPT {return size() == 0;}
 
 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) 
const _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY reference   operator[](size_type __pos)  
 _NOEXCEPT;
@@ -1756,10 +1757,10 @@ template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(
  const _Tp& __t, size_type __pos, size_type __n, const 
allocator_type& __a,
-typename 
enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 
void>::type *)
+ typename enable_if<__can_be_converted_to_string_view<_CharT, 
_Traits, _Tp>::value, void>::type *)
 : __r_(__second_tag(), __a)
 {
-   __self_view __sv = __self_view(__t).substr(__pos, __n);
+__self_view __sv = __self_view(__t).substr(__pos, __n);
 __init(__sv.data(), __sv.size());
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
@@ -2145,7 +2146,7 @@ template 
 typename enable_if
 <
 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
-   basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type 
__pos, size_type __n)
 {
@@ -2493,7 +2494,7 @@ template 
 typename enable_if
 <
 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
-   basic_string<_Cha

[clang-tools-extra] r318329 - [clangd] Fix flag name from r318327

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 12:10:14 2017
New Revision: 318329

URL: http://llvm.org/viewvc/llvm-project?rev=318329&view=rev
Log:
[clangd] Fix flag name from r318327

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=318329&r1=318328&r2=318329&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov 15 
12:10:14 2017
@@ -35,7 +35,7 @@ tooling::CompileCommand getDefaultCompil
   // We force PC because PS4 will change --std from under us.
   // FIXME: there must be a more principled way to do this!
   std::vector CommandLine{
-  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown", File.str()};
+  "clang", "-fsyntax-only", "-target=unknown-pc-unknown", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File), CommandLine,
  /*Output=*/"");


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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2017-11-15 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 123069.
Nebiroth marked 3 inline comments as done.
Nebiroth added a comment.

Added test for didChangeConfiguration notification.
Compilation database and extra file flags are now properly reloaded when 
changing database path.
ClangdConfigurationParams now used instead of map.
changeConfiguration removed from ClangdServer. This class will now handle more 
specific settings.
Added more checks when parsing notification from client..


https://reviews.llvm.org/D39571

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/did-change-configuration.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -1,3 +1,4 @@
+
 # RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
 # It is absolutely vital that this file has CRLF line endings.
 #
@@ -18,6 +19,7 @@
 # CHECK-NEXT:  ":"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "configurationChangeProvider": true,
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
@@ -48,4 +50,4 @@
 # CHECK-NEXT:  "result": null
 Content-Length: 33
 
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0":"method":"exit"}
\ No newline at end of file
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -1,3 +1,4 @@
+
 # RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
 # It is absolutely vital that this file has CRLF line endings.
 #
@@ -18,6 +19,7 @@
 # CHECK-NEXT:  ":"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "configurationChangeProvider": true,
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
@@ -45,4 +47,4 @@
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
 Content-Length: 33
 
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0":"method":"exit"}
\ No newline at end of file
Index: test/clangd/did-change-configuration.test
===
--- /dev/null
+++ test/clangd/did-change-configuration.test
@@ -0,0 +1,46 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 150
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"voidmain(){}"}}}
+
+Content-Length: 86
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":""}}
+#Failed to decode workspace/didChangeConfiguration request.
+#Incorrect mapping node
+
+Content-Length: 114
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":{
+#Failed to decode workspace/didChangeConfiguration request.
+#compilationDatabasePath is not a scalar node
+
+Content-Length: 140
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"/","testBadValue":"foo1234"}}}
+#Ignored unknown field "testBadValue"
+#Failed to find compilation database for / in overriden directory /
+#Bad field, bad compilation database
+
+Content-Length: 722
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///compile_commands.json","languageId":"json","version":1,"text":"[\n{\n"directory":"/",\n"command":"/usr/bin/c++-DGTEST_HAS_RTTI=0-D_GNU_SOURCE-D__STDC_CONSTANT_MACROS-D__STDC_FORMAT_MACROS-D__STDC_LIMIT_MACROS-Ilib/Demangle-I../lib/Demangle-I/usr/include/libxml2-Iinclude-I../include-fPIC-fvisibility-inlines-hidden-Werror=date-time-std=c++11-Wall-W-Wno-unused-parameter-Wwrite-strings-Wcast-qual-Wno-missing-field-initializers-pedantic-Wno-long-long-Wno-maybe-uninitialized-Wdelete-non-virtual-dtor-Wno-comment-O0-g-fno-exceptions-fno-rtti-o/foo.c.o-c/foo.c",\n"file":"/foo.c"\n},"}}}
+
+Content-Length: 115
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"/"}}}
+#CHECK:{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1595-1597
+def err_member_function_call_other : Error<
+  "cannot initialize object parameter of type %0 with an expression "
+  "of type %1">;

jtbandes wrote:
> aaron.ballman wrote:
> > I don't think this diagnostic needs to be moved and renamed; the old name 
> > was more clear than "other" on the new name.
> How about `_bad_type`? I was hoping to give these all similar names since 
> they happen during the same implicit conversion. Also, while "implicit object 
> parameter" is technically a correct name, it seems to be not very commonly 
> used and would confuse users. Though it's also valuable for the diagnostic id 
> to be similar to the actual text...
I'm not too worried about the identifier used for the diagnostic; it doesn't 
seem likely to confuse many people working on Clang (or at least, not confuse 
them for long). However, I wouldn't be opposed to 
`err_member_function_call_bad_type`.


https://reviews.llvm.org/D39937



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


[PATCH] D39879: AMDGPU: Remove -mamdgpu-debugger-abi option

2017-11-15 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl abandoned this revision.
kzhuravl added a comment.

Agreed to do it later.


https://reviews.llvm.org/D39879



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


[clang-tools-extra] r318337 - [clangd] Revert broken r318329 and disable tests on PS4

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 13:33:56 2017
New Revision: 318337

URL: http://llvm.org/viewvc/llvm-project?rev=318337&view=rev
Log:
[clangd] Revert broken r318329 and disable tests on PS4

(Clearly this is not a permanent solution)

Added:
clang-tools-extra/trunk/test/clangd/lit.local.cfg
Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=318337&r1=318336&r2=318337&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov 15 
13:33:56 2017
@@ -31,11 +31,7 @@ static void addExtraFlags(tooling::Compi
 }
 
 tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
-  // We don't specify --std because we want to infer it from the filename.
-  // We force PC because PS4 will change --std from under us.
-  // FIXME: there must be a more principled way to do this!
-  std::vector CommandLine{
-  "clang", "-fsyntax-only", "-target=unknown-pc-unknown", File.str()};
+  std::vector CommandLine{"clang", "-fsyntax-only", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File), CommandLine,
  /*Output=*/"");

Added: clang-tools-extra/trunk/test/clangd/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/lit.local.cfg?rev=318337&view=auto
==
--- clang-tools-extra/trunk/test/clangd/lit.local.cfg (added)
+++ clang-tools-extra/trunk/test/clangd/lit.local.cfg Wed Nov 15 13:33:56 2017
@@ -0,0 +1,6 @@
+import re
+# We rely on the default -std being derived from the filetype.
+# PS4 sets a different -std, and many tests break.
+# FIXME: make our tests less brittle instead.
+if re.match(r'.*-scei-ps4', config.target_triple):
+  config.unsupported = True


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


[PATCH] D39049: [analyzer] Fix wrong calculation of offset in ArrayBoundsV2

2017-11-15 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

> Could you do a similar analysis that I did above to check why does this not 
> work for the multidimensional case? (I.e.: checking what constraints are 
> generated and what the analyzer does with them.)

the "location.dump()" will just say "x".

the ProgramState is:

Expressions:
 (0x2acd12a78a0,0x2acd1478b80) buf : &buf
 (0x2acd12a78a0,0x2acd1478bf8) buf : &element{buf,0 S64b,int [3]}
 (0x2acd12a78a0,0x2acd1478c10) buf[1] : &element{buf,1 S64b,int [3]}
 (0x2acd12a78a0,0x2acd1478c38) x : &x
 (0x2acd12a78a0,0x2acd1478c88) buf[1] : &element{element{buf,1 S64b,int [3]},0 
S64b,int}
Ranges of symbol values:
 reg_$0 : { [4, 10] }

rawOffsetVal => 0

extentBegin => 0

For getSimplifiedOffset() , the offset is not a SymIntExpr it will just return 
0.


Repository:
  rL LLVM

https://reviews.llvm.org/D39049



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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

Hahnfeld wrote:
> rjmccall wrote:
> > ABataev wrote:
> > > Hahnfeld wrote:
> > > > rjmccall wrote:
> > > > > Hahnfeld wrote:
> > > > > > rjmccall wrote:
> > > > > > > Hahnfeld wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > ABataev wrote:
> > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > > > The way you've written this makes it sound 
> > > > > > > > > > > > > > > > > like "does the target support VLAs?", but the 
> > > > > > > > > > > > > > > > > actual semantic checks treat it as "do OpenMP 
> > > > > > > > > > > > > > > > > devices on this target support VLAs?"  Maybe 
> > > > > > > > > > > > > > > > > there should be a more specific way to query 
> > > > > > > > > > > > > > > > > things about OpenMP devices instead of 
> > > > > > > > > > > > > > > > > setting a global flag for the target?
> > > > > > > > > > > > > > > > Actually, the NVPTX and SPIR targets never 
> > > > > > > > > > > > > > > > support VLAs. So I felt like it would be more 
> > > > > > > > > > > > > > > > correct to make this a global property of the 
> > > > > > > > > > > > > > > > target.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > The difference is that the other programming 
> > > > > > > > > > > > > > > > models (OpenCL and CUDA) error out 
> > > > > > > > > > > > > > > > immediatelyand regardless of the target because 
> > > > > > > > > > > > > > > > this limitation is reflected in the standards 
> > > > > > > > > > > > > > > > that disallow VLAs (see SemaType.cpp). For 
> > > > > > > > > > > > > > > > OpenMP we might have target devices that 
> > > > > > > > > > > > > > > > support VLA so we shouldn't error out for those.
> > > > > > > > > > > > > > > If you want to make it a global property of the 
> > > > > > > > > > > > > > > target, that's fine, but then I don't understand 
> > > > > > > > > > > > > > > why your diagnostic only fires when 
> > > > > > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > > > > > That is because of how OpenMP offloading works and 
> > > > > > > > > > > > > > how it is implemented in Clang. Consider the 
> > > > > > > > > > > > > > following snippet from the added test case:
> > > > > > > > > > > > > > ```lang=c
> > > > > > > > > > > > > > int vla[arg];
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > > > > > {
> > > > > > > > > > > > > >// more code here...
> > > > > > > > > > > > > > }
> > > > > > > > > > > > > > ```
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Clang will take the following steps to compile this 
> > > > > > > > > > > > > > into a working binary for a GPU:
> > > > > > > > > > > > > > 1. Parse and (semantically) analyze the code as-is 
> > > > > > > > > > > > > > for the host and produce LLVM Bitcode.
> > > > > > > > > > > > > > 2. Parse and analyze again the code as-is and 
> > > > > > > > > > > > > > generate code for the offloading target, the GPU in 
> > > > > > > > > > > > > > this case.
> > > > > > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary 
> > > > > > > > > > > > > > and embed target binary from 3.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the 
> > > > > > > > > > > > > > complete source code is analyzed. So to not throw 
> > > > > > > > > > > > > > errors for the host code, we have to make sure that 
> > > > > > > > > > > > > > we are actually generating code for the target 
> > > > > > > > > > > > > > device. This is either in a `target` directive or 
> > > > > > > > > > > > > > in a `declare target` region.
> > > > > > > > > > > > > > Note that this is quite similar to what CUDA does, 
> > > > > > > > > > > > > > only they have `CUDADiagIfDeviceCode` for this 
> > > > > > > > > > > > > > logic. If you want me to add something of that kind 
> > > > > > > > > > > > > > for OpenMP target devices, I'm fine with that. 
> > > > > > > > > > > > > > However for the given case, it's a bit different 
> > > > > > > > > > > > > > because this error should only be thrown for target 
> > > > > > > > > > > > > > devices that don't support VLAs...
> > > > > > > > > > > > > I see.  So the entire translation unit is re-parsed 
> > > > > > > > > > > > > and re-Sema'ed from scratch for the target?  Which 
> > > > > > > > > > > > > means you need to avoid generating errors about 
> > > > > > > > > > > > >

[clang-tools-extra] r318339 - [clangd] Loosen more brittle tests

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 13:50:53 2017
New Revision: 318339

URL: http://llvm.org/viewvc/llvm-project?rev=318339&view=rev
Log:
[clangd] Loosen more brittle tests

Modified:
clang-tools-extra/trunk/test/clangd/completion-snippet.test
clang-tools-extra/trunk/test/clangd/completion.test

Modified: clang-tools-extra/trunk/test/clangd/completion-snippet.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion-snippet.test?rev=318339&r1=318338&r2=318339&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion-snippet.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion-snippet.test Wed Nov 15 
13:50:53 2017
@@ -61,16 +61,6 @@ Content-Length: 148
 # CHECK-NEXT:"label": "fake::",
 # CHECK-NEXT:"sortText": "75fake"
 # CHECK-NEXT:  },
-# CHECK-NEXT:  {
-# CHECK-NEXT:"detail": "fake &",
-# CHECK-NEXT:"filterText": "operator=",
-# CHECK-NEXT:"insertText": "operator=(${1:const fake &})",
-# CHECK-NEXT:"insertTextFormat": 2,
-# CHECK-NEXT:"kind": 2,
-# CHECK-NEXT:"label": "operator=(const fake &)",
-# CHECK-NEXT:"sortText": "79operator="
-# CHECK-NEXT:  },
-# FIXME: Why do some buildbots show an extra operator==(fake&&) here?
 #  CHECK:  {
 #  CHECK:"detail": "void",
 # CHECK-NEXT:"filterText": "~fake",

Modified: clang-tools-extra/trunk/test/clangd/completion.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion.test?rev=318339&r1=318338&r2=318339&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Wed Nov 15 13:50:53 2017
@@ -61,16 +61,7 @@ Content-Length: 148
 # CHECK-NEXT:  "label": "fake::",
 # CHECK-NEXT:  "sortText": "75fake"
 # CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "fake &",
-# CHECK-NEXT:  "filterText": "operator=",
-# CHECK-NEXT:  "insertText": "operator=",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "operator=(const fake &)",
-# CHECK-NEXT:  "sortText": "79operator="
-# CHECK-NEXT:},
-# FIXME: Why do some buildbots show an extra operator==(fake&&) here?
+# FIXME: Why do buildbots show different operator=s here?
 #  CHECK:{
 #  CHECK:  "detail": "void",
 # CHECK-NEXT:  "filterText": "~fake",
@@ -133,15 +124,6 @@ Content-Length: 148
 # CHECK-NEXT:  "label": "fake::",
 # CHECK-NEXT:  "sortText": "75fake"
 # CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "fake &",
-# CHECK-NEXT:  "filterText": "operator=",
-# CHECK-NEXT:  "insertText": "operator=",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "operator=(const fake &)",
-# CHECK-NEXT:  "sortText": "79operator="
-# CHECK-NEXT:},
 #  CHECK:{
 #  CHECK:  "detail": "void",
 # CHECK-NEXT:  "filterText": "~fake",
@@ -182,15 +164,6 @@ Content-Length: 148
 # CHECK-NEXT:  "label": "fancy::",
 # CHECK-NEXT:  "sortText": "75fancy"
 # CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "fancy &",
-# CHECK-NEXT:  "filterText": "operator=",
-# CHECK-NEXT:  "insertText": "operator=",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "operator=(const fancy &)",
-# CHECK-NEXT:  "sortText": "79operator="
-# CHECK-NEXT:},
 #  CHECK:{
 #  CHECK:  "detail": "void",
 # CHECK-NEXT:  "filterText": "~fancy",


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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123079.
Wizard marked 10 inline comments as done.
Wizard added a comment.

address comments


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds @throw usages in Objective-C files. For the same reason as the
+Google C++ style guide, we prefer not throwing exceptions from Objective-C code.
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect usage of @throw in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-throwing-exception");
 CheckFactories.registerCheck(
 "google-objc-global-variable-declaration");
 CheckFactories.registerCheck(
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyGoogleModule
   AvoidCStyleCastsCheck.cpp
+  AvoidThrowingObjcExceptionCheck.cpp
   DefaultArgumentsCheck.cpp
   Explicit

[PATCH] D40093: Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 123081.
erichkeane retitled this revision from "Split x86 "Processor" info into its own 
def file." to "Split x86 "Processor" info into its own def file. [NFC]".
erichkeane added a comment.

realized I had added amdfam17 as an alias, which
isn't supposed to happen.  Also makes this NFC to
remove that.


https://reviews.llvm.org/D40093

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h

Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -95,178 +95,8 @@
   /// loosely correspond to the options passed to '-march' or '-mtune' flags.
   enum CPUKind {
 CK_Generic,
-
-/// \name i386
-/// i386-generation processors.
-//@{
-CK_i386,
-//@}
-
-/// \name i486
-/// i486-generation processors.
-//@{
-CK_i486,
-CK_WinChipC6,
-CK_WinChip2,
-CK_C3,
-//@}
-
-/// \name i586
-/// i586-generation processors, P5 microarchitecture based.
-//@{
-CK_i586,
-CK_Pentium,
-CK_PentiumMMX,
-//@}
-
-/// \name i686
-/// i686-generation processors, P6 / Pentium M microarchitecture based.
-//@{
-CK_PentiumPro,
-CK_Pentium2,
-CK_Pentium3,
-CK_PentiumM,
-CK_C3_2,
-
-/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
-/// Clang however has some logic to support this.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Yonah,
-//@}
-
-/// \name Netburst
-/// Netburst microarchitecture based processors.
-//@{
-CK_Pentium4,
-CK_Prescott,
-CK_Nocona,
-//@}
-
-/// \name Core
-/// Core microarchitecture based processors.
-//@{
-CK_Core2,
-
-/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
-/// codename which GCC no longer accepts as an option to -march, but Clang
-/// has some logic for recognizing it.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Penryn,
-//@}
-
-/// \name Atom
-/// Atom processors
-//@{
-CK_Bonnell,
-CK_Silvermont,
-CK_Goldmont,
-//@}
-
-/// \name Nehalem
-/// Nehalem microarchitecture based processors.
-CK_Nehalem,
-
-/// \name Westmere
-/// Westmere microarchitecture based processors.
-CK_Westmere,
-
-/// \name Sandy Bridge
-/// Sandy Bridge microarchitecture based processors.
-CK_SandyBridge,
-
-/// \name Ivy Bridge
-/// Ivy Bridge microarchitecture based processors.
-CK_IvyBridge,
-
-/// \name Haswell
-/// Haswell microarchitecture based processors.
-CK_Haswell,
-
-/// \name Broadwell
-/// Broadwell microarchitecture based processors.
-CK_Broadwell,
-
-/// \name Skylake Client
-/// Skylake client microarchitecture based processors.
-CK_SkylakeClient,
-
-/// \name Skylake Server
-/// Skylake server microarchitecture based processors.
-CK_SkylakeServer,
-
-/// \name Cannonlake Client
-/// Cannonlake client microarchitecture based processors.
-CK_Cannonlake,
-
-/// \name Knights Landing
-/// Knights Landing processor.
-CK_KNL,
-
-/// \name Knights Mill
-/// Knights Mill processor.
-CK_KNM,
-
-/// \name Lakemont
-/// Lakemont microarchitecture based processors.
-CK_Lakemont,
-
-/// \name K6
-/// K6 architecture processors.
-//@{
-CK_K6,
-CK_K6_2,
-CK_K6_3,
-//@}
-
-/// \name K7
-/// K7 architecture processors.
-//@{
-CK_Athlon,
-CK_AthlonXP,
-//@}
-
-/// \name K8
-/// K8 architecture processors.
-//@{
-CK_K8,
-CK_K8SSE3,
-CK_AMDFAM10,
-//@}
-
-/// \name Bobcat
-/// Bobcat architecture processors.
-//@{
-CK_BTVER1,
-CK_BTVER2,
-//@}
-
-/// \name Bulldozer
-/// Bulldozer architecture processors.
-//@{
-CK_BDVER1,
-CK_BDVER2,
-CK_BDVER3,
-CK_BDVER4,
-//@}
-
-/// \name zen
-/// Zen architecture processors.
-//@{
-CK_ZNVER1,
-//@}
-
-/// This specification is deprecated and will be removed in the future.
-/// Users should prefer \see CK_K8.
-// FIXME: Warn on this when the CPU is set to it.
-//@{
-CK_x86_64,
-//@}
-
-/// \name Geode
-/// Geode processors.
-//@{
-CK_Geode
-//@}
+#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
+#include "clang/Basic/X86Target.def"
   } CPU = CK_Generic;
 
   bool checkCPUKind(CPUKind Kind) const;
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -1504,121 +1504,19 @@
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  cas

[PATCH] D40093: Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D40093



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


r318343 - Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Nov 15 14:25:39 2017
New Revision: 318343

URL: http://llvm.org/viewvc/llvm-project?rev=318343&view=rev
Log:
Split x86 "Processor" info into its own def file. [NFC]

A first step toward removing the repetition of
features/CPU info in the x86 target info, this
patch pulls all the processor information out into
its own .def file.

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


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

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=318343&r1=318342&r2=318343&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Wed Nov 15 14:25:39 2017
@@ -1504,121 +1504,19 @@ bool X86TargetInfo::checkCPUKind(CPUKind
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  case CK_PentiumMMX:
-  case CK_PentiumPro:
-  case CK_Pentium2:
-  case CK_Pentium3:
-  case CK_PentiumM:
-  case CK_Yonah:
-  case CK_C3_2:
-  case CK_Pentium4:
-  case CK_Lakemont:
-  case CK_Prescott:
-  case CK_K6:
-  case CK_K6_2:
-  case CK_K6_3:
-  case CK_Athlon:
-  case CK_AthlonXP:
-  case CK_Geode:
-// Only accept certain architectures when compiling in 32-bit mode.
-if (getTriple().getArch() != llvm::Triple::x86)
-  return false;
-
-LLVM_FALLTHROUGH;
-  case CK_Nocona:
-  case CK_Core2:
-  case CK_Penryn:
-  case CK_Bonnell:
-  case CK_Silvermont:
-  case CK_Goldmont:
-  case CK_Nehalem:
-  case CK_Westmere:
-  case CK_SandyBridge:
-  case CK_IvyBridge:
-  case CK_Haswell:
-  case CK_Broadwell:
-  case CK_SkylakeClient:
-  case CK_SkylakeServer:
-  case CK_Cannonlake:
-  case CK_KNL:
-  case CK_KNM:
-  case CK_K8:
-  case CK_K8SSE3:
-  case CK_AMDFAM10:
-  case CK_BTVER1:
-  case CK_BTVER2:
-  case CK_BDVER1:
-  case CK_BDVER2:
-  case CK_BDVER3:
-  case CK_BDVER4:
-  case CK_ZNVER1:
-  case CK_x86_64:
-return true;
+#define PROC(ENUM, STRING, IS64BIT)
\
+  case CK_##ENUM:  
\
+return IS64BIT || getTriple().getArch() == llvm::Triple::x86;
+#include "clang/Basic/X86Target.def"
   }
   llvm_unreachable("Unhandled CPU kind");
 }
 
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch(CPU)
-  .Case("i386", CK_i386)
-  .Case("i486", CK_i486)
-  .Case("winchip-c6", CK_WinChipC6)
-  .Case("winchip2", CK_WinChip2)
-  .Case("c3", CK_C3)
-  .Case("i586", CK_i586)
-  .Case("pentium", CK_Pentium)
-  .Case("pentium-mmx", CK_PentiumMMX)
-  .Cases("i686", "pentiumpro", CK_PentiumPro)
-  .Case("pentium2", CK_Pentium2)
-  .Cases("pentium3", "pentium3m", CK_Pentium3)
-  .Case("pentium-m", CK_PentiumM)
-  .Case("c3-2", CK_C3_2)
-  .Case("yonah", CK_Yonah)
-  .Cases("pentium4", "pentium4m", CK_Pentium4)
-  .Case("prescott", CK_Prescott)
-  .Case("nocona", CK_Nocona)
-  .Case("core2", CK_Core2)
-  .Case("penryn", CK_Penryn)
-  .Cases("bonnell", "atom", CK_Bonnell)
-  .Cases("silvermont", "slm", CK_Silvermont)
-  .Case("goldmont", CK_Goldmont)
-  .Cases("nehalem", "corei7", CK_Nehalem)
-  .Case("westmere", CK_Westmere)
-  .Cases("sandybridge", "corei7-avx", CK_SandyBridge)
-  .Cases("ivybridge", "core-avx-i", CK_IvyBridge)
-  .Cases("haswell", "core-avx2", CK_Haswell)
-  .Case("broadwell", CK_Broadwell)
-  .Case("skylake", CK_SkylakeClient)
-  .Cases("skylake-avx512", "skx", CK_SkylakeServer)
-  .Case("cannonlake", CK_Cannonlake)
-  .Case("knl", CK_KNL)
-  .Case("knm", CK_KNM)
-  .Case("lakemont", CK_Lakemont)
-  .Case("k6", CK_K6)
-  .Case("k6-2", CK_K6_2)
-  .Case("k6-3", CK_K6_3)
-  .Cases("athlon", "athlon-tbird", CK_Athlon)
-  .Cases("athlon-xp", "athlon-mp", "athlon-4", CK_AthlonXP)
-  .Cases("k8", "athlon64", "athlon-fx", "opteron", CK_K8)
-  .Cases("k8-sse3", "athlon64-sse3", "opteron-sse3", CK_K8SSE3)
-  .Cases("amdfam10", "barcelona", CK_AMDFAM10)
-  .Case("btver1", CK_BTVER1)
-  .Case("btver2", CK_BTVER2)
-  .Case("bdver1", CK_BDVER1)
-  .Case("bdver2", CK_BDVER2)
-  .Case("bdver3", CK_BDVER3)
-  .Case("bdver4", CK_BDVER4)
-  .Case("znver1", CK_ZNVER1)
-  .Case("x86-64", CK_x86_64)
-  .Case("geode", CK_Geode)
+#define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)
+#define PROC_ALIAS(ENUM, ALIAS) .Case(ALIAS, CK_##ENUM)
+#include "clang/Basic/X86Target.def"
   .Default(CK_Generic);
 }
 

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev

[PATCH] D39994: Loosen MSVC 2017 path requirements

2017-11-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I haven't dug into this code to really understand if this is right and won't 
change our version detection logic, but yes, broadly I believe we should just 
consult PATH, find a cl.exe, and check its version. I'd like to reduce this 
path validation to a minimum.


https://reviews.llvm.org/D39994



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


[PATCH] D40093: Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318343: Split x86 "Processor" info into its own def file. 
[NFC] (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D40093?vs=123081&id=123083#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40093

Files:
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Basic/Targets/X86.h

Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -95,178 +95,8 @@
   /// loosely correspond to the options passed to '-march' or '-mtune' flags.
   enum CPUKind {
 CK_Generic,
-
-/// \name i386
-/// i386-generation processors.
-//@{
-CK_i386,
-//@}
-
-/// \name i486
-/// i486-generation processors.
-//@{
-CK_i486,
-CK_WinChipC6,
-CK_WinChip2,
-CK_C3,
-//@}
-
-/// \name i586
-/// i586-generation processors, P5 microarchitecture based.
-//@{
-CK_i586,
-CK_Pentium,
-CK_PentiumMMX,
-//@}
-
-/// \name i686
-/// i686-generation processors, P6 / Pentium M microarchitecture based.
-//@{
-CK_PentiumPro,
-CK_Pentium2,
-CK_Pentium3,
-CK_PentiumM,
-CK_C3_2,
-
-/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
-/// Clang however has some logic to support this.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Yonah,
-//@}
-
-/// \name Netburst
-/// Netburst microarchitecture based processors.
-//@{
-CK_Pentium4,
-CK_Prescott,
-CK_Nocona,
-//@}
-
-/// \name Core
-/// Core microarchitecture based processors.
-//@{
-CK_Core2,
-
-/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
-/// codename which GCC no longer accepts as an option to -march, but Clang
-/// has some logic for recognizing it.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Penryn,
-//@}
-
-/// \name Atom
-/// Atom processors
-//@{
-CK_Bonnell,
-CK_Silvermont,
-CK_Goldmont,
-//@}
-
-/// \name Nehalem
-/// Nehalem microarchitecture based processors.
-CK_Nehalem,
-
-/// \name Westmere
-/// Westmere microarchitecture based processors.
-CK_Westmere,
-
-/// \name Sandy Bridge
-/// Sandy Bridge microarchitecture based processors.
-CK_SandyBridge,
-
-/// \name Ivy Bridge
-/// Ivy Bridge microarchitecture based processors.
-CK_IvyBridge,
-
-/// \name Haswell
-/// Haswell microarchitecture based processors.
-CK_Haswell,
-
-/// \name Broadwell
-/// Broadwell microarchitecture based processors.
-CK_Broadwell,
-
-/// \name Skylake Client
-/// Skylake client microarchitecture based processors.
-CK_SkylakeClient,
-
-/// \name Skylake Server
-/// Skylake server microarchitecture based processors.
-CK_SkylakeServer,
-
-/// \name Cannonlake Client
-/// Cannonlake client microarchitecture based processors.
-CK_Cannonlake,
-
-/// \name Knights Landing
-/// Knights Landing processor.
-CK_KNL,
-
-/// \name Knights Mill
-/// Knights Mill processor.
-CK_KNM,
-
-/// \name Lakemont
-/// Lakemont microarchitecture based processors.
-CK_Lakemont,
-
-/// \name K6
-/// K6 architecture processors.
-//@{
-CK_K6,
-CK_K6_2,
-CK_K6_3,
-//@}
-
-/// \name K7
-/// K7 architecture processors.
-//@{
-CK_Athlon,
-CK_AthlonXP,
-//@}
-
-/// \name K8
-/// K8 architecture processors.
-//@{
-CK_K8,
-CK_K8SSE3,
-CK_AMDFAM10,
-//@}
-
-/// \name Bobcat
-/// Bobcat architecture processors.
-//@{
-CK_BTVER1,
-CK_BTVER2,
-//@}
-
-/// \name Bulldozer
-/// Bulldozer architecture processors.
-//@{
-CK_BDVER1,
-CK_BDVER2,
-CK_BDVER3,
-CK_BDVER4,
-//@}
-
-/// \name zen
-/// Zen architecture processors.
-//@{
-CK_ZNVER1,
-//@}
-
-/// This specification is deprecated and will be removed in the future.
-/// Users should prefer \see CK_K8.
-// FIXME: Warn on this when the CPU is set to it.
-//@{
-CK_x86_64,
-//@}
-
-/// \name Geode
-/// Geode processors.
-//@{
-CK_Geode
-//@}
+#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
+#include "clang/Basic/X86Target.def"
   } CPU = CK_Generic;
 
   bool checkCPUKind(CPUKind Kind) const;
Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -1504,121 +1504,19 @@
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  case CK_Penti

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

Looking good. Please rename the files correctly, or it will not build on Linux.




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp:23
+  Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
+  Finder->addMatcher(objcMessageExpr(hasSelector("raise:format:"),
+ hasReceiverType(asString("NSException")))

Also need to match `raise:format:arguments:`.




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjCExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

Don't forget to rename the file to AvoidThrowingObjcExceptionCheck.h.




Comment at: clang-tidy/google/CMakeLists.txt:5
   AvoidCStyleCastsCheck.cpp
+  AvoidThrowingObjcExceptionCheck.cpp
   DefaultArgumentsCheck.cpp

Rename to AvoidThrowingObjCExceptionCheck.cpp



Comment at: clang-tidy/google/GoogleTidyModule.cpp:18
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"

I think you renamed the #include but not the file.. should test on Linux, it 
won't work with a case-sensitive file system ;)



Comment at: docs/ReleaseNotes.rst:63
+
+  Add new check to detect usage of @throw in Objective-C code, which should be 
avoided.
+

detect usage of @throw -> detect throwing exceptions



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6
+
+This check finds @throw usages in Objective-C files. For the same reason as the
+Google C++ style guide, we prefer not throwing exceptions from Objective-C 
code.

Can you include the link to the C++ style guide section here instead of at the 
end? http://google.github.io/styleguide/cppguide.html#Exceptions



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6
+
+This check finds @throw usages in Objective-C files. For the same reason as the
+Google C++ style guide, we prefer not throwing exceptions from Objective-C 
code.

benhamilton wrote:
> Can you include the link to the C++ style guide section here instead of at 
> the end? http://google.github.io/styleguide/cppguide.html#Exceptions
finds @throw usages -> finds uses of throwing exceptions


https://reviews.llvm.org/D40058



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: test/clang-tidy/google-objc-avoid-throwing-exception.m:17-20
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of 
throwing exception to indicate Objective-C errors 
[google-objc-avoid-throwing-exception]
+}

Would be nice to have a test that confirms sending -raise:format: to a 
different object does not hit the warning.


https://reviews.llvm.org/D40058



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjCExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

benhamilton wrote:
> Don't forget to rename the file to AvoidThrowingObjcExceptionCheck.h.
> 
Oops! I mean, rename the file to AvoidThrowingObjCExceptionCheck.h. :)


https://reviews.llvm.org/D40058



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


r318345 - Add X86Target.def that was forgotten in r30734

2017-11-15 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Nov 15 14:36:24 2017
New Revision: 318345

URL: http://llvm.org/viewvc/llvm-project?rev=318345&view=rev
Log:
Add X86Target.def that was forgotten in r30734

Added:
cfe/trunk/include/clang/Basic/X86Target.def

Added: cfe/trunk/include/clang/Basic/X86Target.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/X86Target.def?rev=318345&view=auto
==
--- cfe/trunk/include/clang/Basic/X86Target.def (added)
+++ cfe/trunk/include/clang/Basic/X86Target.def Wed Nov 15 14:36:24 2017
@@ -0,0 +1,228 @@
+//===--- X86Target.def - X86 Feature/Processor Database -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines the X86-specific Features and Processors, as used by
+// the X86 Targets.
+//
+//===--===//
+
+
+#ifndef PROC
+#define PROC(ENUM, STRING, IS64BIT)
+#endif
+
+#ifndef PROC_ALIAS
+#define PROC_ALIAS(ENUM, ALIAS)
+#endif
+
+#define PROC_64_BIT true
+#define PROC_32_BIT false
+
+/// \name i386
+/// i386-generation processors.
+//@{
+PROC(i386, "i386", PROC_32_BIT)
+//@}
+
+/// \name i486
+/// i486-generation processors.
+//@{
+PROC(i486, "i486", PROC_32_BIT)
+PROC(WinChipC6, "winchip-c6", PROC_32_BIT)
+PROC(WinChip2, "winchip2", PROC_32_BIT)
+PROC(C3, "c3", PROC_32_BIT)
+//@}
+
+/// \name i586
+/// i586-generation processors, P5 microarchitecture based.
+//@{
+PROC(i586, "i586", PROC_32_BIT)
+PROC(Pentium, "pentium", PROC_32_BIT)
+PROC(PentiumMMX, "pentium-mmx", PROC_32_BIT)
+//@}
+
+/// \name i686
+/// i686-generation processors, P6 / Pentium M microarchitecture based.
+//@{
+PROC(PentiumPro, "pentiumpro", PROC_32_BIT)
+PROC_ALIAS(PentiumPro, "i686")
+PROC(Pentium2, "pentium2", PROC_32_BIT)
+PROC(Pentium3, "pentium3", PROC_32_BIT)
+PROC_ALIAS(Pentium3, "pentium3m")
+PROC(PentiumM, "pentium-m", PROC_32_BIT)
+PROC(C3_2, "c3-2", PROC_32_BIT)
+
+/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
+/// Clang however has some logic to support this.
+// FIXME: Warn, deprecate, and potentially remove this.
+PROC(Yonah, "yonah", PROC_32_BIT)
+//@}
+
+/// \name Netburst
+/// Netburst microarchitecture based processors.
+//@{
+PROC(Pentium4, "pentium4", PROC_32_BIT)
+PROC_ALIAS(Pentium4, "pentium4m")
+
+PROC(Prescott, "prescott", PROC_32_BIT)
+PROC(Nocona, "nocona", PROC_64_BIT)
+//@}
+
+/// \name Core
+/// Core microarchitecture based processors.
+//@{
+PROC(Core2, "core2", PROC_64_BIT)
+
+/// This enumerator, like Yonah, is a bit odd. It is another
+/// codename which GCC no longer accepts as an option to -march, but Clang
+/// has some logic for recognizing it.
+// FIXME: Warn, deprecate, and potentially remove this.
+PROC(Penryn, "penryn", PROC_64_BIT)
+//@}
+
+/// \name Atom
+/// Atom processors
+//@{
+PROC(Bonnell, "bonnell", PROC_64_BIT)
+PROC_ALIAS(Bonnell, "atom")
+
+PROC(Silvermont, "silvermont", PROC_64_BIT)
+PROC_ALIAS(Silvermont, "slm")
+
+PROC(Goldmont, "goldmont", PROC_64_BIT)
+//@}
+
+/// \name Nehalem
+/// Nehalem microarchitecture based processors.
+PROC(Nehalem, "nehalem", PROC_64_BIT)
+PROC_ALIAS(Nehalem, "corei7")
+
+/// \name Westmere
+/// Westmere microarchitecture based processors.
+PROC(Westmere, "westmere", PROC_64_BIT)
+
+/// \name Sandy Bridge
+/// Sandy Bridge microarchitecture based processors.
+PROC(SandyBridge, "sandybridge", PROC_64_BIT)
+PROC_ALIAS(SandyBridge, "corei7-avx")
+
+/// \name Ivy Bridge
+/// Ivy Bridge microarchitecture based processors.
+PROC(IvyBridge, "ivybridge", PROC_64_BIT)
+PROC_ALIAS(IvyBridge, "core-avx-i")
+
+/// \name Haswell
+/// Haswell microarchitecture based processors.
+PROC(Haswell, "haswell", PROC_64_BIT)
+PROC_ALIAS(Haswell, "core-avx2")
+
+/// \name Broadwell
+/// Broadwell microarchitecture based processors.
+PROC(Broadwell, "broadwell", PROC_64_BIT)
+
+/// \name Skylake Client
+/// Skylake client microarchitecture based processors.
+PROC(SkylakeClient, "skylake", PROC_64_BIT)
+
+/// \name Skylake Server
+/// Skylake server microarchitecture based processors.
+PROC(SkylakeServer, "skylake-avx512", PROC_64_BIT)
+PROC_ALIAS(SkylakeServer, "skx")
+
+/// \name Cannonlake Client
+/// Cannonlake client microarchitecture based processors.
+PROC(Cannonlake, "cannonlake", PROC_64_BIT)
+
+/// \name Knights Landing
+/// Knights Landing processor.
+PROC(KNL, "knl", PROC_64_BIT)
+
+/// \name Knights Mill
+/// Knights Mill processor.
+PROC(KNM, "knm", PROC_64_BIT)
+
+/// \name Lakemont
+/// Lakemont microarchitecture based processors.
+PROC(Lakemont, "lakemont", PROC_32_BIT)
+
+/// \name K6
+/// K6 architecture processors.
+//@{
+PROC(K6, "k6", PROC_32_BIT)
+PROC(K6_2, "k6-2", PROC_32_BIT)
+PROC(K6

[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

@asb I cherry-picked this patch and was able to compile a simple program for 
elf triple. By manually adding a few libs on the link line I was also able to 
make it link for linux triple.
Could you please respond to the comment about risv32-ld? Other than that this 
patch LGTM!


https://reviews.llvm.org/D39963



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


[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: test/Driver/riscv64-toolchain.c:1
+// A basic clang -cc1 command-line, and simple environment check.
+

I just saw that this test fails with the error:

error: backend data layout 'e-m:e-i64:64-n32:64-S128' does not match expected 
target description 'e-m:e-p:64:64-i64:64-i128:128-n64-S128'


https://reviews.llvm.org/D39963



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123089.
Wizard marked 2 inline comments as done.
Wizard added a comment.

address comments


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect usage of @throw in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-throwing-exception");
 

r318347 - clang/module.modulemap: clang/Basic/X86Target.def may be textual header.

2017-11-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Nov 15 15:04:44 2017
New Revision: 318347

URL: http://llvm.org/viewvc/llvm-project?rev=318347&view=rev
Log:
clang/module.modulemap: clang/Basic/X86Target.def may be textual header.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=318347&r1=318346&r2=318347&view=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Wed Nov 15 15:04:44 2017
@@ -49,6 +49,7 @@ module Clang_Basic {
   textual header "Basic/OperatorKinds.def"
   textual header "Basic/Sanitizers.def"
   textual header "Basic/TokenKinds.def"
+  textual header "Basic/X86Target.def"
 
   module * { export * }
 }


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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123090.
Wizard marked 6 inline comments as done.
Wizard added a comment.

rename file


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjC2ExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjC2ExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@interface NotException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NotException raise:@"NotException" format:@"Test"];
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect throwing exceptions in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFact

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123091.
Wizard marked an inline comment as done.
Wizard added a comment.

rename again


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@interface NotException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NotException raise:@"NotException" format:@"Test"];
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect throwing exceptions in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFacto

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

File names look good now, thanks.




Comment at: clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp:1
+//===--- AvoidThrowingObjcExceptionCheck.cpp - 
clang-tidy--===//
+//

Objc -> ObjC



https://reviews.llvm.org/D40058



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123093.
Wizard added a comment.

nit fix


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@interface NotException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NotException raise:@"NotException" format:@"Test"];
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect throwing exceptions in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-na

[PATCH] D37860: [MSan] Enable use-after-dtor instrumentation by default.

2017-11-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

What is the status of this patch?


https://reviews.llvm.org/D37860



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.

LGTM


https://reviews.llvm.org/D40058



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


[PATCH] D40024: Fix skipping of flags in getClangStripDependencyFileAdjuster

2017-11-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

probably a test would be useful


https://reviews.llvm.org/D40024



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


[PATCH] D39279: Stringizing raw string literals containing newline

2017-11-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

On the first glance string erase and insert seem to be done correctly. But we 
can still improve the tests. Can you please add tests for tricky cases where 
new line or backslash appear in unexpected places? Some of the examples are

  R"ab\
  cd"
  
  R"ab
  
  c"
  
  R"ab
  \"
  
  R"ab
  \\"

I didn't check if all of them are valid but I hope you got the idea.




Comment at: lib/Lex/Lexer.cpp:223
+  ++e;
+} else if (auto Size = getEscapedNewLineSize(Result.substr(i).data())) {
+  Result.erase(Result.begin() + i, Result.begin() + i + Size);

`getEscapedNewLineSize` mentions
> P[-1] is known to be a "\" or a trigraph equivalent on entry to this function.
Is this precondition correct in this case?

And `std::string::substr` creates a copy of a substring. It is inefficient in 
the loop and looks like you don't really need `std::string` here anyway.


https://reviews.llvm.org/D39279



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


[PATCH] D37860: [MSan] Enable use-after-dtor instrumentation by default.

2017-11-15 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Patch is out-of-date.  But the flag has been enabled internally for over a 
month with no issues.  I'll update this patch soon, so we can flip the default 
here.


https://reviews.llvm.org/D37860



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


  1   2   >