[PATCH] D33383: [GSoC] Flag value completion for clang

2017-06-18 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 102964.
yamaguchi added a comment.

Made a trivial change in optionMatches.


https://reviews.llvm.org/D33383

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  clang/utils/bash-autocomplete.sh
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/lib/Driver/DarwinLdDriver.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/Option/OptTable.cpp
  llvm/lib/Option/Option.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -196,6 +196,9 @@
   OS << ", nullptr";
 
 // The option meta-variable name (unused).
+OS << ", nullptr";
+
+// The option Values (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -285,6 +288,13 @@
 else
   OS << "nullptr";
 
+// The option Values. Used for shell autocompletion.
+OS << ", ";
+if (!isa(R.getValueInit("Values")))
+  write_cstring(OS, R.getValueAsString("Values"));
+else
+  OS << "nullptr";
+
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,8 +18,9 @@
 
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
-   HELPTEXT, METAVAR) OPT_##ID,
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, ARGVALUE)\
+  OPT_##ID,
 #include "Opts.inc"
   LastOption
 #undef OPTION
@@ -36,10 +37,10 @@
 };
 
 static const OptTable::Info InfoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
-   HELPTEXT, METAVAR)   \
-  { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \
-FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS },
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, ARGVALUE)\
+  {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
+   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp
===
--- llvm/tools/llvm-cvtres/llvm-cvtres.cpp
+++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -37,7 +37,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR)  \
+   HELPTEXT, METAVAR, ARGVALUE)\
   OPT_##ID,
 #include "Opts.inc"
 #undef OPTION
@@ -49,12 +49,12 @@
 
 static const opt::OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR)  \
