[PATCH] D29622: Add a batch query and replace tool based on AST matchers.

2017-02-07 Thread Julian Bangert via Phabricator via cfe-commits
jbangert created this revision.
Herald added a subscriber: mgorny.

This requires https://reviews.llvm.org/D29613. It adds a new tool, 
clang-query-replace that replaces and AST node with the result of evaluating a 
simple template language.


https://reviews.llvm.org/D29622

Files:
  clang-query/CMakeLists.txt
  clang-query/QueryReplace.cpp
  clang-query/QueryReplace.h
  clang-query/replace-tool/CMakeLists.txt
  clang-query/replace-tool/ClangQueryReplace.cpp
  test/CMakeLists.txt
  test/clang-query/replacement.c

Index: test/clang-query/replacement.c
===
--- /dev/null
+++ test/clang-query/replacement.c
@@ -0,0 +1,6 @@
+// RUN: clang-query-replace --spec  '{Query: "varDecl(hasName(\"version\"),
+// hasInitializer(integerLiteral().bind(\"init\"))).bind(\"decl\")", FromId:
+// "decl", ToTemplate: "string version = \"$$-${init}\""}' %s -- && FileCheck %s
+// < %;
+int version = 4;
+// CHECK: string version = "$-4";
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -46,6 +46,7 @@
   clang-include-fixer
   clang-move
   clang-query
+  clang-query-replace
   clang-rename
   clang-reorder-fields
   clang-tidy
@@ -56,11 +57,9 @@
   # Unit tests
   ExtraToolsUnitTests
   )
-
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
   ARGS ${CLANG_TOOLS_TEST_EXTRA_ARGS}
   )
 set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
-
Index: clang-query/replace-tool/ClangQueryReplace.cpp
===
--- /dev/null
+++ clang-query/replace-tool/ClangQueryReplace.cpp
@@ -0,0 +1,86 @@
+//=== ClangQueryReplace.cpp - clang-query-replace tool ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This tool automatically modifies source files based on AST matchers.
+//
+// A given AST matcher is applied to the source, and a bound node in
+// this matcher is replaced by the result of substituting the text
+// corresponding to other bound nodes into a string template.
+//
+// For example:
+// clang-query-replace --spec <
+#include 
+#include 
+
+using namespace clang;
+using namespace clang::query;
+using namespace llvm;
+
+using std::error_code;
+using clang::tooling::CommonOptionsParser;
+
+static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
+static cl::OptionCategory ClangQueryCategory("clang-query-replace options");
+
+static cl::list Commands("spec",
+  cl::desc("YAML action specification"),
+  cl::value_desc("spec"),
+  cl::cat(ClangQueryCategory));
+
+int main(int argc, const char **argv) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+
+  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  if (Commands.empty()) {
+llvm::errs() << "Must specify at least one --spec \n";
+return 1;
+  }
+
+  tooling::RefactoringTool Refactor(OptionsParser.getCompilations(),
+OptionsParser.getSourcePathList());
+
+  QueryReplaceTool Tool(Refactor.getReplacements());
+  for (auto &SpecYaml : Commands) {
+llvm::ErrorOr Spec =
+QueryReplaceSpec::parseFromJSON(SpecYaml);
+if (error_code EC = Spec.getError()) {
+  llvm::errs() << " Error " << EC.message()
+   << " while parsing spec: " << SpecYaml << "\n";
+  return 1;
+}
+Tool.addOperation(*Spec);
+  }
+
+  return Refactor.runAndSave(tooling::newFrontendActionFactory(&Tool).get());
+}
Index: clang-query/replace-tool/CMakeLists.txt
===
--- /dev/null
+++ clang-query/replace-tool/CMakeLists.txt
@@ -0,0 +1,14 @@
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+add_clang_executable(clang-query-replace ClangQueryReplace.cpp)
+target_link_libraries(clang-query-replace
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangDynamicASTMatchers
+  clangFrontend
+  clangQuery
+  clangTooling
+  )
+
+install(TARGETS clang-query-replace RUNTIME DESTINATION bin)
\ No newline at end of file
Index: clang-query/QueryReplace.h
===
--- /dev/null
+++ clang-query/QueryReplace.h
@@ -0,0 +1,58 @@
+//===--- ReplaceSpec.h - clang-query-replace *- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--

[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-07 Thread Julian Bangert via Phabricator via cfe-commits
jbangert created this revision.

This is the first change as part of developing a clang-query based search and 
replace tool.


https://reviews.llvm.org/D29621

Files:
  include/clang/Tooling/RefactoringCallbacks.h
  lib/Tooling/RefactoringCallbacks.cpp
  unittests/Tooling/RefactoringCallbacksTest.cpp

Index: unittests/Tooling/RefactoringCallbacksTest.cpp
===
--- unittests/Tooling/RefactoringCallbacksTest.cpp
+++ unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -7,31 +7,30 @@
 //
 //===--===//
 
-#include "clang/Tooling/RefactoringCallbacks.h"
 #include "RewriterTestContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/RefactoringCallbacks.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 
 using namespace ast_matchers;
 
 template 
-void expectRewritten(const std::string &Code,
- const std::string &Expected,
- const T &AMatcher,
- RefactoringCallback &Callback) {
-  MatchFinder Finder;
+void expectRewritten(const std::string &Code, const std::string &Expected,
+ const T &AMatcher, RefactoringCallback &Callback) {
+  std::map FileToReplace;
+  ASTMatchRefactorer Finder(FileToReplace);
   Finder.addMatcher(AMatcher, &Callback);
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory(&Finder));
   ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code))
   << "Parsing error in \"" << Code << "\"";
   RewriterTestContext Context;
   FileID ID = Context.createInMemoryFile("input.cc", Code);
-  EXPECT_TRUE(tooling::applyAllReplacements(Callback.getReplacements(),
+  EXPECT_TRUE(tooling::applyAllReplacements(FileToReplace["input.cc"],
 Context.Rewrite));
   EXPECT_EQ(Expected, Context.getRewrittenText(ID));
 }
@@ -61,40 +60,65 @@
   std::string Code = "void f() { int i = 1; }";
   std::string Expected = "void f() { int i = 2; }";
   ReplaceStmtWithText Callback("id", "2");
-  expectRewritten(Code, Expected, id("id", expr(integerLiteral())),
-  Callback);
+  expectRewritten(Code, Expected, id("id", expr(integerLiteral())), Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesStmtWithStmt) {
   std::string Code = "void f() { int i = false ? 1 : i * 2; }";
   std::string Expected = "void f() { int i = i * 2; }";
   ReplaceStmtWithStmt Callback("always-false", "should-be");
-  expectRewritten(Code, Expected,
-  id("always-false", conditionalOperator(
-  hasCondition(cxxBoolLiteral(equals(false))),
-  hasFalseExpression(id("should-be", expr(),
+  expectRewritten(
+  Code, Expected,
+  id("always-false",
+ conditionalOperator(hasCondition(cxxBoolLiteral(equals(false))),
+ hasFalseExpression(id("should-be", expr(),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesIfStmt) {
   std::string Code = "bool a; void f() { if (a) f(); else a = true; }";
   std::string Expected = "bool a; void f() { f(); }";
   ReplaceIfStmtWithItsBody Callback("id", true);
-  expectRewritten(Code, Expected,
-  id("id", ifStmt(
-  hasCondition(implicitCastExpr(hasSourceExpression(
-  declRefExpr(to(varDecl(hasName("a"),
+  expectRewritten(
+  Code, Expected,
+  id("id", ifStmt(hasCondition(implicitCastExpr(hasSourceExpression(
+   declRefExpr(to(varDecl(hasName("a"),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, RemovesEntireIfOnEmptyElse) {
   std::string Code = "void f() { if (false) int i = 0; }";
   std::string Expected = "void f() {  }";
   ReplaceIfStmtWithItsBody Callback("id", false);
   expectRewritten(Code, Expected,
-  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
-  Callback);
+  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
+  Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateJustText) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { FOO }";
+  ReplaceNodeWithTemplate Callback("id", "FOO");
+  expectRewritten(Code, Expected, id("id", declStmt()), Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateSimpleSubst) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { long x = 1; }";
+  ReplaceNodeWithTemplate Callback("decl", "long x = ${init}");
+  expectRewritten(Code, Expected,
+  id("decl", varDecl(hasInitializer(id("init", expr(),
+  Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateLiteral) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { string x = \"$-1\"; }";
+  ReplaceNodeWithTemplate Callback("decl", "string x = \"$$-${init}\"");
+  expectRewritten(

[PATCH] D29622: Add a batch query and replace tool based on AST matchers.

2017-02-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang-query/QueryReplace.cpp:50
+
+void QueryReplaceTool::addOperation(clang::query::QueryReplaceSpec &Spec) {
+  ast_matchers::dynamic::Diagnostics Diag;

Shouldn't that also just return the error?



Comment at: clang-query/QueryReplace.h:35-36
+
+  /// \brief Replacement text. %"identifier" will be substituted by the text of
+  /// an identifier.
+  std::string ToTemplate;

This doesn't seem to come up in the test? (and I don't understand what it's 
trying to tell me :)


https://reviews.llvm.org/D29622



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


[PATCH] D27810: Normalize all filenames before searching FileManager caches

2017-02-07 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv updated this revision to Diff 87376.
erikjv added a comment.

Fixed all failing tests on Windows.


https://reviews.llvm.org/D27810

Files:
  lib/Basic/FileManager.cpp
  lib/Basic/VirtualFileSystem.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/CodeGen/debug-prefix-map.c
  test/Driver/ps4-header-search.c
  test/Frontend/dependency-gen.c
  test/Frontend/include-duplicate-removal.c
  test/Index/annotate-module.m
  test/Index/index-module.m
  test/Index/skip-parsed-bodies/compile_commands.json
  test/Modules/filename.cpp
  test/Modules/malformed.cpp
  test/Modules/relative-dep-gen.cpp
  test/Preprocessor/headermap-rel2.c
  test/Preprocessor/iwithprefix.c
  unittests/Basic/FileManagerTest.cpp

Index: unittests/Basic/FileManagerTest.cpp
===
--- unittests/Basic/FileManagerTest.cpp
+++ unittests/Basic/FileManagerTest.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/FileSystemStatCache.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -29,15 +30,17 @@
   llvm::StringMap StatCalls;
 
   void InjectFileOrDirectory(const char *Path, ino_t INode, bool IsFile) {
+SmallString<128> NativePath(Path);
+llvm::sys::path::native(NativePath);
 FileData Data;
-Data.Name = Path;
+Data.Name = NativePath.c_str();
 Data.Size = 0;
 Data.ModTime = 0;
 Data.UniqueID = llvm::sys::fs::UniqueID(1, INode);
 Data.IsDirectory = !IsFile;
 Data.IsNamedPipe = false;
 Data.InPCH = false;
-StatCalls[Path] = Data;
+StatCalls[NativePath] = Data;
   }
 
 public:
@@ -89,7 +92,11 @@
 
   dir = file->getDir();
   ASSERT_TRUE(dir != nullptr);
+#ifdef LLVM_ON_WIN32
+  EXPECT_EQ("x\\y", dir->getName());
+#else
   EXPECT_EQ("x/y", dir->getName());
+#endif
 }
 
 // Before any virtual file is added, no virtual directory exists.
@@ -115,7 +122,9 @@
 
   const DirectoryEntry *dir = manager.getDirectory("virtual/dir");
   ASSERT_TRUE(dir != nullptr);
-  EXPECT_EQ("virtual/dir", dir->getName());
+  SmallString<10> ExpectedName("virtual/dir");
+  llvm::sys::path::native(ExpectedName);
+  EXPECT_EQ(ExpectedName, dir->getName());
 
   dir = manager.getDirectory("virtual");
   ASSERT_TRUE(dir != nullptr);
@@ -140,11 +149,15 @@
 
   const FileEntry *file = manager.getFile("/tmp/test");
   ASSERT_TRUE(file != nullptr);
-  EXPECT_EQ("/tmp/test", file->getName());
+  SmallString<10> ExpectedName("/tmp/test");
+  llvm::sys::path::native(ExpectedName);
+  EXPECT_EQ(ExpectedName, file->getName());
 
   const DirectoryEntry *dir = file->getDir();
   ASSERT_TRUE(dir != nullptr);
-  EXPECT_EQ("/tmp", dir->getName());
+  ExpectedName = "/tmp";
+  llvm::sys::path::native(ExpectedName);
+  EXPECT_EQ(ExpectedName, dir->getName());
 
 #ifdef LLVM_ON_WIN32
   file = manager.getFile(FileName);
@@ -164,11 +177,15 @@
   manager.getVirtualFile("virtual/dir/bar.h", 100, 0);
   const FileEntry *file = manager.getFile("virtual/dir/bar.h");
   ASSERT_TRUE(file != nullptr);
-  EXPECT_EQ("virtual/dir/bar.h", file->getName());
+  SmallString<10> ExpectedName("virtual/dir/bar.h");
+  llvm::sys::path::native(ExpectedName);
+  EXPECT_EQ(ExpectedName, file->getName());
 
   const DirectoryEntry *dir = file->getDir();
   ASSERT_TRUE(dir != nullptr);
-  EXPECT_EQ("virtual/dir", dir->getName());
+  ExpectedName = "virtual/dir";
+  llvm::sys::path::native(ExpectedName);
+  EXPECT_EQ(ExpectedName, dir->getName());
 }
 
 // getFile() returns different FileEntries for different paths when
Index: test/Preprocessor/iwithprefix.c
===
--- test/Preprocessor/iwithprefix.c
+++ test/Preprocessor/iwithprefix.c
@@ -8,9 +8,9 @@
 // RUN: FileCheck %s < %t.out
 
 // CHECK: #include <...> search starts here:
-// CHECK: {{.*}}.tmps/first
+// CHECK: {{.*}}.tmps{{/|\\}}first
 // CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include
-// CHECK: {{.*}}.tmps/second
+// CHECK: {{.*}}.tmps{{/|\\}}second
 // CHECK-NOT: {{.*}}.tmps
 
 
Index: test/Preprocessor/headermap-rel2.c
===
--- test/Preprocessor/headermap-rel2.c
+++ test/Preprocessor/headermap-rel2.c
@@ -5,9 +5,9 @@
 // RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> %t.out
 // RUN: FileCheck %s -input-file %t.out
 
-// CHECK: Product/someheader.h
-// CHECK: system/usr/include{{[/\\]+}}someheader.h
-// CHECK: system/usr/include{{[/\\]+}}someheader.h
+// CHECK: Product{{/|}}someheader.h
+// CHECK: system{{/|}}usr{{/|}}include{{/|}}someheader.h
+// CHECK: system{{/|}}usr{{/|}}include{{/|}}someheader.h
 
 #include "someheader.h"
 #include 
Index: test/Modules/relative-dep-gen.cpp
===

[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a reviewer: hans.
klimek added a comment.

+hans

+1 to "format only current document but save all" not making much sense :)




Comment at: tools/clang-format-vs/ClangFormat/TypeConverterUtils.cs:7
+{
+public sealed class TypeConverterUtils
+{

Perhaps name this "TypeConversion" or something - I find "utils" as part of a 
name to not add anything, and it tends to accumulate cruft :)



Comment at: tools/clang-format-vs/ClangFormat/VsixUtils.cs:13
+{
+internal sealed class VsixUtils
+{

Same here, just call it Vsix? (context seems clear enough)


https://reviews.llvm.org/D29221



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


[clang-tools-extra] r294291 - Add a prototype for clangd

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 04:28:20 2017
New Revision: 294291

URL: http://llvm.org/viewvc/llvm-project?rev=294291&view=rev
Log:
Add a prototype for clangd

clangd is a language server protocol implementation based on clang. It's
supposed to provide editor integration while not suffering from the
confined ABI of libclang.

This implementation is limited to the bare minimum functionality of
doing (whole-document) formatting and rangeFormatting. The JSON parsing
is based on LLVM's YAMLParser but yet most of the code of clangd is
currently dealing with JSON serialization and deserialization.

This was only tested with VS Code so far, mileage with other LSP clients
may vary.

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

Added:
clang-tools-extra/trunk/clangd/
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/clangd/DocumentStore.h
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h
clang-tools-extra/trunk/test/clangd/
clang-tools-extra/trunk/test/clangd/formatting.test   (with props)
Modified:
clang-tools-extra/trunk/CMakeLists.txt
clang-tools-extra/trunk/test/CMakeLists.txt

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=294291&r1=294290&r2=294291&view=diff
==
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Tue Feb  7 04:28:20 2017
@@ -10,6 +10,7 @@ endif()
 add_subdirectory(change-namespace)
 add_subdirectory(clang-query)
 add_subdirectory(clang-move)
+add_subdirectory(clangd)
 add_subdirectory(include-fixer)
 add_subdirectory(pp-trace)
 add_subdirectory(tool-template)

Added: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=294291&view=auto
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Feb  7 04:28:20 2017
@@ -0,0 +1,12 @@
+add_clang_executable(clangd
+  ClangDMain.cpp
+  JSONRPCDispatcher.cpp
+  Protocol.cpp
+  ProtocolHandlers.cpp
+  )
+
+target_link_libraries(clangd
+  clangBasic
+  clangFormat
+  LLVMSupport
+  )

Added: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294291&view=auto
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (added)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Tue Feb  7 04:28:20 2017
@@ -0,0 +1,86 @@
+//===--- ClangDMain.cpp - clangd server loop 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DocumentStore.h"
+#include "JSONRPCDispatcher.h"
+#include "ProtocolHandlers.h"
+#include "llvm/Support/FileSystem.h"
+#include 
+#include 
+using namespace clang::clangd;
+
+int main(int argc, char *argv[]) {
+  llvm::raw_ostream &Outs = llvm::outs();
+  llvm::raw_ostream &Logs = llvm::errs();
+
+  // Set up a document store and intialize all the method handlers for JSONRPC
+  // dispatching.
+  DocumentStore Store;
+  JSONRPCDispatcher Dispatcher(llvm::make_unique(Outs, Logs));
+  Dispatcher.registerHandler("initialize",
+ llvm::make_unique(Outs, Logs));
+  Dispatcher.registerHandler("shutdown",
+ llvm::make_unique(Outs, Logs));
+  Dispatcher.registerHandler(
+  "textDocument/didOpen",
+  llvm::make_unique(Outs, Logs, Store));
+  // FIXME: Implement textDocument/didClose.
+  Dispatcher.registerHandler(
+  "textDocument/didChange",
+  llvm::make_unique(Outs, Logs, Store));
+  Dispatcher.registerHandler(
+  "textDocument/rangeFormatting",
+  llvm::make_unique(Outs, Logs, 
Store));
+  Dispatcher.registerHandler(
+  "textDocument/formatting",
+  llvm::make_unique(Outs, Logs, Store));
+
+  while (std::cin.good()) {
+// A Language Server Protocol message starts with a HTTP header, delimited
+// by \r\n.
+std::string Line;
+std::getline(std::cin, Line);
+
+// Skip empty lines.
+llvm::StringRef LineRef(Line);
+if (LineRef.trim().empty())
+  continue;
+
+unsigned long long Len = 0;
+// FIXME: Content-Type is a specified header, but

[PATCH] D29451: Add a prototype for clangd v0.1

2017-02-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294291: Add a prototype for clangd (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D29451?vs=87226&id=87383#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29451

Files:
  clang-tools-extra/trunk/CMakeLists.txt
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/ClangDMain.cpp
  clang-tools-extra/trunk/clangd/DocumentStore.h
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/clangd/ProtocolHandlers.h
  clang-tools-extra/trunk/test/CMakeLists.txt
  clang-tools-extra/trunk/test/clangd/formatting.test

Index: clang-tools-extra/trunk/test/clangd/formatting.test
===
--- clang-tools-extra/trunk/test/clangd/formatting.test
+++ clang-tools-extra/trunk/test/clangd/formatting.test
@@ -0,0 +1,53 @@
+# RUN: sed -e '/^#/d' %s | clangd | 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"}}
+# CHECK: Content-Length: 191
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:   "textDocumentSync": 1,
+# CHECK:   "documentFormattingProvider": true,
+# CHECK:   "documentRangeFormattingProvider": true
+# CHECK: }}}
+#
+Content-Length: 193
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"int foo ( int x ) {\nx = x+1;\nreturn x;\n}"}}}
+#
+#
+Content-Length: 233
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":1,"character":4},"end":{"line":1,"character":12}},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 0, "character": 19}, "end": {"line": 1, "character": 4}}, "newText": "\n  "},{"range": {"start": {"line": 1, "character": 9}, "end": {"line": 1, "character": 9}}, "newText": " "},{"range": {"start": {"line": 1, "character": 10}, "end": {"line": 1, "character": 10}}, "newText": " "},{"range": {"start": {"line": 1, "character": 12}, "end": {"line": 2, "character": 4}}, "newText": "\n  "}]}
+#
+#
+Content-Length: 197
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///foo.c","version":5},"contentChanges":[{"text":"int foo ( int x ) {\n  x = x + 1;\n  return x;\n}"}]}}
+#
+#
+Content-Length: 233
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":1,"character":2},"end":{"line":1,"character":12}},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[]}
+#
+Content-Length: 153
+
+{"jsonrpc":"2.0","id":3,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":[{"range": {"start": {"line": 0, "character": 7}, "end": {"line": 0, "character": 8}}, "newText": ""},{"range": {"start": {"line": 0, "character": 9}, "end": {"line": 0, "character": 10}}, "newText": ""},{"range": {"start": {"line": 0, "character": 15}, "end": {"line": 0, "character": 16}}, "newText": ""},{"range": {"start": {"line": 2, "character": 11}, "end": {"line": 3, "character": 4}}, "newText": "\n"}]}
+#
+#
+Content-Length: 190
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///foo.c","version":9},"contentChanges":[{"text":"int foo(int x) {\n  x = x + 1;\n  return x;\n}"}]}}
+#
+#
+Content-Length: 153
+
+{"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":4,"result":[]}
+#
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: clang-tools-extra/trunk/test/CMakeLists.txt
===
--- clang-tools-extra/trunk/test/CMakeLists.txt
+++ clang-tools-extra/trunk/test/CMakeLists.txt
@@ -43,6 +43,7 @@
   # Individual tools we test.
   clang-apply-replacements
   clang-change-namespace
+  clangd
   clang-include-fixer
   clang-move
   clang-query
Index: clang-tools-extra/trunk/CMakeLists.txt
===
--- clang-tools-extra/trunk/CMakeLists.txt
+++ clang-tools-extra/trunk/CMakeLists.txt
@@ -10,6 +10,7 @@
 add_subdirectory(change-namespace)
 add_subdirectory(clang-query)
 add_subdirectory(clang-move)
+add_subd

[PATCH] D29386: Clzero flag addition and inclusion under znver1

2017-02-07 Thread Ganesh Gopalasubramanian via Phabricator via cfe-commits
GGanesh updated this revision to Diff 87386.
GGanesh added a comment.

Updated for review comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D29386

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/clzerointrin.h
  lib/Headers/module.modulemap
  lib/Headers/x86intrin.h

Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -80,6 +80,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLZERO__)
+#include 
+#endif
+
 /* FIXME: LWP */
 
 #endif /* __X86INTRIN_H */
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -61,6 +61,7 @@
 textual header "xopintrin.h"
 textual header "fma4intrin.h"
 textual header "mwaitxintrin.h"
+textual header "clzerointrin.h"
 
 explicit module mm_malloc {
   requires !freestanding
Index: lib/Headers/clzerointrin.h
===
--- lib/Headers/clzerointrin.h
+++ lib/Headers/clzerointrin.h
@@ -0,0 +1,50 @@
+/*===--- clzerointrin.h - CLZERO --===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __X86INTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef _CLZEROINTRIN_H
+#define _CLZEROINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __nodebug__,  __target__("clzero")))
+
+/// \brief Loads the cache line address and zero's out the cacheline
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLZERO  instruction.
+///
+/// \param __line
+///A pointer to a cacheline which needs to be zeroed out.
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_clzero (void * __line)
+{
+  __builtin_ia32_clzero ((void *)__line);
+}
+
+#undef __DEFAULT_FN_ATTRS 
+
+#endif /* _CLZEROINTRIN_H */
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -28,6 +28,7 @@
   __clang_cuda_intrinsics.h
   __clang_cuda_math_forward_declares.h
   __clang_cuda_runtime_wrapper.h
+  clzerointrin.h
   cpuid.h
   clflushoptintrin.h
   emmintrin.h
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2489,6 +2489,7 @@
   bool HasXSAVEC = false;
   bool HasXSAVES = false;
   bool HasMWAITX = false;
+  bool HasCLZERO = false;
   bool HasPKU = false;
   bool HasCLFLUSHOPT = false;
   bool HasPCOMMIT = false;
@@ -3205,6 +3206,7 @@
 setFeatureEnabledImpl(Features, "bmi", true);
 setFeatureEnabledImpl(Features, "bmi2", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
+setFeatureEnabledImpl(Features, "clzero", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "f16c", true);
 setFeatureEnabledImpl(Features, "fma", true);
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1714,6 +1714,7 @@
 def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
 def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
 def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
+def mno_clzero : Flag<["-"], "mno-clzero">, Group;
 def mno_pku : Flag<["-"], "mno-pku">, Group;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
@@ -1907,6 +1908,7 @@
 def mxsavec : Flag<["-"], "mxsavec">, Group;
 def mxsaves

[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: lib/Tooling/RefactoringCallbacks.cpp:42
+  void HandleTranslationUnit(ASTContext &Context) override {
+for (const auto &Callback : Refactoring.Callbacks) {
+  Callback->getReplacements().clear();

Could you add a comment here explaining why the replacements in callbacks need 
to be cleared?



Comment at: lib/Tooling/RefactoringCallbacks.cpp:165
+continue;
+  } else if (ToTemplate.substr(Index, 2) == "${") {
+size_t EndOfIdentifier = ToTemplate.find("}", Index);

Just use `if`  since there is a `continue`?



Comment at: lib/Tooling/RefactoringCallbacks.cpp:170
+   << ToTemplate.substr(Index) << "\n";
+  assert(false);
+}

You might want to use `llvm_unreachable` instead so that it also bails out in 
non-assertion build.



Comment at: lib/Tooling/RefactoringCallbacks.cpp:211
+
+}  // end namespace tooling
+}  // end namespace clang

Looks like you are using clang-format with Google-style. Please reformat your 
changes with LLVM style.


https://reviews.llvm.org/D29621



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I feel that this is a bit too rough now; any suggestions on improving the 
architecture/design of this patch are welcome!




Comment at: lib/Format/UnwrappedLineParser.cpp:2206
+const SmallVectorImpl &Comments,
+const FormatToken* NextTok) {
   bool CommentsInCurrentLine = true;

Any suggestions on how to improve the code quality a bit if we stick with this 
design?



Comment at: lib/Format/UnwrappedLineParser.h:118
+  void organiseComments(const SmallVectorImpl &Comments,
+const FormatToken *NextTok);
   void flushComments(bool NewlineBeforeNext);

@djasper: considering what this code does, what would be a better name of this?


https://reviews.llvm.org/D29626



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2207
+const FormatToken* NextTok) {
   bool CommentsInCurrentLine = true;
+  int StartOfSectionAlignedWithNextToken = -1;

Need to add comments about this if we decide we may go with this.


https://reviews.llvm.org/D29626



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


[clang-tools-extra] r294292 - [clangd] Add missing include.

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 04:47:40 2017
New Revision: 294292

URL: http://llvm.org/viewvc/llvm-project?rev=294292&view=rev
Log:
[clangd] Add missing include.

Modified:
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=294292&r1=294291&r2=294292&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Tue Feb  7 04:47:40 2017
@@ -24,6 +24,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/YAMLParser.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {


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


[PATCH] D29622: Add a batch query and replace tool based on AST matchers.

2017-02-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-query/QueryReplace.cpp:1
+#include "QueryReplace.h"
+#include "QueryParser.h"

Please add license header.



Comment at: clang-query/QueryReplace.cpp:37
+
+llvm::ErrorOr QueryReplaceSpec::parseFromJSON(
+StringRef Spec) {

I'd prefer using `llvm::Expected` with an `llvm::StringError`.



Comment at: clang-query/QueryReplace.cpp:58
+Diag.printToStreamFull(llvm::errs());
+llvm::errs() << "\n";
+  }

return error here?

Consider using `llvm::Error` with `llvm::StringError`.



Comment at: clang-query/QueryReplace.cpp:72
+}
+}
+}

Missing `// namespace ...`



Comment at: clang-query/replace-tool/ClangQueryReplace.cpp:76
+llvm::ErrorOr Spec =
+QueryReplaceSpec::parseFromJSON(SpecYaml);
+if (error_code EC = Spec.getError()) {

If this parses yaml string, shouldn't it be called `parseFromYAML` instead?


https://reviews.llvm.org/D29622



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


[PATCH] D29451: Add a prototype for clangd v0.1

2017-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: test/clangd/formatting.txt:9
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:  "textDocumentSync": 1,
+# CHECK:  "documentFormattingProvider": true,

bkramer wrote:
> djasper wrote:
> > How did you come up with this indentation?
> It's hardcoded as a raw string literal in the source. It looks better there ;)
Maybe you could consider clang-format-ing the json output too? :D


Repository:
  rL LLVM

https://reviews.llvm.org/D29451



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2206
+const SmallVectorImpl &Comments,
+const FormatToken* NextTok) {
   bool CommentsInCurrentLine = true;

krasimir wrote:
> Any suggestions on how to improve the code quality a bit if we stick with 
> this design?
I think comments might actually help here, but also this isn't too bad. As in, 
when writing the comments, it might become more obvious how to write this 
better.



Comment at: lib/Format/UnwrappedLineParser.cpp:2207
+const FormatToken* NextTok) {
   bool CommentsInCurrentLine = true;
+  int StartOfSectionAlignedWithNextToken = -1;

krasimir wrote:
> Need to add comments about this if we decide we may go with this.
Yeah.. Commented comment handling is best comment handling :-D



Comment at: lib/Format/UnwrappedLineParser.cpp:2210
+  if (NextTok) {
+for (int i = Comments.size() - 1; i >= 0; --i) {
+  if (Comments[i]->OriginalColumn ==

I think we use "unsigned" in most of these loops.

And to avoid and edge conditions put this at the top of the function:

  if (Comments.empty())
return;



Comment at: lib/Format/UnwrappedLineParser.h:118
+  void organiseComments(const SmallVectorImpl &Comments,
+const FormatToken *NextTok);
   void flushComments(bool NewlineBeforeNext);

krasimir wrote:
> @djasper: considering what this code does, what would be a better name of 
> this?
Maybe analyzeCommentAlignment? Or determineCommentAlignment?


https://reviews.llvm.org/D29626



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


[PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2017-02-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.

This looks very nice now :-D. Thanks for working on this!!




Comment at: lib/Format/WhitespaceManager.cpp:196
+
+  // ScopeStack keeps track of the current scope depth.
+  // We only run the "Matches" function on tokens from the outer-most scope.

Maybe add: "It contains indices of the first token on each scope."


https://reviews.llvm.org/D21279



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

I think this looks pretty good. More comments would help :) Also, organize is 
spelled with a 'z' in American.


https://reviews.llvm.org/D29626



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


[clang-tools-extra] r294293 - [clang-tidy] misc-argument-comment - extended gmock support

2017-02-07 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Feb  7 05:39:56 2017
New Revision: 294293

URL: http://llvm.org/viewvc/llvm-project?rev=294293&view=rev
Log:
[clang-tidy] misc-argument-comment - extended gmock support

It looks like direct calls to mocked methods happen in the wild. This patch
add support for these as well.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment-gmock.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp?rev=294293&r1=294292&r2=294293&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Tue Feb  7 
05:39:56 2017
@@ -147,33 +147,43 @@ static bool sameName(StringRef InComment
   return InComment.compare_lower(InDecl) == 0;
 }
 
+static bool looksLikeExpectMethod(const CXXMethodDecl *Expect) {
+  return Expect != nullptr && Expect->getLocation().isMacroID() &&
+ Expect->getNameInfo().getName().isIdentifier() &&
+ Expect->getName().startswith("gmock_");
+}
+static bool areMockAndExpectMethods(const CXXMethodDecl *Mock,
+const CXXMethodDecl *Expect) {
+  assert(looksLikeExpectMethod(Expect));
+  return Mock != nullptr && Mock->getNextDeclInContext() == Expect &&
+ Mock->getNumParams() == Expect->getNumParams() &&
+ Mock->getLocation().isMacroID() &&
+ Mock->getNameInfo().getName().isIdentifier() &&
+ Mock->getName() == Expect->getName().substr(strlen("gmock_"));
+}
+
 // This uses implementation details of MOCK_METHODx_ macros: for each mocked
 // method M it defines M() with appropriate signature and a method used to set
 // up expectations - gmock_M() - with each argument's type changed the
-// corresponding matcher. This function finds M by gmock_M.
-static const CXXMethodDecl *
-findMockedMethod(const CXXMethodDecl *ExpectMethod) {
-  if (!ExpectMethod->getNameInfo().getName().isIdentifier())
-return nullptr;
-  StringRef Name = ExpectMethod->getName();
-  if (!Name.startswith("gmock_"))
-return nullptr;
-  Name = Name.substr(strlen("gmock_"));
-
-  const DeclContext *Ctx = ExpectMethod->getDeclContext();
-  if (Ctx == nullptr || !Ctx->isRecord())
-return nullptr;
-  for (const auto *D : Ctx->decls()) {
-if (const auto *Method = dyn_cast(D)) {
-  if (Method->getName() != Name)
-continue;
-  // Sanity check the mocked method.
-  if (Method->getNextDeclInContext() == ExpectMethod &&
-  Method->getLocation().isMacroID() &&
-  Method->getNumParams() == ExpectMethod->getNumParams()) {
-return Method;
+// corresponding matcher. This function returns M when given either M or
+// gmock_M.
+static const CXXMethodDecl *findMockedMethod(const CXXMethodDecl *Method) {
+  if (looksLikeExpectMethod(Method)) {
+const DeclContext *Ctx = Method->getDeclContext();
+if (Ctx == nullptr || !Ctx->isRecord())
+  return nullptr;
+for (const auto *D : Ctx->decls()) {
+  if (D->getNextDeclInContext() == Method) {
+const auto *Previous = dyn_cast(D);
+return areMockAndExpectMethods(Previous, Method) ? Previous : nullptr;
   }
 }
+return nullptr;
+  }
+  if (const auto *Next = dyn_cast_or_null(
+ Method->getNextDeclInContext())) {
+if (looksLikeExpectMethod(Next) && areMockAndExpectMethods(Method, Next))
+  return Method;
   }
   return nullptr;
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment-gmock.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment-gmock.cpp?rev=294293&r1=294292&r2=294293&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment-gmock.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment-gmock.cpp Tue 
Feb  7 05:39:56 2017
@@ -80,7 +80,7 @@ class MockStandalone {
   MOCK_METHOD2(Method, void(int aaa, int bbb));
 };
 
-void test_gmock() {
+void test_gmock_expectations() {
   MockDerived m;
   EXPECT_CALL(m, Method(/*param_one=*/1, /*param_tw=*/2));
 // CHECK-MESSAGES: [[@LINE-1]]:42: warning: argument name 'param_tw' in 
comment does not match parameter name 'param_two'
@@ -99,3 +99,10 @@ void test_gmock() {
   MockStandalone m2;
   EXPECT_CALL(m2, Method(/*aaa=*/5, /*bbc=*/6));
 }
+
+void test_gmock_direct_calls() {
+  MockDerived m;
+  m.Method(/*param_one=*/1, /*param_tw=*/2);
+// CHECK-MESSAGES: [[@LINE-1]]:29: warning: argument name 'param_tw' in 
comment does not match parameter name 'param_two'
+// CHECK-FIXES:   m.Method(/*param_one=*/1, /*param_two=*/2);
+}


__

[clang-tools-extra] r294294 - [clangd] Harden test against sed implementations that strip \r.

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 05:49:03 2017
New Revision: 294294

URL: http://llvm.org/viewvc/llvm-project?rev=294294&view=rev
Log:
[clangd] Harden test against sed implementations that strip \r.

Also clean up logging and don't print \0.

Modified:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/test/clangd/formatting.test

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294294&r1=294293&r2=294294&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Tue Feb  7 05:49:03 2017
@@ -68,18 +68,17 @@ int main(int argc, char *argv[]) {
 
 // Now read the JSON. Insert a trailing null byte as required by the YAML
 // parser.
-std::vector JSON(Len + 1);
+std::vector JSON(Len + 1, '\0');
 std::cin.read(JSON.data(), Len);
 
 if (Len > 0) {
+  llvm::StringRef JSONRef(JSON.data(), Len);
   // Log the message.
-  Logs << "<-- ";
-  Logs.write(JSON.data(), JSON.size());
-  Logs << '\n';
+  Logs << "<-- " << JSONRef << '\n';
   Logs.flush();
 
   // Finally, execute the action for this JSON message.
-  if (!Dispatcher.call(llvm::StringRef(JSON.data(), JSON.size() - 1)))
+  if (!Dispatcher.call(JSONRef))
 Logs << "JSON dispatch failed!\n";
 }
   }

Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=294294&r1=294293&r2=294294&view=diff
==
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Tue Feb  7 05:49:03 2017
@@ -1,5 +1,4 @@
-# RUN: sed -e '/^#/d' %s | clangd | FileCheck %s
-# It is absolutely vital that this file has CRLF line endings.
+# RUN: sed -e '/^#/d' -e 's/\r*$/\r/' %s | clangd | FileCheck %s
 #
 Content-Length: 125
 


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


[PATCH] D29628: [compiler-rt] [test] Enable the strace_test only if strace is installed

2017-02-07 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Check whether strace is to be found in PATH, and control the strace_test 
appropriately. This fixes a test failure when strace is not installed.


Repository:
  rL LLVM

https://reviews.llvm.org/D29628

Files:
  test/lsan/TestCases/strace_test.cc
  test/lsan/lit.common.cfg


Index: test/lsan/lit.common.cfg
===
--- test/lsan/lit.common.cfg
+++ test/lsan/lit.common.cfg
@@ -4,6 +4,8 @@
 
 import os
 
+import lit.util
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -29,6 +31,9 @@
   lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
 config.name += config.name_suffix
 
+if lit.util.which('strace'):
+  config.available_features.add('strace')
+
 clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 lsan_incdir = config.test_source_root + "/../"
Index: test/lsan/TestCases/strace_test.cc
===
--- test/lsan/TestCases/strace_test.cc
+++ test/lsan/TestCases/strace_test.cc
@@ -1,4 +1,5 @@
 // Test that lsan reports a proper error when running under strace.
+// REQUIRES: strace
 // RUN: %clangxx_lsan %s -o %t
 // RUN: not strace -o /dev/null %run %t 2>&1 | FileCheck %s
 


Index: test/lsan/lit.common.cfg
===
--- test/lsan/lit.common.cfg
+++ test/lsan/lit.common.cfg
@@ -4,6 +4,8 @@
 
 import os
 
+import lit.util
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -29,6 +31,9 @@
   lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
 config.name += config.name_suffix
 
+if lit.util.which('strace'):
+  config.available_features.add('strace')
+
 clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 lsan_incdir = config.test_source_root + "/../"
Index: test/lsan/TestCases/strace_test.cc
===
--- test/lsan/TestCases/strace_test.cc
+++ test/lsan/TestCases/strace_test.cc
@@ -1,4 +1,5 @@
 // Test that lsan reports a proper error when running under strace.
+// REQUIRES: strace
 // RUN: %clangxx_lsan %s -o %t
 // RUN: not strace -o /dev/null %run %t 2>&1 | FileCheck %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29630: [libcxx] Threading support: externalize sleep_for()

2017-02-07 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath created this revision.

Different platforms implement the wait/sleep behaviour in very different ways. 
It makes sense to hoist this functionality into the threading API.

I also feel similarly about `hardware_concurrecy()` implementation. Any 
thoughts on that?


https://reviews.llvm.org/D29630

Files:
  include/__threading_support
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -114,33 +114,9 @@
 void
 sleep_for(const chrono::nanoseconds& ns)
 {
-using namespace chrono;
-if (ns > nanoseconds::zero())
+if (ns > chrono::nanoseconds::zero())
 {
-#if defined(_LIBCPP_WIN32API)
-milliseconds ms = duration_cast(ns);
-if (ms.count() == 0 || ns > duration_cast(ms))
-  ++ms;
-Sleep(ms.count());
-#else
-seconds s = duration_cast(ns);
-timespec ts;
-typedef decltype(ts.tv_sec) ts_sec;
-_LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
-if (s.count() < ts_sec_max)
-{
-ts.tv_sec = static_cast(s.count());
-ts.tv_nsec = static_cast((ns-s).count());
-}
-else
-{
-ts.tv_sec = ts_sec_max;
-ts.tv_nsec = giga::num - 1;
-}
-
-while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
-;
-#endif
+__libcpp_thread_sleep_for(ns);
 }
 }
 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -12,6 +12,8 @@
 #define _LIBCPP_THREADING_SUPPORT
 
 #include <__config>
+#include 
+#include 
 
 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header
@@ -28,8 +30,6 @@
 #include 
 #include 
 #include 
-
-#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
@@ -183,6 +183,9 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 void __libcpp_thread_yield();
 
+_LIBCPP_THREAD_ABI_VISIBILITY
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& ns);
+
 // Thread local storage
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_tls_create(__libcpp_tls_key* __key,
@@ -345,6 +348,28 @@
   sched_yield();
 }
 
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& ns)
+{
+   using namespace chrono;
+   seconds s = duration_cast(ns);
+   timespec ts;
+   typedef decltype(ts.tv_sec) ts_sec;
+   _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
+
+   if (s.count() < ts_sec_max)
+   {
+ ts.tv_sec = static_cast(s.count());
+ ts.tv_nsec = static_cast((ns-s).count());
+   }
+   else
+   {
+ ts.tv_sec = ts_sec_max;
+ ts.tv_nsec = giga::num - 1;
+   }
+
+   while (nanosleep(&ts, &ts) == -1 && errno == EINTR);
+}
+
 // Thread local storage
 int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
 {
@@ -562,6 +587,15 @@
   SwitchToThread();
 }
 
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& ns)
+{
+  using namespace chrono;
+  milliseconds ms = duration_cast(ns);
+  if (ms.count() == 0 || ns > duration_cast(ms))
+++ms;
+  Sleep(ms.count());
+}
+
 // Thread Local Storage
 int __libcpp_tls_create(__libcpp_tls_key* __key,
 void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r294282 - Revert "Revert "[AVR] Allow specifying the CPU on the command line""

2017-02-07 Thread Dylan McKay via cfe-commits
Author: dylanmckay
Date: Tue Feb  7 00:04:18 2017
New Revision: 294282

URL: http://llvm.org/viewvc/llvm-project?rev=294282&view=rev
Log:
Revert "Revert "[AVR] Allow specifying the CPU on the command line""

This reverts commit 7ac30e0f839fdab6d723ce2ef6a5b7a4cf03d150.

Added:
cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294282&r1=294281&r2=294282&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb  7 00:04:18 2017
@@ -8446,6 +8446,254 @@ public:
   }
 };
 
+/// Information about a specific microcontroller.
+struct MCUInfo {
+  const char *Name;
+  const char *DefineName;
+};
+
+// This list should be kept up-to-date with AVRDevices.td in LLVM.
+static ArrayRef AVRMcus = {
+  { "at90s1200", "__AVR_AT90S1200__" },
+  { "attiny11", "__AVR_ATtiny11" },
+  { "attiny12", "__AVR_ATtiny12" },
+  { "attiny15", "__AVR_ATtiny15" },
+  { "attiny28", "__AVR_ATtiny28" },
+  { "at90s2313", "__AVR_AT90S2313" },
+  { "at90s2323", "__AVR_AT90S2323" },
+  { "at90s2333", "__AVR_AT90S2333" },
+  { "at90s2343", "__AVR_AT90S2343" },
+  { "attiny22", "__AVR_ATtiny22" },
+  { "attiny26", "__AVR_ATtiny26" },
+  { "at86rf401", "__AVR_AT86RF401" },
+  { "at90s4414", "__AVR_AT90S4414" },
+  { "at90s4433", "__AVR_AT90S4433" },
+  { "at90s4434", "__AVR_AT90S4434" },
+  { "at90s8515", "__AVR_AT90S8515" },
+  { "at90c8534", "__AVR_AT90c8534" },
+  { "at90s8535", "__AVR_AT90S8535" },
+  { "ata5272", "__AVR_ATA5272" },
+  { "attiny13", "__AVR_ATtiny13" },
+  { "attiny13a", "__AVR_ATtiny13A" },
+  { "attiny2313", "__AVR_ATtiny2313" },
+  { "attiny2313a", "__AVR_ATtiny2313A" },
+  { "attiny24", "__AVR_ATtiny24" },
+  { "attiny24a", "__AVR_ATtiny24A" },
+  { "attiny4313", "__AVR_ATtiny4313" },
+  { "attiny44", "__AVR_ATtiny44" },
+  { "attiny44a", "__AVR_ATtiny44A" },
+  { "attiny84", "__AVR_ATtiny84" },
+  { "attiny84a", "__AVR_ATtiny84A" },
+  { "attiny25", "__AVR_ATtiny25" },
+  { "attiny45", "__AVR_ATtiny45" },
+  { "attiny85", "__AVR_ATtiny85" },
+  { "attiny261", "__AVR_ATtiny261" },
+  { "attiny261a", "__AVR_ATtiny261A" },
+  { "attiny461", "__AVR_ATtiny461" },
+  { "attiny461a", "__AVR_ATtiny461A" },
+  { "attiny861", "__AVR_ATtiny861" },
+  { "attiny861a", "__AVR_ATtiny861A" },
+  { "attiny87", "__AVR_ATtiny87" },
+  { "attiny43u", "__AVR_ATtiny43U" },
+  { "attiny48", "__AVR_ATtiny48" },
+  { "attiny88", "__AVR_ATtiny88" },
+  { "attiny828", "__AVR_ATtiny828" },
+  { "at43usb355", "__AVR_AT43USB355" },
+  { "at76c711", "__AVR_AT76C711" },
+  { "atmega103", "__AVR_ATmega103" },
+  { "at43usb320", "__AVR_AT43USB320" },
+  { "attiny167", "__AVR_ATtiny167" },
+  { "at90usb82", "__AVR_AT90USB82" },
+  { "at90usb162", "__AVR_AT90USB162" },
+  { "ata5505", "__AVR_ATA5505" },
+  { "atmega8u2", "__AVR_ATmega8U2" },
+  { "atmega16u2", "__AVR_ATmega16U2" },
+  { "atmega32u2", "__AVR_ATmega32U2" },
+  { "attiny1634", "__AVR_ATtiny1634" },
+  { "atmega8", "__AVR_ATmega8" },
+  { "ata6289", "__AVR_ATA6289" },
+  { "atmega8a", "__AVR_ATmega8A" },
+  { "ata6285", "__AVR_ATA6285" },
+  { "ata6286", "__AVR_ATA6286" },
+  { "atmega48", "__AVR_ATmega48" },
+  { "atmega48a", "__AVR_ATmega48A" },
+  { "atmega48pa", "__AVR_ATmega48PA" },
+  { "atmega48p", "__AVR_ATmega48P" },
+  { "atmega88", "__AVR_ATmega88" },
+  { "atmega88a", "__AVR_ATmega88A" },
+  { "atmega88p", "__AVR_ATmega88P" },
+  { "atmega88pa", "__AVR_ATmega88PA" },
+  { "atmega8515", "__AVR_ATmega8515" },
+  { "atmega8535", "__AVR_ATmega8535" },
+  { "atmega8hva", "__AVR_ATmega8HVA" },
+  { "at90pwm1", "__AVR_AT90PWM1" },
+  { "at90pwm2", "__AVR_AT90PWM2" },
+  { "at90pwm2b", "__AVR_AT90PWM2B" },
+  { "at90pwm3", "__AVR_AT90PWM3" },
+  { "at90pwm3b", "__AVR_AT90PWM3B" },
+  { "at90pwm81", "__AVR_AT90PWM81" },
+  { "ata5790", "__AVR_ATA5790" },
+  { "ata5795", "__AVR_ATA5795" },
+  { "atmega16", "__AVR_ATmega16" },
+  { "atmega16a", "__AVR_ATmega16A" },
+  { "atmega161", "__AVR_ATmega161" },
+  { "atmega162", "__AVR_ATmega162" },
+  { "atmega163", "__AVR_ATmega163" },
+  { "atmega164a", "__AVR_ATmega164A" },
+  { "atmega164p", "__AVR_ATmega164P" },
+  { "atmega164pa", "__AVR_ATmega164PA" },
+  { "atmega165", "__AVR_ATmega165" },
+  { "atmega165a", "__AVR_ATmega165A" },
+  { "atmega165p", "__AVR_ATmega165P" },
+  { "atmega165pa", "__AVR_ATmega165PA" },
+  { "atmega168", "__AVR_ATmega168" },
+  { "atmega168a", "__AVR_ATmega168A" },
+  { "atmega168p", "__AVR_ATmega168P" },
+  { "atmega168pa", "__AVR_ATmega168PA" },
+  { "atmega169", "__AVR_ATmega169" },
+  { "atmega169a", "__AVR_ATmega169A" },
+  { "atmega169p", "__AVR_ATmega169P" },
+  { "atmega169pa", "__AVR_ATmega169

[clang-tools-extra] r294297 - [clangd] Set stdin to binary to fix tests on windows.

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 06:40:59 2017
New Revision: 294297

URL: http://llvm.org/viewvc/llvm-project?rev=294297&view=rev
Log:
[clangd] Set stdin to binary to fix tests on windows.

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

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294297&r1=294296&r2=294297&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Tue Feb  7 06:40:59 2017
@@ -11,6 +11,7 @@
 #include "JSONRPCDispatcher.h"
 #include "ProtocolHandlers.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Program.h"
 #include 
 #include 
 using namespace clang::clangd;
@@ -19,6 +20,9 @@ int main(int argc, char *argv[]) {
   llvm::raw_ostream &Outs = llvm::outs();
   llvm::raw_ostream &Logs = llvm::errs();
 
+  // Change stdin to binary to not lose \r\n on windows.
+  llvm::sys::ChangeStdinToBinary();
+
   // Set up a document store and intialize all the method handlers for JSONRPC
   // dispatching.
   DocumentStore Store;


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


[PATCH] D28451: [AVR] Add support for the 'interrupt' and 'naked' attributes

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

LGTM!


https://reviews.llvm.org/D28451



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


[clang-tools-extra] r294299 - Disable test on windows buildbots without shell support

2017-02-07 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Feb  7 07:08:22 2017
New Revision: 294299

URL: http://llvm.org/viewvc/llvm-project?rev=294299&view=rev
Log:
Disable test on windows buildbots without shell support

Modified:
clang-tools-extra/trunk/test/clangd/formatting.test

Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=294299&r1=294298&r2=294299&view=diff
==
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Tue Feb  7 07:08:22 2017
@@ -1,3 +1,4 @@
+# REQUIRES: shell
 # RUN: sed -e '/^#/d' -e 's/\r*$/\r/' %s | clangd | FileCheck %s
 #
 Content-Length: 125


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


[PATCH] D29634: clang-format: [JS] exclaim preceding regex literals.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

Regex detection would incorrectly classify a trailing `!` operator
(nullability cast) followed by a `/` as the start of a regular
expression literal. This fixes code such as:

  var foo = x()! / 10;

Which would previously parse a regexp all the way to the end of the
source file (or next `/`).


https://reviews.llvm.org/D29634

Files:
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -941,6 +941,7 @@
   verifyFormat("var x = a ? /abc/ : /abc/;");
   verifyFormat("for (var i = 0; /abc/.test(s[i]); i++) {\n}");
   verifyFormat("var x = !/abc/.test(y);");
+  verifyFormat("var x = foo()! / 10;");
   verifyFormat("var x = a && /abc/.test(y);");
   verifyFormat("var x = a || /abc/.test(y);");
   verifyFormat("var x = a + /abc/.search(y);");
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -157,7 +157,9 @@
   // postfix unary operators. If the '++' is followed by a non-operand
   // introducing token, the slash here is the operand and not the start of a
   // regex.
-  if (Prev->isOneOf(tok::plusplus, tok::minusminus))
+  // `!` is an unary prefix operator, but also a post-fix operator that casts
+  // away nullability, so the same check applies.
+  if (Prev->isOneOf(tok::plusplus, tok::minusminus, tok::exclaim))
 return (Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3]));
 
   // The previous token must introduce an operand location where regex


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -941,6 +941,7 @@
   verifyFormat("var x = a ? /abc/ : /abc/;");
   verifyFormat("for (var i = 0; /abc/.test(s[i]); i++) {\n}");
   verifyFormat("var x = !/abc/.test(y);");
+  verifyFormat("var x = foo()! / 10;");
   verifyFormat("var x = a && /abc/.test(y);");
   verifyFormat("var x = a || /abc/.test(y);");
   verifyFormat("var x = a + /abc/.search(y);");
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -157,7 +157,9 @@
   // postfix unary operators. If the '++' is followed by a non-operand
   // introducing token, the slash here is the operand and not the start of a
   // regex.
-  if (Prev->isOneOf(tok::plusplus, tok::minusminus))
+  // `!` is an unary prefix operator, but also a post-fix operator that casts
+  // away nullability, so the same check applies.
+  if (Prev->isOneOf(tok::plusplus, tok::minusminus, tok::exclaim))
 return (Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3]));
 
   // The previous token must introduce an operand location where regex
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] [clang-format]: Add support for changing case/default indent/outdent with clang-format

2017-02-07 Thread Ryan Livingston via cfe-commits
When adding more tests, an issue with this approach was found using scopes:


switch (x) {
  case 1:
break;
  case (2):
break;
  case 3: {
break;
} // <-- Seems we should offset this by 2
}

I'll look into getting this behavior and update the patch.

~Ryan



From: Ryan Livingston
Sent: Monday, February 6, 2017 7:28:54 AM
To: cfe-commits@lists.llvm.org
Subject: [PATCH] [clang-format]: Add support for changing case/default 
indent/outdent with clang-format


Hi all,


First time submitting a patch here. Any feedback is appreciated.


This proposed patch adds a new configuration option CaseLabelOffset for 
clang-format which behaves similarly to AccessModifierOffset. Namely, it 
permits modifying the indent/outdent of case and default labels.


With indent level 4, IndentCaseLabels false, and CaseLabelOffset 2 you'll get a 
switch like:


switch (x) {
  case 1:
break;
  case (2):
break;
}

Our team uses this style of formatting and when investigating switching to 
clang-format, I couldn't find a way to accomplish it. So I thought trying a 
patch would be a good route.

For verification, I ran:

  make clang-test

My new tests failed and I iterated running:

  tools/clang/unittests/Format/FormatTests

until everything passed.

Thanks,
Ryan Livingston

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


[PATCH] D29635: clang-format: [JS] handle parenthesized class expressions.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

In JavaScript, classes are expressions, so they can appear e.g. in
argument lists.

  var C = foo(class {
bar() {
  return 1;
}
  };


https://reviews.llvm.org/D29635

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


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1109,6 +1109,10 @@
   verifyFormat("class C {\n  static x(): string {\nreturn 'asd';\n  }\n}");
   verifyFormat("class C extends P implements I {}");
   verifyFormat("class C extends p.P implements i.I {}");
+  verifyFormat(
+  "x(class {\n"
+  "  a(): A {}\n"
+  "});");
   verifyFormat("class Test {\n"
"  (aaa: ):\n"
"  aa {}\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1381,6 +1381,14 @@
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+parseRecord();
+addUnwrappedLine();
+  } else {
+nextToken();
+  }
+  break;
 case tok::identifier:
   if (Style.Language == FormatStyle::LK_JavaScript &&
   (FormatTok->is(Keywords.kw_function) ||


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1109,6 +1109,10 @@
   verifyFormat("class C {\n  static x(): string {\nreturn 'asd';\n  }\n}");
   verifyFormat("class C extends P implements I {}");
   verifyFormat("class C extends p.P implements i.I {}");
+  verifyFormat(
+  "x(class {\n"
+  "  a(): A {}\n"
+  "});");
   verifyFormat("class Test {\n"
"  (aaa: ):\n"
"  aa {}\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1381,6 +1381,14 @@
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+parseRecord();
+addUnwrappedLine();
+  } else {
+nextToken();
+  }
+  break;
 case tok::identifier:
   if (Style.Language == FormatStyle::LK_JavaScript &&
   (FormatTok->is(Keywords.kw_function) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29634: clang-format: [JS] exclaim preceding regex literals.

2017-02-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D29634



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


[PATCH] D29635: clang-format: [JS] handle parenthesized class expressions.

2017-02-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Thanks


https://reviews.llvm.org/D29635



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


[PATCH] D28814: [OpenCL] Add missing address spaces in IR generation of Blocks

2017-02-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia marked an inline comment as done.
Anastasia added a comment.

Committed in r 293286


https://reviews.llvm.org/D28814



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


[PATCH] D16135: Macro Debug Info support in Clang

2017-02-07 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud updated this revision to Diff 87408.
aaboud marked 2 inline comments as done.
aaboud added a comment.

Addressed Adrian last comments.
Added a LIT tests that covers all the macro kinds:

1. built-in (define)
2. command-line (define, include, undef)
3. main source (define, include, undef)

Checked the above with and without PCH include.

Notice, that current implementation does not support debug info for macro 
definition and inclusion generated during the PCH file creation.
To support that, we need to extend the PCH format to preserve this information.
If you believe this feature is important, I will open a bugzilla ticket and we 
can handle it separately.


https://reviews.llvm.org/D16135

Files:
  include/clang/CodeGen/ModuleBuilder.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/MacroPPCallbacks.cpp
  lib/CodeGen/MacroPPCallbacks.h
  lib/CodeGen/ModuleBuilder.cpp
  test/CodeGen/debug-info-global-constant.c
  test/CodeGen/debug-info-macro.c
  test/CodeGen/include/debug-info-macro.h

Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -92,6 +92,10 @@
   return M.get();
 }
 
+CGDebugInfo *getCGDebugInfo() {
+  return Builder->getModuleDebugInfo();
+}
+
 llvm::Module *ReleaseModule() {
   return M.release();
 }
@@ -299,6 +303,10 @@
   return static_cast(this)->ReleaseModule();
 }
 
+CGDebugInfo *CodeGenerator::getCGDebugInfo() {
+  return static_cast(this)->getCGDebugInfo();
+}
+
 const Decl *CodeGenerator::GetDeclForMangledName(llvm::StringRef name) {
   return static_cast(this)->GetDeclForMangledName(name);
 }
Index: lib/CodeGen/MacroPPCallbacks.h
===
--- lib/CodeGen/MacroPPCallbacks.h
+++ lib/CodeGen/MacroPPCallbacks.h
@@ -0,0 +1,118 @@
+//===--- MacroPPCallbacks.h -*- 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 implementation for the macro preprocessors callbacks.
+//
+//===--===//
+
+#include "clang/Lex/PPCallbacks.h"
+
+namespace llvm {
+class DIMacroFile;
+class DIMacroNode;
+}
+namespace clang {
+class Preprocessor;
+class MacroInfo;
+class CodeGenerator;
+
+class MacroPPCallbacks : public PPCallbacks {
+  /// A pointer to code generator, where debug info generator can be found.
+  CodeGenerator *Gen;
+
+  /// Preprocessor.
+  Preprocessor &PP;
+
+  /// Location of recent included file, used for line number.
+  SourceLocation LastHashLoc;
+
+  /// Counts current number of command line included files, which were entered
+  /// and were not exited yet.
+  int EnteredCommandLineIncludeFiles = 0;
+
+  enum FileScopeStatus {
+NoScope = 0,  // Scope is not initialized yet.
+InitializedScope, // Main file scope is initialized but not set yet.
+BuiltinScope, //  and  file scopes.
+CommandLineIncludeScope,  // Included file, from  file, scope.
+MainFileScope // Main file scope.
+  };
+  FileScopeStatus Status;
+
+  /// Parent contains all entered files that were not exited yet according to
+  /// the inclusion order.
+  llvm::SmallVector Scopes;
+
+  /// Get current DIMacroFile scope.
+  /// \return current DIMacroFile scope or nullptr if there is no such scope.
+  llvm::DIMacroFile *getCurrentScope();
+
+  /// Get current line location or invalid location.
+  /// \param Loc current line location.
+  /// \return current line location \p `Loc`, or invalid location if it's in a
+  /// skipped file scope.
+  SourceLocation getCorrectLocation(SourceLocation Loc);
+
+  /// Use the passed preprocessor to write the macro name and value from the
+  /// given macro info and identifier info into the given \p `Name` and \p
+  /// `Value` output streams.
+  ///
+  /// \param II Identifier info, used to get the Macro name.
+  /// \param MI Macro info, used to get the Macro argumets and values.
+  /// \param PP Preprocessor.
+  /// \param [out] Name Place holder for returned macro name and arguments.
+  /// \param [out] Value Place holder for returned macro value.
+  static void writeMacroDefinition(const IdentifierInfo &II,
+   const MacroInfo &MI, Preprocessor &PP,
+   raw_ostream &Name, raw_ostream &Value);
+
+  /// Update current file scope status to next file scope.
+  void updateStatusToNextScope();
+
+  /// Handle the case when entering a file.
+  ///
+  /// \param Loc Indicates the new location.
+  /// \Return tr

[PATCH] D29038: [OpenCL] Accept logical NOT for pointer types in CL1.1

2017-02-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/logical-ops.cl:1-3
+// RUN: %clang_cc1 %s -verify -cl-std=CL1.1 -triple x86_64-unknown-linux-gnu
+// RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple x86_64-unknown-linux-gnu
+

arsenm wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > arsenm wrote:
> > > > arsenm wrote:
> > > > > Should this have a 2.0 run line for good measure?
> > > > 1.0 too I suppose
> > > Sure!
> > Apparently CL1.0 is not supported! I missed that
> That sounds like a bug?
Yeah, I can't see why it is this way. Probably nobody ever had 1.0 in their 
release...


https://reviews.llvm.org/D29038



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


[PATCH] D29630: [libcxx] Threading support: externalize sleep_for()

2017-02-07 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: include/__threading_support:367
+ ts.tv_sec = ts_sec_max;
+ ts.tv_nsec = giga::num - 1;
+   }

I don't think giga::num makes things any clear compared to just spelling it out.



Comment at: include/__threading_support:593
+  using namespace chrono;
+  milliseconds ms = duration_cast(ns);
+  if (ms.count() == 0 || ns > duration_cast(ms))

Use (ns + 99) so that the cast rounds up.



Comment at: include/__threading_support:594
+  milliseconds ms = duration_cast(ns);
+  if (ms.count() == 0 || ns > duration_cast(ms))
+++ms;

Why is ns == 0 supposed to sleep at all? In fact, the caller already ensures 
that can't happen?


https://reviews.llvm.org/D29630



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 87410.
krasimir marked 6 inline comments as done.
krasimir added a comment.

- Address review comments.


https://reviews.llvm.org/D29626

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11924,6 +11924,122 @@
"\n"
"// long",
getLLVMStyleWithColumns(15)));
+
+  // Align comment line sections aligned with the next token with the next
+  // token.
+  EXPECT_EQ("class A {\n"
+"public: // public comment\n"
+"  // comment about a\n"
+"  int a;\n"
+"};",
+format("class A {\n"
+   "public: // public comment\n"
+   "  // comment about a\n"
+   "  int a;\n"
+   "};",
+   getLLVMStyleWithColumns(40)));
+  EXPECT_EQ("class A {\n"
+"public: // public comment 1\n"
+"// public comment 2\n"
+"  // comment 1 about a\n"
+"  // comment 2 about a\n"
+"  int a;\n"
+"};",
+format("class A {\n"
+   "public: // public comment 1\n"
+   "   // public comment 2\n"
+   "  // comment 1 about a\n"
+   "  // comment 2 about a\n"
+   "  int a;\n"
+   "};",
+   getLLVMStyleWithColumns(40)));
+  EXPECT_EQ("int f(int n) { // comment line 1 on f\n"
+"   // comment line 2 on f\n"
+"  // comment line 1 before return\n"
+"  // comment line 2 before return\n"
+"  return n; // comment line 1 on return\n"
+"// comment line 2 on return\n"
+"  // comment line 1 after return\n"
+"}",
+format("int f(int n) { // comment line 1 on f\n"
+   "   // comment line 2 on f\n"
+   "  // comment line 1 before return\n"
+   "  // comment line 2 before return\n"
+   "  return n; // comment line 1 on return\n"
+   "   // comment line 2 on return\n"
+   "  // comment line 1 after return\n"
+   "}",
+   getLLVMStyleWithColumns(40)));
+  EXPECT_EQ("int f(int n) {\n"
+"  switch (n) { // comment line 1 on switch\n"
+"   // comment line 2 on switch\n"
+"  // comment line 1 before case 1\n"
+"  // comment line 2 before case 1\n"
+"  case 1: // comment line 1 on case 1\n"
+"  // comment line 2 on case 1\n"
+"// comment line 1 before return 1\n"
+"// comment line 2 before return 1\n"
+"return 1; // comment line 1 on return 1\n"
+"  // comment line 2 on return 1\n"
+"  // comment line 1 before default\n"
+"  // comment line 2 before default\n"
+"  default: // comment line 1 on default\n"
+"   // comment line 2 on default\n"
+"// comment line 1 before return 2\n"
+"return 2 * f(n - 1); // comment line 1 on return 2\n"
+" // comment line 2 on return 2\n"
+"// comment line 1 after return\n"
+"// comment line 2 after return\n"
+"  }\n"
+"}",
+format("int f(int n) {\n"
+   "  switch (n) { // comment line 1 on switch\n"
+   "  // comment line 2 on switch\n"
+   "// comment line 1 before case 1\n"
+   "// comment line 2 before case 1\n"
+   "case 1: // comment line 1 on case 1\n"
+   "  // comment line 2 on case 1\n"
+   "// comment line 1 before return 1\n"
+   "// comment line 2 before return 1\n"
+   "return 1;  // comment line 1 on return 1\n"
+   " // comment line 2 on return 1\n"
+   "// comment line 1 before default\n"
+   "// comment line 2 before default\n"
+   "default:   // comment line 1 on default\n"
+   "// comment line 2 on default\n"
+   "// comment line 1 before return 2\n"
+   "return 2 * f(n - 1); // comment line 1 on return 2\n"
+   "// comment line 2 on return 2\n"
+   "// comment line 1 after return\n"
+   " // comment line 2 after return\n"
+   "  }

[PATCH] D29635: clang-format: [JS] handle parenthesized class expressions.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 87412.
mprobst added a comment.

- Parse nested classes as child expressions.


https://reviews.llvm.org/D29635

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1109,6 +1109,10 @@
   verifyFormat("class C {\n  static x(): string {\nreturn 'asd';\n  }\n}");
   verifyFormat("class C extends P implements I {}");
   verifyFormat("class C extends p.P implements i.I {}");
+  verifyFormat(
+  "x(class {\n"
+  "  a(): A {}\n"
+  "});");
   verifyFormat("class Test {\n"
"  (aaa: ):\n"
"  aa {}\n"
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -100,7 +100,10 @@
   void parseAccessSpecifier();
   bool parseEnum();
   void parseJavaEnumBody();
-  void parseRecord();
+  // Parses a record (aka class) as a top level element. If ParseAsExpr is 
true,
+  // parses the record as a child block, i.e. if the class declaration is an
+  // expression.
+  void parseRecord(bool ParseAsExpr = false);
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
@@ -162,7 +165,7 @@
 
   const FormatStyle &Style;
   const AdditionalKeywords &Keywords;
-  
+
   llvm::Regex CommentPragmasRegex;
 
   FormatTokenSource *Tokens;
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1381,6 +1381,12 @@
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if (Style.Language == FormatStyle::LK_JavaScript)
+parseRecord(/*ParseAsExpr=*/true);
+  else
+nextToken();
+  break;
 case tok::identifier:
   if (Style.Language == FormatStyle::LK_JavaScript &&
   (FormatTok->is(Keywords.kw_function) ||
@@ -1819,7 +1825,7 @@
   addUnwrappedLine();
 }
 
-void UnwrappedLineParser::parseRecord() {
+void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   const FormatToken &InitialToken = *FormatTok;
   nextToken();
 
@@ -1863,11 +1869,15 @@
 }
   }
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (ShouldBreakBeforeBrace(Style, InitialToken))
-  addUnwrappedLine();
+if (ParseAsExpr) {
+  parseChildBlock();
+} else {
+  if (ShouldBreakBeforeBrace(Style, InitialToken))
+addUnwrappedLine();
 
-parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true,
-   /*MunchSemi=*/false);
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true,
+ /*MunchSemi=*/false);
+}
   }
   // There is no addUnwrappedLine() here so that we fall through to parsing a
   // structural element afterwards. Thus, in "class A {} n, m;",


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1109,6 +1109,10 @@
   verifyFormat("class C {\n  static x(): string {\nreturn 'asd';\n  }\n}");
   verifyFormat("class C extends P implements I {}");
   verifyFormat("class C extends p.P implements i.I {}");
+  verifyFormat(
+  "x(class {\n"
+  "  a(): A {}\n"
+  "});");
   verifyFormat("class Test {\n"
"  (aaa: ):\n"
"  aa {}\n"
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -100,7 +100,10 @@
   void parseAccessSpecifier();
   bool parseEnum();
   void parseJavaEnumBody();
-  void parseRecord();
+  // Parses a record (aka class) as a top level element. If ParseAsExpr is true,
+  // parses the record as a child block, i.e. if the class declaration is an
+  // expression.
+  void parseRecord(bool ParseAsExpr = false);
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
@@ -162,7 +165,7 @@
 
   const FormatStyle &Style;
   const AdditionalKeywords &Keywords;
-  
+
   llvm::Regex CommentPragmasRegex;
 
   FormatTokenSource *Tokens;
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1381,6 +1381,12 @@
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if 

[PATCH] D29635: clang-format: [JS] handle parenthesized class expressions.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294302: clang-format: [JS] handle parenthesized class 
expressions. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D29635?vs=87412&id=87416#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29635

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.h
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.h
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.h
+++ cfe/trunk/lib/Format/UnwrappedLineParser.h
@@ -100,7 +100,10 @@
   void parseAccessSpecifier();
   bool parseEnum();
   void parseJavaEnumBody();
-  void parseRecord();
+  // Parses a record (aka class) as a top level element. If ParseAsExpr is 
true,
+  // parses the record as a child block, i.e. if the class declaration is an
+  // expression.
+  void parseRecord(bool ParseAsExpr = false);
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
@@ -162,7 +165,7 @@
 
   const FormatStyle &Style;
   const AdditionalKeywords &Keywords;
-  
+
   llvm::Regex CommentPragmasRegex;
 
   FormatTokenSource *Tokens;
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1381,6 +1381,12 @@
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if (Style.Language == FormatStyle::LK_JavaScript)
+parseRecord(/*ParseAsExpr=*/true);
+  else
+nextToken();
+  break;
 case tok::identifier:
   if (Style.Language == FormatStyle::LK_JavaScript &&
   (FormatTok->is(Keywords.kw_function) ||
@@ -1819,7 +1825,7 @@
   addUnwrappedLine();
 }
 
-void UnwrappedLineParser::parseRecord() {
+void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   const FormatToken &InitialToken = *FormatTok;
   nextToken();
 
@@ -1863,11 +1869,15 @@
 }
   }
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (ShouldBreakBeforeBrace(Style, InitialToken))
-  addUnwrappedLine();
+if (ParseAsExpr) {
+  parseChildBlock();
+} else {
+  if (ShouldBreakBeforeBrace(Style, InitialToken))
+addUnwrappedLine();
 
-parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true,
-   /*MunchSemi=*/false);
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true,
+ /*MunchSemi=*/false);
+}
   }
   // There is no addUnwrappedLine() here so that we fall through to parsing a
   // structural element afterwards. Thus, in "class A {} n, m;",
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1109,6 +1109,10 @@
   verifyFormat("class C {\n  static x(): string {\nreturn 'asd';\n  }\n}");
   verifyFormat("class C extends P implements I {}");
   verifyFormat("class C extends p.P implements i.I {}");
+  verifyFormat(
+  "x(class {\n"
+  "  a(): A {}\n"
+  "});");
   verifyFormat("class Test {\n"
"  (aaa: ):\n"
"  aa {}\n"


Index: cfe/trunk/lib/Format/UnwrappedLineParser.h
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.h
+++ cfe/trunk/lib/Format/UnwrappedLineParser.h
@@ -100,7 +100,10 @@
   void parseAccessSpecifier();
   bool parseEnum();
   void parseJavaEnumBody();
-  void parseRecord();
+  // Parses a record (aka class) as a top level element. If ParseAsExpr is true,
+  // parses the record as a child block, i.e. if the class declaration is an
+  // expression.
+  void parseRecord(bool ParseAsExpr = false);
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
@@ -162,7 +165,7 @@
 
   const FormatStyle &Style;
   const AdditionalKeywords &Keywords;
-  
+
   llvm::Regex CommentPragmasRegex;
 
   FormatTokenSource *Tokens;
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1381,6 +1381,12 @@
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if (Style.Language == FormatStyle::LK_JavaScript)
+parseRecord(/*ParseAsExpr=*/true);
+  else
+nextToken();
+  break;
 case tok::identifier:
   if (Style.Language == FormatStyle::LK_JavaScript &&
   (FormatTok->is(Keywords.kw_function) ||
@@ -1819,7 +1

r294302 - clang-format: [JS] handle parenthesized class expressions.

2017-02-07 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Feb  7 08:05:30 2017
New Revision: 294302

URL: http://llvm.org/viewvc/llvm-project?rev=294302&view=rev
Log:
clang-format: [JS] handle parenthesized class expressions.

Summary:
In JavaScript, classes are expressions, so they can appear e.g. in
argument lists.

var C = foo(class {
  bar() {
return 1;
  }
};

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=294302&r1=294301&r2=294302&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Feb  7 08:05:30 2017
@@ -1381,6 +1381,12 @@ void UnwrappedLineParser::parseParens()
   if (FormatTok->Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::kw_class:
+  if (Style.Language == FormatStyle::LK_JavaScript)
+parseRecord(/*ParseAsExpr=*/true);
+  else
+nextToken();
+  break;
 case tok::identifier:
   if (Style.Language == FormatStyle::LK_JavaScript &&
   (FormatTok->is(Keywords.kw_function) ||
@@ -1819,7 +1825,7 @@ void UnwrappedLineParser::parseJavaEnumB
   addUnwrappedLine();
 }
 
-void UnwrappedLineParser::parseRecord() {
+void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   const FormatToken &InitialToken = *FormatTok;
   nextToken();
 
@@ -1863,11 +1869,15 @@ void UnwrappedLineParser::parseRecord()
 }
   }
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (ShouldBreakBeforeBrace(Style, InitialToken))
-  addUnwrappedLine();
+if (ParseAsExpr) {
+  parseChildBlock();
+} else {
+  if (ShouldBreakBeforeBrace(Style, InitialToken))
+addUnwrappedLine();
 
-parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true,
-   /*MunchSemi=*/false);
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true,
+ /*MunchSemi=*/false);
+}
   }
   // There is no addUnwrappedLine() here so that we fall through to parsing a
   // structural element afterwards. Thus, in "class A {} n, m;",

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=294302&r1=294301&r2=294302&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.h (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.h Tue Feb  7 08:05:30 2017
@@ -100,7 +100,10 @@ private:
   void parseAccessSpecifier();
   bool parseEnum();
   void parseJavaEnumBody();
-  void parseRecord();
+  // Parses a record (aka class) as a top level element. If ParseAsExpr is 
true,
+  // parses the record as a child block, i.e. if the class declaration is an
+  // expression.
+  void parseRecord(bool ParseAsExpr = false);
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
@@ -162,7 +165,7 @@ private:
 
   const FormatStyle &Style;
   const AdditionalKeywords &Keywords;
-  
+
   llvm::Regex CommentPragmasRegex;
 
   FormatTokenSource *Tokens;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=294302&r1=294301&r2=294302&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Feb  7 08:05:30 2017
@@ -1109,6 +1109,10 @@ TEST_F(FormatTestJS, ClassDeclarations)
   verifyFormat("class C {\n  static x(): string {\nreturn 'asd';\n  }\n}");
   verifyFormat("class C extends P implements I {}");
   verifyFormat("class C extends p.P implements i.I {}");
+  verifyFormat(
+  "x(class {\n"
+  "  a(): A {}\n"
+  "});");
   verifyFormat("class Test {\n"
"  (aaa: ):\n"
"  aa {}\n"


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


[PATCH] D29635: clang-format: [JS] handle parenthesized class expressions.

2017-02-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Sorry.. Should have caught this in the initial review. Still looks good.


https://reviews.llvm.org/D29635



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


r294304 - clang-format: [JS] exclaim preceding regex literals.

2017-02-07 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Feb  7 08:08:03 2017
New Revision: 294304

URL: http://llvm.org/viewvc/llvm-project?rev=294304&view=rev
Log:
clang-format: [JS] exclaim preceding regex literals.

Summary:
Regex detection would incorrectly classify a trailing `!` operator
(nullability cast) followed by a `/` as the start of a regular
expression literal. This fixes code such as:

var foo = x()! / 10;

Which would previously parse a regexp all the way to the end of the
source file (or next `/`).

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=294304&r1=294303&r2=294304&view=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Tue Feb  7 08:08:03 2017
@@ -157,7 +157,9 @@ bool FormatTokenLexer::canPrecedeRegexLi
   // postfix unary operators. If the '++' is followed by a non-operand
   // introducing token, the slash here is the operand and not the start of a
   // regex.
-  if (Prev->isOneOf(tok::plusplus, tok::minusminus))
+  // `!` is an unary prefix operator, but also a post-fix operator that casts
+  // away nullability, so the same check applies.
+  if (Prev->isOneOf(tok::plusplus, tok::minusminus, tok::exclaim))
 return (Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3]));
 
   // The previous token must introduce an operand location where regex

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=294304&r1=294303&r2=294304&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Feb  7 08:08:03 2017
@@ -941,6 +941,7 @@ TEST_F(FormatTestJS, RegexLiteralClassif
   verifyFormat("var x = a ? /abc/ : /abc/;");
   verifyFormat("for (var i = 0; /abc/.test(s[i]); i++) {\n}");
   verifyFormat("var x = !/abc/.test(y);");
+  verifyFormat("var x = foo()! / 10;");
   verifyFormat("var x = a && /abc/.test(y);");
   verifyFormat("var x = a || /abc/.test(y);");
   verifyFormat("var x = a + /abc/.search(y);");


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


[PATCH] D29634: clang-format: [JS] exclaim preceding regex literals.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294304: clang-format: [JS] exclaim preceding regex literals. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D29634?vs=87402&id=87417#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29634

Files:
  cfe/trunk/lib/Format/FormatTokenLexer.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -157,7 +157,9 @@
   // postfix unary operators. If the '++' is followed by a non-operand
   // introducing token, the slash here is the operand and not the start of a
   // regex.
-  if (Prev->isOneOf(tok::plusplus, tok::minusminus))
+  // `!` is an unary prefix operator, but also a post-fix operator that casts
+  // away nullability, so the same check applies.
+  if (Prev->isOneOf(tok::plusplus, tok::minusminus, tok::exclaim))
 return (Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3]));
 
   // The previous token must introduce an operand location where regex
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -941,6 +941,7 @@
   verifyFormat("var x = a ? /abc/ : /abc/;");
   verifyFormat("for (var i = 0; /abc/.test(s[i]); i++) {\n}");
   verifyFormat("var x = !/abc/.test(y);");
+  verifyFormat("var x = foo()! / 10;");
   verifyFormat("var x = a && /abc/.test(y);");
   verifyFormat("var x = a || /abc/.test(y);");
   verifyFormat("var x = a + /abc/.search(y);");


Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -157,7 +157,9 @@
   // postfix unary operators. If the '++' is followed by a non-operand
   // introducing token, the slash here is the operand and not the start of a
   // regex.
-  if (Prev->isOneOf(tok::plusplus, tok::minusminus))
+  // `!` is an unary prefix operator, but also a post-fix operator that casts
+  // away nullability, so the same check applies.
+  if (Prev->isOneOf(tok::plusplus, tok::minusminus, tok::exclaim))
 return (Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3]));
 
   // The previous token must introduce an operand location where regex
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -941,6 +941,7 @@
   verifyFormat("var x = a ? /abc/ : /abc/;");
   verifyFormat("for (var i = 0; /abc/.test(s[i]); i++) {\n}");
   verifyFormat("var x = !/abc/.test(y);");
+  verifyFormat("var x = foo()! / 10;");
   verifyFormat("var x = a && /abc/.test(y);");
   verifyFormat("var x = a || /abc/.test(y);");
   verifyFormat("var x = a + /abc/.search(y);");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29630: [libcxx] Threading support: externalize sleep_for()

2017-02-07 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added inline comments.



Comment at: include/__threading_support:593
+  using namespace chrono;
+  milliseconds ms = duration_cast(ns);
+  if (ms.count() == 0 || ns > duration_cast(ms))

joerg wrote:
> Use (ns + 99) so that the cast rounds up.
So, this code was lifted from the sources as-is. I will do this change, I think 
it makes sense.



Comment at: include/__threading_support:594
+  milliseconds ms = duration_cast(ns);
+  if (ms.count() == 0 || ns > duration_cast(ms))
+++ms;

joerg wrote:
> Why is ns == 0 supposed to sleep at all? In fact, the caller already ensures 
> that can't happen?
IIUC, this is trying to detect round-downs and then compensate for it. With the 
above suggestion, this should no longer be needed. Will get rid of it as well.


https://reviews.llvm.org/D29630



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2207-2208
+const FormatToken *NextTok) {
+  // Decides which comment tokens should be added to the current line and which
+  // should be added as comments before the next token.
+  //

Put these 2 lines and what it does to the arguments into the header.


https://reviews.llvm.org/D29626



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


[clang-tools-extra] r294309 - [clangd] Fix subtle use after return.

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 08:35:09 2017
New Revision: 294309

URL: http://llvm.org/viewvc/llvm-project?rev=294309&view=rev
Log:
[clangd] Fix subtle use after return.

I didn't find this because my main development machine still happens to
use libstdc++ with the broken C++11 ABI, which has a global empty
string.

Modified:
clang-tools-extra/trunk/clangd/DocumentStore.h

Modified: clang-tools-extra/trunk/clangd/DocumentStore.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/DocumentStore.h?rev=294309&r1=294308&r2=294309&view=diff
==
--- clang-tools-extra/trunk/clangd/DocumentStore.h (original)
+++ clang-tools-extra/trunk/clangd/DocumentStore.h Tue Feb  7 08:35:09 2017
@@ -26,7 +26,10 @@ public:
   /// Delete a document from the store.
   void removeDocument(StringRef Uri) { Docs.erase(Uri); }
   /// Retrieve a document from the store. Empty string if it's unknown.
-  StringRef getDocument(StringRef Uri) const { return Docs.lookup(Uri); }
+  StringRef getDocument(StringRef Uri) const {
+auto I = Docs.find(Uri);
+return I == Docs.end() ? StringRef("") : StringRef(I->second);
+  }
 
 private:
   llvm::StringMap Docs;


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


[PATCH] D29386: Clzero flag addition and inclusion under znver1

2017-02-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Still missing a test in llvm\tools\clang\test\CodeGen\builtins-x86.c


Repository:
  rL LLVM

https://reviews.llvm.org/D29386



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 87424.
krasimir added a comment.

- Moved method summary from the implementation to the declaration.


https://reviews.llvm.org/D29626

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11924,6 +11924,122 @@
"\n"
"// long",
getLLVMStyleWithColumns(15)));
+
+  // Align comment line sections aligned with the next token with the next
+  // token.
+  EXPECT_EQ("class A {\n"
+"public: // public comment\n"
+"  // comment about a\n"
+"  int a;\n"
+"};",
+format("class A {\n"
+   "public: // public comment\n"
+   "  // comment about a\n"
+   "  int a;\n"
+   "};",
+   getLLVMStyleWithColumns(40)));
+  EXPECT_EQ("class A {\n"
+"public: // public comment 1\n"
+"// public comment 2\n"
+"  // comment 1 about a\n"
+"  // comment 2 about a\n"
+"  int a;\n"
+"};",
+format("class A {\n"
+   "public: // public comment 1\n"
+   "   // public comment 2\n"
+   "  // comment 1 about a\n"
+   "  // comment 2 about a\n"
+   "  int a;\n"
+   "};",
+   getLLVMStyleWithColumns(40)));
+  EXPECT_EQ("int f(int n) { // comment line 1 on f\n"
+"   // comment line 2 on f\n"
+"  // comment line 1 before return\n"
+"  // comment line 2 before return\n"
+"  return n; // comment line 1 on return\n"
+"// comment line 2 on return\n"
+"  // comment line 1 after return\n"
+"}",
+format("int f(int n) { // comment line 1 on f\n"
+   "   // comment line 2 on f\n"
+   "  // comment line 1 before return\n"
+   "  // comment line 2 before return\n"
+   "  return n; // comment line 1 on return\n"
+   "   // comment line 2 on return\n"
+   "  // comment line 1 after return\n"
+   "}",
+   getLLVMStyleWithColumns(40)));
+  EXPECT_EQ("int f(int n) {\n"
+"  switch (n) { // comment line 1 on switch\n"
+"   // comment line 2 on switch\n"
+"  // comment line 1 before case 1\n"
+"  // comment line 2 before case 1\n"
+"  case 1: // comment line 1 on case 1\n"
+"  // comment line 2 on case 1\n"
+"// comment line 1 before return 1\n"
+"// comment line 2 before return 1\n"
+"return 1; // comment line 1 on return 1\n"
+"  // comment line 2 on return 1\n"
+"  // comment line 1 before default\n"
+"  // comment line 2 before default\n"
+"  default: // comment line 1 on default\n"
+"   // comment line 2 on default\n"
+"// comment line 1 before return 2\n"
+"return 2 * f(n - 1); // comment line 1 on return 2\n"
+" // comment line 2 on return 2\n"
+"// comment line 1 after return\n"
+"// comment line 2 after return\n"
+"  }\n"
+"}",
+format("int f(int n) {\n"
+   "  switch (n) { // comment line 1 on switch\n"
+   "  // comment line 2 on switch\n"
+   "// comment line 1 before case 1\n"
+   "// comment line 2 before case 1\n"
+   "case 1: // comment line 1 on case 1\n"
+   "  // comment line 2 on case 1\n"
+   "// comment line 1 before return 1\n"
+   "// comment line 2 before return 1\n"
+   "return 1;  // comment line 1 on return 1\n"
+   " // comment line 2 on return 1\n"
+   "// comment line 1 before default\n"
+   "// comment line 2 before default\n"
+   "default:   // comment line 1 on default\n"
+   "// comment line 2 on default\n"
+   "// comment line 1 before return 2\n"
+   "return 2 * f(n - 1); // comment line 1 on return 2\n"
+   "// comment line 2 on return 2\n"
+   "// comment line 1 after return\n"
+   " // comment line 2 after return\n"
+   "  }\n"

[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/UnwrappedLineParser.h:121-123
+  // Comments specifies the sequence of comment tokens to analyze. They get
+  // either pushed to the current line or added to the comments before the next
+  // token.

Given this, I'd perhaps call this addSection or addCommentSection or something 
similar? analyze sounds like it doesn't change the state of the class...


https://reviews.llvm.org/D29626



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


[PATCH] D29626: [clang-format] Break before a sequence of line comments aligned with the next line.

2017-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2207-2208
+const FormatToken *NextTok) {
+  // Decides which comment tokens should be added to the current line and which
+  // should be added as comments before the next token.
+  //

klimek wrote:
> Put these 2 lines and what it does to the arguments into the header.
Done. Thanks!


https://reviews.llvm.org/D29626



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


[PATCH] D29622: Add a batch query and replace tool based on AST matchers.

2017-02-07 Thread Samuel Benzaquen via Phabricator via cfe-commits
sbenza added inline comments.



Comment at: clang-query/QueryReplace.h:35-36
+
+  /// \brief Replacement text. %"identifier" will be substituted by the text of
+  /// an identifier.
+  std::string ToTemplate;

klimek wrote:
> This doesn't seem to come up in the test? (and I don't understand what it's 
> trying to tell me :)
In the other change the identifier was specified with ${identifier}, not 
%"identifier".
They should be consistent, no?


https://reviews.llvm.org/D29622



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


RE: r285733 - clang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts with "opt -instnamer".

2017-02-07 Thread Anastasia Stulova via cfe-commits
I don't understand why we need this extra step in testing now? Did anything 
fail?

Thanks,
Anastasia

-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
NAKAMURA Takumi via cfe-commits
Sent: 01 November 2016 20:08
To: cfe-commits@lists.llvm.org
Subject: r285733 - clang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts 
with "opt -instnamer".

Author: chapuni
Date: Tue Nov  1 15:08:17 2016
New Revision: 285733

URL: http://llvm.org/viewvc/llvm-project?rev=285733&view=rev
Log:
clang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts with "opt -instnamer".

Modified:
cfe/trunk/test/CodeGenOpenCL/convergent.cl

Modified: cfe/trunk/test/CodeGenOpenCL/convergent.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/convergent.cl?rev=285733&r1=285732&r2=285733&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/convergent.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/convergent.cl Tue Nov  1 15:08:17 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | 
+opt -instnamer -S | FileCheck %s
 
 void convfun(void) __attribute__((convergent));  void non_convfun(void);


___
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


[clang-tools-extra] r294312 - [clangd] Ignore comments in clangd input, so we can write tests without sed.

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 09:37:17 2017
New Revision: 294312

URL: http://llvm.org/viewvc/llvm-project?rev=294312&view=rev
Log:
[clangd] Ignore comments in clangd input, so we can write tests without sed.

Another attempt on making this work on windows.

Modified:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/test/clangd/formatting.test

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294312&r1=294311&r2=294312&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Tue Feb  7 09:37:17 2017
@@ -56,6 +56,11 @@ int main(int argc, char *argv[]) {
 if (LineRef.trim().empty())
   continue;
 
+// We allow YAML-style comments. Technically this isn't part of the
+// LSP specification, but makes writing tests easier.
+if (LineRef.startswith("#"))
+  continue;
+
 unsigned long long Len = 0;
 // FIXME: Content-Type is a specified header, but does nothing.
 // Content-Length is a mandatory header. It specifies the length of the

Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=294312&r1=294311&r2=294312&view=diff
==
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Tue Feb  7 09:37:17 2017
@@ -1,5 +1,5 @@
-# REQUIRES: shell
-# RUN: sed -e '/^#/d' -e 's/\r*$/\r/' %s | clangd | FileCheck %s
+# RUN: clangd < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
 #
 Content-Length: 125
 


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


[PATCH] D29643: [analyzer] Do not duplicate call graph nodes for function that has definition and forward declaration.

2017-02-07 Thread Ivan Sidorenko via Phabricator via cfe-commits
IvanSidorenko created this revision.

Fix in call graph construction: don't build call graph node for callee function 
twice for functions with forward declarations.

Maybe the same fix should be done and for VisitObjCMethodDecl. Unfortunately, I 
have not enough expertise in ObjC, so I did not touch this code.

Test case:
void do_nothing() {}
void test_single_call();
void test_single_call() {

  do_nothing();

}

Output for the test case WITHOUT patch:
Function: test_single_call calls: **do_nothing do_nothing**
Function: do_nothing calls:

Output for the test case WITH patch:
Function: test_single_call calls: **do_nothing**
Function: do_nothing calls:


https://reviews.llvm.org/D29643

Files:
  include/clang/Analysis/CallGraph.h
  test/Analysis/debug-CallGraph.c


Index: test/Analysis/debug-CallGraph.c
===
--- test/Analysis/debug-CallGraph.c
+++ test/Analysis/debug-CallGraph.c
@@ -43,8 +43,18 @@
 void eee() {}
 void fff() { eee(); }
 
+// This test case tests that forward declaration for the top-level function
+// does not affect call graph construction.
+void do_nothing() {}
+void test_single_call();
+void test_single_call() {
+  do_nothing();
+}
+
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ccc ddd eee fff $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call $}}
+// CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}}
+// CHECK-NEXT: {{Function: do_nothing calls: $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}
 // CHECK-NEXT: {{Function: eee calls: $}}
 // CHECK-NEXT: {{Function: ddd calls: ccc $}}
Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -98,7 +98,7 @@
   bool VisitFunctionDecl(FunctionDecl *FD) {
 // We skip function template definitions, as their semantics is
 // only determined when they are instantiated.
-if (includeInGraph(FD)) {
+if (includeInGraph(FD) && FD->isThisDeclarationADefinition()) {
   // Add all blocks declared inside this function to the graph.
   addNodesForBlocks(FD);
   // If this function has external linkage, anything could call it.


Index: test/Analysis/debug-CallGraph.c
===
--- test/Analysis/debug-CallGraph.c
+++ test/Analysis/debug-CallGraph.c
@@ -43,8 +43,18 @@
 void eee() {}
 void fff() { eee(); }
 
+// This test case tests that forward declaration for the top-level function
+// does not affect call graph construction.
+void do_nothing() {}
+void test_single_call();
+void test_single_call() {
+  do_nothing();
+}
+
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ccc ddd eee fff $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call $}}
+// CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}}
+// CHECK-NEXT: {{Function: do_nothing calls: $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}
 // CHECK-NEXT: {{Function: eee calls: $}}
 // CHECK-NEXT: {{Function: ddd calls: ccc $}}
Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -98,7 +98,7 @@
   bool VisitFunctionDecl(FunctionDecl *FD) {
 // We skip function template definitions, as their semantics is
 // only determined when they are instantiated.
-if (includeInGraph(FD)) {
+if (includeInGraph(FD) && FD->isThisDeclarationADefinition()) {
   // Add all blocks declared inside this function to the graph.
   addNodesForBlocks(FD);
   // If this function has external linkage, anything could call it.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r285733 - clang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts with "opt -instnamer".

2017-02-07 Thread NAKAMURA Takumi via cfe-commits
The test depends on named labels. It failed with -Asserts.

On Wed, Feb 8, 2017 at 12:45 AM Anastasia Stulova 
wrote:

> I don't understand why we need this extra step in testing now? Did
> anything fail?
>
> Thanks,
> Anastasia
>
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of NAKAMURA Takumi via cfe-commits
> Sent: 01 November 2016 20:08
> To: cfe-commits@lists.llvm.org
> Subject: r285733 - clang/test/CodeGenOpenCL/convergent.cl: Satisfy
> -Asserts with "opt -instnamer".
>
> Author: chapuni
> Date: Tue Nov  1 15:08:17 2016
> New Revision: 285733
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285733&view=rev
> Log:
> clang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts with "opt
> -instnamer".
>
> Modified:
> cfe/trunk/test/CodeGenOpenCL/convergent.cl
>
> Modified: cfe/trunk/test/CodeGenOpenCL/convergent.cl
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/convergent.cl?rev=285733&r1=285732&r2=285733&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenOpenCL/convergent.cl (original)
> +++ cfe/trunk/test/CodeGenOpenCL/convergent.cl Tue Nov  1 15:08:17 2016
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - |
> FileCheck %s
> +// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - |
> +opt -instnamer -S | FileCheck %s
>
>  void convfun(void) __attribute__((convergent));  void non_convfun(void);
>
>
> ___
> 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


[libcxx] r294311 - Mark LWG2784 as ready

2017-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Feb  7 09:34:20 2017
New Revision: 294311

URL: http://llvm.org/viewvc/llvm-project?rev=294311&view=rev
Log:
Mark LWG2784 as ready

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=294311&r1=294310&r2=294311&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Tue Feb  7 09:34:20 2017
@@ -64,7 +64,7 @@
http://wg21.link/LWG2769";>2769Redundant 
const in the return type of any_cast(const 
any&)Kona
http://wg21.link/LWG2781";>2781Contradictory requirements for 
std::function and std::reference_wrapperKona
http://wg21.link/LWG2782";>2782scoped_allocator_adaptor 
constructors must be constrainedKona
-   http://wg21.link/LWG2784";>2784Resolution 
to LWG 2484 is missing "otherwise, no effects" and is hard to 
parseKona
+   http://wg21.link/LWG2784";>2784Resolution 
to LWG 2484 is missing "otherwise, no effects" and is hard to 
parseKonaPatch Ready
http://wg21.link/LWG2785";>2785quoted 
should work with basic_string_viewKonaWe do this 
already
http://wg21.link/LWG2786";>2786Annex C 
should mention shared_ptr changes for array 
supportKonaNothing to do
http://wg21.link/LWG2787";>2787§[file_status.cons] 
doesn't match class definitionKona
@@ -98,7 +98,7 @@
 2769 - This should be easy; trick will be devising tests.
 2781 - 
 2782 - Looks straightforward.
-2784 - I think we do this already; maybe more tests (esp about 
'inaccessible base class')
+2784 - Patch Ready
 2785 - We do this already.
 2786 - Nothing to do; just moving words around
 2787 - Eric? 


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


[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-07 Thread Samuel Benzaquen via Phabricator via cfe-commits
sbenza added inline comments.



Comment at: include/clang/Tooling/RefactoringCallbacks.h:61
+MatchFinder.addMatcher(Matcher, Callback);
+Callbacks.emplace_back(Callback);
+  }

Why emplace_back instead of push_back?



Comment at: lib/Tooling/RefactoringCallbacks.cpp:160
+  for (size_t Index = 0; Index < ToTemplate.size();) {
+if (ToTemplate[Index] == '$') {
+  if (ToTemplate.substr(Index, 2) == "$$") {

We should do the parsing in the constructor, instead of on each match.
We could store a vector of {string, bool is_id;} that we just iterate during 
each match.
It also has the advantage of hitting the error+assert before in the run.



Comment at: lib/Tooling/RefactoringCallbacks.cpp:174
+ToTemplate.substr(Index + 2, EndOfIdentifier - Index - 2);
+if (NodeMap.count(SourceNodeName) == 0) {
+  llvm::errs()

This is making two lookups into the map when one is enough.



Comment at: lib/Tooling/RefactoringCallbacks.cpp:192
+  size_t NextIndex = ToTemplate.find('$', Index + 1);
+  ToText = ToText + ToTemplate.substr(Index, NextIndex - Index);
+  Index = NextIndex;

X += instead of X = X +


https://reviews.llvm.org/D29621



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


[PATCH] D29386: Clzero flag addition and inclusion under znver1

2017-02-07 Thread Ganesh Gopalasubramanian via Phabricator via cfe-commits
GGanesh updated this revision to Diff 87437.
GGanesh added a comment.

Updated the builtins test for "__builtin_ia32_clzero"


Repository:
  rL LLVM

https://reviews.llvm.org/D29386

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/clzerointrin.h
  lib/Headers/module.modulemap
  lib/Headers/x86intrin.h
  test/CodeGen/builtins-x86.c

Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -emit-llvm -o %t %s
-// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -fsyntax-only -o %t %s
+// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -emit-llvm -o %t %s
+// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -fsyntax-only -o %t %s
 
 #ifdef USE_ALL
 #define USE_3DNOW
@@ -285,6 +285,7 @@
 
   (void) __builtin_ia32_monitorx(tmp_vp, tmp_Ui, tmp_Ui);
   (void) __builtin_ia32_mwaitx(tmp_Ui, tmp_Ui, tmp_Ui);
+  (void) __builtin_ia32_clzero(tmp_vp);
 
   tmp_V4f = __builtin_ia32_cvtpi2ps(tmp_V4f, tmp_V2i);
   tmp_V2i = __builtin_ia32_cvtps2pi(tmp_V4f);
Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -80,6 +80,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLZERO__)
+#include 
+#endif
+
 /* FIXME: LWP */
 
 #endif /* __X86INTRIN_H */
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -61,6 +61,7 @@
 textual header "xopintrin.h"
 textual header "fma4intrin.h"
 textual header "mwaitxintrin.h"
+textual header "clzerointrin.h"
 
 explicit module mm_malloc {
   requires !freestanding
Index: lib/Headers/clzerointrin.h
===
--- lib/Headers/clzerointrin.h
+++ lib/Headers/clzerointrin.h
@@ -0,0 +1,50 @@
+/*===--- clzerointrin.h - CLZERO --===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __X86INTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef _CLZEROINTRIN_H
+#define _CLZEROINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __nodebug__,  __target__("clzero")))
+
+/// \brief Loads the cache line address and zero's out the cacheline
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLZERO  instruction.
+///
+/// \param __line
+///A pointer to a cacheline which needs to be zeroed out.
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_clzero (void * __line)
+{
+  __builtin_ia32_clzero ((void *)__line);
+}
+
+#undef __DEFAULT_FN_ATTRS 
+
+#endif /* _CLZEROINTRIN_H */
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -28,6 +28,7 @@
   __clang_cuda_intrinsics.

r294313 - [OpenCL] Accept logical NOT for pointer types in CL1.1

2017-02-07 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Tue Feb  7 10:09:41 2017
New Revision: 294313

URL: http://llvm.org/viewvc/llvm-project?rev=294313&view=rev
Log:
[OpenCL] Accept logical NOT for pointer types in CL1.1

Fix for bug 30217 - incorrect error given for logical
NOT operation with a pointer type: corrected sema check
and improved related tests.

Review: D29038


Added:
cfe/trunk/test/SemaOpenCL/logical-ops.cl
Removed:
cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl
cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=294313&r1=294312&r2=294313&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb  7 10:09:41 2017
@@ -11686,7 +11686,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
  Context.getLangOpts().OpenCLVersion < 120) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on scalar float types.
-if (!resultType->isIntegerType())
+if (!resultType->isIntegerType() && !resultType->isPointerType())
   return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
<< resultType << Input.get()->getSourceRange());
   }

Removed: cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl?rev=294312&view=auto
==
--- cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl (removed)
@@ -1,57 +0,0 @@
-// RUN: %clang_cc1 %s -verify -cl-std=CL1.1 -triple x86_64-unknown-linux-gnu
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-typedef __attribute__((ext_vector_type(4))) float float4;
-typedef __attribute__((ext_vector_type(4))) double double4;
-typedef __attribute__((ext_vector_type(4))) int int4;
-typedef __attribute__((ext_vector_type(4))) long long4;
-
-kernel void float_ops() {
-  int flaf = 0.0f && 0.0f; // expected-error {{invalid operands}}
-  int flof = 0.0f || 0.0f; // expected-error {{invalid operands}}
-  float fbaf = 0.0f & 0.0f; // expected-error {{invalid operands}}
-  float fbof = 0.0f | 0.0f; // expected-error {{invalid operands}}
-  float fbxf = 0.0f ^ 0.0f; // expected-error {{invalid operands}}
-  int flai = 0.0f && 0; // expected-error {{invalid operands}}
-  int floi = 0.0f || 0; // expected-error {{invalid operands}}
-  float ibaf = 0 & 0.0f; // expected-error {{invalid operands}}
-  float ibof = 0 | 0.0f; // expected-error {{invalid operands}}
-  float bnf = ~0.0f; // expected-error {{invalid argument type}}
-  float lnf = !0.0f; // expected-error {{invalid argument type}}
-}
-
-kernel void vec_float_ops() {
-  float4 f4 = (float4)(0, 0, 0, 0);
-  int4 f4laf = f4 && 0.0f; // expected-error {{invalid operands}}
-  int4 f4lof = f4 || 0.0f; // expected-error {{invalid operands}}
-  float4 f4baf = f4 & 0.0f; // expected-error {{invalid operands}}
-  float4 f4bof = f4 | 0.0f; // expected-error {{invalid operands}}
-  float4 f4bxf = f4 ^ 0.0f; // expected-error {{invalid operands}}
-  float bnf4 = ~f4; // expected-error {{invalid argument type}}
-  int4 lnf4 = !f4; // expected-error {{invalid argument type}}
-}
-
-kernel void double_ops() {
-  int flaf = 0.0 && 0.0; // expected-error {{invalid operands}}
-  int flof = 0.0 || 0.0; // expected-error {{invalid operands}}
-  double fbaf = 0.0 & 0.0; // expected-error {{invalid operands}}
-  double fbof = 0.0 | 0.0; // expected-error {{invalid operands}}
-  double fbxf = 0.0 ^ 0.0; // expected-error {{invalid operands}}
-  int flai = 0.0 && 0; // expected-error {{invalid operands}}
-  int floi = 0.0 || 0; // expected-error {{invalid operands}}
-  double ibaf = 0 & 0.0; // expected-error {{invalid operands}}
-  double ibof = 0 | 0.0; // expected-error {{invalid operands}}
-  double bnf = ~0.0; // expected-error {{invalid argument type}}
-  double lnf = !0.0; // expected-error {{invalid argument type}}
-}
-
-kernel void vec_double_ops() {
-  double4 f4 = (double4)(0, 0, 0, 0);
-  long4 f4laf = f4 && 0.0; // expected-error {{invalid operands}}
-  long4 f4lof = f4 || 0.0; // expected-error {{invalid operands}}
-  double4 f4baf = f4 & 0.0; // expected-error {{invalid operands}}
-  double4 f4bof = f4 | 0.0; // expected-error {{invalid operands}}
-  double4 f4bxf = f4 ^ 0.0; // expected-error {{invalid operands}}
-  double bnf4 = ~f4; // expected-error {{invalid argument type}}
-  long4 lnf4 = !f4; // expected-error {{invalid argument type}}
-}

Removed: cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl?rev=294312&view=auto
=

[PATCH] D29027: [Stack Protection] Add remark for reasons why Stack Protection has been applied

2017-02-07 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

Ping!


https://reviews.llvm.org/D29027



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


[clang-tools-extra] r294314 - [clangd] Strip file:// from the URI when calling formatting.

2017-02-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  7 10:10:17 2017
New Revision: 294314

URL: http://llvm.org/viewvc/llvm-project?rev=294314&view=rev
Log:
[clangd] Strip file:// from the URI when calling formatting.

It confuses FileManager on windows.

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

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=294314&r1=294313&r2=294314&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Tue Feb  7 10:10:17 2017
@@ -63,6 +63,9 @@ static std::string formatCode(StringRef
   // Call clang-format.
   // FIXME: Don't ignore style.
   format::FormatStyle Style = format::getLLVMStyle();
+  // On windows FileManager doesn't like file://. Just strip it, clang-format
+  // doesn't need it.
+  Filename.consume_front("file://");
   tooling::Replacements Replacements =
   format::reformat(Style, Code, Ranges, Filename);
 


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


[PATCH] D29038: [OpenCL] Accept logical NOT for pointer types in CL1.1

2017-02-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed in r294313


https://reviews.llvm.org/D29038



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


[PATCH] D17092: [X86] Add -mseparate-stack-seg

2017-02-07 Thread Michael LeMay via Phabricator via cfe-commits
mlemay-intel updated this revision to Diff 87453.
mlemay-intel added a comment.

Removed the portions that are specific to 32-bit segmentation.  I plan to 
resubmit those later as a separate patch.


https://reviews.llvm.org/D17092

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1605,6 +1605,7 @@
 def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
 def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
 def mno_pku : Flag<["-"], "mno-pku">, Group;
+def mno_separate_stack_seg : Flag<["-"], "mno-separate-stack-seg">, 
Group;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
   HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
@@ -1785,6 +1786,7 @@
 def mprfchw : Flag<["-"], "mprfchw">, Group;
 def mrdseed : Flag<["-"], "mrdseed">, Group;
 def mpku : Flag<["-"], "mpku">, Group;
+def mseparate_stack_seg : Flag<["-"], "mseparate-stack-seg">, 
Group;
 def madx : Flag<["-"], "madx">, Group;
 def msha : Flag<["-"], "msha">, Group;
 def mcx16 : Flag<["-"], "mcx16">, Group;


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1605,6 +1605,7 @@
 def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
 def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
 def mno_pku : Flag<["-"], "mno-pku">, Group;
+def mno_separate_stack_seg : Flag<["-"], "mno-separate-stack-seg">, Group;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
   HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
@@ -1785,6 +1786,7 @@
 def mprfchw : Flag<["-"], "mprfchw">, Group;
 def mrdseed : Flag<["-"], "mrdseed">, Group;
 def mpku : Flag<["-"], "mpku">, Group;
+def mseparate_stack_seg : Flag<["-"], "mseparate-stack-seg">, Group;
 def madx : Flag<["-"], "madx">, Group;
 def msha : Flag<["-"], "msha">, Group;
 def mcx16 : Flag<["-"], "mcx16">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23421: [Clang-tidy] CERT-MSC53-CPP (checker for std namespace modification)

2017-02-07 Thread Benedek Kiss via cfe-commits
Unfortunatelly I wont have time now to work on this check... Thank you for
understanding!

On Mon, Feb 6, 2017 at 3:44 PM, Gábor Horváth via Phabricator <
revi...@reviews.llvm.org> wrote:

> xazax.hun added a comment.
>
> Benedek, do you have time to address the review comments or do you want me
> to commandeer this revision?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D23421
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29656: clang-format: [JS] correcly format object literal methods.

2017-02-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Format/UnwrappedLineParser.cpp:1306
+// Could be a method inside of a braced list `{a() { return 1; }}`.
+if (tryToParseBracedList()) {
+  continue;

nit: remove braces ;)


https://reviews.llvm.org/D29656



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


[PATCH] D29656: clang-format: [JS] correcly format object literal methods.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

In JavaScript, object literals can contain methods:

  var x = {
a() { return 1; },
  };

Previously, clang-format always parsed nested {} inside a braced list as
further braced lists. Special case this logic for JavaScript to try
parsing as a braced list, but fall back to parsing as a child block.


https://reviews.llvm.org/D29656

Files:
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -240,6 +240,18 @@
"};");
   verifyFormat("var x = {y: (a) => a};");
 
+  // Methods in object literals.
+  verifyFormat("var x = {\n"
+   "  y(a: string): number {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+  verifyFormat("var x = {\n"
+   "  y(a: string) {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+
   // Computed keys.
   verifyFormat("var x = {[a]: 1, b: 2, [c]: 3};");
   verifyFormat("var x = {\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -335,8 +335,11 @@
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok &&
   PrevTok->is(tok::colon))
-// In TypeScript's TypeMemberLists, there can be semicolons between the
-// individual members.
+// A colon indicates this code is in a type, or a braced list following
+// a label in an object literal ({a: {b: 1}}).
+// The code below could be confused by semicolons between the 
individual
+// members in a type member list, which would normally trigger 
BK_Block.
+// In both cases, this must be parsed as an inline braced init.
 Tok->BlockKind = BK_BracedInit;
   else
 Tok->BlockKind = BK_Unknown;
@@ -1298,6 +1301,13 @@
   continue;
 }
   }
+  if (FormatTok->is(tok::l_brace)) {
+// Could be a method inside of a braced list `{a() { return 1; }}`.
+if (tryToParseBracedList()) {
+  continue;
+}
+parseChildBlock();
+  }
 }
 switch (FormatTok->Tok.getKind()) {
 case tok::caret:
@@ -1309,12 +1319,6 @@
 case tok::l_square:
   tryToParseLambda();
   break;
-case tok::l_brace:
-  // Assume there are no blocks inside a braced init list apart
-  // from the ones we explicitly parse out (like lambdas).
-  FormatTok->BlockKind = BK_BracedInit;
-  parseBracedList();
-  break;
 case tok::l_paren:
   parseParens();
   // JavaScript can just have free standing methods and getters/setters in
@@ -1325,6 +1329,12 @@
 break;
   }
   break;
+case tok::l_brace:
+  // Assume there are no blocks inside a braced init list apart
+  // from the ones we explicitly parse out (like lambdas).
+  FormatTok->BlockKind = BK_BracedInit;
+  parseBracedList();
+  break;
 case tok::r_brace:
   nextToken();
   return !HasError;
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2648,6 +2648,7 @@
  << " T=" << getTokenTypeName(Tok->Type)
  << " S=" << Tok->SpacesRequiredBefore
  << " B=" << Tok->BlockParameterCount
+ << " BK=" << Tok->BlockKind
  << " P=" << Tok->SplitPenalty << " Name=" << 
Tok->Tok.getName()
  << " L=" << Tok->TotalLength << " PPK=" << Tok->PackingKind
  << " FakeLParens=";


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -240,6 +240,18 @@
"};");
   verifyFormat("var x = {y: (a) => a};");
 
+  // Methods in object literals.
+  verifyFormat("var x = {\n"
+   "  y(a: string): number {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+  verifyFormat("var x = {\n"
+   "  y(a: string) {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+
   // Computed keys.
   verifyFormat("var x = {[a]: 1, b: 2, [c]: 3};");
   verifyFormat("var x = {\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -335,8 +335,11 @@
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok &&
   PrevTok->i

[PATCH] D29415: [Assembler] Inline assembly diagnostics test.

2017-02-07 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 updated this revision to Diff 87461.
sanwou01 added a comment.

Update the tests.  Note that the diagnostics for backend errors are missing the
"instantiated into assembly here" messages.  This is unfortunate but expected:
the origin information is no longer available at this stage.


https://reviews.llvm.org/D29415

Files:
  test/Misc/inline-asm-diags.c


Index: test/Misc/inline-asm-diags.c
===
--- /dev/null
+++ test/Misc/inline-asm-diags.c
@@ -0,0 +1,25 @@
+// RUN: not %clang -c --target=armv7a-arm-none-eabi %s -o /dev/null 2>&1 | 
FileCheck %s
+
+void foo2() {
+   asm(" wibble");
+}
+
+// CHECK: 4:6: error: invalid instruction
+// CHECK:   asm(" wibble");
+// CHECK:   ^
+// CHECK: :1:3: note: instantiated into assembly here
+// CHECK:  wibble
+// CHECK:  ^~
+
+void foo() {
+   asm(" .word -bar");
+   asm(" .word -foo");
+}
+
+// CHECK: :1:3: error: expected relocatable expression
+// CHECK:  .word -bar
+// CHECK:  ^
+
+// CHECK: :1:3: error: expected relocatable expression
+// CHECK:  .word -foo
+// CHECK:  ^


Index: test/Misc/inline-asm-diags.c
===
--- /dev/null
+++ test/Misc/inline-asm-diags.c
@@ -0,0 +1,25 @@
+// RUN: not %clang -c --target=armv7a-arm-none-eabi %s -o /dev/null 2>&1 | FileCheck %s
+
+void foo2() {
+	asm(" wibble");
+}
+
+// CHECK: 4:6: error: invalid instruction
+// CHECK:   asm(" wibble");
+// CHECK:   ^
+// CHECK: :1:3: note: instantiated into assembly here
+// CHECK:  wibble
+// CHECK:  ^~
+
+void foo() {
+	asm(" .word -bar");
+	asm(" .word -foo");
+}
+
+// CHECK: :1:3: error: expected relocatable expression
+// CHECK:  .word -bar
+// CHECK:  ^
+
+// CHECK: :1:3: error: expected relocatable expression
+// CHECK:  .word -foo
+// CHECK:  ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r294315 - clang-format: [JS] correcly format object literal methods.

2017-02-07 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Feb  7 10:33:13 2017
New Revision: 294315

URL: http://llvm.org/viewvc/llvm-project?rev=294315&view=rev
Log:
clang-format: [JS] correcly format object literal methods.

Summary:
In JavaScript, object literals can contain methods:

   var x = {
 a() { return 1; },
   };

Previously, clang-format always parsed nested {} inside a braced list as
further braced lists. Special case this logic for JavaScript to try
parsing as a braced list, but fall back to parsing as a child block.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=294315&r1=294314&r2=294315&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Feb  7 10:33:13 2017
@@ -2648,6 +2648,7 @@ void TokenAnnotator::printDebugInfo(cons
  << " T=" << getTokenTypeName(Tok->Type)
  << " S=" << Tok->SpacesRequiredBefore
  << " B=" << Tok->BlockParameterCount
+ << " BK=" << Tok->BlockKind
  << " P=" << Tok->SplitPenalty << " Name=" << 
Tok->Tok.getName()
  << " L=" << Tok->TotalLength << " PPK=" << Tok->PackingKind
  << " FakeLParens=";

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=294315&r1=294314&r2=294315&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Feb  7 10:33:13 2017
@@ -335,8 +335,11 @@ void UnwrappedLineParser::calculateBrace
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok &&
   PrevTok->is(tok::colon))
-// In TypeScript's TypeMemberLists, there can be semicolons between the
-// individual members.
+// A colon indicates this code is in a type, or a braced list following
+// a label in an object literal ({a: {b: 1}}).
+// The code below could be confused by semicolons between the 
individual
+// members in a type member list, which would normally trigger 
BK_Block.
+// In both cases, this must be parsed as an inline braced init.
 Tok->BlockKind = BK_BracedInit;
   else
 Tok->BlockKind = BK_Unknown;
@@ -1298,6 +1301,12 @@ bool UnwrappedLineParser::parseBracedLis
   continue;
 }
   }
+  if (FormatTok->is(tok::l_brace)) {
+// Could be a method inside of a braced list `{a() { return 1; }}`.
+if (tryToParseBracedList())
+  continue;
+parseChildBlock();
+  }
 }
 switch (FormatTok->Tok.getKind()) {
 case tok::caret:
@@ -1309,12 +1318,6 @@ bool UnwrappedLineParser::parseBracedLis
 case tok::l_square:
   tryToParseLambda();
   break;
-case tok::l_brace:
-  // Assume there are no blocks inside a braced init list apart
-  // from the ones we explicitly parse out (like lambdas).
-  FormatTok->BlockKind = BK_BracedInit;
-  parseBracedList();
-  break;
 case tok::l_paren:
   parseParens();
   // JavaScript can just have free standing methods and getters/setters in
@@ -1325,6 +1328,12 @@ bool UnwrappedLineParser::parseBracedLis
 break;
   }
   break;
+case tok::l_brace:
+  // Assume there are no blocks inside a braced init list apart
+  // from the ones we explicitly parse out (like lambdas).
+  FormatTok->BlockKind = BK_BracedInit;
+  parseBracedList();
+  break;
 case tok::r_brace:
   nextToken();
   return !HasError;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=294315&r1=294314&r2=294315&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Feb  7 10:33:13 2017
@@ -240,6 +240,18 @@ TEST_F(FormatTestJS, ContainerLiterals)
"};");
   verifyFormat("var x = {y: (a) => a};");
 
+  // Methods in object literals.
+  verifyFormat("var x = {\n"
+   "  y(a: string): number {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+  verifyFormat("var x = {\n"
+   "  y(a: string) {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+
   // Computed keys.
   verifyFormat("va

[PATCH] D29659: [OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.

2017-02-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

Previously we have added the "-c" flag which gets passed to PTXAS by default to 
generate relocatable OpenMP target code by default. This set of flags exposes 
control over this behaviour.


Repository:
  rL LLVM

https://reviews.llvm.org/D29659

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -610,6 +610,14 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C %s
+
+// CHK-PTXAS-C-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -12211,7 +12211,9 @@
 CmdArgs.push_back(Args.MakeArgString(A));
 
   // In OpenMP we need to generate relocatable code.
-  if (JA.isOffloading(Action::OFK_OpenMP))
+  if (JA.isOffloading(Action::OFK_OpenMP) &&
+  !Args.hasFlag(options::OPT_fnoopenmp_relocatable_target,
+options::OPT_fopenmp_relocatable_target, false))
 CmdArgs.push_back("-c");
 
   const char *Exec;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1213,6 +1213,10 @@
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group, 
   Flags<[NoArgumentUnused]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
+def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Do not compile OpenMP target code as relocatable.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -610,6 +610,14 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C %s
+
+// CHK-PTXAS-C-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -12211,7 +12211,9 @@
 CmdArgs.push_back(Args.MakeArgString(A));
 
   // In OpenMP we need to generate relocatable code.
-  if (JA.isOffloading(Action::OFK_OpenMP))
+  if (JA.isOffloading(Action::OFK_OpenMP) &&
+  !Args.hasFlag(options::OPT_fnoopenmp_relocatable_target,
+options::OPT_fopenmp_relocatable_target, false))
 CmdArgs.push_back("-c");
 
   const char *Exec;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1213,6 +1213,10 @@
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets to be supported">;
 def fopenmp_dump_offload_linker_script : Flag<["-"], "fopenmp-dump-offload-linker-script">, Group, 
   Flags<[NoArgumentUnused]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, Group, Flags<[CC1

[PATCH] D23421: [Clang-tidy] CERT-MSC53-CPP (checker for std namespace modification)

2017-02-07 Thread Benedek Kiss via Phabricator via cfe-commits
falho added a comment.

Unfortunately I wont have time to work on this check anymore... thank you for 
understanding!


Repository:
  rL LLVM

https://reviews.llvm.org/D23421



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


[PATCH] D29656: clang-format: [JS] correcly format object literal methods.

2017-02-07 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294315: clang-format: [JS] correcly format object literal 
methods. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D29656?vs=87456&id=87462#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29656

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2648,6 +2648,7 @@
  << " T=" << getTokenTypeName(Tok->Type)
  << " S=" << Tok->SpacesRequiredBefore
  << " B=" << Tok->BlockParameterCount
+ << " BK=" << Tok->BlockKind
  << " P=" << Tok->SplitPenalty << " Name=" << 
Tok->Tok.getName()
  << " L=" << Tok->TotalLength << " PPK=" << Tok->PackingKind
  << " FakeLParens=";
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -335,8 +335,11 @@
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok &&
   PrevTok->is(tok::colon))
-// In TypeScript's TypeMemberLists, there can be semicolons between the
-// individual members.
+// A colon indicates this code is in a type, or a braced list following
+// a label in an object literal ({a: {b: 1}}).
+// The code below could be confused by semicolons between the 
individual
+// members in a type member list, which would normally trigger 
BK_Block.
+// In both cases, this must be parsed as an inline braced init.
 Tok->BlockKind = BK_BracedInit;
   else
 Tok->BlockKind = BK_Unknown;
@@ -1298,6 +1301,12 @@
   continue;
 }
   }
+  if (FormatTok->is(tok::l_brace)) {
+// Could be a method inside of a braced list `{a() { return 1; }}`.
+if (tryToParseBracedList())
+  continue;
+parseChildBlock();
+  }
 }
 switch (FormatTok->Tok.getKind()) {
 case tok::caret:
@@ -1309,12 +1318,6 @@
 case tok::l_square:
   tryToParseLambda();
   break;
-case tok::l_brace:
-  // Assume there are no blocks inside a braced init list apart
-  // from the ones we explicitly parse out (like lambdas).
-  FormatTok->BlockKind = BK_BracedInit;
-  parseBracedList();
-  break;
 case tok::l_paren:
   parseParens();
   // JavaScript can just have free standing methods and getters/setters in
@@ -1325,6 +1328,12 @@
 break;
   }
   break;
+case tok::l_brace:
+  // Assume there are no blocks inside a braced init list apart
+  // from the ones we explicitly parse out (like lambdas).
+  FormatTok->BlockKind = BK_BracedInit;
+  parseBracedList();
+  break;
 case tok::r_brace:
   nextToken();
   return !HasError;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -240,6 +240,18 @@
"};");
   verifyFormat("var x = {y: (a) => a};");
 
+  // Methods in object literals.
+  verifyFormat("var x = {\n"
+   "  y(a: string): number {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+  verifyFormat("var x = {\n"
+   "  y(a: string) {\n"
+   "return a;\n"
+   "  }\n"
+   "};");
+
   // Computed keys.
   verifyFormat("var x = {[a]: 1, b: 2, [c]: 3};");
   verifyFormat("var x = {\n"


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2648,6 +2648,7 @@
  << " T=" << getTokenTypeName(Tok->Type)
  << " S=" << Tok->SpacesRequiredBefore
  << " B=" << Tok->BlockParameterCount
+ << " BK=" << Tok->BlockKind
  << " P=" << Tok->SplitPenalty << " Name=" << Tok->Tok.getName()
  << " L=" << Tok->TotalLength << " PPK=" << Tok->PackingKind
  << " FakeLParens=";
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -335,8 +335,11 @@
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok &&
   PrevTok->is(tok::colon))
-/

[PATCH] D29659: [OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.

2017-02-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 87463.
gtbercea added a comment.

Additional test added to check "-c" is passed in appropriately.


Repository:
  rL LLVM

https://reviews.llvm.org/D29659

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -610,6 +610,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C %s
+
+// CHK-PTXAS-C-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C-RELO %s
+
+// CHK-PTXAS-C-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -12211,7 +12211,9 @@
 CmdArgs.push_back(Args.MakeArgString(A));
 
   // In OpenMP we need to generate relocatable code.
-  if (JA.isOffloading(Action::OFK_OpenMP))
+  if (JA.isOffloading(Action::OFK_OpenMP) &&
+  !Args.hasFlag(options::OPT_fnoopenmp_relocatable_target,
+options::OPT_fopenmp_relocatable_target, false))
 CmdArgs.push_back("-c");
 
   const char *Exec;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1213,6 +1213,10 @@
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group, 
   Flags<[NoArgumentUnused]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
+def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Do not compile OpenMP target code as relocatable.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -610,6 +610,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C %s
+
+// CHK-PTXAS-C-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C-RELO %s
+
+// CHK-PTXAS-C-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -12211,7 +1

[PATCH] D28445: [Analyzer] Extend taint propagation and checking

2017-02-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Artem,
Thank you for adding me, I missed this patch. I have few comments below. If you 
(and Vlad) can wait for two or  three days, I will re-check the place I'm 
worrying about and post the results.




Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:442
+
+const RecordDecl *RD = RT->getDecl()->getDefinition();
+for (const auto *I : RD->fields()) {

NoQ wrote:
> We need to be careful in the case when we don't have the definition in the 
> current translation unit. In this case we may still have derived symbols by 
> casting the pointer into some blindly guessed type, which may be primitive or 
> having well-defined primitive fields.
> 
> By the way, in D26837 i'm suspecting that there are other errors of this kind 
> in the checker, eg. when a function returns a void pointer, we put taint on 
> symbols of type "void", which is weird.
> 
> Adding Alexey who may recall something on this topic.
I will check the correctness of this code sample because I have some doubts 
about it.
The problem of casts is hard because of our approach to put taints on 0th 
elements. We lose casts and may get some strange void symbols. However, I guess 
this patch isn't related to this problem directly.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:502
+RegionBindingsRef B = getRegionBindings(S);
+const MemRegion *MR  = L.getRegion()->getBaseRegion();
+if (Optional V = B.getDefaultBinding(MR))

We get the LazyCompoundVal for some region but return the symbol for its base. 
It means that at least method name is very confusing.


https://reviews.llvm.org/D28445



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


[PATCH] D16135: Macro Debug Info support in Clang

2017-02-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In https://reviews.llvm.org/D16135#669045, @aaboud wrote:

> Addressed Adrian last comments.
>  Added a LIT tests that covers all the macro kinds:
>
> 1. built-in (define)
> 2. command-line (define, include, undef)
> 3. main source (define, include, undef) Checked the above with and without 
> PCH include.
>
>   Notice, that current implementation does not support debug info for macro 
> definition and inclusion generated during the PCH file creation. To support 
> that, we need to extend the PCH format to preserve this information. If you 
> believe this feature is important, I will open a bugzilla ticket and we can 
> handle it separately.


That would be a good idea and important to fix. I don't think we want the the 
generated code (or the debug info for that matter) to change just because the 
user decides to switch to PCH. Ideally turning on PCH should be transparent.

I have one final question: What's the impact of this change on, e.g., building 
clang?

- How much does the build directory grow?
- Is there any noticeable compile time regression?




Comment at: test/CodeGen/debug-info-macro.c:14
+
+// Please, keep the source lines aligned as below:
+/*Line 15*/ #define D1 1

Alternatively, you may be able to use #line to force an easily recognizable 
line number (unless that messes with the macro debug info, or you can use 
FileCheck's [[@LINE-offset]] feature.


https://reviews.llvm.org/D16135



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


[PATCH] D29661: [clang-tidy] Add -quiet option to suppress extra output

2017-02-07 Thread Ehsan Akhgari via Phabricator via cfe-commits
ehsan created this revision.
Herald added a subscriber: JDevlieghere.

This new flag instructs clang-tidy to not output anything
except for errors and warnings.  This makes it easier to
script clang-tidy to run as part of external build systems.


https://reviews.llvm.org/D29661

Files:
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/clang-tidy-diff.py
  clang-tidy/tool/run-clang-tidy.py
  test/clang-tidy/clang-tidy-diff.cpp
  test/clang-tidy/file-filter.cpp
  test/clang-tidy/werrors-diagnostics.cpp
  test/clang-tidy/werrors-plural.cpp
  test/clang-tidy/werrors.cpp

Index: test/clang-tidy/werrors.cpp
===
--- test/clang-tidy/werrors.cpp
+++ test/clang-tidy/werrors.cpp
@@ -1,10 +1,13 @@
 // RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
 // RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -quiet -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
 
 namespace i {
 }
 // CHECK-WARN: warning: namespace 'i' not terminated with a closing comment [llvm-namespace-comment]
 // CHECK-WERR: error: namespace 'i' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: namespace 'i' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
 
 // CHECK-WARN-NOT: treated as
 // CHECK-WERR: 1 warning treated as error
+// CHECK-WERR-QUIET-NOT: treated as
Index: test/clang-tidy/werrors-plural.cpp
===
--- test/clang-tidy/werrors-plural.cpp
+++ test/clang-tidy/werrors-plural.cpp
@@ -3,16 +3,22 @@
 // RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
 // RUN:   -warnings-as-errors='llvm-namespace-comment' -- 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN:   -warnings-as-errors='llvm-namespace-comment' -quiet -- 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
 
 namespace j {
 }
 // CHECK-WARN: warning: namespace 'j' not terminated with a closing comment [llvm-namespace-comment]
 // CHECK-WERR: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
 
 namespace k {
 }
 // CHECK-WARN: warning: namespace 'k' not terminated with a closing comment [llvm-namespace-comment]
 // CHECK-WERR: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
 
 // CHECK-WARN-NOT: treated as
 // CHECK-WERR: 2 warnings treated as errors
+// CHECK-WERR-QUIET-NOT: treated as
Index: test/clang-tidy/werrors-diagnostics.cpp
===
--- test/clang-tidy/werrors-diagnostics.cpp
+++ test/clang-tidy/werrors-diagnostics.cpp
@@ -4,10 +4,15 @@
 // RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
 // RUN:   -warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN:   -warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
 
 void f() { int i; }
 // CHECK-WARN: warning: unused variable 'i' [clang-diagnostic-unused-variable]
 // CHECK-WERR: error: unused variable 'i' [clang-diagnostic-unused-variable,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: unused variable 'i' [clang-diagnostic-unused-variable,-warnings-as-errors]
 
 // CHECK-WARN-NOT: treated as
 // CHECK-WERR: 1 warning treated as error
+// CHECK-WERR-QUIET-NOT: treated as
Index: test/clang-tidy/file-filter.cpp
===
--- test/clang-tidy/file-filter.cpp
+++ test/clang-tidy/file-filter.cpp
@@ -1,45 +1,73 @@
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='' -quiet %s -- -I %S/Inputs/file-filte

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-02-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

This flag "--fopenmp-ptx=" enables the overwriting of the default PTX version 
used for GPU offloaded OpenMP target regions: "+ptx42".


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -627,6 +627,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTX %s
+
+// CHK-PTX: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4932,8 +4932,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+  !PtxVersion.empty()) {
+// Use PTX version passed to the driver.
+CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
 if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -490,6 +490,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -627,6 +627,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTX %s
+
+// CHK-PTX: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4932,8 +4932,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+  !PtxVersion.empty()) {
+// Use PTX version passed to the driver.
+CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
 if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -490,6 +490,8 @@
   

[PATCH] D29644: [OpenMP] Pass -v to PTXAS if it was passed to the driver.

2017-02-07 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

I'm fine with this.


Repository:
  rL LLVM

https://reviews.llvm.org/D29644



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-07 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D29221#668867, @klimek wrote:

> +hans
>
> +1 to "format only current document but save all" not making much sense :)


Yes, I've been using this version for a little while now, and it's not useful 
to have the current document version. I'll remove it, which will simplify the 
code as well.

I'll wait a bit more for comments from others before uploading a new version.

Thanks!




Comment at: tools/clang-format-vs/ClangFormat/TypeConverterUtils.cs:7
+{
+public sealed class TypeConverterUtils
+{

klimek wrote:
> Perhaps name this "TypeConversion" or something - I find "utils" as part of a 
> name to not add anything, and it tends to accumulate cruft :)
Sounds great, will do that.



Comment at: tools/clang-format-vs/ClangFormat/VsixUtils.cs:13
+{
+internal sealed class VsixUtils
+{

klimek wrote:
> Same here, just call it Vsix? (context seems clear enough)
Perfect, will also make this change.


https://reviews.llvm.org/D29221



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


[PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2017-02-07 Thread Ben Harper via Phabricator via cfe-commits
bmharper updated this revision to Diff 87478.
bmharper added a comment.

small comment tweak


https://reviews.llvm.org/D21279

Files:
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9404,12 +9404,11 @@
"};",
Alignment);
 
-  // FIXME: Should align all three assignments
   verifyFormat(
   "int i  = 1;\n"
   "SomeType a = SomeFunction(looongParameterA,\n"
   "  loongParameterB);\n"
-  "int j = 2;",
+  "int j  = 2;",
   Alignment);
 
   verifyFormat("template  2) ? 3 : 4);\n"
"float b[1][] = {{3.f}};\n",
Alignment);
+  verifyFormat("for (int i = 0; i < 1; i++)\n"
+   "  int x = 1;\n",
+   Alignment);
+  verifyFormat("for (i = 0; i < 1; i++)\n"
+   "  x = 1;\n"
+   "y = 1;\n",
+   Alignment);
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
@@ -9491,7 +9497,57 @@
"unsigned oneTwoThree = 123;\n"
"int oneTwo = 12;",
Alignment));
+  // Function prototype alignment
+  verifyFormat("inta();\n"
+   "double b();",
+   Alignment);
+  verifyFormat("inta(int x);\n"
+   "double b();",
+   Alignment);
+  unsigned OldColumnLimit = Alignment.ColumnLimit;
+  // We need to set ColumnLimit to zero, in order to stress nested alignments,
+  // otherwise the function parameters will be re-flowed onto a single line.
+  Alignment.ColumnLimit = 0;
+  EXPECT_EQ("inta(int   x,\n"
+" float y);\n"
+"double b(intx,\n"
+" double y);",
+format("int a(int x,\n"
+   " float y);\n"
+   "double b(int x,\n"
+   " double y);",
+   Alignment));
+  // This ensures that function parameters of function declarations are
+  // correctly indented when their owning functions are indented.
+  // The failure case here is for 'double y' to not be indented enough.
+  EXPECT_EQ("double a(int x);\n"
+"intb(inty,\n"
+" double z);",
+format("double a(int x);\n"
+   "int b(int y,\n"
+   " double z);",
+   Alignment));
+  // Set ColumnLimit low so that we induce wrapping immediately after
+  // the function name and opening paren.
+  Alignment.ColumnLimit = 13;
+  verifyFormat("int function(\n"
+   "int  x,\n"
+   "bool y);",
+   Alignment);
+  Alignment.ColumnLimit = OldColumnLimit;
+  // Ensure function pointers don't screw up recursive alignment
+  verifyFormat("inta(int x, void (*fp)(int y));\n"
+   "double b();",
+   Alignment);
   Alignment.AlignConsecutiveAssignments = true;
+  // Ensure recursive alignment is broken by function braces, so that the
+  // "a = 1" does not align with subsequent assignments inside the function
+  // body.
+  verifyFormat("int func(int a = 1) {\n"
+   "  int b  = 2;\n"
+   "  int cc = 3;\n"
+   "}",
+   Alignment);
   verifyFormat("float  something = 2000;\n"
"double another   = 911;\n"
"inti = 1, j = 10;\n"
@@ -9501,6 +9557,28 @@
   verifyFormat("int  oneTwoThree = {0}; // comment\n"
"unsigned oneTwo  = 0;   // comment",
Alignment);
+  // Make sure that scope is correctly tracked, in the absence of braces
+  verifyFormat("for (int i = 0; i < n; i++)\n"
+   "  j = i;\n"
+   "double x = 1;\n",
+   Alignment);
+  verifyFormat("if (int i = 0)\n"
+   "  j = i;\n"
+   "double x = 1;\n",
+   Alignment);
+  // Ensure operator[] and operator() are comprehended
+  verifyFormat("struct test {\n"
+   "  long long int foo();\n"
+   "  int   operator[](int a);\n"
+   "  doublebar();\n"
+   "};\n",
+   Alignment);
+  verifyFormat("struct test {\n"
+   "  long long int foo();\n"
+   "  int   operator()(int a);\n"
+   "  doublebar();\n"
+   "};\n",
+   Alignment);
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
 "  int const i   = 1;\n"
 "  int * j   = 2;\n"
@@ -9602,17 +9680,16 @@
Alignment);
   Alignment.AlignConsecutiveAssignments = false;
 
-  // FIXME: Should align all three declarations
   verifyFormat(
   "int  i = 1;\n"
   "SomeType a = SomeFun

[PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2017-02-07 Thread Ben Harper via Phabricator via cfe-commits
bmharper added a comment.

Thanks for all the code review work! I'm impressed by the quality standard 
maintained here.


https://reviews.llvm.org/D21279



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


[libcxx] r294328 - Stop using random_shuffle in the libc++ test suite. It's going to be removed in c++17. Use shuffle() instead. No change to libc++, just the tests.

2017-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Feb  7 12:41:25 2017
New Revision: 294328

URL: http://llvm.org/viewvc/llvm-project?rev=294328&view=rev
Log:
Stop using random_shuffle in the libc++ test suite. It's going to be removed in 
c++17. Use shuffle() instead. No change to libc++, just the tests.

Modified:

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp?rev=294328&r1=294327&r2=294328&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
 Tue Feb  7 12:41:25 2017
@@ -15,14 +15,17 @@
 //   make_heap(Iter first, Iter last);
 
 #include 
+#include 
 #include 
 
+std::mt19937 randomness;
+
 void test(int N)
 {
 int* ia = new int [N];
 for (int i = 0; i < N; ++i)
 ia[i] = i;
-std::random_shuffle(ia, ia+N);
+std::shuffle(ia, ia+N, randomness);
 std::make_heap(ia, ia+N);
 assert(std::is_heap(ia, ia+N));
 delete [] ia;

Modified: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp?rev=294328&r1=294327&r2=294328&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
 Tue Feb  7 12:41:25 2017
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -29,6 +30,7 @@ struct indirect_less
 {return *x < *y;}
 };
 
+std::mt19937 randomness;
 
 void test(int N)
 {
@@ -36,7 +38,7 @@ void test(int N)
 {
 for (int i = 0; i < N; ++i)
 ia[i] = i;
-std::random_shuffle(ia, ia+N);
+std::shuffle(ia, ia+N, randomness);
 std::make_h

Re: Add warning for c++ member variable shadowing

2017-02-07 Thread James Sun via cfe-commits
Hi Richard, Saleem

I cleaned up the patch by removing some unrelated unit tests. Also Saleem can 
help me with the commit.

Thanks!

James

From: James Sun 
Date: Saturday, February 4, 2017 at 11:35 PM
To: Richard Smith 
Cc: Saleem Abdulrasool , "cfe-commits@lists.llvm.org" 
, Aaron Ballman 
Subject: Re: Add warning for c++ member variable shadowing

Thanks Richard! Hopefully this is the last patch :D
Could you please help me to commit it maybe?

Thanks

James

From:  on behalf of Richard Smith 
Date: Saturday, February 4, 2017 at 10:43 PM
To: James Sun 
Cc: Saleem Abdulrasool , "cfe-commits@lists.llvm.org" 
, Aaron Ballman 
Subject: Re: Add warning for c++ member variable shadowing

Thanks, just one more thing I noticed (sorry!) and this looks good to go.

+def warn_shadow_field : Warning<
+  "non-static data member '%0' of '%1' shadows member inherited from type 
'%2'">,
+   InGroup;

-Wshadow-ivar doesn't really make sense for this; that's for an Objective-C 
feature. A new -Wshadow-field group might make sense (especially since we 
already have -Wshadow-field-in-constructor). Also, the other -Wshadow warnings 
(other than -Wshadow-ivar) are DefaultIgnore; this one should probably be too.

Do you need someone to commit for you?

On 4 February 2017 at 22:21, James Sun 
mailto:james...@fb.com>> wrote:
oops

From: James Sun mailto:james...@fb.com>>
Date: Saturday, February 4, 2017 at 9:19 PM

To: Richard Smith mailto:rich...@metafoo.co.uk>>
Cc: Saleem Abdulrasool mailto:compn...@compnerd.org>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, Aaron Ballman 
mailto:aa...@aaronballman.com>>
Subject: Re: Add warning for c++ member variable shadowing

updated

From: James Sun mailto:james...@fb.com>>
Date: Saturday, February 4, 2017 at 6:52 PM
To: Richard Smith mailto:rich...@metafoo.co.uk>>
Cc: Saleem Abdulrasool mailto:compn...@compnerd.org>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, Aaron Ballman 
mailto:aa...@aaronballman.com>>
Subject: Re: Add warning for c++ member variable shadowing

Ok I get your point. Suppose there are two paths from class B to base class A. 
One is with access as_none; the other is as_public. Then there is a chance that 
the as_none path is recorded and the as_public one is skipped. In this case we 
should give the warning as well. Should be easy to fix with the existing map. 
Will do.

Sent from my iPhone

On Feb 4, 2017, at 6:22 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:
Hmm, now we're emitting one warning per path, it looks like we might diagnose 
shadowing the same field more than once (for a repeated non-virtual base 
class). Is that intentional? Maybe we should just skip producing the warning if 
the lookup would be ambiguous, since any use of the shadowed field would 
otherwise be ill-formed.

On 4 February 2017 at 17:48, James Sun 
mailto:james...@fb.com>> wrote:
Thanks Richard! Good catch! The updated version is attached. --James

From: mailto:meta...@gmail.com>> on behalf of Richard Smith 
mailto:rich...@metafoo.co.uk>>
Date: Thursday, February 2, 2017 at 11:59 AM
To: James Sun mailto:james...@fb.com>>
Cc: Saleem Abdulrasool mailto:compn...@compnerd.org>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, Aaron Ballman 
mailto:aa...@aaronballman.com>>
Subject: Re: Add warning for c++ member variable shadowing

Thanks, James! I think I have only one more substantive comment:

+  (Field->getAccess() == AS_public || Field->getAccess() == 
AS_protected)) {

Have you considered also taking into account the access of the inheritance 
path? Eg, a public member of a private base class of a public base class is 
typically inaccessible, even though it was declared public:

  struct A { int n; };
  struct B : private A {};
  struct C : B { int n; }; // A::n is not accessible here, should we suppress 
the warning?

You can use CXXRecordDecl::MergeAccess to combine the access of the path with 
the access of the field and compute the effective access of the field in the 
derived class (and you should test to see if the resulting access is AS_None to 
tell if the field is inaccessible; fields with effective access of AS_Private 
-- such as public members of a private direct base class -- are accessible from 
the derived class). You'll need to set RecordPaths to true in the CXXBasePaths 
object in order for lookupInBases to compute the path access.

Oh, and you may as well use a range-based for loop here:

+auto Result = Base->lookup(FieldName);
+for (auto I = Result.begin(); I != Result.end(); ++I) {


On 2 February 2017 at 00:19, James Sun 
mailto:james...@fb.com>> wrote:
Hi Richard

Thanks for the feedback! Hopefully addressed!

Thanks

James



From: mailto:meta...@gmail.com>> on behalf of Richard Smith 
mailto:rich...@metafoo.co.uk>>
Date: Wednesday, February 1, 2017 at 3:50 PM
To: James

[PATCH] D16135: Macro Debug Info support in Clang

2017-02-07 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud added a comment.

In https://reviews.llvm.org/D16135#669416, @aprantl wrote:

> In https://reviews.llvm.org/D16135#669045, @aaboud wrote:
>
> > Addressed Adrian last comments.
> >  Added a LIT tests that covers all the macro kinds:
> >
> > 1. built-in (define)
> > 2. command-line (define, include, undef)
> > 3. main source (define, include, undef) Checked the above with and without 
> > PCH include.
> >
> >   Notice, that current implementation does not support debug info for macro 
> > definition and inclusion generated during the PCH file creation. To support 
> > that, we need to extend the PCH format to preserve this information. If you 
> > believe this feature is important, I will open a bugzilla ticket and we can 
> > handle it separately.
>
>
> That would be a good idea and important to fix. I don't think we want the the 
> generated code (or the debug info for that matter) to change just because the 
> user decides to switch to PCH. Ideally turning on PCH should be transparent.
>
> I have one final question: What's the impact of this change on, e.g., 
> building clang?
>
> - How much does the build directory grow?
> - Is there any noticeable compile time regression?


I will run self-build and come back with answers for these questions.
I am just wondering, if I build in debug mode, will it use the flag 
"-fstandalone-debug"?
This flag is set by default only for DarwinClang and FreeBSD, is there a way to 
assure it will be used with self-build?
Notice that without this flag, there will be no debug info macro generated.


https://reviews.llvm.org/D16135



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


[PATCH] D29506: [OpenMP] Teams reduction on the NVPTX device.

2017-02-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

The patch is too big and quite hard to review? Could you split it into several 
smaller parts?




Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4280-4282
+  // We don't need debug information in this function as nothing here refers to
+  // user source code.
+  CGF.disableDebugInfo();

It is not quite so, at least we have a reference in a list of reductions in 
`reduction` clause, which may be considered a debug position



Comment at: lib/CodeGen/CGOpenMPRuntime.h:524
+
+  static bool classof(const CGOpenMPRuntime *RT) {
+return RT->getKind() == RK_HOST;

arpith-jacob wrote:
> This is required to cast to the NVPTX runtime in a static function as follows;
> 
> CGOpenMPRuntimeNVPTX &RT = cast(CGM.getOpenMPRuntime());
Are you going to make calls to `isa()`, `dyn_cast()` functions? If not, just 
use `static_cast<>()` instead.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:972-973
+  auto CastTy = Size <= 4 ? CGM.Int32Ty : CGM.Int64Ty;
+  auto *ElemCast = Bld.CreateSExtOrBitCast(Elem, CastTy);
+  auto *WarpSize = Bld.CreateTruncOrBitCast(getNVPTXWarpSize(CGF), 
CGM.Int16Ty);
+

I'd prefer you to use `CGF.EmitScalarConversion()` rather than Builder casts.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:975-978
+  llvm::SmallVector Args;
+  Args.push_back(ElemCast);
+  Args.push_back(Offset);
+  Args.push_back(WarpSize);

Do you really need a SmallVector<> or you can use just an array here?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1140-1141
+if (ShuffleInElement)
+  Elem = createRuntimeShuffleFunction(CGF, Private->getType(), Elem,
+  RemoteLaneOffset);
+

Enclose in braces



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1153-1156
+  CGF.EmitStoreOfScalar(Bld.CreatePointerBitCastOrAddrSpaceCast(
+DestElementAddr.getPointer(), CGF.VoidPtrTy),
+DestElementPtrAddr, /*Volatile=*/false,
+C.VoidPtrTy);

Braces



Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2249
+ ? OMPD_parallel_for_simd
+ : OMPD_parallel);
   // Emit post-update of the reduction variables if IsLastIter != 0.

OMPD_parallel or OMPD_parallel_for?



Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2424
 CGF.OMPCancelStack.emitExit(CGF, S.getDirectiveKind(), CodeGen);
-CGF.EmitOMPReductionClauseFinal(S);
+CGF.EmitOMPReductionClauseFinal(S, OMPD_parallel);
 // Emit post-update of the reduction variables if IsLastIter != 0.

OMPD_parallel_for?


https://reviews.llvm.org/D29506



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


r294332 - Revert "Basic: match GCC behaviour for SuS macro"

2017-02-07 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Feb  7 13:00:06 2017
New Revision: 294332

URL: http://llvm.org/viewvc/llvm-project?rev=294332&view=rev
Log:
Revert "Basic: match GCC behaviour for SuS macro"

This reverts commit SVN r294148.  Seems that it was mistaken, and GCC
does still define `__unix` and `unix` when in GNU mode.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/mipsel-nacl-defines.cpp
cfe/trunk/test/Driver/x86_64-nacl-defines.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294332&r1=294331&r2=294332&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb  7 13:00:06 2017
@@ -303,10 +303,10 @@ protected:
 // DragonFly defines; list based off of gcc output
 Builder.defineMacro("__DragonFly__");
 Builder.defineMacro("__DragonFly_cc_version", "11");
-Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
 Builder.defineMacro("__tune_i386__");
+DefineStd(Builder, "unix", Opts);
   }
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
@@ -343,7 +343,7 @@ protected:
 Builder.defineMacro("__FreeBSD__", Twine(Release));
 Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
-Builder.defineMacro("__unix__");
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");
 
 // On FreeBSD, wchar_t contains the number of the code point as
@@ -388,9 +388,9 @@ protected:
 MacroBuilder &Builder) const override {
 // GNU/kFreeBSD defines; list based off of gcc output
 
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__FreeBSD_kernel__");
 Builder.defineMacro("__GLIBC__");
-Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
@@ -410,8 +410,8 @@ protected:
 MacroBuilder &Builder) const override {
 // Haiku defines; list based off of gcc output
 Builder.defineMacro("__HAIKU__");
-Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
+DefineStd(Builder, "unix", Opts);
   }
 public:
   HaikuTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
@@ -440,8 +440,8 @@ protected:
 Builder.defineMacro("_EM_LSIZE", "4");
 Builder.defineMacro("_EM_FSIZE", "4");
 Builder.defineMacro("_EM_DSIZE", "8");
-Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
+DefineStd(Builder, "unix", Opts);
   }
 public:
   MinixTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
@@ -455,7 +455,7 @@ protected:
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
 MacroBuilder &Builder) const override {
 // Linux defines; list based off of gcc output
-Builder.defineMacro("__unix__");
+DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
 Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
@@ -541,7 +541,7 @@ protected:
 // OpenBSD defines; list based off of gcc output
 
 Builder.defineMacro("__OpenBSD__");
-Builder.defineMacro("__unix__");
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
@@ -578,7 +578,7 @@ protected:
 // Bitrig defines; list based off of gcc output
 
 Builder.defineMacro("__Bitrig__");
-Builder.defineMacro("__unix__");
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
@@ -652,7 +652,7 @@ protected:
 Builder.defineMacro("__FreeBSD__", "9");
 Builder.defineMacro("__FreeBSD_cc_version", "91");
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
-Builder.defineMacro("__unix__");
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__ORBIS__");
   }
@@ -683,8 +683,8 @@ class SolarisTargetInfo : public OSTarge
 protected:
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
 MacroBuilder &Builder) const override {
-Builder.defineMacro("__unix__");
 DefineStd(Builder, "sun", Opts);
+DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__svr4__");
 Builder.defineMacro("__SVR4");
@@ -786,7 +786,7 @@ protected:
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
 
-Builder.defineMacro("__unix__");
+DefineStd(Builder, "unix", Opts)

Re: [PATCH] D16135: Macro Debug Info support in Clang

2017-02-07 Thread David Blaikie via cfe-commits
On Tue, Feb 7, 2017 at 11:01 AM Amjad Aboud via Phabricator <
revi...@reviews.llvm.org> wrote:

> aaboud added a comment.
>
> In https://reviews.llvm.org/D16135#669416, @aprantl wrote:
>
> > In https://reviews.llvm.org/D16135#669045, @aaboud wrote:
> >
> > > Addressed Adrian last comments.
> > >  Added a LIT tests that covers all the macro kinds:
> > >
> > > 1. built-in (define)
> > > 2. command-line (define, include, undef)
> > > 3. main source (define, include, undef) Checked the above with and
> without PCH include.
> > >
> > >   Notice, that current implementation does not support debug info for
> macro definition and inclusion generated during the PCH file creation. To
> support that, we need to extend the PCH format to preserve this
> information. If you believe this feature is important, I will open a
> bugzilla ticket and we can handle it separately.
> >
> >
> > That would be a good idea and important to fix. I don't think we want
> the the generated code (or the debug info for that matter) to change just
> because the user decides to switch to PCH. Ideally turning on PCH should be
> transparent.
> >
> > I have one final question: What's the impact of this change on, e.g.,
> building clang?
> >
> > - How much does the build directory grow?
> > - Is there any noticeable compile time regression?
>
>
> I will run self-build and come back with answers for these questions.
> I am just wondering, if I build in debug mode, will it use the flag
> "-fstandalone-debug"?
>

I'm not sure it makes sense to motivate this feature with this flag. I'm
going to assume Darwin and FreeBSD don't want to implicitly pick up this
feature because of the default on their platforms which is really to
address a particular limitation in LLDB due to some other debug info.

So this probably needs a separate flag.


> This flag is set by default only for DarwinClang and FreeBSD, is there a
> way to assure it will be used with self-build?
>

You can add flags to your build by modifying your CMakeCache.txt file and
putting them int he CMAKE_CXX_FLAGS/CMAKE_C_FLAGS values (or the specific
ones for teh build mode you'd like them to go with, like the DEBUG build,
most likely)


> Notice that without this flag, there will be no debug info macro generated.
>
>
> https://reviews.llvm.org/D16135
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28973: Supresses misc-move-constructor-init warning for const fields.

2017-02-07 Thread CJ DiMeglio via Phabricator via cfe-commits
lethalantidote updated this revision to Diff 87484.
lethalantidote marked an inline comment as done.
lethalantidote added a comment.

- Addresses alexfh's comments.


https://reviews.llvm.org/D28973

Files:
  clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp


Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
+++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
@@ -84,6 +84,16 @@
   N(N &&RHS) : Mem(move(RHS.Mem)) {}
 };
 
+struct O {
+  O(O&& other) : b(other.b) {} // ok
+  const B b;
+};
+
+struct P {
+  P(O&& other) : b(other.b) {} // ok
+  B b;
+};
+
 struct Movable {
   Movable(Movable &&) = default;
   Movable(const Movable &) = default;
Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -57,6 +57,9 @@
   if (QT.isTriviallyCopyableType(*Result.Context))
 return;
 
+  if (QT.isConstQualified())
+return;
+
   const auto *RD = QT->getAsCXXRecordDecl();
   if (RD && RD->isTriviallyCopyable())
 return;


Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
+++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
@@ -84,6 +84,16 @@
   N(N &&RHS) : Mem(move(RHS.Mem)) {}
 };
 
+struct O {
+  O(O&& other) : b(other.b) {} // ok
+  const B b;
+};
+
+struct P {
+  P(O&& other) : b(other.b) {} // ok
+  B b;
+};
+
 struct Movable {
   Movable(Movable &&) = default;
   Movable(const Movable &) = default;
Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -57,6 +57,9 @@
   if (QT.isTriviallyCopyableType(*Result.Context))
 return;
 
+  if (QT.isConstQualified())
+return;
+
   const auto *RD = QT->getAsCXXRecordDecl();
   if (RD && RD->isTriviallyCopyable())
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-02-07 Thread Stanisław Barzowski via Phabricator via cfe-commits
sbarzowski added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:54
+// FIXME use DiagnosticIDs::Level::Note
+diag(NoExceptRange.getBegin(), "in a function declared no-throw here:", 
DiagnosticIDs::Note)
+<< FixItHint::CreateRemoval(NoExceptRange);

alexfh wrote:
> nit: `nothrow` (without a dash), no colon needed (it will look weird, since 
> the location is mentioned _before_ the message, not after it)
No, it's after the message now. When I changed the level to note the order of 
messages changed as well.

It looks like that:
```
/Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:5:5:
 warning: 'throw' expression in a function declared with a non-throwing 
exception specification [misc-throw-with-noexcept]
throw 5;
^
/Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
 note: FIX-IT applied suggested code changes
void f_throw_with_ne() noexcept(true) {
   ^
/Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
 note: in a function declared nothrow here:
void f_throw_with_ne() noexcept(true) {
   ^

```

So, should I leave the colon or remove it anyway?


https://reviews.llvm.org/D19201



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2017-02-07 Thread Nikita Kakuev via Phabricator via cfe-commits
nkakuev added a comment.

Thanks for the response, Alex!

The problem I tried to address in this patch was that notes in source files 
were "unsuppressing" warnings from third-party headers (this is what we were 
discussing in https://reviews.llvm.org/D26418#590417).  But at this point, I no 
longer think that my patch is the right way to handle this situation. A 
general-purpose suppression list looks like a way better idea to me.

As for delegating the suppression of warnings to an external tool, I'm not 
entirely sure that this is always a good idea. I run clang-tidy on incremental 
builds on developers machines and use //-warnings-as-errors=*//. In other 
words, I treat clang-tidy warnings the same way I treat compiler warnings (with 
//-Werror// enabled). A suppression list will let me keep this workflow while 
using an external tool is likely to break it.

So what do you think about extending existing suppression mechanisms to support 
suppression lists?


https://reviews.llvm.org/D26418



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


[PATCH] D29676: Enable -dump-deserialized-decls and -error-on-deserialized-decl for modules

2017-02-07 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.

Enable the useful -dump-deserialized-decls and -error-on-deserialized-decl 
 flags for modules builds, too.


Repository:
  rL LLVM

https://reviews.llvm.org/D29676

Files:
  lib/Frontend/FrontendAction.cpp


Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -352,8 +352,9 @@
 goto failure;
   CI.setModuleManager(static_cast(FinalReader.get()));
   CI.getASTContext().setExternalSource(source);
-} else if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
-  // Use PCH.
+} else if (CI.getLangOpts().Modules ||
+   !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+  // Use PCM or PCH.
   assert(hasPCHSupport() && "This action does not have PCH support!");
   ASTDeserializationListener *DeserialListener =
   Consumer->GetASTDeserializationListener();
@@ -370,13 +371,24 @@
 DeserialListener, DeleteDeserialListener);
 DeleteDeserialListener = true;
   }
-  CI.createPCHExternalASTSource(
-  CI.getPreprocessorOpts().ImplicitPCHInclude,
-  CI.getPreprocessorOpts().DisablePCHValidation,
+  if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+CI.createPCHExternalASTSource(
+CI.getPreprocessorOpts().ImplicitPCHInclude,
+CI.getPreprocessorOpts().DisablePCHValidation,
   CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, 
DeserialListener,
-  DeleteDeserialListener);
-  if (!CI.getASTContext().getExternalSource())
-goto failure;
+DeleteDeserialListener);
+if (!CI.getASTContext().getExternalSource())
+  goto failure;
+  }
+  // If modules are enabled, create the module manager before creating
+  // any builtins, so that all declarations know that they might be
+  // extended by an external source.
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalSource()) {
+CI.createModuleManager();
+CI.getModuleManager()->setDeserializationListener(DeserialListener,
+
DeleteDeserialListener);
+  }
 }
 
 CI.setASTConsumer(std::move(Consumer));
@@ -386,15 +398,9 @@
 
   // Initialize built-in info as long as we aren't using an external AST
   // source.
-  if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource()) {
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalSource()) {
 Preprocessor &PP = CI.getPreprocessor();
-
-// If modules are enabled, create the module manager before creating
-// any builtins, so that all declarations know that they might be
-// extended by an external source.
-if (CI.getLangOpts().Modules)
-  CI.createModuleManager();
-
 PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(),
PP.getLangOpts());
   } else {


Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -352,8 +352,9 @@
 goto failure;
   CI.setModuleManager(static_cast(FinalReader.get()));
   CI.getASTContext().setExternalSource(source);
-} else if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
-  // Use PCH.
+} else if (CI.getLangOpts().Modules ||
+   !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+  // Use PCM or PCH.
   assert(hasPCHSupport() && "This action does not have PCH support!");
   ASTDeserializationListener *DeserialListener =
   Consumer->GetASTDeserializationListener();
@@ -370,13 +371,24 @@
 DeserialListener, DeleteDeserialListener);
 DeleteDeserialListener = true;
   }
-  CI.createPCHExternalASTSource(
-  CI.getPreprocessorOpts().ImplicitPCHInclude,
-  CI.getPreprocessorOpts().DisablePCHValidation,
+  if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+CI.createPCHExternalASTSource(
+CI.getPreprocessorOpts().ImplicitPCHInclude,
+CI.getPreprocessorOpts().DisablePCHValidation,
   CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, DeserialListener,
-  DeleteDeserialListener);
-  if (!CI.getASTContext().getExternalSource())
-goto failure;
+DeleteDeserialListener);
+if (!CI.getASTContext().getExternalSource())
+  goto failure;
+  }
+  // If modules are enabled, create the module manager before creating
+  // any builtins, so that all declarations know that they might be
+  // extended by an external source.
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalS

Re: Add warning for c++ member variable shadowing

2017-02-07 Thread Richard Smith via cfe-commits
Great, thanks!

On 7 February 2017 at 10:54, James Sun  wrote:

> Hi Richard, Saleem
>
>
>
> I cleaned up the patch by removing some unrelated unit tests. Also Saleem
> can help me with the commit.
>
>
>
> Thanks!
>
>
>
> James
>
>
>
> *From: *James Sun 
> *Date: *Saturday, February 4, 2017 at 11:35 PM
>
> *To: *Richard Smith 
> *Cc: *Saleem Abdulrasool , "
> cfe-commits@lists.llvm.org" , Aaron Ballman <
> aa...@aaronballman.com>
> *Subject: *Re: Add warning for c++ member variable shadowing
>
>
>
> Thanks Richard! Hopefully this is the last patch :D
>
> Could you please help me to commit it maybe?
>
>
>
> Thanks
>
>
>
> James
>
>
>
> *From: * on behalf of Richard Smith <
> rich...@metafoo.co.uk>
> *Date: *Saturday, February 4, 2017 at 10:43 PM
> *To: *James Sun 
> *Cc: *Saleem Abdulrasool , "
> cfe-commits@lists.llvm.org" , Aaron Ballman <
> aa...@aaronballman.com>
> *Subject: *Re: Add warning for c++ member variable shadowing
>
>
>
> Thanks, just one more thing I noticed (sorry!) and this looks good to go.
>
>
>
> +def warn_shadow_field : Warning<
>
> +  "non-static data member '%0' of '%1' shadows member inherited from type
> '%2'">,
>
> +   InGroup;
>
>
>
> -Wshadow-ivar doesn't really make sense for this; that's for an
> Objective-C feature. A new -Wshadow-field group might make sense
> (especially since we already have -Wshadow-field-in-constructor). Also,
> the other -Wshadow warnings (other than -Wshadow-ivar) are DefaultIgnore;
> this one should probably be too.
>
>
>
> Do you need someone to commit for you?
>
>
>
> On 4 February 2017 at 22:21, James Sun  wrote:
>
> oops
>
>
>
> *From: *James Sun 
> *Date: *Saturday, February 4, 2017 at 9:19 PM
>
>
> *To: *Richard Smith 
> *Cc: *Saleem Abdulrasool , "
> cfe-commits@lists.llvm.org" , Aaron Ballman <
> aa...@aaronballman.com>
> *Subject: *Re: Add warning for c++ member variable shadowing
>
>
>
> updated
>
>
>
> *From: *James Sun 
> *Date: *Saturday, February 4, 2017 at 6:52 PM
> *To: *Richard Smith 
> *Cc: *Saleem Abdulrasool , "
> cfe-commits@lists.llvm.org" , Aaron Ballman <
> aa...@aaronballman.com>
> *Subject: *Re: Add warning for c++ member variable shadowing
>
>
>
> Ok I get your point. Suppose there are two paths from class B to base
> class A. One is with access as_none; the other is as_public. Then there is
> a chance that the as_none path is recorded and the as_public one is
> skipped. In this case we should give the warning as well. Should be easy to
> fix with the existing map. Will do.
>
> Sent from my iPhone
>
>
> On Feb 4, 2017, at 6:22 PM, Richard Smith  wrote:
>
> Hmm, now we're emitting one warning per path, it looks like we might
> diagnose shadowing the same field more than once (for a repeated
> non-virtual base class). Is that intentional? Maybe we should just skip
> producing the warning if the lookup would be ambiguous, since any use of
> the shadowed field would otherwise be ill-formed.
>
>
>
> On 4 February 2017 at 17:48, James Sun  wrote:
>
> Thanks Richard! Good catch! The updated version is attached. --James
>
>
>
> *From: * on behalf of Richard Smith <
> rich...@metafoo.co.uk>
> *Date: *Thursday, February 2, 2017 at 11:59 AM
>
> *To: *James Sun 
> *Cc: *Saleem Abdulrasool , "
> cfe-commits@lists.llvm.org" , Aaron Ballman <
> aa...@aaronballman.com>
> *Subject: *Re: Add warning for c++ member variable shadowing
>
>
>
> Thanks, James! I think I have only one more substantive comment:
>
>
>
> +  (Field->getAccess() == AS_public || Field->getAccess() ==
> AS_protected)) {
>
>
>
> Have you considered also taking into account the access of the inheritance
> path? Eg, a public member of a private base class of a public base class is
> typically inaccessible, even though it was declared public:
>
>
>
>   struct A { int n; };
>
>   struct B : private A {};
>
>   struct C : B { int n; }; // A::n is not accessible here, should we
> suppress the warning?
>
>
>
> You can use CXXRecordDecl::MergeAccess to combine the access of the path
> with the access of the field and compute the effective access of the field
> in the derived class (and you should test to see if the resulting access is
> AS_None to tell if the field is inaccessible; fields with effective access
> of AS_Private -- such as public members of a private direct base class --
> are accessible from the derived class). You'll need to set RecordPaths to
> true in the CXXBasePaths object in order for lookupInBases to compute the
> path access.
>
>
>
> Oh, and you may as well use a range-based for loop here:
>
>
>
> +auto Result = Base->lookup(FieldName);
>
> +for (auto I = Result.begin(); I != Result.end(); ++I) {
>
>
>
>
>
> On 2 February 2017 at 00:19, James Sun  wrote:
>
> Hi Richard
>
>
>
> Thanks for the feedback! Hopefully addressed!
>
>
>
> Thanks
>
>
>
> James
>
>
>
>
>
>
>
> *From: * on behalf of Richard Smith <
> rich...@metafoo.co.uk>
> *Date: *Wednesday, February 1, 2017 at 3:50 PM
> *To: *James Sun 
>
>
> *Cc: *Saleem Abdulrasool , "
> cfe-commits

Re: Add warning for c++ member variable shadowing

2017-02-07 Thread Jonathan Roelofs via cfe-commits



On 1/24/17 8:10 PM, Saleem Abdulrasool via cfe-commits wrote:

Don't use the cast for the check, use isa.  Although, since you use the
value later, it is probably better to write this as:

if (const auto *RD = cast(CurContext))
  CheckShadowInheritedVariabless(Loc, Name.getAsString(), RD, RD);



@compnerd: s/cast/dyn_cast/ or s/cast/dyn_cast_or_null/, right?


Jon


--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-02-07 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:54
+// FIXME use DiagnosticIDs::Level::Note
+diag(NoExceptRange.getBegin(), "in a function declared no-throw here:", 
DiagnosticIDs::Note)
+<< FixItHint::CreateRemoval(NoExceptRange);

sbarzowski wrote:
> alexfh wrote:
> > nit: `nothrow` (without a dash), no colon needed (it will look weird, since 
> > the location is mentioned _before_ the message, not after it)
> No, it's after the message now. When I changed the level to note the order of 
> messages changed as well.
> 
> It looks like that:
> ```
> /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:5:5:
>  warning: 'throw' expression in a function declared with a non-throwing 
> exception specification [misc-throw-with-noexcept]
> throw 5;
> ^
> /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
>  note: FIX-IT applied suggested code changes
> void f_throw_with_ne() noexcept(true) {
>^
> /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
>  note: in a function declared nothrow here:
> void f_throw_with_ne() noexcept(true) {
>^
> 
> ```
> 
> So, should I leave the colon or remove it anyway?
I think that the best way would be to have warnings in order:

warning function declared nothrow here have throw statement inside:
Note: throw statement here

Note: Fixit applied for every other declaration

What do you think Alex?





https://reviews.llvm.org/D19201



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


[libcxx] r294350 - Use copy.deepcopy instead of doing it manually.

2017-02-07 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Feb  7 15:04:19 2017
New Revision: 294350

URL: http://llvm.org/viewvc/llvm-project?rev=294350&view=rev
Log:
Use copy.deepcopy instead of doing it manually.

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/test/libcxx/compiler.py
libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=294350&r1=294349&r2=294350&view=diff
==
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Tue Feb  7 15:04:19 2017
@@ -49,18 +49,6 @@ class CXXCompiler(object):
 if self.type is None or self.version is None:
 self._initTypeAndVersion()
 
-def copy(self):
-new_cxx = CXXCompiler(
-self.path, flags=self.flags, compile_flags=self.compile_flags,
-link_flags=self.link_flags, warning_flags=self.warning_flags,
-verify_supported=self.verify_supported,
-verify_flags=self.verify_flags, use_verify=self.use_verify,
-modules_flags=self.modules_flags, use_modules=self.use_modules,
-use_ccache=self.use_ccache, use_warnings=self.use_warnings,
-compile_env=self.compile_env, cxx_type=self.type,
-cxx_version=self.version)
-return new_cxx
-
 def isVerifySupported(self):
 if self.verify_supported is None:
 self.verify_supported = self.hasCompileFlag(['-Xclang',

Modified: libcxx/trunk/test/libcxx/test/format.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=294350&r1=294349&r2=294350&view=diff
==
--- libcxx/trunk/test/libcxx/test/format.py (original)
+++ libcxx/trunk/test/libcxx/test/format.py Tue Feb  7 15:04:19 2017
@@ -7,6 +7,7 @@
 #
 #===--===##
 
+import copy
 import errno
 import os
 import time
@@ -36,7 +37,7 @@ class LibcxxTestFormat(object):
 
 def __init__(self, cxx, use_verify_for_fail, execute_external,
  executor, exec_env):
-self.cxx = cxx.copy()
+self.cxx = copy.deepcopy(cxx)
 self.use_verify_for_fail = use_verify_for_fail
 self.execute_external = execute_external
 self.executor = executor
@@ -115,7 +116,7 @@ class LibcxxTestFormat(object):
tmpBase)
 script = lit.TestRunner.applySubstitutions(script, substitutions)
 
-test_cxx = self.cxx.copy()
+test_cxx = copy.deepcopy(self.cxx)
 if is_fail_test:
 test_cxx.useCCache(False)
 test_cxx.useWarnings(False)


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


[PATCH] D29209: Use copy.deepcopy instead of doing it manually.

2017-02-07 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294350: Use copy.deepcopy instead of doing it manually. 
(authored by danalbert).

Changed prior to commit:
  https://reviews.llvm.org/D29209?vs=85999&id=87507#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29209

Files:
  libcxx/trunk/test/libcxx/compiler.py
  libcxx/trunk/test/libcxx/test/format.py


Index: libcxx/trunk/test/libcxx/test/format.py
===
--- libcxx/trunk/test/libcxx/test/format.py
+++ libcxx/trunk/test/libcxx/test/format.py
@@ -7,6 +7,7 @@
 #
 #===--===##
 
+import copy
 import errno
 import os
 import time
@@ -36,7 +37,7 @@
 
 def __init__(self, cxx, use_verify_for_fail, execute_external,
  executor, exec_env):
-self.cxx = cxx.copy()
+self.cxx = copy.deepcopy(cxx)
 self.use_verify_for_fail = use_verify_for_fail
 self.execute_external = execute_external
 self.executor = executor
@@ -115,7 +116,7 @@
tmpBase)
 script = lit.TestRunner.applySubstitutions(script, substitutions)
 
-test_cxx = self.cxx.copy()
+test_cxx = copy.deepcopy(self.cxx)
 if is_fail_test:
 test_cxx.useCCache(False)
 test_cxx.useWarnings(False)
Index: libcxx/trunk/test/libcxx/compiler.py
===
--- libcxx/trunk/test/libcxx/compiler.py
+++ libcxx/trunk/test/libcxx/compiler.py
@@ -49,18 +49,6 @@
 if self.type is None or self.version is None:
 self._initTypeAndVersion()
 
-def copy(self):
-new_cxx = CXXCompiler(
-self.path, flags=self.flags, compile_flags=self.compile_flags,
-link_flags=self.link_flags, warning_flags=self.warning_flags,
-verify_supported=self.verify_supported,
-verify_flags=self.verify_flags, use_verify=self.use_verify,
-modules_flags=self.modules_flags, use_modules=self.use_modules,
-use_ccache=self.use_ccache, use_warnings=self.use_warnings,
-compile_env=self.compile_env, cxx_type=self.type,
-cxx_version=self.version)
-return new_cxx
-
 def isVerifySupported(self):
 if self.verify_supported is None:
 self.verify_supported = self.hasCompileFlag(['-Xclang',


Index: libcxx/trunk/test/libcxx/test/format.py
===
--- libcxx/trunk/test/libcxx/test/format.py
+++ libcxx/trunk/test/libcxx/test/format.py
@@ -7,6 +7,7 @@
 #
 #===--===##
 
+import copy
 import errno
 import os
 import time
@@ -36,7 +37,7 @@
 
 def __init__(self, cxx, use_verify_for_fail, execute_external,
  executor, exec_env):
-self.cxx = cxx.copy()
+self.cxx = copy.deepcopy(cxx)
 self.use_verify_for_fail = use_verify_for_fail
 self.execute_external = execute_external
 self.executor = executor
@@ -115,7 +116,7 @@
tmpBase)
 script = lit.TestRunner.applySubstitutions(script, substitutions)
 
-test_cxx = self.cxx.copy()
+test_cxx = copy.deepcopy(self.cxx)
 if is_fail_test:
 test_cxx.useCCache(False)
 test_cxx.useWarnings(False)
Index: libcxx/trunk/test/libcxx/compiler.py
===
--- libcxx/trunk/test/libcxx/compiler.py
+++ libcxx/trunk/test/libcxx/compiler.py
@@ -49,18 +49,6 @@
 if self.type is None or self.version is None:
 self._initTypeAndVersion()
 
-def copy(self):
-new_cxx = CXXCompiler(
-self.path, flags=self.flags, compile_flags=self.compile_flags,
-link_flags=self.link_flags, warning_flags=self.warning_flags,
-verify_supported=self.verify_supported,
-verify_flags=self.verify_flags, use_verify=self.use_verify,
-modules_flags=self.modules_flags, use_modules=self.use_modules,
-use_ccache=self.use_ccache, use_warnings=self.use_warnings,
-compile_env=self.compile_env, cxx_type=self.type,
-cxx_version=self.version)
-return new_cxx
-
 def isVerifySupported(self):
 if self.verify_supported is None:
 self.verify_supported = self.hasCompileFlag(['-Xclang',
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-02-07 Thread Stanisław Barzowski via Phabricator via cfe-commits
sbarzowski added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:54
+// FIXME use DiagnosticIDs::Level::Note
+diag(NoExceptRange.getBegin(), "in a function declared no-throw here:", 
DiagnosticIDs::Note)
+<< FixItHint::CreateRemoval(NoExceptRange);

Prazek wrote:
> sbarzowski wrote:
> > alexfh wrote:
> > > nit: `nothrow` (without a dash), no colon needed (it will look weird, 
> > > since the location is mentioned _before_ the message, not after it)
> > No, it's after the message now. When I changed the level to note the order 
> > of messages changed as well.
> > 
> > It looks like that:
> > ```
> > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:5:5:
> >  warning: 'throw' expression in a function declared with a non-throwing 
> > exception specification [misc-throw-with-noexcept]
> > throw 5;
> > ^
> > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
> >  note: FIX-IT applied suggested code changes
> > void f_throw_with_ne() noexcept(true) {
> >^
> > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
> >  note: in a function declared nothrow here:
> > void f_throw_with_ne() noexcept(true) {
> >^
> > 
> > ```
> > 
> > So, should I leave the colon or remove it anyway?
> I think that the best way would be to have warnings in order:
> 
> warning function declared nothrow here have throw statement inside:
> Note: throw statement here
> 
> Note: Fixit applied for every other declaration
> 
> What do you think Alex?
> 
> 
> 
@Prazek 
So, do you suggest that we don't emit anything for additional declarations 
(without -fix)?

BTW (in the current version) I don't know if I can control if FIX-IT goes first 
or the location message. As you can see in the code the FIX-IT goes after the 
location.


https://reviews.llvm.org/D19201



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


[libcxx] r294353 - Fix test failures when using modules.

2017-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb  7 15:20:31 2017
New Revision: 294353

URL: http://llvm.org/viewvc/llvm-project?rev=294353&view=rev
Log:
Fix test failures when using modules.

Modified:

libcxx/trunk/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp

libcxx/trunk/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp
libcxx/trunk/test/libcxx/debug/containers/db_string.pass.cpp
libcxx/trunk/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp
libcxx/trunk/test/libcxx/debug/debug_abort.pass.cpp
libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp
libcxx/trunk/test/libcxx/debug/debug_throw_register.pass.cpp
libcxx/trunk/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp?rev=294353&r1=294352&r2=294353&view=diff
==
--- 
libcxx/trunk/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp
 Tue Feb  7 15:20:31 2017
@@ -9,11 +9,14 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
+// MODULES_DEFINES: _LIBCPP_DEBUG=1
+// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
 
 // test container debugging
 
 #define _LIBCPP_DEBUG 1
 #define _LIBCPP_DEBUG_USE_EXCEPTIONS
+
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp?rev=294353&r1=294352&r2=294353&view=diff
==
--- 
libcxx/trunk/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp
 Tue Feb  7 15:20:31 2017
@@ -9,6 +9,8 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
+// MODULES_DEFINES: _LIBCPP_DEBUG=1
+// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
 
 // test container debugging
 

Modified: libcxx/trunk/test/libcxx/debug/containers/db_string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/containers/db_string.pass.cpp?rev=294353&r1=294352&r2=294353&view=diff
==
--- libcxx/trunk/test/libcxx/debug/containers/db_string.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/debug/containers/db_string.pass.cpp Tue Feb  7 
15:20:31 2017
@@ -9,6 +9,8 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
+// MODULES_DEFINES: _LIBCPP_DEBUG=1
+// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
 
 // test container debugging
 

Modified: 
libcxx/trunk/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp?rev=294353&r1=294352&r2=294353&view=diff
==
--- libcxx/trunk/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp 
Tue Feb  7 15:20:31 2017
@@ -9,6 +9,8 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
+// MODULES_DEFINES: _LIBCPP_DEBUG=1
+// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
 
 // test container debugging
 

Modified: libcxx/trunk/test/libcxx/debug/debug_abort.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/debug_abort.pass.cpp?rev=294353&r1=294352&r2=294353&view=diff
==
--- libcxx/trunk/test/libcxx/debug/debug_abort.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/debug/debug_abort.pass.cpp Tue Feb  7 15:20:31 2017
@@ -7,6 +7,9 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
+
+// MODULES_DEFINES: _LIBCPP_DEBUG=0
+
 // Test that the default debug handler aborts the program.
 
 #define _LIBCPP_DEBUG 0

Modified: libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp?rev=294353&r1=294352&r2=294353&view=diff
==
--- libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp (original)
+++ libcxx/trunk/test/

[libcxx] r294355 - fix python3 syntax error

2017-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb  7 15:21:17 2017
New Revision: 294355

URL: http://llvm.org/viewvc/llvm-project?rev=294355&view=rev
Log:
fix python3 syntax error

Modified:
libcxx/trunk/test/support/filesystem_dynamic_test_helper.py

Modified: libcxx/trunk/test/support/filesystem_dynamic_test_helper.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_dynamic_test_helper.py?rev=294355&r1=294354&r2=294355&view=diff
==
--- libcxx/trunk/test/support/filesystem_dynamic_test_helper.py (original)
+++ libcxx/trunk/test/support/filesystem_dynamic_test_helper.py Tue Feb  7 
15:21:17 2017
@@ -75,7 +75,7 @@ def create_fifo(source):
 
 
 def create_socket(source):
-mode = 0600|stat.S_IFSOCK
+mode = 0o600 | stat.S_IFSOCK
 os.mknod(sanitize(source), mode)
 
 


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


[PATCH] D29628: [compiler-rt] [test] Enable the strace_test only if strace is installed

2017-02-07 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc accepted this revision.
kcc added a comment.
This revision is now accepted and ready to land.

LGTM, 
but please manually verify that the test runs if strace *is* available.


Repository:
  rL LLVM

https://reviews.llvm.org/D29628



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


r294358 - clang-format: Fix bad variable declaration detection.

2017-02-07 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Feb  7 15:38:16 2017
New Revision: 294358

URL: http://llvm.org/viewvc/llvm-project?rev=294358&view=rev
Log:
clang-format: Fix bad variable declaration detection.

Before:
  LongType
  variable(nullptr, [](A *a) {});

After:
  LongType
  variable(nullptr, [](A *a) {});

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=294358&r1=294357&r2=294358&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Feb  7 15:38:16 2017
@@ -1707,7 +1707,7 @@ static bool isFunctionDeclarationName(co
 }
   }
 
-  // Check whether parameter list can be long to a function declaration.
+  // Check whether parameter list can belong to a function declaration.
   if (!Next || !Next->is(tok::l_paren) || !Next->MatchingParen)
 return false;
   // If the lines ends with "{", this is likely an function definition.
@@ -1721,6 +1721,10 @@ static bool isFunctionDeclarationName(co
 return true;
   for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
Tok = Tok->Next) {
+if (Tok->is(tok::l_paren) && Tok->MatchingParen) {
+  Tok = Tok->MatchingParen;
+  continue;
+}
 if (Tok->is(tok::kw_const) || Tok->isSimpleTypeSpecifier() ||
 Tok->isOneOf(TT_PointerOrReference, TT_StartOfName, tok::ellipsis))
   return true;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=294358&r1=294357&r2=294358&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Feb  7 15:38:16 2017
@@ -6934,6 +6934,11 @@ TEST_F(FormatTest, BreaksLongVariableDec
"LngVariable({});");
   verifyFormat("LngType\n"
"LoongVariable([A 
a]);");
+
+  // Lambdas should not confuse the variable declaration heuristic.
+  verifyFormat("LongType\n"
+   "variable(nullptr, [](A *a) {});",
+   getLLVMStyleWithColumns(40));
 }
 
 TEST_F(FormatTest, BreaksLongDeclarations) {


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


r294359 - Enable -dump-deserialized-decls and -error-on-deserialized-decl for modules.

2017-02-07 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Feb  7 15:49:41 2017
New Revision: 294359

URL: http://llvm.org/viewvc/llvm-project?rev=294359&view=rev
Log:
Enable -dump-deserialized-decls and -error-on-deserialized-decl for modules.

Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=294359&r1=294358&r2=294359&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Tue Feb  7 15:49:41 2017
@@ -352,8 +352,9 @@ bool FrontendAction::BeginSourceFile(Com
 goto failure;
   CI.setModuleManager(static_cast(FinalReader.get()));
   CI.getASTContext().setExternalSource(source);
-} else if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
-  // Use PCH.
+} else if (CI.getLangOpts().Modules ||
+   !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+  // Use PCM or PCH.
   assert(hasPCHSupport() && "This action does not have PCH support!");
   ASTDeserializationListener *DeserialListener =
   Consumer->GetASTDeserializationListener();
@@ -370,13 +371,24 @@ bool FrontendAction::BeginSourceFile(Com
 DeserialListener, DeleteDeserialListener);
 DeleteDeserialListener = true;
   }
-  CI.createPCHExternalASTSource(
-  CI.getPreprocessorOpts().ImplicitPCHInclude,
-  CI.getPreprocessorOpts().DisablePCHValidation,
+  if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+CI.createPCHExternalASTSource(
+CI.getPreprocessorOpts().ImplicitPCHInclude,
+CI.getPreprocessorOpts().DisablePCHValidation,
   CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, 
DeserialListener,
-  DeleteDeserialListener);
-  if (!CI.getASTContext().getExternalSource())
-goto failure;
+DeleteDeserialListener);
+if (!CI.getASTContext().getExternalSource())
+  goto failure;
+  }
+  // If modules are enabled, create the module manager before creating
+  // any builtins, so that all declarations know that they might be
+  // extended by an external source.
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalSource()) {
+CI.createModuleManager();
+CI.getModuleManager()->setDeserializationListener(DeserialListener,
+
DeleteDeserialListener);
+  }
 }
 
 CI.setASTConsumer(std::move(Consumer));
@@ -386,15 +398,9 @@ bool FrontendAction::BeginSourceFile(Com
 
   // Initialize built-in info as long as we aren't using an external AST
   // source.
-  if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource()) {
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalSource()) {
 Preprocessor &PP = CI.getPreprocessor();
-
-// If modules are enabled, create the module manager before creating
-// any builtins, so that all declarations know that they might be
-// extended by an external source.
-if (CI.getLangOpts().Modules)
-  CI.createModuleManager();
-
 PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(),
PP.getLangOpts());
   } else {


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


[libcxx] r294360 - Fix bugs in filesystem detected by _LIBCPP_ASSERT.

2017-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb  7 15:51:58 2017
New Revision: 294360

URL: http://llvm.org/viewvc/llvm-project?rev=294360&view=rev
Log:
Fix bugs in filesystem detected by _LIBCPP_ASSERT.

Recently I turned on libc++'s debug mode assertions when
CMake is configured with -DLIBCXX_ENABLE_ASSERTIONS=ON. This
change exposed assertion failures caused by bugs in filesystem.
This patch fixes those failures.

The first bug was that `PathParser` was using front()/back()
on empty string views in order to get the address of the character.
However this is UB on empty strings. Those operations now use data()
to obtain the pointer.

The second bug was that directory_iterator attempted to capture errno when it
was unset and there was an assertion to detect this.

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
libcxx/trunk/src/experimental/filesystem/path.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=294360&r1=294359&r2=294360&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Tue Feb  7 
15:51:58 2017
@@ -45,11 +45,12 @@ inline bool set_or_throw(std::error_code
 inline path::string_type posix_readdir(DIR *dir_stream, error_code& ec) {
 struct dirent* dir_entry_ptr = nullptr;
 errno = 0; // zero errno in order to detect errors
+ec.clear();
 if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {
-ec = capture_errno();
+if (errno)
+  ec = capture_errno();
 return {};
 } else {
-ec.clear();
 return dir_entry_ptr->d_name;
 }
 }

Modified: libcxx/trunk/src/experimental/filesystem/path.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=294360&r1=294359&r2=294360&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/path.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/path.cpp Tue Feb  7 15:51:58 2017
@@ -56,13 +56,13 @@ public:
   }
 
   PosPtr peek() const noexcept {
-auto End = &Path.back() + 1;
 auto TkEnd = getNextTokenStartPos();
+auto End = getAfterBack();
 return TkEnd == End ? nullptr : TkEnd;
   }
 
   void increment() noexcept {
-const PosPtr End = &Path.back() + 1;
+const PosPtr End = getAfterBack();
 const PosPtr Start = getNextTokenStartPos();
 if (Start == End)
   return makeState(PS_AtEnd);
@@ -109,7 +109,7 @@ public:
   }
 
   void decrement() noexcept {
-const PosPtr REnd = &Path.front() - 1;
+const PosPtr REnd = getBeforeFront();
 const PosPtr RStart = getCurrentTokenStartPos() - 1;
 
 switch (State) {
@@ -195,19 +195,27 @@ private:
 RawEntry = {};
   }
 
+  PosPtr getAfterBack() const noexcept {
+return Path.data() + Path.size();
+  }
+
+  PosPtr getBeforeFront() const noexcept {
+return Path.data() - 1;
+  }
+
   /// \brief Return a pointer to the first character after the currently
   ///   lexed element.
   PosPtr getNextTokenStartPos() const noexcept {
 switch (State) {
 case PS_BeforeBegin:
-  return &Path.front();
+  return Path.data();
 case PS_InRootName:
 case PS_InRootDir:
 case PS_InFilenames:
   return &RawEntry.back() + 1;
 case PS_InTrailingSep:
 case PS_AtEnd:
-  return &Path.back() + 1;
+  return getAfterBack();
 }
 _LIBCPP_UNREACHABLE();
   }


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


  1   2   >