+   HELPTEXT, METAVAR, ARGVALUE)\
   {\
-  PREFIX,  NAME, HELPTEXT, \
-  METAVAR, OPT_##ID, opt::Option::KIND##Class, \
-  PARAM,   FLAGS,OPT_##GROUP,  \
-  OPT_##ALIAS, ALIASARGS},
+  PREFIX,  NAME,  HELPTEXT,\
+  METAVAR, OPT_##ID,  opt::Option::KIND##Class,\
+  PARAM,   FLAGS, OPT_##GROUP, \
+  OPT_##ALIAS, ALIASARGS, ARGVALUE},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -31,7 +31,7 @@
 
 enum {
   OPT_INVALID = 0,
-#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID,
+#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
 #include "Options.inc"
 #undef OPTION
 };
@@ -41,11 +41,9 @@
 #undef PREFIX
 
 static const 

[libcxx] r305647 - any: Add availability for experimental::bad_any_cast

2017-06-18 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sun Jun 18 09:52:26 2017
New Revision: 305647

URL: http://llvm.org/viewvc/llvm-project?rev=305647&view=rev
Log:
any: Add availability for experimental::bad_any_cast

As a follow up to r302172, add missing availability for bad_any_cast.

rdar://problem/32161524

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/experimental/any
libcxx/trunk/test/std/experimental/any/any.class/any.assign/copy.pass.cpp
libcxx/trunk/test/std/experimental/any/any.class/any.assign/move.pass.cpp
libcxx/trunk/test/std/experimental/any/any.class/any.assign/value.pass.cpp
libcxx/trunk/test/std/experimental/any/any.class/any.cons/copy.pass.cpp
libcxx/trunk/test/std/experimental/any/any.class/any.cons/move.pass.cpp
libcxx/trunk/test/std/experimental/any/any.class/any.cons/value.pass.cpp

libcxx/trunk/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp
libcxx/trunk/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp
libcxx/trunk/test/support/experimental_any_helpers.h

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=305647&r1=305646&r2=305647&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sun Jun 18 09:52:26 2017
@@ -1154,6 +1154,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
   __attribute__((availability(watchos,strict,introduced=3.0)))
 #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
 #define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
+#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
 #define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS   
\
   __attribute__((availability(macosx,strict,introduced=10.12)))
\
   __attribute__((availability(ios,strict,introduced=10.0)))
\
@@ -1179,6 +1180,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_AVAILABILITY_SHARED_MUTEX
 #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
 #define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
+#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
 #define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
 #define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
 #define _LIBCPP_AVAILABILITY_FUTURE_ERROR
@@ -1191,9 +1193,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #ifdef _LIBCPP_NO_EXCEPTIONS
 #define _LIBCPP_AVAILABILITY_DYNARRAY
 #define _LIBCPP_AVAILABILITY_FUTURE
+#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 #else
 #define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
 #define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
+#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
\
+  _LIBCPP_AVAILABILITY_BAD_ANY_CAST
 #endif
 
 // Availability of stream API in the dylib got dropped and re-added.  The

Modified: libcxx/trunk/include/experimental/any
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/any?rev=305647&r1=305646&r2=305647&view=diff
==
--- libcxx/trunk/include/experimental/any (original)
+++ libcxx/trunk/include/experimental/any Sun Jun 18 09:52:26 2017
@@ -89,7 +89,7 @@ inline namespace fundamentals_v1 {
 
 _LIBCPP_BEGIN_NAMESPACE_LFTS
 
-class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : 
public bad_cast
 {
 public:
 virtual const char* what() const _NOEXCEPT;
@@ -98,6 +98,7 @@ public:
 #if _LIBCPP_STD_VER > 11// C++ > 11
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 void __throw_bad_any_cast()
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
@@ -506,7 +507,7 @@ void swap(any & __lhs, any & __rhs) _NOE
 }
 
 template 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 _ValueType any_cast(any const & __v)
 {
 static_assert(
@@ -522,7 +523,7 @@ _ValueType any_cast(any const & __v)
 }
 
 template 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 _ValueType any_cast(any & __v)
 {
 static_assert(
@@ -537,7 +538,7 @@ _ValueType any_cast(any & __v)
 }
 
 template 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 _ValueType any_cast(any && __v)
 {
 static_assert(

Modified: 
libcxx/trunk/test/std/experimental/any/any.class/any.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/any/any.class/any.assign/copy.pass.cpp?rev=305647&r1=305646&r2=305647&view=diff
==
--- libcxx/trunk/test/std/experimental/any/any.class/any.assign/copy.pass.cpp 
(original)
+++ libcxx/trunk/tes

[PATCH] D33177: any: Add availability for experimental::bad_any_cast

2017-06-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith added a comment.

Committed in r305647.


https://reviews.llvm.org/D33177



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


[libcxx] r305648 - func.wrap.func.con: Fix test comment

2017-06-18 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sun Jun 18 10:34:47 2017
New Revision: 305648

URL: http://llvm.org/viewvc/llvm-project?rev=305648&view=rev
Log:
func.wrap.func.con: Fix test comment

This tests moving `function`, not `const function`.

Modified:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp?rev=305648&r1=305647&r2=305648&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
 Sun Jun 18 10:34:47 2017
@@ -12,7 +12,7 @@
 // class function
 
 // function(const function&  f);
-// function(const function&& f);
+// function(function&& f);
 
 #include 
 #include 


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


[PATCH] D33383: [GSoC] Flag value completion for clang

2017-06-18 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Yuka,

This is beautiful. Overall looking pretty good. Some minor stylistic comments.




Comment at: clang/include/clang/Driver/Options.h:43
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
+   HELPTEXT, METAVAR, ARGVALUE)
\
+  OPT_##ID,

Since you are now using `Values` as a variable name, you want to rename 
ARGVALUE VALUES.



Comment at: clang/include/clang/Driver/Options.td:1709-1710
   HelpText<"The thread model to use, e.g. posix, single (posix by default)">;
-def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
+def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>, 
Values<"default,4,5,gnu">,
   HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">;
 

You wrote `Values` before `HelpText` here but in the opposite order for 
stdlib_EQ. This is not a strict rule or anything, but it is better to be 
consistent in the option order.



Comment at: clang/lib/Driver/Driver.cpp:1233
+
+// When the flag was passed like "--autocomplete=-fsyn"
+// we want to autocomplete "-fsyn" as "-fsyntax-only"

Move this inside the first `if` so that it is clear that this comment does not 
describe the entire `if` and `else` but only the `if` part.

You could improve the comment: If the flag is in the form of 
"--autocomplete=-foo", we were requested to print out all option names that 
start with "-foo". For example, "--autocomplete=-fsyn" is expanded to 
"-fsyntax-only".



Comment at: clang/lib/Driver/Driver.cpp:1238
+} else {
+  // When flags were passed like "--autocomplete=-stdlib=,l"
+  // we want to autocomplete appropriate value which starts with "l"

Likewise: If the flag is in the form of "--autocomplete=-foo,bar", we were 
requested to print out all option values for "-foo" that start with "bar". For 
example, "--autocomplete=-stdlib=,l" is expanded to "libc++" and "libstdc++".



Comment at: clang/utils/bash-autocomplete.sh:7
 
-  flags=$( clang --autocomplete="$cur" )
-  if [[ "$flags" == "" || "$cur" == "" ]]; then
+  local w1="${COMP_WORDS[$cword - 1]}"
+  local w2="${COMP_WORDS[$cword - 2]}"

It is better to describe what you are doing here and why. How about this:

bash autocompletion always separates '=' as a token even if there's no space 
before/after it. On the other hand, '=' is just a regular character for clang 
options that contain '='. For example, "-stdlib=" is defined as is, instead of 
"-stdlib" and "=". So, we need to partially undo bash tokenization here for 
impedance matching.



Comment at: llvm/lib/Option/OptTable.cpp:189
 
+// returns true if one of the Prefixes + In.Names matches Option
+static bool optionMatches(const OptTable::Info &In, StringRef Option) {

returns -> Returns


https://reviews.llvm.org/D33383



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


[PATCH] D34329: [GSoC] Clang AST diffing

2017-06-18 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes created this revision.
Herald added subscribers: mgorny, klimek.

https://reviews.llvm.org/D34329

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  lib/Tooling/ASTDiff/CMakeLists.txt
  lib/Tooling/CMakeLists.txt
  tools/CMakeLists.txt
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- /dev/null
+++ tools/clang-diff/ClangDiff.cpp
@@ -0,0 +1,58 @@
+//===- ClangDiff.cpp - compare source files by AST nodes --*- C++ -*- -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief
+///
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+
+static cl::OptionCategory ClangDiffCategory("clang-diff options");
+
+static cl::opt
+DumpAST("ast-dump",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+int main(int argc, const char **argv) {
+  tooling::CommonOptionsParser Options(argc, argv, ClangDiffCategory);
+  ArrayRef Files = Options.getSourcePathList();
+
+  tooling::ClangTool Tool(Options.getCompilations(), Files);
+
+  if (DumpAST) {
+if (Files.size() != 1) {
+  errs() << "Error: please specify exactly one filename.\n";
+  return 1;
+}
+std::vector> ASTs;
+Tool.buildASTs(ASTs);
+if (ASTs.size() != 1) {
+  return 1;
+}
+clang::diff::TreeRoot Tree(*ASTs[0]);
+Tree.dumpAsJson();
+return 0;
+  }
+  if (Files.size() != 2) {
+errs() << "Error: exactly two filenames are required.\n";
+return 1;
+  }
+  std::vector> ASTs;
+  Tool.buildASTs(ASTs);
+  if (ASTs.size() != 2) {
+return 1;
+  }
+  clang::diff::runDiff(*ASTs[0], *ASTs[1]);
+  return 0;
+}
Index: tools/clang-diff/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-diff/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_executable(clang-diff
+  ClangDiff.cpp
+  )
+
+target_link_libraries(clang-diff
+  clangAST
+  clangBasic
+  clangFrontend
+  clangLex
+  clangTooling
+  clangToolingASTDiff
+  )
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_subdirectory(diagtool)
 add_clang_subdirectory(driver)
+add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
Index: lib/Tooling/CMakeLists.txt
===
--- lib/Tooling/CMakeLists.txt
+++ lib/Tooling/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_subdirectory(Core)
 add_subdirectory(Refactoring)
+add_subdirectory(ASTDiff)
 
 add_clang_library(clangTooling
   ArgumentsAdjusters.cpp
Index: lib/Tooling/ASTDiff/CMakeLists.txt
===
--- /dev/null
+++ lib/Tooling/ASTDiff/CMakeLists.txt
@@ -0,0 +1,12 @@
+set(LLVM_LINK_COMPONENTS
+  # Option
+  Support
+  )
+
+add_clang_library(clangToolingASTDiff
+  ASTDiff.cpp
+  LINK_LIBS
+  clangBasic
+  clangAST
+  # clangToolingCore
+  )
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- /dev/null
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -0,0 +1,865 @@
+//===- ASTDiff.cpp - AST differencing implementation---*- C++ -*- -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief
+///
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "llvm/ADT/PriorityQueue.h"
+#include "llvm/Support/FormatVariadic.h"
+
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+namespace clang {
+namespace diff {
+
+static bool isRelevantNode(Decl *D) { return D != nullptr; }
+static bool isRelevantNode(Stmt *S) { return S != nullptr; }
+
+namespace {
+// Count the number of non-null nodes
+struct NodeCountVisitor : public RecursiveASTVisitor {
+  int Count = 0;
+  bool TraverseDecl(Decl *D) {
+if (isRelevantNode(D)) {
+  ++Count;
+  RecursiveASTVisitor::Trave

[libcxx] r305649 - iostreams: Fix deployment target for streams dylib support

2017-06-18 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sun Jun 18 11:50:23 2017
New Revision: 305649

URL: http://llvm.org/viewvc/llvm-project?rev=305649&view=rev
Log:
iostreams: Fix deployment target for streams dylib support

Fix an off-by-one in r302172, which triggered building local versions of
the iostreams when deploying to `<= macOS 10.9`, when it should have
been `< macOS 10.9`.  10.9 had the dylib support.

This defines `_LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE` less
often, reducing code size for users with deployment targets of exactly
macOS 10.9 or iOS 7.0.

rdar://problem/32233981

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=305649&r1=305648&r2=305649&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sun Jun 18 11:50:23 2017
@@ -1207,9 +1207,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 //availability(ios,introduced=7.0)
 #if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && 
\
 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
\
-  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1090) ||
\
+  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || 
\
  (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) &&   
\
-  __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ <= 7))
+  __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 7))
 #define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
 #endif
 


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


Re: [libcxx] r276238 - Implement std::string_view as described in http://wg21.link/P0254R1. Reviewed as https://reviews.llvm.org/D21459

2017-06-18 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2017-Jun-16, at 05:58, Duncan Exon Smith  wrote:
> 
> 
> On Jun 15, 2017, at 22:22, Eric Fiselier mailto:e...@efcs.ca>> 
> wrote:
> 
>> 
>> 
>> On Thu, Jun 15, 2017 at 11:00 PM, Duncan P. N. Exon Smith 
>> mailto:dexonsm...@apple.com>> wrote:
>> Your suggestion is essentially to replace experimental/string_view with 
>> something like:
>> 
>> namespace std { inline namespace __1 { namespace experimental {
>>   template 
>>   using basic_string_view = _VSTD::basic_string_view;
>> }}}
>> 
>> That breaks:
>> 1. User compiles 1.cpp with older toolchain.  1.cpp implements 
>> foo(std::experimental::string_view).
>> 2. User compiles 2.cpp with newer toolchain.  2.cpp calls 
>> foo(std::experimental::string_view).
>> 3. User links 1.o with 2.o.
>> 
>> I'm not sure if this matters.
>> 
>> It can't matter.  are allowed to break both their API and 
>> ABI as needed.
>> 
>> Also I was suggesting 
>> 
>>namespace std { namespace experimental {
>>  using std::basic_string_view;
>>  using std::string_view;
>>   }}
>>  
>> This approach will break code that expects experimental::string_view and 
>> std::string_view are different types:
>> Example:
>> 
>>   void foo(std::string_view);
>>   void foo(std::experimental::string_view);
>>   foo(std::string_view{}); // ambiguous

FTR, it also breaks code that relies on string_view::clear(), which disappeared.

>>> On Jun 15, 2017, at 21:55, Eric Fiselier >> > wrote:
>>> 
>>> I would also want to do serious performance analysis on this patch. Does 
>>> removing the string_view overloads cause less optimal overloads to be 
>>> chosen? Perhaps allocating ones?
>>> That would be really unfortunate, and I'm not sure that's in the best 
>>> interest of our users at large.
>> 
>> Less optimal compared to what?  C++17 code?
>> 
>> Not sure yet, I'm trying to figure out what types the `const Tp&` overloads
>> are attempting to soak up. Is it only string_view? 
> 
> The type trait restricts it to things convertible to string_view that are not 
> const char *.

I had a bit of a look at experimental/filesystem, and it relies pretty heavily 
on the string/string_view conversions.  I still feel like this approach might 
be "the right one", but perhaps it's not worth it.

>>> /Eric
>>> 
>>> On Thu, Jun 15, 2017 at 10:51 PM, Duncan P. N. Exon Smith 
>>> mailto:dexonsm...@apple.com>> wrote:
>>> 
 On Jun 15, 2017, at 19:42, Eric Fiselier >>> > wrote:
 
 
 
 On Thu, Jun 15, 2017 at 8:38 PM, Duncan P. N. Exon Smith 
 mailto:dexonsm...@apple.com>> wrote:
 I just started working on a patch to add #if guards, and the first 
 interesting thing I found was the basic_string constructor:
 
> template 
> template 
> basic_string<_CharT, _Traits, _Allocator>::basic_string(
>  const _Tp& __t, size_type __pos, size_type __n, const 
> allocator_type& __a,
>typename 
> enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 
> void>::type *)
> : __r_(__second_tag(), __a)
> {
>   __self_view __sv = __self_view(__t).substr(__pos, __n);
> __init(__sv.data(), __sv.size());
> #if _LIBCPP_DEBUG_LEVEL >= 2
> __get_db()->__insert_c(this);
> #endif
> }
 
 
 That constructor was added in C++17, so removing it along with string_view 
 should be OK.
 Assuming we don't use it to implement older constructors using a single 
 template.
 
  
 I suppose the decision was made so that std::string could take advantage 
 of it.
 
 Is it a conforming extension?
 
 No, because it can change the meaning of otherwise well defined code, as 
 you pointed out initially. 
>>> 
>>> Let me know if this patch is along the right lines.  If so, I'll finish it 
>>> up and put it on phab.
>>> 
>>> experimental/filesystem/path.cpp doesn't compile, since 
>>> experimental/filesystem uses things like operator+=(string, string_view) 
>>> extensively.  But I'd like an early opinion on the approach before I dig in.
>>> 
>>> In string, the only function that needed to be rewritten was 
>>> string::compare(size, size, string, size, size).  I'm nervous that 
>>> filesystem will be a bigger job.
>>> 
>>> 
>>> 
  
 
> On Jun 15, 2017, at 18:35, Eric Fiselier  > wrote:
> 
> It *shouldn't* include , that's a given.
> 
> IIRC, and Marshall would know better, I believe it was untenable to
> maintain a version of  that didn't depend on  after 
> making
> the changes required for C++17.
> 
> However inspecting  now it does seem possible that the 
> entanglement
> is avoidable.Though it's also likely I'm just not seeing the whole 
> picture. 
> 
> /Eric
> 
> On Thu, Jun 15, 2017 at 6:42 PM, Duncan P. N. Exon Smith 
> mailto:dexonsm...@apple.com>>wrote:
> 
> > 

Re: [libcxx] r276238 - Implement std::string_view as described in http://wg21.link/P0254R1. Reviewed as https://reviews.llvm.org/D21459

2017-06-18 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2017-Jun-18, at 10:46, Duncan P. N. Exon Smith  
> wrote:
> 
>> 
>> On 2017-Jun-16, at 05:58, Duncan Exon Smith > > wrote:
>> 
>> 
>> On Jun 15, 2017, at 22:22, Eric Fiselier > > wrote:
>> 
>>> 
>>> 
>>> On Thu, Jun 15, 2017 at 11:00 PM, Duncan P. N. Exon Smith 
>>> mailto:dexonsm...@apple.com>> wrote:
>>> Your suggestion is essentially to replace experimental/string_view with 
>>> something like:
>>> 
>>> namespace std { inline namespace __1 { namespace experimental {
>>>   template 
>>>   using basic_string_view = _VSTD::basic_string_view;
>>> }}}
>>> 
>>> That breaks:
>>> 1. User compiles 1.cpp with older toolchain.  1.cpp implements 
>>> foo(std::experimental::string_view).
>>> 2. User compiles 2.cpp with newer toolchain.  2.cpp calls 
>>> foo(std::experimental::string_view).
>>> 3. User links 1.o with 2.o.
>>> 
>>> I'm not sure if this matters.
>>> 
>>> It can't matter.  are allowed to break both their API and 
>>> ABI as needed.
>>> 
>>> Also I was suggesting 
>>> 
>>>namespace std { namespace experimental {
>>>  using std::basic_string_view;
>>>  using std::string_view;
>>>   }}
>>>  
>>> This approach will break code that expects experimental::string_view and 
>>> std::string_view are different types:
>>> Example:
>>> 
>>>   void foo(std::string_view);
>>>   void foo(std::experimental::string_view);
>>>   foo(std::string_view{}); // ambiguous
> 
> FTR, it also breaks code that relies on string_view::clear(), which 
> disappeared.

More importantly, it breaks code that relies on string_view::to_string().  This 
one matters, since a "true" std::experimental::string_view wouldn't have the 
implicit conversions.

> 
 On Jun 15, 2017, at 21:55, Eric Fiselier >>> > wrote:
 
 I would also want to do serious performance analysis on this patch. Does 
 removing the string_view overloads cause less optimal overloads to be 
 chosen? Perhaps allocating ones?
 That would be really unfortunate, and I'm not sure that's in the best 
 interest of our users at large.
>>> 
>>> Less optimal compared to what?  C++17 code?
>>> 
>>> Not sure yet, I'm trying to figure out what types the `const Tp&` overloads
>>> are attempting to soak up. Is it only string_view? 
>> 
>> The type trait restricts it to things convertible to string_view that are 
>> not const char *.
> 
> I had a bit of a look at experimental/filesystem, and it relies pretty 
> heavily on the string/string_view conversions.  I still feel like this 
> approach might be "the right one", but perhaps it's not worth it.
> 
 /Eric
 
 On Thu, Jun 15, 2017 at 10:51 PM, Duncan P. N. Exon Smith 
 mailto:dexonsm...@apple.com>> wrote:
 
> On Jun 15, 2017, at 19:42, Eric Fiselier  > wrote:
> 
> 
> 
> On Thu, Jun 15, 2017 at 8:38 PM, Duncan P. N. Exon Smith 
> mailto:dexonsm...@apple.com>> wrote:
> I just started working on a patch to add #if guards, and the first 
> interesting thing I found was the basic_string constructor:
> 
>> template 
>> template 
>> basic_string<_CharT, _Traits, _Allocator>::basic_string(
>>  const _Tp& __t, size_type __pos, size_type __n, const 
>> allocator_type& __a,
>>   typename 
>> enable_if<__can_be_converted_to_string_view<_CharT, _Traits, 
>> _Tp>::value, void>::type *)
>> : __r_(__second_tag(), __a)
>> {
>>  __self_view __sv = __self_view(__t).substr(__pos, __n);
>> __init(__sv.data(), __sv.size());
>> #if _LIBCPP_DEBUG_LEVEL >= 2
>> __get_db()->__insert_c(this);
>> #endif
>> }
> 
> 
> That constructor was added in C++17, so removing it along with 
> string_view should be OK.
> Assuming we don't use it to implement older constructors using a single 
> template.
> 
>  
> I suppose the decision was made so that std::string could take advantage 
> of it.
> 
> Is it a conforming extension?
> 
> No, because it can change the meaning of otherwise well defined code, as 
> you pointed out initially. 
 
 Let me know if this patch is along the right lines.  If so, I'll finish it 
 up and put it on phab.
 
 experimental/filesystem/path.cpp doesn't compile, since 
 experimental/filesystem uses things like operator+=(string, string_view) 
 extensively.  But I'd like an early opinion on the approach before I dig 
 in.
 
 In string, the only function that needed to be rewritten was 
 string::compare(size, size, string, size, size).  I'm nervous that 
 filesystem will be a bigger job.
 
 
 
>  
> 
>> On Jun 15, 2017, at 18:35, Eric Fiselier > > wrote:
>> 
>> It *shouldn't* include , that's a given.
>> 
>> IIRC, and Marshall would know better, I believe it was untenable to

[PATCH] D34330: [clang-format] handle `if constexpr`

2017-06-18 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes created this revision.
Herald added a subscriber: klimek.

Changes to handle `if constexpr` the same way as `if`.


https://reviews.llvm.org/D34330

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -341,6 +341,18 @@
   verifyFormat("if (true)\n  f();\ng();");
   verifyFormat("if (a)\n  if (b)\nif (c)\n  g();\nh();");
   verifyFormat("if (a)\n  if (b) {\nf();\n  }\ng();");
+  verifyFormat("if constexpr (true)\n"
+   "  f();\ng();");
+  verifyFormat("if constexpr (a)\n"
+   "  if constexpr (b)\n"
+   "if constexpr (c)\n"
+   "  g();\n"
+   "h();");
+  verifyFormat("if constexpr (a)\n"
+   "  if constexpr (b) {\n"
+   "f();\n"
+   "  }\n"
+   "g();");
 
   FormatStyle AllowsMergedIf = getLLVMStyle();
   AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
@@ -423,9 +435,11 @@
   AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
 
   verifyFormat("if (true) {}", AllowSimpleBracedStatements);
+  verifyFormat("if constexpr (true) {}", AllowSimpleBracedStatements);
   verifyFormat("while (true) {}", AllowSimpleBracedStatements);
   verifyFormat("for (;;) {}", AllowSimpleBracedStatements);
   verifyFormat("if (true) { f(); }", AllowSimpleBracedStatements);
+  verifyFormat("if constexpr (true) { f(); }", AllowSimpleBracedStatements);
   verifyFormat("while (true) { f(); }", AllowSimpleBracedStatements);
   verifyFormat("for (;;) { f(); }", AllowSimpleBracedStatements);
   verifyFormat("if (true) { //\n"
@@ -496,6 +510,19 @@
"else {\n"
"  i();\n"
"}");
+  verifyFormat("if (true)\n"
+   "  if constexpr (true)\n"
+   "if (true) {\n"
+   "  if constexpr (true)\n"
+   "f();\n"
+   "} else {\n"
+   "  g();\n"
+   "}\n"
+   "  else\n"
+   "h();\n"
+   "else {\n"
+   "  i();\n"
+   "}");
   verifyFormat("void f() {\n"
"  if (a) {\n"
"  } else {\n"
@@ -511,6 +538,12 @@
"  g();\n"
"else\n"
"  h();");
+  verifyFormat("if constexpr (a)\n"
+   "  f();\n"
+   "else if constexpr (b)\n"
+   "  g();\n"
+   "else\n"
+   "  h();");
   verifyFormat("if (a) {\n"
"  f();\n"
"}\n"
@@ -528,6 +561,11 @@
"a) {\n"
"}",
getLLVMStyleWithColumns(62));
+  verifyFormat("if (a) {\n"
+   "} else if constexpr (\n"
+   "a) {\n"
+   "}",
+   getLLVMStyleWithColumns(62));
 }
 
 TEST_F(FormatTest, FormatsForLoop) {
@@ -2371,6 +2409,9 @@
   verifyFormat("if ((aa ||\n"
" bb) && // \n"
"cc) {\n}");
+  verifyFormat("if constexpr ((aa ||\n"
+   "   bb) && // aaa\n"
+   "  cc) {\n}");
   verifyFormat("b = a &&\n"
"// Comment\n"
"b.c && d;");
@@ -6492,6 +6533,10 @@
"  if (true) continue;\n"
"}",
ShortMergedIf);
+  ShortMergedIf.ColumnLimit = 33;
+  verifyFormat("#define A \\\n"
+   "  if constexpr (true) return 42;",
+   ShortMergedIf);
   ShortMergedIf.ColumnLimit = 29;
   verifyFormat("#define A   \\\n"
"  if (aa) return 1; \\\n"
@@ -6503,6 +6548,11 @@
"return 1; \\\n"
"  return 2;",
ShortMergedIf);
+  verifyFormat("#define A\\\n"
+   "  if constexpr (aaa) \\\n"
+   "return 1;\\\n"
+   "  return 2;",
+   ShortMergedIf);
 }
 
 TEST_F(FormatTest, FormatStarDependingOnContext) {
@@ -8712,11 +8762,24 @@
BreakBeforeBraceShortIfs);
   verifyFormat("void f(bool b)\n"
"{\n"
+   "  if constexpr (b)\n"
+   "  {\n"
+   "return;\n"
+   "  }\n"
+   "}\n",
+   BreakBeforeBraceShortIfs);
+  verifyFormat("void f(bool b)\n"
+   "{\n"
"  if (b) return;\n"
"}\n",
BreakBeforeBraceShortIfs);
 

[PATCH] D26953: clang-format: handle formatting on constexpr if

2017-06-18 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Hm, I probably should've searched first โ€” but I just re-implemented this in 
https://reviews.llvm.org/D34330.  Actually, I think my implementation solves 
the `AllowShortIfStatementsOnASingleLine` issue you were mentioning here ๐ŸŽ‰


https://reviews.llvm.org/D26953



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-06-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.

Be defensive against a reentrant std::function::operator=(), in case the held 
function object has a non-trivial destructor.  Destroying the function object 
in-place can lead to the destructor being called twice.

rdar://problem/32836603


https://reviews.llvm.org/D34331

Files:
  libcxx/include/functional
  
libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
  
libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp

Index: libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp
@@ -0,0 +1,44 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// class function
+
+// function& operator=(nullptr_t);
+
+#include 
+#include 
+
+struct A
+{
+  static std::function global;
+  static bool cancel;
+
+  ~A() {
+asm("");
+if (cancel)
+  global = nullptr;
+  }
+  void operator()() {}
+};
+
+std::function A::global;
+bool A::cancel = false;
+
+int main()
+{
+  A::global = A();
+  assert(A::global.target());
+
+  // Check that we don't recurse in A::~A().
+  A::cancel = true;
+  A::global = nullptr;
+  assert(!A::global.target());
+}
Index: libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
@@ -0,0 +1,44 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// class function
+
+// function& operator=(function &&);
+
+#include 
+#include 
+
+struct A
+{
+  static std::function global;
+  static bool cancel;
+
+  ~A() {
+asm("");
+if (cancel)
+  global = std::function(nullptr);
+  }
+  void operator()() {}
+};
+
+std::function A::global;
+bool A::cancel = false;
+
+int main()
+{
+  A::global = A();
+  assert(A::global.target());
+
+  // Check that we don't recurse in A::~A().
+  A::cancel = true;
+  A::global = std::function(nullptr);
+  assert(!A::global.target());
+}
Index: libcxx/include/functional
===
--- libcxx/include/functional
+++ libcxx/include/functional
@@ -1821,11 +1821,7 @@
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
 {
-if ((void *)__f_ == &__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
-__f_ = 0;
+function::operator=(nullptr);
 if (__f.__f_ == 0)
 __f_ = 0;
 else if ((void *)__f.__f_ == &__f.__buf_)
@@ -1845,11 +1841,12 @@
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
 {
-if ((void *)__f_ == &__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if ((void *)__t == &__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34332: path: Use string_view_t consistently

2017-06-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.

Most of filesystem/path.cpp uses `string_view_t`.  This fixes the two spots 
that use `string_view` directly.


https://reviews.llvm.org/D34332

Files:
  libcxx/src/experimental/filesystem/path.cpp


Index: libcxx/src/experimental/filesystem/path.cpp
===
--- libcxx/src/experimental/filesystem/path.cpp
+++ libcxx/src/experimental/filesystem/path.cpp
@@ -261,7 +261,8 @@
 string_view_pair separate_filename(string_view_t const & s) {
 if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""};
 auto pos = s.find_last_of('.');
-if (pos == string_view_t::npos) return string_view_pair{s, string_view{}};
+if (pos == string_view_t::npos)
+return string_view_pair{s, string_view_t{}};
 return string_view_pair{s.substr(0, pos), s.substr(pos)};
 }
 
@@ -396,7 +397,7 @@
 size_t hash_value(const path& __p) noexcept {
   auto PP = PathParser::CreateBegin(__p.native());
   size_t hash_value = 0;
-  std::hash hasher;
+  std::hash hasher;
   while (PP) {
 hash_value = __hash_combine(hash_value, hasher(*PP));
 ++PP;


Index: libcxx/src/experimental/filesystem/path.cpp
===
--- libcxx/src/experimental/filesystem/path.cpp
+++ libcxx/src/experimental/filesystem/path.cpp
@@ -261,7 +261,8 @@
 string_view_pair separate_filename(string_view_t const & s) {
 if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""};
 auto pos = s.find_last_of('.');
-if (pos == string_view_t::npos) return string_view_pair{s, string_view{}};
+if (pos == string_view_t::npos)
+return string_view_pair{s, string_view_t{}};
 return string_view_pair{s.substr(0, pos), s.substr(pos)};
 }
 
@@ -396,7 +397,7 @@
 size_t hash_value(const path& __p) noexcept {
   auto PP = PathParser::CreateBegin(__p.native());
   size_t hash_value = 0;
-  std::hash hasher;
+  std::hash hasher;
   while (PP) {
 hash_value = __hash_combine(hash_value, hasher(*PP));
 ++PP;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

2017-06-18 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.

LGTM, thanks for the patch!


Repository:
  rL LLVM

https://reviews.llvm.org/D31320



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


[PATCH] D34332: path: Use string_view_t consistently

2017-06-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Thanks!


https://reviews.llvm.org/D34332



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


[PATCH] D33383: [GSoC] Flag value completion for clang

2017-06-18 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 102981.
yamaguchi marked 6 inline comments as done.
yamaguchi added a comment.

Update code comment according to Rui's comment.


https://reviews.llvm.org/D33383

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  clang/utils/bash-autocomplete.sh
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/lib/Driver/DarwinLdDriver.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/Option/OptTable.cpp
  llvm/lib/Option/Option.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -196,6 +196,9 @@
   OS << ", nullptr";
 
 // The option meta-variable name (unused).
+OS << ", nullptr";
+
+// The option Values (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -285,6 +288,13 @@
 else
   OS << "nullptr";
 
+// The option Values. Used for shell autocompletion.
+OS << ", ";
+if (!isa(R.getValueInit("Values")))
+  write_cstring(OS, R.getValueAsString("Values"));
+else
+  OS << "nullptr";
+
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,8 +18,9 @@
 
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
-   HELPTEXT, METAVAR) OPT_##ID,
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  OPT_##ID,
 #include "Opts.inc"
   LastOption
 #undef OPTION
@@ -36,10 +37,10 @@
 };
 
 static const OptTable::Info InfoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
-   HELPTEXT, METAVAR)   \
-  { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \
-FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS },
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
+   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp
===
--- llvm/tools/llvm-cvtres/llvm-cvtres.cpp
+++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -37,7 +37,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR)  \
+   HELPTEXT, METAVAR, VALUES)  \
   OPT_##ID,
 #include "Opts.inc"
 #undef OPTION
@@ -49,12 +49,12 @@
 
 static const opt::OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR)  \
+   HELPTEXT, METAVAR, VALUES)  \
   {\
-  PREFIX,  NAME, HELPTEXT, \
-  METAVAR, OPT_##ID, opt::Option::KIND##Class, \
-  PARAM,   FLAGS,OPT_##GROUP,  \
-  OPT_##ALIAS, ALIASARGS},
+  PREFIX,  NAME,  HELPTEXT,\
+  METAVAR, OPT_##ID,  opt::Option::KIND##Class,\
+  PARAM,   FLAGS, OPT_##GROUP, \
+  OPT_##ALIAS, ALIASARGS, VALUES},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -31,7 +31,7 @@
 
 enum {
   OPT_INVALID = 0,
-#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID,
+#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
 #include "Options.inc"
 #undef OPTION
 };
@@

[PATCH] D33383: [GSoC] Flag value completion for clang

2017-06-18 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 102982.
yamaguchi added a comment.

Add support and test for 
-cl-std=,-fno-sanitize-coverage=,-ffp-contract=,-flto=,-fveclib=,-fshow-overloads=,-fvisibility=,-mfloat-abi=,-mthread-model.


https://reviews.llvm.org/D33383

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  clang/utils/bash-autocomplete.sh
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/lib/Driver/DarwinLdDriver.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/Option/OptTable.cpp
  llvm/lib/Option/Option.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -196,6 +196,9 @@
   OS << ", nullptr";
 
 // The option meta-variable name (unused).
+OS << ", nullptr";
+
+// The option Values (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -285,6 +288,13 @@
 else
   OS << "nullptr";
 
+// The option Values. Used for shell autocompletion.
+OS << ", ";
+if (!isa(R.getValueInit("Values")))
+  write_cstring(OS, R.getValueAsString("Values"));
+else
+  OS << "nullptr";
+
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,8 +18,9 @@
 
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
-   HELPTEXT, METAVAR) OPT_##ID,
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  OPT_##ID,
 #include "Opts.inc"
   LastOption
 #undef OPTION
@@ -36,10 +37,10 @@
 };
 
 static const OptTable::Info InfoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
-   HELPTEXT, METAVAR)   \
-  { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \
-FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS },
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
+   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp
===
--- llvm/tools/llvm-cvtres/llvm-cvtres.cpp
+++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -37,7 +37,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR)  \
+   HELPTEXT, METAVAR, VALUES)  \
   OPT_##ID,
 #include "Opts.inc"
 #undef OPTION
@@ -49,12 +49,12 @@
 
 static const opt::OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR)  \
+   HELPTEXT, METAVAR, VALUES)  \
   {\
-  PREFIX,  NAME, HELPTEXT, \
-  METAVAR, OPT_##ID, opt::Option::KIND##Class, \
-  PARAM,   FLAGS,OPT_##GROUP,  \
-  OPT_##ALIAS, ALIASARGS},
+  PREFIX,  NAME,  HELPTEXT,\
+  METAVAR, OPT_##ID,  opt::Option::KIND##Class,\
+  PARAM,   FLAGS, OPT_##GROUP, \
+  OPT_##ALIAS, ALIASARGS, VALUES},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -31,7 +31,7 @@
 
 enum {
   OPT_INVALID = 0,
-#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID,
+#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, 

r305659 - [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

2017-06-18 Thread Leslie Zhai via cfe-commits
Author: xiangzhai
Date: Sun Jun 18 20:55:50 2017
New Revision: 305659

URL: http://llvm.org/viewvc/llvm-project?rev=305659&view=rev
Log:
[analyzer] Teach CloneDetection about Qt Meta-Object Compiler

Reviewers: v.g.vassilev, zaks.anna, NoQ, teemperor

Reviewed By: v.g.vassilev, zaks.anna, NoQ, teemperor

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

Added:
cfe/trunk/test/Analysis/copypaste/autogenerated_automoc.cpp
cfe/trunk/test/Analysis/copypaste/dbus_autogenerated.cpp
cfe/trunk/test/Analysis/copypaste/moc_autogenerated.cpp
cfe/trunk/test/Analysis/copypaste/not-autogenerated.cpp
cfe/trunk/test/Analysis/copypaste/ui_autogenerated.cpp
Modified:
cfe/trunk/include/clang/Analysis/CloneDetection.h
cfe/trunk/lib/Analysis/CloneDetection.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=305659&r1=305658&r2=305659&view=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Sun Jun 18 20:55:50 2017
@@ -17,6 +17,8 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -319,6 +321,26 @@ struct OnlyLargestCloneConstraint {
   void constrain(std::vector &Result);
 };
 
+struct AutoGeneratedCloneConstraint {
+  StringRef IgnoredFilesPattern;
+  std::shared_ptr IgnoredFilesRegex;
+
+  AutoGeneratedCloneConstraint(StringRef IgnoredFilesPattern) 
+  : IgnoredFilesPattern(IgnoredFilesPattern) {
+IgnoredFilesRegex = std::make_shared("^(" +
+IgnoredFilesPattern.str() + "$)");
+  }
+
+  bool isAutoGenerated(const CloneDetector::CloneGroup &Group);
+
+  void constrain(std::vector &CloneGroups) {
+CloneConstraint::filterGroups(
+CloneGroups, [this](const CloneDetector::CloneGroup &Group) {
+  return isAutoGenerated(Group);
+});
+  }
+};
+
 /// Analyzes the pattern of the referenced variables in a statement.
 class VariablePattern {
 

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=305659&r1=305658&r2=305659&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Sun Jun 18 20:55:50 2017
@@ -18,9 +18,9 @@
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Lex/Lexer.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang;
 
@@ -366,6 +366,23 @@ void OnlyLargestCloneConstraint::constra
   }
 }
 
+bool AutoGeneratedCloneConstraint::isAutoGenerated(const 
CloneDetector::CloneGroup &Group) {
+  std::string Error;
+  if (IgnoredFilesPattern.empty() || Group.empty() || 
+  !IgnoredFilesRegex->isValid(Error))
+return false;
+
+  for (const StmtSequence &S : Group) {
+const SourceManager &SM = S.getASTContext().getSourceManager();
+StringRef Filename = llvm::sys::path::filename(SM.getFilename(
+S.getContainingDecl()->getLocation()));
+if (IgnoredFilesRegex->match(Filename))
+  return true;
+  }
+
+  return false;
+}
+
 static size_t createHash(llvm::MD5 &Hash) {
   size_t HashCode;
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp?rev=305659&r1=305658&r2=305659&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp Sun Jun 18 20:55:50 
2017
@@ -73,12 +73,17 @@ void CloneChecker::checkEndOfTranslation
   bool ReportNormalClones = Mgr.getAnalyzerOptions().getBooleanOption(
   "ReportNormalClones", true, this);
 
+  StringRef IgnoredFilesPattern = Mgr.getAnalyzerOptions().getOptionAsString(
+  "IgnoredFilesPattern", "", this);
+
   // Let the CloneDetector create a list of clones from all the analyzed
   // statements. We don't filter for matching variable patterns at this point
   // because reportSuspiciousClones() wants to search them for errors.
   std::vector AllCloneGroups;
 
-  Detector.findClones(AllCloneGroups, RecursiveCloneTypeIIConstraint(),
+  Detector.findClones(AllCloneGroups,
+  AutoGeneratedCloneConstraint(IgnoredFilesPattern),
+  RecursiveCloneTypeIIConstraint(),
   MinComplexityConstraint(MinComplexity),
   MinGroupSizeConstraint(2), OnlyLargestCloneConstr

[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

2017-06-18 Thread Leslie Zhai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305659: [analyzer] Teach CloneDetection about Qt Meta-Object 
Compiler (authored by xiangzhai).

Changed prior to commit:
  https://reviews.llvm.org/D31320?vs=102840&id=102984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31320

Files:
  cfe/trunk/include/clang/Analysis/CloneDetection.h
  cfe/trunk/lib/Analysis/CloneDetection.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  cfe/trunk/test/Analysis/copypaste/autogenerated_automoc.cpp
  cfe/trunk/test/Analysis/copypaste/dbus_autogenerated.cpp
  cfe/trunk/test/Analysis/copypaste/moc_autogenerated.cpp
  cfe/trunk/test/Analysis/copypaste/not-autogenerated.cpp
  cfe/trunk/test/Analysis/copypaste/ui_autogenerated.cpp

Index: cfe/trunk/lib/Analysis/CloneDetection.cpp
===
--- cfe/trunk/lib/Analysis/CloneDetection.cpp
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp
@@ -18,9 +18,9 @@
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Lex/Lexer.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang;
 
@@ -366,6 +366,23 @@
   }
 }
 
+bool AutoGeneratedCloneConstraint::isAutoGenerated(const CloneDetector::CloneGroup &Group) {
+  std::string Error;
+  if (IgnoredFilesPattern.empty() || Group.empty() || 
+  !IgnoredFilesRegex->isValid(Error))
+return false;
+
+  for (const StmtSequence &S : Group) {
+const SourceManager &SM = S.getASTContext().getSourceManager();
+StringRef Filename = llvm::sys::path::filename(SM.getFilename(
+S.getContainingDecl()->getLocation()));
+if (IgnoredFilesRegex->match(Filename))
+  return true;
+  }
+
+  return false;
+}
+
 static size_t createHash(llvm::MD5 &Hash) {
   size_t HashCode;
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -73,12 +73,17 @@
   bool ReportNormalClones = Mgr.getAnalyzerOptions().getBooleanOption(
   "ReportNormalClones", true, this);
 
+  StringRef IgnoredFilesPattern = Mgr.getAnalyzerOptions().getOptionAsString(
+  "IgnoredFilesPattern", "", this);
+
   // Let the CloneDetector create a list of clones from all the analyzed
   // statements. We don't filter for matching variable patterns at this point
   // because reportSuspiciousClones() wants to search them for errors.
   std::vector AllCloneGroups;
 
-  Detector.findClones(AllCloneGroups, RecursiveCloneTypeIIConstraint(),
+  Detector.findClones(AllCloneGroups,
+  AutoGeneratedCloneConstraint(IgnoredFilesPattern),
+  RecursiveCloneTypeIIConstraint(),
   MinComplexityConstraint(MinComplexity),
   MinGroupSizeConstraint(2), OnlyLargestCloneConstraint());
 
Index: cfe/trunk/include/clang/Analysis/CloneDetection.h
===
--- cfe/trunk/include/clang/Analysis/CloneDetection.h
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h
@@ -17,6 +17,8 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -319,6 +321,26 @@
   void constrain(std::vector &Result);
 };
 
+struct AutoGeneratedCloneConstraint {
+  StringRef IgnoredFilesPattern;
+  std::shared_ptr IgnoredFilesRegex;
+
+  AutoGeneratedCloneConstraint(StringRef IgnoredFilesPattern) 
+  : IgnoredFilesPattern(IgnoredFilesPattern) {
+IgnoredFilesRegex = std::make_shared("^(" +
+IgnoredFilesPattern.str() + "$)");
+  }
+
+  bool isAutoGenerated(const CloneDetector::CloneGroup &Group);
+
+  void constrain(std::vector &CloneGroups) {
+CloneConstraint::filterGroups(
+CloneGroups, [this](const CloneDetector::CloneGroup &Group) {
+  return isAutoGenerated(Group);
+});
+  }
+};
+
 /// Analyzes the pattern of the referenced variables in a statement.
 class VariablePattern {
 
Index: cfe/trunk/test/Analysis/copypaste/dbus_autogenerated.cpp
===
--- cfe/trunk/test/Analysis/copypaste/dbus_autogenerated.cpp
+++ cfe/trunk/test/Analysis/copypaste/dbus_autogenerated.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|dbus_|.*_automoc" -verify %s
+
+// Because files that have `dbus_' in their names are most likely autogenerated,
+// we suppress copy-paste warnings here.
+
+// expected-no-diagnostics
+
+void f1() {
+  int *p1 = new int[1];
+  int *p2 = new int[1];
+  if (p1) {
+delete [] p1;
+p1 = nu

[PATCH] D34329: [GSoC] Clang AST diffing

2017-06-18 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 102986.

https://reviews.llvm.org/D34329

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  lib/Tooling/ASTDiff/CMakeLists.txt
  lib/Tooling/CMakeLists.txt
  tools/CMakeLists.txt
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- /dev/null
+++ tools/clang-diff/ClangDiff.cpp
@@ -0,0 +1,94 @@
+//===- ClangDiff.cpp - compare source files by AST nodes --*- C++ -*- -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief
+///
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace tooling;
+
+static cl::OptionCategory ClangDiffCategory("clang-diff options");
+
+static cl::opt
+DumpAST("ast-dump",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt SourcePath(cl::Positional, cl::desc(""),
+   cl::Required,
+   cl::cat(ClangDiffCategory));
+
+static cl::opt DestinationPath(cl::Positional,
+cl::desc(""),
+cl::Optional,
+cl::cat(ClangDiffCategory));
+
+static std::unique_ptr getAST(const StringRef Filename) {
+  std::string ErrorMessage;
+  std::unique_ptr Compilations =
+  CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
+  if (!Compilations) {
+errs() << "Error while trying to load a compilation database, running "
+  "without flags.\n"
+   << ErrorMessage;
+Compilations.reset(
+new FixedCompilationDatabase(".", std::vector()));
+  }
+  std::array Files = {{Filename}};
+  ClangTool Tool(*Compilations, Files);
+  std::vector> ASTs;
+  Tool.buildASTs(ASTs);
+  if (ASTs.size() != Files.size()) {
+return nullptr;
+  }
+  return std::move(ASTs[0]);
+}
+
+int main(int argc, const char **argv) {
+  cl::HideUnrelatedOptions(ClangDiffCategory);
+  if (!cl::ParseCommandLineOptions(argc, argv)) {
+cl::PrintOptionValues();
+return 1;
+  }
+
+  if (DumpAST) {
+if (!DestinationPath.empty()) {
+  errs() << "Error: Please specify exactly one filename.\n";
+  return 1;
+}
+std::unique_ptr AST = getAST(SourcePath);
+if (!AST) {
+  return 1;
+}
+clang::diff::TreeRoot Tree(*AST);
+Tree.dumpAsJson();
+return 0;
+  }
+
+  if (DestinationPath.empty()) {
+errs() << "Error: Exactly two paths are required.\n";
+return 1;
+  }
+
+  std::unique_ptr Src = getAST(SourcePath);
+  std::unique_ptr Dst = getAST(DestinationPath);
+  if (!Src || !Dst) {
+return 1;
+  }
+
+  clang::diff::runDiff(*Src, *Dst);
+
+  return 0;
+}
Index: tools/clang-diff/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-diff/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_executable(clang-diff
+  ClangDiff.cpp
+  )
+
+target_link_libraries(clang-diff
+  clangAST
+  clangBasic
+  clangFrontend
+  clangLex
+  clangTooling
+  clangToolingASTDiff
+  )
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_subdirectory(diagtool)
 add_clang_subdirectory(driver)
+add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
Index: lib/Tooling/CMakeLists.txt
===
--- lib/Tooling/CMakeLists.txt
+++ lib/Tooling/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_subdirectory(Core)
 add_subdirectory(Refactoring)
+add_subdirectory(ASTDiff)
 
 add_clang_library(clangTooling
   ArgumentsAdjusters.cpp
Index: lib/Tooling/ASTDiff/CMakeLists.txt
===
--- /dev/null
+++ lib/Tooling/ASTDiff/CMakeLists.txt
@@ -0,0 +1,12 @@
+set(LLVM_LINK_COMPONENTS
+  # Option
+  Support
+  )
+
+add_clang_library(clangToolingASTDiff
+  ASTDiff.cpp
+  LINK_LIBS
+  clangBasic
+  clangAST
+  # clangToolingCore
+  )
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- /dev/null
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -0,0 +1,836 @@
+//===- ASTDiff.cpp - AST di

[libcxx] r305661 - path: Use string_view_t consistently

2017-06-18 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sun Jun 18 23:27:41 2017
New Revision: 305661

URL: http://llvm.org/viewvc/llvm-project?rev=305661&view=rev
Log:
path: Use string_view_t consistently

Most of filesystem/path.cpp uses string_view_t. This fixes the two spots
that use string_view directly.

https://reviews.llvm.org/D34332

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

Modified: libcxx/trunk/src/experimental/filesystem/path.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=305661&r1=305660&r2=305661&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/path.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/path.cpp Sun Jun 18 23:27:41 2017
@@ -261,7 +261,8 @@ private:
 string_view_pair separate_filename(string_view_t const & s) {
 if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""};
 auto pos = s.find_last_of('.');
-if (pos == string_view_t::npos) return string_view_pair{s, string_view{}};
+if (pos == string_view_t::npos)
+return string_view_pair{s, string_view_t{}};
 return string_view_pair{s.substr(0, pos), s.substr(pos)};
 }
 
@@ -396,7 +397,7 @@ int path::__compare(string_view_t __s) c
 size_t hash_value(const path& __p) noexcept {
   auto PP = PathParser::CreateBegin(__p.native());
   size_t hash_value = 0;
-  std::hash hasher;
+  std::hash hasher;
   while (PP) {
 hash_value = __hash_combine(hash_value, hasher(*PP));
 ++PP;


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


[PATCH] D34332: path: Use string_view_t consistently

2017-06-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith added a comment.

Fixed in r305661.


https://reviews.llvm.org/D34332



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


[PATCH] D34330: [clang-format] handle `if constexpr`

2017-06-18 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. Thanks for implementing this.


https://reviews.llvm.org/D34330



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


[PATCH] D34279: Fix release_40 build with MSVC (VS 2015)

2017-06-18 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

I've checked once again. Werror is disabled and no /WX flag is used. So this is 
a compiler error in case of msvc even without these flags.


https://reviews.llvm.org/D34279



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


[PATCH] D34279: Fix release_40 build with MSVC (VS 2015)

2017-06-18 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

btw my cl version is 19.00.24215.1 (MS VS 2015 Update 3). Do you use the same 
one?


https://reviews.llvm.org/D34279



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


[PATCH] D34330: [clang-format] handle `if constexpr`

2017-06-18 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Thanks for the review. Please note that there was a prior effort to implement 
this in https://reviews.llvm.org/D26953. However if you are happy with this 
version, feel free to commit (as I donโ€™t have commit access).


https://reviews.llvm.org/D34330



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