[PATCH] D37249: [Bash-autocomplete] Refactor autocomplete code into own function

2017-08-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:1160
 
+void Driver::handleAutocompletions(const llvm::opt::Arg *A) const {
+  // Print out all options that start with a given argument. This is used for

I think a more generic interface would be `void 
Driver::handleAutocompletions(StringRef PassedFlags) const {` as we don't 
really require that the user of this function actually has an `Arg` with a 
value before calling this function.


https://reviews.llvm.org/D37249



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


[clang-tools-extra] r311983 - [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Aug 28 22:58:08 2017
New Revision: 311983

URL: http://llvm.org/viewvc/llvm-project?rev=311983=rev
Log:
[cmake] Support running extra clang tool tests without static analyzer

Support running the extra clang tool tests when the static analyzer
is disabled. Disable the relevant clang-tidy tests and one include-fixer
test that require it to work.

Previously, the tests were disabled entirely with
CLANG_ENABLE_STATIC_ANALYZER being false. Now, the tests are being
enabled and the relevant tests are excluded and marked unsupported
appropriately.

In order to disable clang-tidy tests, the whole test directory is added
to the exclude lists, to avoid having to explicitly add 'REQUIRES' line
to every single test. If the other solution is preferable, I can update
the patch.

The yamldb_plugin include-fixer test is also updated to be disabled
without static analyzer. It fails in that case because clang is not
outputting a replacement suggestion -- but I don't know the exact
reason why it does not do that.

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

Modified:
clang-tools-extra/trunk/CMakeLists.txt
clang-tools-extra/trunk/test/CMakeLists.txt
clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
clang-tools-extra/trunk/test/lit.cfg
clang-tools-extra/trunk/test/lit.site.cfg.in
clang-tools-extra/trunk/unittests/CMakeLists.txt

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=311983=311982=311983=diff
==
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Mon Aug 28 22:58:08 2017
@@ -15,8 +15,7 @@ add_subdirectory(pp-trace)
 add_subdirectory(tool-template)
 
 # Add the common testsuite after all the tools.
-# TODO: Support tests with more granularity when features are off?
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_INCLUDE_TESTS)
+if(CLANG_INCLUDE_TESTS)
 add_subdirectory(test)
 add_subdirectory(unittests)
 endif()

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=311983=311982=311983=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Mon Aug 28 22:58:08 2017
@@ -15,6 +15,9 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+llvm_canonicalize_cmake_booleans(
+  CLANG_ENABLE_STATIC_ANALYZER)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@@ -31,11 +34,6 @@ if(CLANG_TOOLS_TEST_USE_VG)
 endif()
 
 set(CLANG_TOOLS_TEST_DEPS
-  # clang-tidy tests require it.
-  clang-headers
-
-  # For the clang-tidy libclang integration test.
-  c-index-test
   # For the clang-apply-replacements test that uses clang-rename.
   clang-rename
 
@@ -47,7 +45,6 @@ set(CLANG_TOOLS_TEST_DEPS
   clang-move
   clang-query
   clang-reorder-fields
-  clang-tidy
   find-all-symbols
   modularize
   pp-trace
@@ -56,6 +53,17 @@ set(CLANG_TOOLS_TEST_DEPS
   ExtraToolsUnitTests
   )
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  list(APPEND CLANG_TOOLS_TEST_DEPS
+# For the clang-tidy libclang integration test.
+c-index-test
+# clang-tidy tests require it.
+clang-headers
+
+clang-tidy
+)
+endif()
+
 set(llvm_utils
   FileCheck count not
   )

Modified: clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp?rev=311983=311982=311983=diff
==
--- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp (original)
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp Mon Aug 28 
22:58:08 2017
@@ -1,23 +1,24 @@
+// REQUIRES: static-analyzer
 // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin 
-Xclang clang-include-fixer -fspell-checking -Xclang 
-plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 
| FileCheck %s
 
 foo f;
 foo g;
 unknown u;
 
-// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 
'foo'?
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Replace [3:1 - 3:4] with "foo"
-// CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the 
missing declaration [clang-include-fixer]
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Insert "#include "foo.h"
 // CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 
'foo'?
 // CHECK: Number FIX-ITs = 1
 // CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo"
 // CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the 
missing declaration 

[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311983: [cmake] Support running extra clang tool tests 
without static analyzer (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D37188?vs=112811=113024#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37188

Files:
  clang-tools-extra/trunk/CMakeLists.txt
  clang-tools-extra/trunk/test/CMakeLists.txt
  clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
  clang-tools-extra/trunk/test/lit.cfg
  clang-tools-extra/trunk/test/lit.site.cfg.in
  clang-tools-extra/trunk/unittests/CMakeLists.txt

Index: clang-tools-extra/trunk/CMakeLists.txt
===
--- clang-tools-extra/trunk/CMakeLists.txt
+++ clang-tools-extra/trunk/CMakeLists.txt
@@ -15,8 +15,7 @@
 add_subdirectory(tool-template)
 
 # Add the common testsuite after all the tools.
-# TODO: Support tests with more granularity when features are off?
-if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_INCLUDE_TESTS)
+if(CLANG_INCLUDE_TESTS)
 add_subdirectory(test)
 add_subdirectory(unittests)
 endif()
Index: clang-tools-extra/trunk/unittests/CMakeLists.txt
===
--- clang-tools-extra/trunk/unittests/CMakeLists.txt
+++ clang-tools-extra/trunk/unittests/CMakeLists.txt
@@ -9,6 +9,8 @@
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
-add_subdirectory(clang-tidy)
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  add_subdirectory(clang-tidy)
+endif()
 add_subdirectory(clangd)
 add_subdirectory(include-fixer)
Index: clang-tools-extra/trunk/test/lit.site.cfg.in
===
--- clang-tools-extra/trunk/test/lit.site.cfg.in
+++ clang-tools-extra/trunk/test/lit.site.cfg.in
@@ -10,6 +10,7 @@
 config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
===
--- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
@@ -1,23 +1,24 @@
+// REQUIRES: static-analyzer
 // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-include-fixer -fspell-checking -Xclang -plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 | FileCheck %s
 
 foo f;
 foo g;
 unknown u;
 
-// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'?
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Replace [3:1 - 3:4] with "foo"
-// CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer]
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Insert "#include "foo.h"
 // CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 'foo'?
 // CHECK: Number FIX-ITs = 1
 // CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo"
 // CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer]
 // CHECK: Number FIX-ITs = 1
 // CHECK: FIX-IT: Insert "#include "foo.h"
-// CHECK: " at 3:1
-// CHECK: yamldb_plugin.cpp:5:1:
+// CHECK: yamldb_plugin.cpp:5:1: error: unknown type name 'foo'; did you mean 'foo'?
+// CHECK: Number FIX-ITs = 1
+// CHECK: FIX-IT: Replace [5:1 - 5:4] with "foo"
+// CHECK: yamldb_plugin.cpp:5:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer]
+// CHECK: Number FIX-ITs = 1
+// CHECK: FIX-IT: Insert "#include "foo.h"
+// CHECK: " at 4:1
+// CHECK: yamldb_plugin.cpp:6:1:
 // CHECK: error: unknown type name 'unknown'
 // CHECK: Number FIX-ITs = 0
 // CHECK-NOT: error
Index: clang-tools-extra/trunk/test/CMakeLists.txt
===
--- clang-tools-extra/trunk/test/CMakeLists.txt
+++ clang-tools-extra/trunk/test/CMakeLists.txt
@@ -15,6 +15,9 @@
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+llvm_canonicalize_cmake_booleans(
+  CLANG_ENABLE_STATIC_ANALYZER)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@@ -31,11 +34,6 @@
 endif()
 
 set(CLANG_TOOLS_TEST_DEPS
-  # clang-tidy tests require it.
-  clang-headers
-
-  # For the clang-tidy libclang integration test.
-  c-index-test
   # For the clang-apply-replacements test that uses clang-rename.
   clang-rename
 
@@ -47,15 +45,25 @@
   clang-move
   clang-query
   clang-reorder-fields
-  clang-tidy
   find-all-symbols
   

[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thanks for the clarification.


Repository:
  rL LLVM

https://reviews.llvm.org/D37188



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


[PATCH] D36057: Use class to pass information about executable name

2017-08-28 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

@echristo Committed, thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D36057



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


[PATCH] D36057: Use class to pass information about executable name

2017-08-28 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311981: Use class to pass information about executable name 
(authored by sepavloff).

Repository:
  rL LLVM

https://reviews.llvm.org/D36057

Files:
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Tooling/Tooling.cpp
  cfe/trunk/tools/driver/driver.cpp
  cfe/trunk/unittests/Driver/CMakeLists.txt
  cfe/trunk/unittests/Driver/ToolChainTest.cpp

Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -190,11 +190,12 @@
 }
 auto TargetMode =
 clang::driver::ToolChain::getTargetAndModeFromProgramName(InvokedAs);
-if (!AlreadyHasMode && !TargetMode.second.empty()) {
-  CommandLine.insert(++CommandLine.begin(), TargetMode.second);
+if (!AlreadyHasMode && TargetMode.DriverMode) {
+  CommandLine.insert(++CommandLine.begin(), TargetMode.DriverMode);
 }
-if (!AlreadyHasTarget && !TargetMode.first.empty()) {
-  CommandLine.insert(++CommandLine.begin(), {"-target", TargetMode.first});
+if (!AlreadyHasTarget && TargetMode.TargetIsValid) {
+  CommandLine.insert(++CommandLine.begin(), {"-target",
+ TargetMode.TargetPrefix});
 }
   }
 }
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -119,9 +119,8 @@
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  auto Default = ToolChain::getTargetAndModeFromProgramName(ProgramName);
-  StringRef DefaultMode(Default.second);
-  setDriverModeFromOption(DefaultMode);
+  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {
 // Ingore nullptrs, they are response file's EOL markers
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -113,7 +113,7 @@
   const char *ModeFlag;
 };
 
-const DriverSuffix *FindDriverSuffix(StringRef ProgName) {
+const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t ) {
   // A list of known driver suffixes. Suffixes are compared against the
   // program name in order. If there is a match, the frontend type is updated as
   // necessary by applying the ModeFlag.
@@ -132,9 +132,13 @@
   {"++", "--driver-mode=g++"},
   };
 
-  for (size_t i = 0; i < llvm::array_lengthof(DriverSuffixes); ++i)
-if (ProgName.endswith(DriverSuffixes[i].Suffix))
+  for (size_t i = 0; i < llvm::array_lengthof(DriverSuffixes); ++i) {
+StringRef Suffix(DriverSuffixes[i].Suffix);
+if (ProgName.endswith(Suffix)) {
+  Pos = ProgName.size() - Suffix.size();
   return [i];
+}
+  }
   return nullptr;
 }
 
@@ -149,55 +153,54 @@
   return ProgName;
 }
 
-const DriverSuffix *parseDriverSuffix(StringRef ProgName) {
+const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t ) {
   // Try to infer frontend type and default target from the program name by
   // comparing it against DriverSuffixes in order.
 
   // If there is a match, the function tries to identify a target as prefix.
   // E.g. "x86_64-linux-clang" as interpreted as suffix "clang" with target
   // prefix "x86_64-linux". If such a target prefix is found, it may be
   // added via -target as implicit first argument.
-  const DriverSuffix *DS = FindDriverSuffix(ProgName);
+  const DriverSuffix *DS = FindDriverSuffix(ProgName, Pos);
 
   if (!DS) {
 // Try again after stripping any trailing version number:
 // clang++3.5 -> clang++
 ProgName = ProgName.rtrim("0123456789.");
-DS = FindDriverSuffix(ProgName);
+DS = FindDriverSuffix(ProgName, Pos);
   }
 
   if (!DS) {
 // Try again after stripping trailing -component.
 // clang++-tot -> clang++
 ProgName = ProgName.slice(0, ProgName.rfind('-'));
-DS = FindDriverSuffix(ProgName);
+DS = FindDriverSuffix(ProgName, Pos);
   }
   return DS;
 }
 } // anonymous namespace
 
-std::pair
+ParsedClangName
 ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
   std::string ProgName = normalizeProgramName(PN);
-  const DriverSuffix *DS = parseDriverSuffix(ProgName);
+  size_t SuffixPos;
+  const DriverSuffix *DS = parseDriverSuffix(ProgName, SuffixPos);
   if (!DS)
-return std::make_pair("", "");
-  std::string ModeFlag = DS->ModeFlag == nullptr ? "" : DS->ModeFlag;
+return ParsedClangName();
+  size_t SuffixEnd = SuffixPos + strlen(DS->Suffix);
 
-  std::string::size_type LastComponent =
- 

[PATCH] D36101: Fix usage of right shift operator in fold expressions

2017-08-28 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete updated this revision to Diff 113020.
Rakete added a comment.

Updated test to use the -std=c++17 option + friendly ping


https://reviews.llvm.org/D36101

Files:
  lib/Parse/ParseExpr.cpp
  test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp


Index: test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
+++ test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+
+// PR32563
+template
+constexpr int right_shift(int value, Ts... args) {
+  return (value >> ... >> args); // expected-no-diagnostics
+}
+
+void test_folds() {
+  static_assert(right_shift(10, 2) == 2);
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -270,7 +270,7 @@
   return Level > prec::Unknown && Level != prec::Conditional;
 }
 static bool isFoldOperator(tok::TokenKind Kind) {
-  return isFoldOperator(getBinOpPrecedence(Kind, false, true));
+  return isFoldOperator(getBinOpPrecedence(Kind, true, true));
 }
 
 /// \brief Parse a binary expression that starts with \p LHS and has a


Index: test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
+++ test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+
+// PR32563
+template
+constexpr int right_shift(int value, Ts... args) {
+  return (value >> ... >> args); // expected-no-diagnostics
+}
+
+void test_folds() {
+  static_assert(right_shift(10, 2) == 2);
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -270,7 +270,7 @@
   return Level > prec::Unknown && Level != prec::Conditional;
 }
 static bool isFoldOperator(tok::TokenKind Kind) {
-  return isFoldOperator(getBinOpPrecedence(Kind, false, true));
+  return isFoldOperator(getBinOpPrecedence(Kind, true, true));
 }
 
 /// \brief Parse a binary expression that starts with \p LHS and has a
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311981 - Use class to pass information about executable name

2017-08-28 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Mon Aug 28 22:22:26 2017
New Revision: 311981

URL: http://llvm.org/viewvc/llvm-project?rev=311981=rev
Log:
Use class to pass information about executable name

Information about clang executable name components, such as target and
driver mode, was passes in std::pair. With this change it is passed in
a special structure. It improves readability and makes access to this
information more convenient.

NFC.

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

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/tools/driver/driver.cpp
cfe/trunk/unittests/Driver/CMakeLists.txt
cfe/trunk/unittests/Driver/ToolChainTest.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=311981=311980=311981=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Mon Aug 28 22:22:26 2017
@@ -129,6 +129,9 @@ public:
   /// The original path to the clang executable.
   std::string ClangExecutable;
 
+  /// Target and driver mode components extracted from clang executable name.
+  ParsedClangName ClangNameParts;
+
   /// The path to the installed clang directory, if any.
   std::string InstalledDir;
 
@@ -284,6 +287,8 @@ public:
 
   void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
 
+  void setTargetAndMode(const ParsedClangName ) { ClangNameParts = TM; }
+
   const std::string () { return DriverTitle; }
   void setTitle(std::string Value) { DriverTitle = std::move(Value); }
 

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=311981=311980=311981=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Aug 28 22:22:26 2017
@@ -46,6 +46,28 @@ namespace driver {
   class Tool;
   class XRayArgs;
 
+/// Helper structure used to pass information extracted from clang executable
+/// name such as `i686-linux-android-g++`.
+///
+struct ParsedClangName {
+  /// Target part of the executable name, as `i686-linux-android`.
+  std::string TargetPrefix;
+  /// Driver mode part of the executable name, as `g++`.
+  std::string ModeSuffix;
+  /// Corresponding driver mode argument, as '--driver-mode=g++'
+  const char *DriverMode;
+  /// True if TargetPrefix is recognized as a registered target name.
+  bool TargetIsValid;
+
+  ParsedClangName() : DriverMode(nullptr), TargetIsValid(false) {}
+  ParsedClangName(std::string Suffix, const char *Mode)
+  : ModeSuffix(Suffix), DriverMode(Mode), TargetIsValid(false) {}
+  ParsedClangName(std::string Target, std::string Suffix, const char *Mode,
+  bool IsRegistered)
+  : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
+TargetIsValid(IsRegistered) {}
+};
+
 /// ToolChain - Access to tools for a single platform.
 class ToolChain {
 public:
@@ -193,13 +215,16 @@ public:
   /// For example, when called with i686-linux-android-g++, the first element
   /// of the return value will be set to `"i686-linux-android"` and the second
   /// will be set to "--driver-mode=g++"`.
+  /// It is OK if the target name is not registered. In this case the return
+  /// value contains false in the field TargetIsValid.
   ///
   /// \pre `llvm::InitializeAllTargets()` has been called.
   /// \param ProgName The name the Clang driver was invoked with (from,
-  /// e.g., argv[0])
-  /// \return A pair of (`target`, `mode-flag`), where one or both may be 
empty.
-  static std::pair
-  getTargetAndModeFromProgramName(StringRef ProgName);
+  /// e.g., argv[0]).
+  /// \return A structure of type ParsedClangName that contains the executable
+  /// name parts.
+  ///
+  static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
 
   // Tool access.
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=311981=311980=311981=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Aug 28 22:22:26 2017
@@ -119,9 +119,8 @@ Driver::Driver(StringRef ClangExecutable
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  auto Default = ToolChain::getTargetAndModeFromProgramName(ProgramName);
-  StringRef DefaultMode(Default.second);
-  setDriverModeFromOption(DefaultMode);
+  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  

[PATCH] D37249: [Bash-autocomplete] Refactor autocomplete code into own function

2017-08-28 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi created this revision.

We wrote many codes in HandleImediateArgs, so I've refactored it into
handleAutocompletions.


https://reviews.llvm.org/D37249

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp

Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1157,6 +1157,57 @@
 OS << i << ',' << DiagnosticIDs::getCategoryNameFromID(i) << '\n';
 }
 
+void Driver::handleAutocompletions(const llvm::opt::Arg *A) const {
+  // Print out all options that start with a given argument. This is used for
+  // shell autocompletion.
+  StringRef PassedFlags = A->getValue();
+  std::vector SuggestedCompletions;
+
+  unsigned short DisableFlags =
+  options::NoDriverOption | options::Unsupported | options::Ignored;
+  // We want to show cc1-only options only when clang is invoked as "clang
+  // -cc1".
+  // When clang is invoked as "clang -cc1", we add "#" to the beginning of an
+  // --autocomplete
+  // option so that the clang driver can distinguish whether it is requested to
+  // show cc1-only options or not.
+  if (PassedFlags[0] == '#') {
+DisableFlags &= ~options::NoDriverOption;
+PassedFlags = PassedFlags.substr(1);
+  }
+
+  if (PassedFlags.find(',') == StringRef::npos) {
+// 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".
+SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+// We have to query the -W flags manually as they're not in the OptTable.
+// TODO: Find a good way to add them to OptTable instead and them remove
+// this code.
+for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+  if (S.startswith(PassedFlags))
+SuggestedCompletions.push_back(S);
+  } else {
+// 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++".
+StringRef Option, Arg;
+std::tie(Option, Arg) = PassedFlags.split(',');
+SuggestedCompletions = Opts->suggestValueCompletions(Option, Arg);
+  }
+
+  // Sort the autocomplete candidates so that shells print them out in a
+  // deterministic order. We could sort in any way, but we chose
+  // case-insensitive sorting for consistency with the -help option
+  // which prints out options in the case-insensitive alphabetical order.
+  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
+[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+
+  llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
+}
+
 bool Driver::HandleImmediateArgs(const Compilation ) {
   // The order these options are handled in gcc is all over the place, but we
   // don't expect inconsistencies w.r.t. that to matter in practice.
@@ -1250,50 +1301,7 @@
   }
 
   if (Arg *A = C.getArgs().getLastArg(options::OPT_autocomplete)) {
-// Print out all options that start with a given argument. This is used for
-// shell autocompletion.
-StringRef PassedFlags = A->getValue();
-std::vector SuggestedCompletions;
-
-unsigned short DisableFlags = options::NoDriverOption | options::Unsupported | options::Ignored;
-// We want to show cc1-only options only when clang is invoked as "clang -cc1".
-// When clang is invoked as "clang -cc1", we add "#" to the beginning of an --autocomplete
-// option so that the clang driver can distinguish whether it is requested to show cc1-only options or not.
-if (PassedFlags[0] == '#') {
-  DisableFlags &= ~options::NoDriverOption;
-  PassedFlags = PassedFlags.substr(1);
-}
-
-if (PassedFlags.find(',') == StringRef::npos) {
-  // 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".
-  SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
-
-  // We have to query the -W flags manually as they're not in the OptTable.
-  // TODO: Find a good way to add them to OptTable instead and them remove
-  // this code.
-  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
-if (S.startswith(PassedFlags))
-  SuggestedCompletions.push_back(S);
-} else {
-  // 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++".
-  StringRef Option, Arg;
-  std::tie(Option, Arg) = PassedFlags.split(',');
-  

[PATCH] D37203: [Bash-autocompletion] Follow up patch for D36782

2017-08-28 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi abandoned this revision.
yamaguchi added a comment.

https://reviews.llvm.org/D37217 has already landed, so we don't need this 
anymore.


https://reviews.llvm.org/D37203



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


r311975 - revert r311839 (ongoing cwg discussion)

2017-08-28 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon Aug 28 20:04:13 2017
New Revision: 311975

URL: http://llvm.org/viewvc/llvm-project?rev=311975=rev
Log:
revert r311839 (ongoing cwg discussion)

apologies.

Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/SemaCXX/member-expr.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=311975=311974=311975=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Mon Aug 28 20:04:13 2017
@@ -243,6 +243,7 @@ Sema::BuildPossibleImplicitMemberExpr(co
 return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, true, 
S);
 
   case IMA_Mixed:
+  case IMA_Mixed_Unrelated:
   case IMA_Unresolved:
 return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, false,
S);
@@ -251,7 +252,6 @@ Sema::BuildPossibleImplicitMemberExpr(co
 Diag(R.getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)
   << R.getLookupNameInfo().getName();
 // Fall through.
-  case IMA_Mixed_Unrelated:
   case IMA_Static:
   case IMA_Abstract:
   case IMA_Mixed_StaticContext:

Modified: cfe/trunk/test/SemaCXX/member-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr.cpp?rev=311975=311974=311975=diff
==
--- cfe/trunk/test/SemaCXX/member-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-expr.cpp Mon Aug 28 20:04:13 2017
@@ -228,25 +228,3 @@ namespace pr16676 {
 .i;  // expected-error {{member reference type 'pr16676::S *' is a 
pointer; did you mean to use '->'}}
   }
 }
-
-namespace unrelated_class_instance_call_should_be_illformed {
-
-
-struct A {
-  void bar(int) { }
-  static void bar(double) { }
-  
-  void g(int*);
-  static void g(char *);
-};
-
-
-struct B {
-  void f() {
-A::bar(3);  //expected-error{{call to non-static member}}
-A::g((int*)0); //expected-error{{call to non-static member}}
-  }
-};
-
-
-} // ns unrelated_class_mixed_static_nonstatic_call_should_be_illformed


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


r311971 - [Bash-autocompletion] Add support for -std=

2017-08-28 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Mon Aug 28 19:01:56 2017
New Revision: 311971

URL: http://llvm.org/viewvc/llvm-project?rev=311971=rev
Log:
[Bash-autocompletion] Add support for -std=

Summary:
Add support for autocompleting values of -std= by including
LangStandards.def. This patch relies on D36782, and is using two-stage
code generation.

Reviewers: v.g.vassilev, teemperor, ruiu

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/autocomplete.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=311971=311970=311971=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Aug 28 19:01:56 2017
@@ -2270,7 +2270,14 @@ def static_libstdcxx : Flag<["-"], "stat
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
-  Group, HelpText<"Language standard to compile for">;
+  Group, HelpText<"Language standard to compile for">,
+  ValuesCode<[{
+const char *Values =
+#define LANGSTANDARD(id, name, lang, desc, features) name ","
+#define LANGSTANDARD_ALIAS(id, alias) alias ","
+#include "clang/Frontend/LangStandards.def"
+;
+  }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;

Modified: cfe/trunk/test/Driver/autocomplete.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=311971=311970=311971=diff
==
--- cfe/trunk/test/Driver/autocomplete.c (original)
+++ cfe/trunk/test/Driver/autocomplete.c Mon Aug 28 19:01:56 2017
@@ -95,3 +95,5 @@
 // NOWARNING: -Wno-invalid-pp-token
 // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s 
-check-prefix=ANALYZER
 // ANALYZER: unix.Malloc
+// RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL
+// STDVAL: c99


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


[PATCH] D36820: [Bash-autocompletion] Add support for -std=

2017-08-28 Thread Yuka Takahashi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311971: [Bash-autocompletion] Add support for -std= 
(authored by yamaguchi).

Changed prior to commit:
  https://reviews.llvm.org/D36820?vs=111804=113009#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36820

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/test/Driver/autocomplete.c
  llvm/trunk/utils/TableGen/OptParserEmitter.cpp


Index: llvm/trunk/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/trunk/utils/TableGen/OptParserEmitter.cpp
+++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp
@@ -308,11 +308,11 @@
 if (isa(R.getValueInit("ValuesCode")))
   continue;
 OS << "{\n";
+OS << "bool ValuesWereAdded;\n";
 OS << R.getValueAsString("ValuesCode");
 OS << "\n";
 for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-  OS << "bool ValuesWereAdded = ";
-  OS << "Opt.addValues(";
+  OS << "ValuesWereAdded = Opt.addValues(";
   std::string S = (Pref + R.getValueAsString("Name")).str();
   write_cstring(OS, S);
   OS << ", Values);\n";
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2270,7 +2270,14 @@
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
-  Group, HelpText<"Language standard to compile for">;
+  Group, HelpText<"Language standard to compile for">,
+  ValuesCode<[{
+const char *Values =
+#define LANGSTANDARD(id, name, lang, desc, features) name ","
+#define LANGSTANDARD_ALIAS(id, alias) alias ","
+#include "clang/Frontend/LangStandards.def"
+;
+  }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;
Index: cfe/trunk/test/Driver/autocomplete.c
===
--- cfe/trunk/test/Driver/autocomplete.c
+++ cfe/trunk/test/Driver/autocomplete.c
@@ -95,3 +95,5 @@
 // NOWARNING: -Wno-invalid-pp-token
 // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s 
-check-prefix=ANALYZER
 // ANALYZER: unix.Malloc
+// RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL
+// STDVAL: c99


Index: llvm/trunk/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/trunk/utils/TableGen/OptParserEmitter.cpp
+++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp
@@ -308,11 +308,11 @@
 if (isa(R.getValueInit("ValuesCode")))
   continue;
 OS << "{\n";
+OS << "bool ValuesWereAdded;\n";
 OS << R.getValueAsString("ValuesCode");
 OS << "\n";
 for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-  OS << "bool ValuesWereAdded = ";
-  OS << "Opt.addValues(";
+  OS << "ValuesWereAdded = Opt.addValues(";
   std::string S = (Pref + R.getValueAsString("Name")).str();
   write_cstring(OS, S);
   OS << ", Values);\n";
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2270,7 +2270,14 @@
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
-  Group, HelpText<"Language standard to compile for">;
+  Group, HelpText<"Language standard to compile for">,
+  ValuesCode<[{
+const char *Values =
+#define LANGSTANDARD(id, name, lang, desc, features) name ","
+#define LANGSTANDARD_ALIAS(id, alias) alias ","
+#include "clang/Frontend/LangStandards.def"
+;
+  }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;
Index: cfe/trunk/test/Driver/autocomplete.c
===
--- cfe/trunk/test/Driver/autocomplete.c
+++ cfe/trunk/test/Driver/autocomplete.c
@@ -95,3 +95,5 @@
 // NOWARNING: -Wno-invalid-pp-token
 // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER
 // ANALYZER: unix.Malloc
+// RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL
+// STDVAL: c99
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311970 - Improve constant expression evaluation of arrays of unknown bound.

2017-08-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 28 18:52:13 2017
New Revision: 311970

URL: http://llvm.org/viewvc/llvm-project?rev=311970=rev
Log:
Improve constant expression evaluation of arrays of unknown bound.

The standard is not clear on how these are supposed to be handled, so we
conservatively treat as non-constant any cases whose value is unknown or whose
evaluation might result in undefined behavior.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=311970=311969=311970=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Mon Aug 28 18:52:13 2017
@@ -127,6 +127,10 @@ def note_constexpr_access_null : Note<
 def note_constexpr_access_past_end : Note<
   "%select{read of|assignment to|increment of|decrement of}0 "
   "dereferenced one-past-the-end pointer is not allowed in a constant 
expression">;
+def note_constexpr_access_unsized_array : Note<
+  "%select{read of|assignment to|increment of|decrement of}0 "
+  "pointer to element of array without known bound "
+  "is not allowed in a constant expression">;
 def note_constexpr_access_inactive_union_member : Note<
   "%select{read of|assignment to|increment of|decrement of}0 "
   "member %1 of union with %select{active member %3|no active member}2 "
@@ -154,6 +158,11 @@ def note_constexpr_baa_insufficient_alig
 def note_constexpr_baa_value_insufficient_alignment : Note<
   "value of the aligned pointer (%0) is not a multiple of the asserted %1 "
   "%plural{1:byte|:bytes}1">;
+def note_constexpr_unsupported_unsized_array : Note<
+  "array-to-pointer decay of array member without known bound is not 
supported">;
+def note_constexpr_unsized_array_indexed : Note<
+  "indexing of array without known bound is not allowed "
+  "in a constant expression">;
 
 def warn_integer_constant_overflow : Warning<
   "overflow in expression; result is %0 with type %1">,

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=311970=311969=311970=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Mon Aug 28 18:52:13 2017
@@ -34,7 +34,7 @@ namespace clang {
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,
   DIAG_SIZE_PARSE =  500,
-  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_AST   =  150,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_SEMA  = 3500,
   DIAG_SIZE_ANALYSIS  =  100

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=311970=311969=311970=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Aug 28 18:52:13 2017
@@ -141,6 +141,12 @@ namespace {
 return E && E->getType()->isPointerType() && tryUnwrapAllocSizeCall(E);
   }
 
+  /// The bound to claim that an array of unknown bound has.
+  /// The value in MostDerivedArraySize is undefined in this case. So, set it
+  /// to an arbitrary value that's likely to loudly break things if it's used.
+  static const uint64_t AssumedSizeForUnsizedArray =
+  std::numeric_limits::max() / 2;
+
   /// Determines if an LValue with the given LValueBase will have an unsized
   /// array in its designator.
   /// Find the path length and type of the most-derived subobject in the given
@@ -148,7 +154,8 @@ namespace {
   static unsigned
   findMostDerivedSubobject(ASTContext , APValue::LValueBase Base,
ArrayRef Path,
-   uint64_t , QualType , bool ) 
{
+   uint64_t , QualType , bool ,
+   bool ) {
 // This only accepts LValueBases from APValues, and APValues don't support
 // arrays that lack size info.
 assert(!isBaseAnAllocSizeCall(Base) &&
@@ -158,12 +165,18 @@ namespace {
 
 for (unsigned I = 0, N = Path.size(); I != N; ++I) {
   if (Type->isArrayType()) {
-const ConstantArrayType *CAT =
-cast(Ctx.getAsArrayType(Type));
-Type = CAT->getElementType();
-ArraySize = CAT->getSize().getZExtValue();
+const ArrayType *AT = Ctx.getAsArrayType(Type);
+Type = AT->getElementType();
 MostDerivedLength = I + 1;
 IsArray = true;
+
+if (auto *CAT = dyn_cast(AT)) {
+  

[libcxx] r311967 - Fix test for C++03

2017-08-28 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Aug 28 18:10:51 2017
New Revision: 311967

URL: http://llvm.org/viewvc/llvm-project?rev=311967=rev
Log:
Fix test for C++03

Modified:

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

Modified: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp?rev=311967=311966=311967=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
 Mon Aug 28 18:10:51 2017
@@ -127,11 +127,12 @@ void test_PR31166 ()
 {
 typedef std::pair P;
 typedef std::vector V;
-const V vec {{1, 0}, {2, 0}, {2, 1}, {2, 2}, {2, 3}};
+P vec[5] = {P(1, 0), P(2, 0), P(2, 1), P(2, 2), P(2, 3)};
 for ( int i = 0; i < 5; ++i ) {
-V res = vec;
+V res(vec, vec + 5);
 std::inplace_merge(res.begin(), res.begin() + i, res.end(), 
less_by_first());
-assert(res == vec);
+assert(res.size() == 5);
+assert(std::equal(res.begin(), res.end(), vec));
 }
 }
 


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


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

2017-08-28 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

In https://reviews.llvm.org/D36527#854883, @faisalv wrote:

>




> Interestingly we don't (explicitly) visit the lambda's function parameters?

This is obviously false - sorry :)


https://reviews.llvm.org/D36527



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


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

2017-08-28 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

In https://reviews.llvm.org/D36527#854600, @rsmith wrote:

> This patch appears to be missing some necessary changes in the following 
> places:
>
> - lib/Serialization -- round-trip the new information through PCH / modules


Shouldn't the explicit template parameter information be automatically 
serialized within the non-implicitness of the corresponding template parameter 
decls within our TemplateParameterList?

> - lib/AST/StmtPrinter.cpp -- pretty-printing lambdas with explicit template 
> parameters

yes - this would be nice.

> - lib/Sema/TreeTransform.h -- template instantiation of lambdas with explicit 
> template arguments

yes - i had wondered about TreeTransform - I had hoped that the transformation 
of the template parameter list (for all generic lambdas) would be sufficient 
(perhaps only need to be tweaked to maintain the implicit flag on template 
parameters, if that's not transferred through?) - but I agree this does need to 
be tested well (substitution into default template arguments, non-type-template 
parameters for e.g.).

> - lib/AST/RecursiveASTVisitor.h -- recursive AST visitation should visit 
> explicit template parameters

Would we also want to (explicitly) visit the implicit template parameters?
Interestingly we don't (explicitly) visit the lambda's function parameters?

> We'll also need to agree within the cxx-abi-dev list how to mangle lambda 
> closure types for this form and lib/AST/ItaniumMangle.cpp's `mangleLambda` 
> will need to be updated to match. (The MS mangling is not based on the type 
> of the lambda call operator, so we probably don't need changes there.)




https://reviews.llvm.org/D36527



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


[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning

2017-08-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Dumping the whole module, the temporary DICompositeType node for CBdVfsImpl is 
used both as the scope node for the DISubprogram, and also as the baseType of a 
DIDerivedType which is a pointer type in the type list for the subprogram.

Given that the DICompositeType is a scope for the method, but is still marked 
as a forward declaration, I'm guessing that the composite type will be expanded 
into a full type, but that apparently happens after codegen for its methods.  
So, it would be premature to finalize the metadata node at this point?


https://reviews.llvm.org/D37038



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


[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D37188#854144, @mgorny wrote:

> I might be missing something but currently clang-tidy is not built at all 
> when static analyzer is disabled.


Yes, but it could be built except for the parts that actually need the static 
analyzer. As I've said, this would require careful surgery of ClangTidy.cpp and 
of some other files.

We can do that later.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D37188



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


[PATCH] D36057: Use class to pass information about executable name

2017-08-28 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Fine with me.

-eric


https://reviews.llvm.org/D36057



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


Re: r310905 - Avoid PointerIntPair of constexpr EvalInfo structs

2017-08-28 Thread David Blaikie via cfe-commits
On Mon, Aug 28, 2017 at 5:21 PM Reid Kleckner  wrote:

> On Mon, Aug 28, 2017 at 5:02 PM, David Blaikie  wrote:
>
>> Feels like this alignment attribute may be a bit of a death trap, then?
>> Should other uses of the attribute be scrutinized, or could we come up with
>> a portable way to use it safely? (using a different attribute on different
>> compilers - sounded like maybe one form worked with MSVC and a different
>> form worked with GCC? Maybe the attribute could be improved to use those as
>> appropriate?)
>>
>
> I never was able to reproduce the user issue, so I have very little
> information. I have a hard time believing that mingw32 gcc miscompiles all
> alignment attributes. There must have been something funny about our usage
> of it in ExprConstant.cpp that triggered the bug. In the unlikely case that
> we hit it again, hopefully the next user that hits the bug will provide
> more information about what went wrong.
>

Hrm - I really don't like the idea of making changes without really
understanding what's being addressed. :/

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


Re: r310905 - Avoid PointerIntPair of constexpr EvalInfo structs

2017-08-28 Thread Reid Kleckner via cfe-commits
On Mon, Aug 28, 2017 at 5:02 PM, David Blaikie  wrote:

> Feels like this alignment attribute may be a bit of a death trap, then?
> Should other uses of the attribute be scrutinized, or could we come up with
> a portable way to use it safely? (using a different attribute on different
> compilers - sounded like maybe one form worked with MSVC and a different
> form worked with GCC? Maybe the attribute could be improved to use those as
> appropriate?)
>

I never was able to reproduce the user issue, so I have very little
information. I have a hard time believing that mingw32 gcc miscompiles all
alignment attributes. There must have been something funny about our usage
of it in ExprConstant.cpp that triggered the bug. In the unlikely case that
we hit it again, hopefully the next user that hits the bug will provide
more information about what went wrong.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311958 - Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"

2017-08-28 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Mon Aug 28 17:09:31 2017
New Revision: 311958

URL: http://llvm.org/viewvc/llvm-project?rev=311958=rev
Log:
Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer 
flags"

This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e.

r311552 broke lld buildbot because I've changed OptionInfos type from
ArrayRef to vector. However the bug is fixed, so I'll commit this again.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/DriverOptions.cpp
cfe/trunk/test/Driver/autocomplete.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=311958=311957=311958=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 28 17:09:31 2017
@@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz
   HelpText<"Print internal analyzer statistics.">;
 
 def analyzer_checker : Separate<["-"], "analyzer-checker">,
-  HelpText<"Choose analyzer checkers to enable">;
+  HelpText<"Choose analyzer checkers to enable">,
+  ValuesCode<[{
+const char *Values =
+#define GET_CHECKERS
+#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H)  FULLNAME ","
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef GET_CHECKERS
+#define GET_PACKAGES
+#define PACKAGE(FULLNAME, G, D)  FULLNAME ","
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef GET_PACKAGES
+;
+  }]>;
 def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">,
   Alias;
 

Modified: cfe/trunk/lib/Driver/DriverOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/DriverOptions.cpp?rev=311958=311957=311958=diff
==
--- cfe/trunk/lib/Driver/DriverOptions.cpp (original)
+++ cfe/trunk/lib/Driver/DriverOptions.cpp Mon Aug 28 17:09:31 2017
@@ -11,6 +11,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include 
 
 using namespace clang::driver;
 using namespace clang::driver::options;
@@ -40,5 +41,13 @@ public:
 }
 
 std::unique_ptr clang::driver::createDriverOptTable() {
-  return llvm::make_unique();
+  auto Result = llvm::make_unique();
+  // Options.inc is included in DriverOptions.cpp, and calls OptTable's
+  // addValues function.
+  // Opt is a variable used in the code fragment in Options.inc.
+  OptTable  = *Result;
+#define OPTTABLE_ARG_INIT
+#include "clang/Driver/Options.inc"
+#undef OPTTABLE_ARG_INIT
+  return std::move(Result);
 }

Modified: cfe/trunk/test/Driver/autocomplete.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=311958=311957=311958=diff
==
--- cfe/trunk/test/Driver/autocomplete.c (original)
+++ cfe/trunk/test/Driver/autocomplete.c Mon Aug 28 17:09:31 2017
@@ -93,3 +93,5 @@
 // WARNING-NEXT: -Wmax-unsigned-zero
 // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s 
-check-prefix=NOWARNING
 // NOWARNING: -Wno-invalid-pp-token
+// RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s 
-check-prefix=ANALYZER
+// ANALYZER: unix.Malloc


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


Re: r310905 - Avoid PointerIntPair of constexpr EvalInfo structs

2017-08-28 Thread David Blaikie via cfe-commits
Feels like this alignment attribute may be a bit of a death trap, then?
Should other uses of the attribute be scrutinized, or could we come up with
a portable way to use it safely? (using a different attribute on different
compilers - sounded like maybe one form worked with MSVC and a different
form worked with GCC? Maybe the attribute could be improved to use those as
appropriate?)

On Mon, Aug 14, 2017 at 6:18 PM Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Mon Aug 14 18:17:47 2017
> New Revision: 310905
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310905=rev
> Log:
> Avoid PointerIntPair of constexpr EvalInfo structs
>
> They are stack allocated, so their alignment is not to be trusted.
> 32-bit MSVC only guarantees 4 byte stack alignment, even though alignof
> would tell you otherwise. I tried fixing this with __declspec align, but
> that apparently upsets GCC. Hopefully this version will satisfy all
> compilers.
>
> See PR32018 for some info about the mingw issues.
>
> Should supercede https://reviews.llvm.org/D34873
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=310905=310904=310905=diff
>
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Aug 14 18:17:47 2017
> @@ -537,7 +537,7 @@ namespace {
>/// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We
> can
>/// evaluate the expression regardless of what the RHS is, but C only
> allows
>/// certain things in certain situations.
> -  struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EvalInfo {
> +  struct EvalInfo {
>  ASTContext 
>
>  /// EvalStatus - Contains information about the evaluation.
> @@ -977,24 +977,22 @@ namespace {
>/// RAII object used to optionally suppress diagnostics and
> side-effects from
>/// a speculative evaluation.
>class SpeculativeEvaluationRAII {
> -/// Pair of EvalInfo, and a bit that stores whether or not we were
> -/// speculatively evaluating when we created this RAII.
> -llvm::PointerIntPair InfoAndOldSpecEval;
> -Expr::EvalStatus Old;
> +EvalInfo *Info;
> +Expr::EvalStatus OldStatus;
> +bool OldIsSpeculativelyEvaluating;
>
>  void moveFromAndCancel(SpeculativeEvaluationRAII &) {
> -  InfoAndOldSpecEval = Other.InfoAndOldSpecEval;
> -  Old = Other.Old;
> -  Other.InfoAndOldSpecEval.setPointer(nullptr);
> +  Info = Other.Info;
> +  OldStatus = Other.OldStatus;
> +  Other.Info = nullptr;
>  }
>
>  void maybeRestoreState() {
> -  EvalInfo *Info = InfoAndOldSpecEval.getPointer();
>if (!Info)
>  return;
>
> -  Info->EvalStatus = Old;
> -  Info->IsSpeculativelyEvaluating = InfoAndOldSpecEval.getInt();
> +  Info->EvalStatus = OldStatus;
> +  Info->IsSpeculativelyEvaluating = OldIsSpeculativelyEvaluating;
>  }
>
>public:
> @@ -1002,8 +1000,8 @@ namespace {
>
>  SpeculativeEvaluationRAII(
>  EvalInfo , SmallVectorImpl *NewDiag =
> nullptr)
> -: InfoAndOldSpecEval(, Info.IsSpeculativelyEvaluating),
> -  Old(Info.EvalStatus) {
> +: Info(), OldStatus(Info.EvalStatus),
> +  OldIsSpeculativelyEvaluating(Info.IsSpeculativelyEvaluating) {
>Info.EvalStatus.Diag = NewDiag;
>Info.IsSpeculativelyEvaluating = true;
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-08-28 Thread Richard Smith via cfe-commits
On 28 August 2017 at 13:47, Akira Hatanaka via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> clang currently rejects "void foo(int = a);"  and so does gcc.
>
> I'm trying to search the defect reports, but it looks like the c++
> standard's site is currently unreachable.


It's http://lists.isocpp.org/core/2017/04/2108.php, but that's too recent
for the latest issues list (
http://wiki.edg.com/pub/Wg21albuquerque/CoreWorkingGroup/cwg_active.html).
(Apologies for the committee-internal links; as you say, the public site is
down.)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D37235: Let -Wdelete-non-virtual-dtor fire in system headers too.

2017-08-28 Thread Nico Weber via cfe-commits
On Mon, Aug 28, 2017 at 7:40 PM, Richard Smith - zygoloid via Phabricator
via cfe-commits  wrote:

> rsmith added inline comments.
>
>
> 
> Comment at: test/SemaCXX/destructor.cpp:27
> +#define BE_THE_HEADER
> +#include __FILE__
> +
> 
> Do we guarantee that `__FILE__` names a path that can be used to include
> the current file? In other tests, we add `-include %s` to the `RUN:` line
> to model this situation.
>

 `ack 'include __FILE__' test` finds plenty of hits at least, this is a
somewhat common pattern. (As far as I can remember, introduced by you :-)
-- I might be misremembering though.)


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


[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning

2017-08-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D37038#854722, @probinson wrote:

> finalizeSubprogram() retrieves the variables from the subprogram and handles 
> them; what is it missing?


For temp-md-nodes2.cpp, the assertion in mapTopLevelUniquedNode() trips on a 
DICompositeType for CBdVfsImpl.  This appears to be the "scope" operand of the 
(distinct) DISubprogram for "ReqCacheHint" which is the function being cloned.

For temp-md-nodes1.cpp, the assertion in visitOperands() trips on a 
DICompositeType for "Charlie" but I haven't worked out where it's used yet.  Is 
there a straightforward way to dump all the metadata for a function?  Calling 
`print()` or 'dump()` just does the one node.


https://reviews.llvm.org/D37038



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


Re: [PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-28 Thread David Blaikie via cfe-commits
On Fri, Aug 18, 2017 at 6:59 PM Stephan T. Lavavej via Phabricator via
cfe-commits  wrote:

> STL_MSFT added a comment.
>
> In https://reviews.llvm.org/D36860#846232, @thakis wrote:
>
> > Many driver tests check in a basic representative directory structure
> (e.g. test/Driver/Inputs/basic_freebsd_tree/ and its many siblings).
> >
> > But if you're happy with others breaking this code, I suppose having no
> tests is ok; I imagine most people won't use this code :-)
>
>
> I can't check in copies of `cl.exe` and `link.exe` (the former's version
> is inspected, so it can't just be a dummy file).


Version as in file metadata, or version as in "cl -v" printed output or the
like?

If it's file metadata (such that Clang can discover it without having to
run the binary on a test machine) might be worth making a dummy file with
just the version metadata in it.

But yeah *shrug* your call


> I'm happy without upstream tests for this logic. In the long run, I hope
> that we can eliminate this internal directory structure and make it
> identical to the released directory structure.
>
>
> https://reviews.llvm.org/D36860
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r311601 - Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be

2017-08-28 Thread David Blaikie via cfe-commits
*nod* Thanks - let me know if you have trouble simplifying or explaining it
& I'll see if fresh eyes help :)

On Mon, Aug 28, 2017 at 4:46 PM Adrian Prantl  wrote:

> It's possible that this testcase can be golfed some more. I copied it
> almost verbatim from the PR. I'll see what I can do. The important thing is
> that it needs to trigger the situation where the frontend is creating an
> inlined function.
>
> -- adrian
>
> On Aug 28, 2017, at 4:43 PM, David Blaikie  wrote:
>
> Seems like a rather complex test case - could you explain what's going on
> there? (maybe in the form of a comment in the code - what path through all
> those classes is required to tickle this)
>
> On Wed, Aug 23, 2017 at 2:25 PM Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Wed Aug 23 14:24:12 2017
>> New Revision: 311601
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=311601=rev
>> Log:
>> Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to
>> be
>> parented in function declarations.
>>
>> Fixes PR33997.
>> https://bugs.llvm.org/show_bug.cgi?id=33997
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601=311600=311601=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 23 14:24:12 2017
>> @@ -3287,7 +3287,7 @@ void CGDebugInfo::EmitInlineFunctionStar
>>llvm::DISubprogram *SP = nullptr;
>>if (FI != SPCache.end())
>>  SP = dyn_cast_or_null(FI->second);
>> -  if (!SP)
>> +  if (!SP || !SP->isDefinition())
>>  SP = getFunctionStub(GD);
>>FnBeginRegionCount.push_back(LexicalBlockStack.size());
>>LexicalBlockStack.emplace_back(SP);
>>
>> Added: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601=auto
>>
>> ==
>> --- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (added)
>> +++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 23 14:24:12
>> 2017
>> @@ -0,0 +1,45 @@
>> +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213
>> -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
>> +// PR33997.
>> +struct already_AddRefed {
>> +  ~already_AddRefed();
>> +};
>> +struct RefPtr {
>> +  operator int *();
>> +};
>> +struct ServoCssRulesStrong {
>> +  already_AddRefed Consume();
>> +};
>> +struct GroupRule {
>> +  GroupRule(already_AddRefed);
>> +};
>> +class ConditionRule : GroupRule {
>> +  using GroupRule::GroupRule;
>> +};
>> +class CSSMediaRule : ConditionRule {
>> +  using ConditionRule::ConditionRule;
>> +};
>> +class CSSMozDocumentRule : ConditionRule {
>> +  using ConditionRule::ConditionRule;
>> +};
>> +class ServoDocumentRule : CSSMozDocumentRule {
>> +  ServoDocumentRule(RefPtr);
>> +};
>> +class ServoMediaRule : CSSMediaRule {
>> +  ServoMediaRule(RefPtr);
>> +};
>> +ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
>> +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
>> +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
>> +:
>> CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
>> +
>> +ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
>> +: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
>> +
>> +// CHECK: define{{.*}}ServoMediaRule
>> +// CHECK-NOT: {{ ret }}
>> +// CHECK: store %class.ConditionRule* %
>> +// CHECK-SAME: %class.ConditionRule** %
>> +// CHECK-SAME: !dbg ![[INL:[0-9]+]]
>> +
>> +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]],
>> inlinedAt:
>> +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule",
>> {{.*}}isDefinition: true
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r311601 - Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be

2017-08-28 Thread Adrian Prantl via cfe-commits
It's possible that this testcase can be golfed some more. I copied it almost 
verbatim from the PR. I'll see what I can do. The important thing is that it 
needs to trigger the situation where the frontend is creating an inlined 
function.

-- adrian
> On Aug 28, 2017, at 4:43 PM, David Blaikie  wrote:
> 
> Seems like a rather complex test case - could you explain what's going on 
> there? (maybe in the form of a comment in the code - what path through all 
> those classes is required to tickle this)
> 
> On Wed, Aug 23, 2017 at 2:25 PM Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Wed Aug 23 14:24:12 2017
> New Revision: 311601
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=311601=rev 
> 
> Log:
> Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be
> parented in function declarations.
> 
> Fixes PR33997.
> https://bugs.llvm.org/show_bug.cgi?id=33997 
> 
> 
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601=311600=311601=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 23 14:24:12 2017
> @@ -3287,7 +3287,7 @@ void CGDebugInfo::EmitInlineFunctionStar
>llvm::DISubprogram *SP = nullptr;
>if (FI != SPCache.end())
>  SP = dyn_cast_or_null(FI->second);
> -  if (!SP)
> +  if (!SP || !SP->isDefinition())
>  SP = getFunctionStub(GD);
>FnBeginRegionCount.push_back(LexicalBlockStack.size());
>LexicalBlockStack.emplace_back(SP);
> 
> Added: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601=auto
>  
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 23 14:24:12 2017
> @@ -0,0 +1,45 @@
> +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 
> -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
> +// PR33997.
> +struct already_AddRefed {
> +  ~already_AddRefed();
> +};
> +struct RefPtr {
> +  operator int *();
> +};
> +struct ServoCssRulesStrong {
> +  already_AddRefed Consume();
> +};
> +struct GroupRule {
> +  GroupRule(already_AddRefed);
> +};
> +class ConditionRule : GroupRule {
> +  using GroupRule::GroupRule;
> +};
> +class CSSMediaRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class CSSMozDocumentRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class ServoDocumentRule : CSSMozDocumentRule {
> +  ServoDocumentRule(RefPtr);
> +};
> +class ServoMediaRule : CSSMediaRule {
> +  ServoMediaRule(RefPtr);
> +};
> +ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
> +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
> +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
> +: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
> +
> +ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
> +: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
> +
> +// CHECK: define{{.*}}ServoMediaRule
> +// CHECK-NOT: {{ ret }}
> +// CHECK: store %class.ConditionRule* %
> +// CHECK-SAME: %class.ConditionRule** %
> +// CHECK-SAME: !dbg ![[INL:[0-9]+]]
> +
> +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt:
> +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", 
> {{.*}}isDefinition: true
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 

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


Re: r311601 - Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be

2017-08-28 Thread David Blaikie via cfe-commits
Seems like a rather complex test case - could you explain what's going on
there? (maybe in the form of a comment in the code - what path through all
those classes is required to tickle this)

On Wed, Aug 23, 2017 at 2:25 PM Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Wed Aug 23 14:24:12 2017
> New Revision: 311601
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311601=rev
> Log:
> Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be
> parented in function declarations.
>
> Fixes PR33997.
> https://bugs.llvm.org/show_bug.cgi?id=33997
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601=311600=311601=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 23 14:24:12 2017
> @@ -3287,7 +3287,7 @@ void CGDebugInfo::EmitInlineFunctionStar
>llvm::DISubprogram *SP = nullptr;
>if (FI != SPCache.end())
>  SP = dyn_cast_or_null(FI->second);
> -  if (!SP)
> +  if (!SP || !SP->isDefinition())
>  SP = getFunctionStub(GD);
>FnBeginRegionCount.push_back(LexicalBlockStack.size());
>LexicalBlockStack.emplace_back(SP);
>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601=auto
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 23 14:24:12
> 2017
> @@ -0,0 +1,45 @@
> +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213
> -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
> +// PR33997.
> +struct already_AddRefed {
> +  ~already_AddRefed();
> +};
> +struct RefPtr {
> +  operator int *();
> +};
> +struct ServoCssRulesStrong {
> +  already_AddRefed Consume();
> +};
> +struct GroupRule {
> +  GroupRule(already_AddRefed);
> +};
> +class ConditionRule : GroupRule {
> +  using GroupRule::GroupRule;
> +};
> +class CSSMediaRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class CSSMozDocumentRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class ServoDocumentRule : CSSMozDocumentRule {
> +  ServoDocumentRule(RefPtr);
> +};
> +class ServoMediaRule : CSSMediaRule {
> +  ServoMediaRule(RefPtr);
> +};
> +ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
> +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
> +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
> +: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume())
> {}
> +
> +ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
> +: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
> +
> +// CHECK: define{{.*}}ServoMediaRule
> +// CHECK-NOT: {{ ret }}
> +// CHECK: store %class.ConditionRule* %
> +// CHECK-SAME: %class.ConditionRule** %
> +// CHECK-SAME: !dbg ![[INL:[0-9]+]]
> +
> +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]],
> inlinedAt:
> +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule",
> {{.*}}isDefinition: true
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37235: Let -Wdelete-non-virtual-dtor fire in system headers too.

2017-08-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/SemaCXX/destructor.cpp:27
+#define BE_THE_HEADER
+#include __FILE__
+

Do we guarantee that `__FILE__` names a path that can be used to include the 
current file? In other tests, we add `-include %s` to the `RUN:` line to model 
this situation.


https://reviews.llvm.org/D37235



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


[PATCH] D37235: Let -Wdelete-non-virtual-dtor fire in system headers too.

2017-08-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

(if you'd prefer to wait for Reid or Richard to take a look, that's OK too :) )

Looks good to me, though wouldn't mind if the tests were a bit simpler - if 
they can be made so.




Comment at: test/SemaCXX/destructor.cpp:3-28
+
+#if defined(BE_THE_HEADER)
+
+// Wdelete-non-virtual-dtor should warn about the delete from smart pointer
+// classes in system headers (std::unique_ptr...) too.
+
+#pragma clang system_header

Could this be simpler?

For example would it work to put this test at the end of the file, something 
like:

  struct foo { virtual void f(); };
  #pragma clang system_header
  void f(foo *p) { delete p; }


https://reviews.llvm.org/D37235



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


[PATCH] D32788: Fix std::inplace_merge to be stable for all inputs

2017-08-28 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I committed as r311952 which fixes this - based on Jan's suggestion, but not 
quite the same as this patch.


https://reviews.llvm.org/D32788



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


r311947 - [analyzer] Adjust ptr arithmetic test

2017-08-28 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Aug 28 15:58:54 2017
New Revision: 311947

URL: http://llvm.org/viewvc/llvm-project?rev=311947=rev
Log:
[analyzer] Adjust ptr arithmetic test

Replace "long" with __UINTPTR_TYPE__
to make the test added in rL311935 Windows-friendly.
Caught by the buildbot llvm-clang-x86_64-expensive-checks-win.

Modified:
cfe/trunk/test/Analysis/ptr-arith.cpp

Modified: cfe/trunk/test/Analysis/ptr-arith.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ptr-arith.cpp?rev=311947=311946=311947=diff
==
--- cfe/trunk/test/Analysis/ptr-arith.cpp (original)
+++ cfe/trunk/test/Analysis/ptr-arith.cpp Mon Aug 28 15:58:54 2017
@@ -107,7 +107,7 @@ unsigned ptrSubtractionNoCrash(char *Beg
 }
 
 // Bug 34309
-bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
-  long y = (long)p - 1;
+bool ptrAsIntegerSubtractionNoCrash(__UINTPTR_TYPE__ x, char *p) {
+  __UINTPTR_TYPE__ y = (__UINTPTR_TYPE__)p - 1;
   return y == x;
 }


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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-28 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Except for some drive-by nits, this is a high-level review.

I have some high-level questions about the design of the library:

1. **How do you intend to handle the case when there are multiple function 
definitions with the same USR?** Whose responsibility it is to deal with this: 
the client (for example, the static analyzer) or the index/database 
(libCrossTU)? This seems to me to be a fundamental part of the design for this 
feature that is missing. If you expect the client to handle this scenario (for 
example, to pick a definition) I would expect the library API to return more 
than a single potential result for a query. If you expect the the library to 
pick a definition then at a minimum you should document how this will be done. 
If the library will treat this as an error then you should communicate this to 
the client so it can attempt to recover from it.

2. **Whose responsibility is it to handle errors that the library runs into?** 
Right now several errors appear to reported to the end user as diagnostics. It 
seems to me that the decision of how (or whether) to report these errors to the 
end user should be up to a particular client. Are these errors even actionable 
on the part of end users? My sense it that with the envisioned workflow users 
would not know/care about the format of the database file.

3. **Where should the code that understands the database file format live?** 
Right now the logic for the parsing of the index format is in libCrossTU and 
the emission of the index is in the command-line tool. I think it would be 
easier to maintain if there were a single place that understand the file 
format. This way consumers and emitters of the index could be easily updated 
when the format/representation changes. Additionally, I think it is important 
to document this format.




Comment at: include/clang/Basic/DiagnosticCrossTUKinds.td:13
+def err_fnmap_parsing : Error<
+  "error parsing CrossTU index file: '%0' line: %1 'USR filename' format "
+  "expected">;

Is this a user-facing diagnostic? Do we expect users to know what 'CrossTU' 
means? Or what 'USR' means?



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:60
+  ///
+  /// Note that the AST files should also be in the \p CrossTUDir.
+  const FunctionDecl *getCrossTUDefinition(const FunctionDecl *FD,

Can this document what happens when the function declaration cannot be found? 
And what happens when multiple function declarations are found?



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:48
+   StringRef LookupFnName) 
{
+  if (!DC)
+return nullptr;

Should this assert that DC is not null? What is the reason to accept null here?



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:81
+  if (!ExternalFnMapFile) {
+Context.getDiagnostics().Report(diag::err_fe_error_opening)
+<< ExternalFunctionMap << "required by the CrossTU functionality";

What is the rationale behind emitting this as a diagnostic? In general for a 
library I would expect that errors would be communicated to the client, which 
then would have responsibility for handling them, reporting them to the user, 
or aborting.



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:92
+StringRef LineRef{Line};
+if (Pos > 0 && Pos != std::string::npos) {
+  FunctionName = LineRef.substr(0, Pos);

It looks like this is parsing. Is the file format documented anywhere? Also, it 
would be good to keep the parsing and generation code  in the same place so 
that it is easy to figure out what to update when the file format changes.



Comment at: tools/clang-func-mapping/ClangFnMapGen.cpp:86
+  if (SM.isInMainFile(Body->getLocStart()))
+DefinedFuncsStr << LookupName.str().str() << " " << CurrentFileName
+<< "\n";

It seems like the functionality that writes an entry and the functionality that 
reads an entry should ideally be in the same place. This way when the format is 
updated it is obvious what other places need to be updated. Can the code that 
writes a mapping be moved to libCrossTU and can we have this tool link against 
it?


https://reviews.llvm.org/D34512



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


[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning

2017-08-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Trying to understand the broader context here, I looked back through the list 
of revisions mentioned in PR33930 to see if that helped.

When called on a method, CodeGenModule::EmitGlobalDefinition() calls 
CodeGenModule::EmitGlobalFunctionDefinition(), which in turn calls 
CodeGenFunction::GenerateCode(), which calls CodeGenFunction::FinishFunction(), 
which calls CGDebugInfo::EmitFunctionEnd(), which calls 
DIBuilder::finalizeSubprogram().  This is supposed to finalize the metadata for 
the subprogram.
If the method is virtual, EmitGlobalDefinition() then calls 
getVTables().EmitThunks() which eventually gets to GenerateVarArgsThunk().  
Which crashes when it tries to CloneFunction the original virtual method, 
because an operand of some piece of metadata is still temporary.

So, either something happens such that EmitFunctionEnd() doesn't actually call 
finalizeSubprogram(), or finalizeSubprogram() doesn't finalize everything that 
it needs to finalize.

finalizeSubprogram() retrieves the variables from the subprogram and handles 
them; what is it missing?


https://reviews.llvm.org/D37038



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


[PATCH] D37235: Let -Wdelete-non-virtual-dtor fire in system headers too.

2017-08-28 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 112981.
thakis edited the summary of this revision.
thakis added a comment.

Don't warn in unevaluated contexts. Ready for a look now.


https://reviews.llvm.org/D37235

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/destructor.cpp
  test/SemaCXX/implicit-exception-spec.cpp

Index: test/SemaCXX/implicit-exception-spec.cpp
===
--- test/SemaCXX/implicit-exception-spec.cpp
+++ test/SemaCXX/implicit-exception-spec.cpp
@@ -121,7 +121,7 @@
 T  = *p;
 static_assert(noexcept(a = a) == D, "");
 static_assert(noexcept(a = static_cast(a)) == E, "");
-static_assert(noexcept(delete ) == F, ""); // expected-warning 2{{abstract}}
+static_assert(noexcept(delete ) == F, "");
 
 // These are last because the first failure here causes instantiation to bail out.
 static_assert(noexcept(new (nothrow) T()) == A, ""); // expected-error 2{{abstract}}
Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -1,5 +1,31 @@
 // RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -fcxx-exceptions -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple %ms_abi_triple -DMSABI -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s
+
+#if defined(BE_THE_HEADER)
+
+// Wdelete-non-virtual-dtor should warn about the delete from smart pointer
+// classes in system headers (std::unique_ptr...) too.
+
+#pragma clang system_header
+namespace dnvd {
+template 
+class simple_ptr {
+public:
+  simple_ptr(T* t): _ptr(t) {}
+  ~simple_ptr() { delete _ptr; } // \
+// expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \
+// expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}
+  T& operator*() const { return *_ptr; }
+private:
+  T* _ptr;
+};
+}
+
+#else
+
+#define BE_THE_HEADER
+#include __FILE__
+
 class A {
 public:
   ~A();
@@ -213,18 +239,6 @@
 struct VF final: VB {};
 
 template 
-class simple_ptr {
-public:
-  simple_ptr(T* t): _ptr(t) {}
-  ~simple_ptr() { delete _ptr; } // \
-// expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \
-// expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}
-  T& operator*() const { return *_ptr; }
-private:
-  T* _ptr;
-};
-
-template 
 class simple_ptr2 {
 public:
   simple_ptr2(T* t): _ptr(t) {}
@@ -335,10 +349,28 @@
   }
 }
 
+// Taken from libc++, slightly simplified.
+template 
+struct __is_destructible_apply { typedef int type; };
+struct __two {char __lx[2];};
+template 
+struct __is_destructor_wellformed {
+  template 
+  static char __test(typename __is_destructible_apply<
+   decltype(_Tp1().~_Tp1())>::type);
+  template 
+  static __two __test (...);
+  
+  static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
+};
+
 void warn0_explicit_dtor(B* b, B& br, D* d) {
   b->~B(); // expected-warning {{destructor called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} expected-note{{qualify call to silence this warning}}
   b->B::~B(); // No warning when the call isn't virtual.
 
+  // No warning in unevaluated contexts.
+  (void)__is_destructor_wellformed::value;
+
   br.~B(); // expected-warning {{destructor called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} expected-note{{qualify call to silence this warning}}
   br.B::~B();
 
@@ -451,3 +483,4 @@
   x.foo1();
 }
 }
+#endif // BE_THE_HEADER
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3284,7 +3284,7 @@
 bool IsDelete, bool CallCanBeVirtual,
 bool WarnOnNonAbstractTypes,
 SourceLocation DtorLoc) {
-  if (!dtor || dtor->isVirtual() || !CallCanBeVirtual)
+  if (!dtor || dtor->isVirtual() || !CallCanBeVirtual || isUnevaluatedContext())
 return;
 
   // C++ [expr.delete]p3:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6414,12 +6414,12 @@
 def warn_delete_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on non-final %1 that has "
   "virtual functions but non-virtual destructor">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore, ShowInSystemHeader;
 def note_delete_non_virtual : Note<
   "qualify call to silence this warning">;
 def 

Re: [PATCH] D37235: Let -Wdelete-non-virtual-dtor fire in system headers too.

2017-08-28 Thread Nico Weber via cfe-commits
I had compiled a bunch of code with this, but right after I sent this out
my local build of something failed with this:

../../buildtools/third_party/libc++/trunk/include/type_traits:2156:51:
error: destructor called on non-final
'Ice::VariableDeclaration::RelocInitializer' that has virtual functions but
non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
typename
__is_destructible_apply().~_Tp1())>::type
  ^
../../buildtools/third_party/libc++/trunk/include/__config:435:15: note:
expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/third_party/libc++/trunk/include/type_traits:2156:76:
note: qualify call to silence this warning
typename
__is_destructible_apply().~_Tp1())>::type
   ^


So I'll have to tweak the warning to not fire in unevaluated contexts
first. Feel free to ignore for now.



On Mon, Aug 28, 2017 at 6:08 PM, Nico Weber via Phabricator via cfe-commits
 wrote:

> thakis created this revision.
>
> Makes the warning useful again in a std::unique_ptr world, PR28460.
>
>
> https://reviews.llvm.org/D37235
>
> Files:
>   include/clang/Basic/DiagnosticSemaKinds.td
>   test/SemaCXX/destructor.cpp
>
>
> Index: test/SemaCXX/destructor.cpp
> ===
> --- test/SemaCXX/destructor.cpp
> +++ test/SemaCXX/destructor.cpp
> @@ -1,5 +1,31 @@
>  // RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fsyntax-only
> -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -fcxx-exceptions -verify %s
>  // RUN: %clang_cc1 -std=c++11 -triple %ms_abi_triple -DMSABI
> -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s
> +
> +#if defined(BE_THE_HEADER)
> +
> +// Wdelete-non-virtual-dtor should warn about the delete from smart
> pointer
> +// classes in system headers (std::unique_ptr...) too.
> +
> +#pragma clang system_header
> +namespace dnvd {
> +template 
> +class simple_ptr {
> +public:
> +  simple_ptr(T* t): _ptr(t) {}
> +  ~simple_ptr() { delete _ptr; } // \
> +// expected-warning {{delete called on non-final 'dnvd::B' that has
> virtual functions but non-virtual destructor}} \
> +// expected-warning {{delete called on non-final 'dnvd::D' that has
> virtual functions but non-virtual destructor}}
> +  T& operator*() const { return *_ptr; }
> +private:
> +  T* _ptr;
> +};
> +}
> +
> +#else
> +
> +#define BE_THE_HEADER
> +#include __FILE__
> +
>  class A {
>  public:
>~A();
> @@ -213,18 +239,6 @@
>  struct VF final: VB {};
>
>  template 
> -class simple_ptr {
> -public:
> -  simple_ptr(T* t): _ptr(t) {}
> -  ~simple_ptr() { delete _ptr; } // \
> -// expected-warning {{delete called on non-final 'dnvd::B' that has
> virtual functions but non-virtual destructor}} \
> -// expected-warning {{delete called on non-final 'dnvd::D' that has
> virtual functions but non-virtual destructor}}
> -  T& operator*() const { return *_ptr; }
> -private:
> -  T* _ptr;
> -};
> -
> -template 
>  class simple_ptr2 {
>  public:
>simple_ptr2(T* t): _ptr(t) {}
> @@ -451,3 +465,4 @@
>x.foo1();
>  }
>  }
> +#endif // BE_THE_HEADER
> Index: include/clang/Basic/DiagnosticSemaKinds.td
> ===
> --- include/clang/Basic/DiagnosticSemaKinds.td
> +++ include/clang/Basic/DiagnosticSemaKinds.td
> @@ -6414,12 +6414,12 @@
>  def warn_delete_non_virtual_dtor : Warning<
>"%select{delete|destructor}0 called on non-final %1 that has "
>"virtual functions but non-virtual destructor">,
> -  InGroup, DefaultIgnore;
> +  InGroup, DefaultIgnore, ShowInSystemHeader;
>  def note_delete_non_virtual : Note<
>"qualify call to silence this warning">;
>  def warn_delete_abstract_non_virtual_dtor : Warning<
>"%select{delete|destructor}0 called on %1 that is abstract but has "
> -  "non-virtual destructor">, InGroup;
> +  "non-virtual destructor">, InGroup,
> ShowInSystemHeader;
>  def warn_overloaded_virtual : Warning<
>"%q0 hides overloaded virtual %select{function|functions}1">,
>InGroup, DefaultIgnore;
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37235: Let -Wdelete-non-virtual-dtor fire in system headers too.

2017-08-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

Makes the warning useful again in a std::unique_ptr world, PR28460.


https://reviews.llvm.org/D37235

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  test/SemaCXX/destructor.cpp


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -1,5 +1,31 @@
 // RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fsyntax-only 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -fcxx-exceptions -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple %ms_abi_triple -DMSABI -fsyntax-only 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s
+
+#if defined(BE_THE_HEADER)
+
+// Wdelete-non-virtual-dtor should warn about the delete from smart pointer
+// classes in system headers (std::unique_ptr...) too.
+
+#pragma clang system_header
+namespace dnvd {
+template 
+class simple_ptr {
+public:
+  simple_ptr(T* t): _ptr(t) {}
+  ~simple_ptr() { delete _ptr; } // \
+// expected-warning {{delete called on non-final 'dnvd::B' that has 
virtual functions but non-virtual destructor}} \
+// expected-warning {{delete called on non-final 'dnvd::D' that has 
virtual functions but non-virtual destructor}}
+  T& operator*() const { return *_ptr; }
+private:
+  T* _ptr;
+};
+}
+
+#else
+
+#define BE_THE_HEADER
+#include __FILE__
+
 class A {
 public:
   ~A();
@@ -213,18 +239,6 @@
 struct VF final: VB {};
 
 template 
-class simple_ptr {
-public:
-  simple_ptr(T* t): _ptr(t) {}
-  ~simple_ptr() { delete _ptr; } // \
-// expected-warning {{delete called on non-final 'dnvd::B' that has 
virtual functions but non-virtual destructor}} \
-// expected-warning {{delete called on non-final 'dnvd::D' that has 
virtual functions but non-virtual destructor}}
-  T& operator*() const { return *_ptr; }
-private:
-  T* _ptr;
-};
-
-template 
 class simple_ptr2 {
 public:
   simple_ptr2(T* t): _ptr(t) {}
@@ -451,3 +465,4 @@
   x.foo1();
 }
 }
+#endif // BE_THE_HEADER
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6414,12 +6414,12 @@
 def warn_delete_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on non-final %1 that has "
   "virtual functions but non-virtual destructor">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore, ShowInSystemHeader;
 def note_delete_non_virtual : Note<
   "qualify call to silence this warning">;
 def warn_delete_abstract_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on %1 that is abstract but has "
-  "non-virtual destructor">, InGroup;
+  "non-virtual destructor">, InGroup, ShowInSystemHeader;
 def warn_overloaded_virtual : Warning<
   "%q0 hides overloaded virtual %select{function|functions}1">,
   InGroup, DefaultIgnore;


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -1,5 +1,31 @@
 // RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -fcxx-exceptions -verify %s
 // RUN: %clang_cc1 -std=c++11 -triple %ms_abi_triple -DMSABI -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s
+
+#if defined(BE_THE_HEADER)
+
+// Wdelete-non-virtual-dtor should warn about the delete from smart pointer
+// classes in system headers (std::unique_ptr...) too.
+
+#pragma clang system_header
+namespace dnvd {
+template 
+class simple_ptr {
+public:
+  simple_ptr(T* t): _ptr(t) {}
+  ~simple_ptr() { delete _ptr; } // \
+// expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \
+// expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}
+  T& operator*() const { return *_ptr; }
+private:
+  T* _ptr;
+};
+}
+
+#else
+
+#define BE_THE_HEADER
+#include __FILE__
+
 class A {
 public:
   ~A();
@@ -213,18 +239,6 @@
 struct VF final: VB {};
 
 template 
-class simple_ptr {
-public:
-  simple_ptr(T* t): _ptr(t) {}
-  ~simple_ptr() { delete _ptr; } // \
-// expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \
-// expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}
-  T& operator*() const { return *_ptr; }
-private:
-  T* _ptr;
-};
-
-template 
 class simple_ptr2 {
 public:
   simple_ptr2(T* t): _ptr(t) {}
@@ -451,3 +465,4 @@
   x.foo1();
 }
 }
+#endif // BE_THE_HEADER
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6414,12 +6414,12 @@
 def warn_delete_non_virtual_dtor : 

r311936 - Remove trailing space.

2017-08-28 Thread Rui Ueyama via cfe-commits
Author: ruiu
Date: Mon Aug 28 14:38:14 2017
New Revision: 311936

URL: http://llvm.org/viewvc/llvm-project?rev=311936=rev
Log:
Remove trailing space.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=311936=311935=311936=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Mon Aug 28 14:38:14 
2017
@@ -360,15 +360,15 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
 case nonloc::LocAsIntegerKind:
-  // FIXME: at the moment the implementation 
+  // FIXME: at the moment the implementation
   // of modeling "pointers as integers" is not complete.
   if (!BinaryOperator::isComparisonOp(op))
-return UnknownVal(); 
+return UnknownVal();
   return evalBinOpLL(state, op, lhsL,
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
-  // FIXME: at the moment the implementation 
+  // FIXME: at the moment the implementation
   // of modeling "pointers as integers" is not complete.
   if (!BinaryOperator::isComparisonOp(op))
 return UnknownVal();


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


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

2017-08-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D36527#854600, @rsmith wrote:

> We'll also need to agree within the cxx-abi-dev list how to mangle lambda 
> closure types for this form


I filed https://github.com/itanium-cxx-abi/cxx-abi/issues/31 for this.


https://reviews.llvm.org/D36527



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


LLVM buildmaster will be updated and restarted in 3 hours

2017-08-28 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted in about 3 hours (after 5 PM
Pacific time).

Thanks

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


Re: r311857 - Emit static constexpr member as available_externally definition

2017-08-28 Thread Mehdi AMINI via cfe-commits
Sorry for the inconvenience!

I will follow-up in the PR.

-- 
Mehdi


2017-08-28 12:42 GMT-07:00 Hans Wennborg :

> I reverted this in r311898 as it caused Chromium builds to fail with
> an assertion; see PR34348.
>
> On Sun, Aug 27, 2017 at 1:24 PM, Mehdi Amini via cfe-commits
>  wrote:
> > Author: mehdi_amini
> > Date: Sun Aug 27 13:24:09 2017
> > New Revision: 311857
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=311857=rev
> > Log:
> > Emit static constexpr member as available_externally definition
> >
> > By exposing the constant initializer, the optimizer can fold many
> > of these constructs.
> >
> > Differential Revision: https://reviews.llvm.org/D34992
> >
> > Added:
> > cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp
> > Modified:
> > cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenModule.cpp?rev=311857=311856=311857=diff
> > 
> ==
> > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Aug 27 13:24:09 2017
> > @@ -2437,6 +2437,28 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
> >  D->getType().isConstant(Context) &&
> >  isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
> >GV->setSection(".cp.rodata");
> > +
> > +// Check if we a have a const declaration with an initializer, we
> may be
> > +// able to emit it as available_externally to expose it's value to
> the
> > +// optimizer.
> > +if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() &&
> > +D->getType().isConstQualified() && !GV->hasInitializer() &&
> > +!D->hasDefinition() && D->hasInit() &&
> !D->hasAttr()) {
> > +  const auto *Record =
> > +  Context.getBaseElementType(D->getType())->
> getAsCXXRecordDecl();
> > +  bool HasMutableFields = Record && Record->hasMutableFields();
> > +  if (!HasMutableFields) {
> > +const VarDecl *InitDecl;
> > +const Expr *InitExpr = D->getAnyInitializer(InitDecl);
> > +if (InitExpr) {
> > +  GV->setConstant(true);
> > +  GV->setLinkage(llvm::GlobalValue::
> AvailableExternallyLinkage);
> > +  ConstantEmitter emitter(*this);
> > +  GV->setInitializer(emitter.tryEmitForInitializer(*InitDecl));
> > +  emitter.finalize(GV);
> > +}
> > +  }
> > +}
> >}
> >
> >auto ExpectedAS =
> >
> > Added: cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/cxx11-extern-constexpr.cpp?rev=311857=auto
> > 
> ==
> > --- cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp (added)
> > +++ cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp Sun Aug 27
> 13:24:09 2017
> > @@ -0,0 +1,55 @@
> > +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple
> x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX11
> > +// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple
> x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX17
> > +
> > +struct A {
> > +  static const int Foo = 123;
> > +};
> > +// CHECK: @_ZN1A3FooE = constant i32 123, align 4
> > +const int *p = ::Foo; // emit available_externally
> > +const int A::Foo;   // convert to full definition
> > +
> > +struct Bar {
> > +  int b;
> > +};
> > +
> > +struct MutableBar {
> > +  mutable int b;
> > +};
> > +
> > +struct Foo {
> > +  // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally
> constant i32 42,
> > +  // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant
> i32 42,
> > +  static constexpr int ConstexprStaticMember = 42;
> > +  // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally
> constant i32 43,
> > +  static const int ConstStaticMember = 43;
> > +
> > +  // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally
> constant %struct.Bar { i32 44 },
> > +  // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant
> %struct.Bar { i32 44 },
> > +  static constexpr Bar ConstStaticStructMember = {44};
> > +
> > +  // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external
> global %struct.MutableBar,
> > +  // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE =
> linkonce_odr global %struct.MutableBar { i32 45 },
> > +  static constexpr MutableBar ConstexprStaticMutableStructMember =
> {45};
> > +};
> > +// CHECK: @_ZL15ConstStaticexpr = internal constant i32 46,
> > +static constexpr int ConstStaticexpr = 46;
> > +// CHECK: @_ZL9ConstExpr = internal constant i32 46, align 4
> > +static const int ConstExpr = 46;
> > +
> > +// CHECK: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar {
> i32 47 },
> > +static 

[PATCH] D37120: [analyzer] Fix modeling arithmetic

2017-08-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311935: [analyzer] Fix crash in modeling arithmetic 
(authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D37120?vs=112784=112967#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37120

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/ptr-arith.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -360,10 +360,18 @@
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
 case nonloc::LocAsIntegerKind:
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal(); 
   return evalBinOpLL(state, op, lhsL,
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal();
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
Index: cfe/trunk/test/Analysis/ptr-arith.cpp
===
--- cfe/trunk/test/Analysis/ptr-arith.cpp
+++ cfe/trunk/test/Analysis/ptr-arith.cpp
@@ -105,3 +105,9 @@
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -360,10 +360,18 @@
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
 case nonloc::LocAsIntegerKind:
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal(); 
   return evalBinOpLL(state, op, lhsL,
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal();
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
Index: cfe/trunk/test/Analysis/ptr-arith.cpp
===
--- cfe/trunk/test/Analysis/ptr-arith.cpp
+++ cfe/trunk/test/Analysis/ptr-arith.cpp
@@ -105,3 +105,9 @@
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311935 - [analyzer] Fix crash in modeling arithmetic

2017-08-28 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Aug 28 14:15:21 2017
New Revision: 311935

URL: http://llvm.org/viewvc/llvm-project?rev=311935=rev
Log:
[analyzer] Fix crash in modeling arithmetic

This diff fixes modeling of arithmetic 
expressions where pointers are treated as integers 
(i.e. via C-style / reinterpret casts).
For now we return UnknownVal unless the operation is a comparison.

Test plan: make check-all

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/ptr-arith.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=311935=311934=311935=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Mon Aug 28 14:15:21 
2017
@@ -360,10 +360,18 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
 case nonloc::LocAsIntegerKind:
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal(); 
   return evalBinOpLL(state, op, lhsL,
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal();
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,

Modified: cfe/trunk/test/Analysis/ptr-arith.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ptr-arith.cpp?rev=311935=311934=311935=diff
==
--- cfe/trunk/test/Analysis/ptr-arith.cpp (original)
+++ cfe/trunk/test/Analysis/ptr-arith.cpp Mon Aug 28 14:15:21 2017
@@ -105,3 +105,9 @@ unsigned ptrSubtractionNoCrash(char *Beg
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}


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


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

2017-08-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This patch appears to be missing some necessary changes in the following places:

- lib/Serialization -- round-trip the new information through PCH / modules
- lib/AST/StmtPrinter.cpp -- pretty-printing lambdas with explicit template 
parameters
- lib/Sema/TreeTransform.h -- template instantiation of lambdas with explicit 
template arguments
- lib/AST/RecursiveASTVisitor.h -- recursive AST visitation should visit 
explicit template parameters

We'll also need to agree within the cxx-abi-dev list how to mangle lambda 
closure types for this form and lib/AST/ItaniumMangle.cpp's `mangleLambda` will 
need to be updated to match. (The MS mangling is not based on the type of the 
lambda call operator, so we probably don't need changes there.)


https://reviews.llvm.org/D36527



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-08-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D33852#854213, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33852#854176, @Prazek wrote:
>
> > In https://reviews.llvm.org/D33852#853982, @aaron.ballman wrote:
> >
> > > In https://reviews.llvm.org/D33852#853410, @Prazek wrote:
> > >
> > > > Sorry for so late fixes, but it would be good to put it in 5.0
> > >
> > >
> > > I do not think this should be in 5.0, as I believe we're only accepting 
> > > regression fixes at this point.
> >
> >
> > This is a regression. __declspec(selectany) works completely fine on linux 
> > with 4.0. Without it clang-5.0 will be useless for any major windows 
> > project compiled on linux.
> >
> > edit:
> >  here is a regression: https://reviews.llvm.org/D32083
>
>
> This is also adding new functionality that has had zero testing because it 
> removes *all* target-specific checking for the attribute. Under the previous 
> functionality (changed in https://reviews.llvm.org/D32083), this still 
> required some mention of microsoft something (it went from requiring 
> microsoft extensions to be enabled to instead require a Windows target) -- 
> that's been entirely removed from this patch so now you can use this 
> attribute for all target architectures, so it's not purely fixing a 
> regression. Given how late we are in the release cycle, I am uncomfortable 
> with this going in to 5.0, but I'd have no problems letting it bake for a bit 
> and putting it into 5.1 (or 5.0.1, however we're naming bug releases these 
> days).


I agree. The idea of taking this so late (and it hasn't even landed in trunk 
yet) makes me nervous. I think 5.0.1 would be more appropriate.


https://reviews.llvm.org/D33852



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


[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-08-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

clang currently rejects "void foo(int = a);"  and so does gcc.

I'm trying to search the defect reports, but it looks like the c++ standard's 
site is currently unreachable.


https://reviews.llvm.org/D36915



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


[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

Yeah, this seems to be the best solution for this. I think I ran into the same 
issue when working on the StmtDataCollector - basically there can only be two 
Traverse*, one in the Derived class and the other one needs to do all the magic 
with walking the specialisation hierarchy.


https://reviews.llvm.org/D37200



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


[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386

2017-08-28 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311924: Reland r311842 - [cmake] Remove i686 target that is 
duplicate to i386 (authored by mgorny).

Repository:
  rL LLVM

https://reviews.llvm.org/D26764

Files:
  compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/trunk/cmake/base-config-ix.cmake
  compiler-rt/trunk/cmake/builtin-config-ix.cmake
  compiler-rt/trunk/cmake/config-ix.cmake
  compiler-rt/trunk/lib/asan/CMakeLists.txt
  compiler-rt/trunk/lib/asan/scripts/asan_device_setup
  compiler-rt/trunk/lib/builtins/CMakeLists.txt
  compiler-rt/trunk/lib/ubsan/CMakeLists.txt
  compiler-rt/trunk/test/asan/CMakeLists.txt
  compiler-rt/trunk/test/asan/lit.cfg
  compiler-rt/trunk/test/lit.common.cfg
  compiler-rt/trunk/test/lsan/TestCases/Linux/use_tls_dynamic.cc
  compiler-rt/trunk/test/sanitizer_common/lit.common.cfg
  compiler-rt/trunk/test/scudo/random_shuffle.cpp

Index: compiler-rt/trunk/cmake/builtin-config-ix.cmake
===
--- compiler-rt/trunk/cmake/builtin-config-ix.cmake
+++ compiler-rt/trunk/cmake/builtin-config-ix.cmake
@@ -25,7 +25,8 @@
 
 set(ARM64 aarch64)
 set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)
-set(X86 i386 i686)
+set(ARM32 arm armhf)
+set(X86 i386)
 set(X86_64 x86_64)
 set(MIPS32 mips mipsel)
 set(MIPS64 mips64 mips64el)
Index: compiler-rt/trunk/cmake/config-ix.cmake
===
--- compiler-rt/trunk/cmake/config-ix.cmake
+++ compiler-rt/trunk/cmake/config-ix.cmake
@@ -174,7 +174,7 @@
 
 set(ARM64 aarch64)
 set(ARM32 arm armhf)
-set(X86 i386 i686)
+set(X86 i386)
 set(X86_64 x86_64)
 set(MIPS32 mips mipsel)
 set(MIPS64 mips64 mips64el)
Index: compiler-rt/trunk/cmake/base-config-ix.cmake
===
--- compiler-rt/trunk/cmake/base-config-ix.cmake
+++ compiler-rt/trunk/cmake/base-config-ix.cmake
@@ -139,10 +139,6 @@
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64")
   if(NOT MSVC)
 test_target_arch(x86_64 "" "-m64")
-# FIXME: We build runtimes for both i686 and i386, as "clang -m32" may
-# target different variant than "$CMAKE_C_COMPILER -m32". This part should
-# be gone after we resolve PR14109.
-test_target_arch(i686 __i686__ "-m32")
 test_target_arch(i386 __i386__ "-m32")
   else()
 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -163,7 +163,6 @@
   check_symbol_exists(__arm__ "" __ARM)
   check_symbol_exists(__aarch64__ "" __AARCH64)
   check_symbol_exists(__x86_64__ "" __X86_64)
-  check_symbol_exists(__i686__ "" __I686)
   check_symbol_exists(__i386__ "" __I386)
   check_symbol_exists(__mips__ "" __MIPS)
   check_symbol_exists(__mips64__ "" __MIPS64)
@@ -176,8 +175,6 @@
 add_default_target_arch(aarch64)
   elseif(__X86_64)
 add_default_target_arch(x86_64)
-  elseif(__I686)
-add_default_target_arch(i686)
   elseif(__I386)
 add_default_target_arch(i386)
   elseif(__MIPS64) # must be checked before __MIPS
Index: compiler-rt/trunk/test/asan/CMakeLists.txt
===
--- compiler-rt/trunk/test/asan/CMakeLists.txt
+++ compiler-rt/trunk/test/asan/CMakeLists.txt
@@ -18,7 +18,7 @@
 endif()
 
 macro(get_bits_for_arch arch bits)
-  if (${arch} MATCHES "i386|i686|arm|mips|mipsel")
+  if (${arch} MATCHES "i386|arm|mips|mipsel")
 set(${bits} 32)
   elseif (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|mips64|mips64el|s390x")
 set(${bits} 64)
Index: compiler-rt/trunk/test/asan/lit.cfg
===
--- compiler-rt/trunk/test/asan/lit.cfg
+++ compiler-rt/trunk/test/asan/lit.cfg
@@ -121,16 +121,11 @@
 def build_invocation(compile_flags):
   return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " "
 
-# Clang driver link 'x86' (i686) architecture to 'i386'.
-target_arch = config.target_arch
-if (target_arch == "i686"):
-  target_arch = "i386"
-
 config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
 config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
 config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) )
 config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) )
-config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % target_arch))
+config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % config.target_arch))
 if config.asan_dynamic:
   config.substitutions.append( ("%clang_asan_static ", 

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-28 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311923: Reland r311836 - [Driver] Use arch type to find 
compiler-rt libraries (on Linux) (authored by mgorny).

Repository:
  rL LLVM

https://reviews.llvm.org/D26796

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep
  
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
  cfe/trunk/test/Driver/linux-ld.c
  cfe/trunk/test/Driver/nostdlib.c
  cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
  cfe/trunk/test/Driver/windows-cross.c


Index: cfe/trunk/test/Driver/windows-cross.c
===
--- cfe/trunk/test/Driver/windows-cross.c
+++ cfe/trunk/test/Driver/windows-cross.c
@@ -64,7 +64,7 @@
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86
 
 // CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address"
-// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i686.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk-i686.lib" "--undefined" 
"___asan_seh_interceptor"
+// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i386.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib" "--undefined" 
"___asan_seh_interceptor"
 
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin 
-fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-TSAN
Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -71,6 +71,27 @@
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i686-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: --rtlib=compiler-rt \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
+// CHECK-LD-RT-I686-NOT: warning:
+// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-RT-I686: "--eh-frame-hdr"
+// CHECK-LD-RT-I686: "-m" "elf_i386"
+// CHECK-LD-RT-I686: "-dynamic-linker"
+// CHECK-LD-RT-I686: 
"{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.."
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+// CHECK-LD-RT-I686: "-lc"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
Index: cfe/trunk/test/Driver/nostdlib.c
===
--- cfe/trunk/test/Driver/nostdlib.c
+++ cfe/trunk/test/Driver/nostdlib.c
@@ -27,5 +27,5 @@
 //
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
+// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i386.a"
 // CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
Index: cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
===
--- cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
+++ cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
@@ -6,9 +6,15 @@
 // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i386-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
+// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a
+
+// Check whether alternate arch values map to the correct library.
+//
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-pc-linux \
-// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
-// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=arm-linux-gnueabi \
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- 

r311923 - Reland r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-28 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Aug 28 13:29:52 2017
New Revision: 311923

URL: http://llvm.org/viewvc/llvm-project?rev=311923=rev
Log:
Reland r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux)

Use llvm::Triple::getArchTypeName() when looking for compiler-rt
libraries, rather than the exact arch string from the triple. This is
more correct as it matches the values used when building compiler-rt
(builtin-config-ix.cmake) which are the subset of the values allowed
in triples.

For example, this fixes an issue when the compiler set for
i686-pc-linux-gnu triple would not find an i386 compiler-rt library,
while this is the exact arch that is detected by compiler-rt. The same
applies to any other i?86 variant allowed by LLVM.

This also makes the special case for MSVC unnecessary, since now i386
will be used reliably for all 32-bit x86 variants.

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

Added:

cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep

cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/linux-ld.c
cfe/trunk/test/Driver/nostdlib.c
cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=311923=311922=311923=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Aug 28 13:29:52 2017
@@ -297,15 +297,12 @@ static StringRef getArchNameForCompilerR
   const llvm::Triple  = TC.getTriple();
   bool IsWindows = Triple.isOSWindows();
 
-  if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86)
-return "i386";
-
   if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
 return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
? "armhf"
: "arm";
 
-  return TC.getArchName();
+  return llvm::Triple::getArchTypeName(TC.getArch());
 }
 
 std::string ToolChain::getCompilerRTPath() const {

Added: 
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep?rev=311923=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o?rev=311923=auto
==
(empty)

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=311923=311922=311923=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Mon Aug 28 13:29:52 2017
@@ -71,6 +71,27 @@
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i686-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: --rtlib=compiler-rt \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
+// CHECK-LD-RT-I686-NOT: warning:
+// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-RT-I686: "--eh-frame-hdr"
+// CHECK-LD-RT-I686: "-m" "elf_i386"
+// CHECK-LD-RT-I686: "-dynamic-linker"
+// CHECK-LD-RT-I686: 
"{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.."
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+// CHECK-LD-RT-I686: "-lc"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \

Modified: cfe/trunk/test/Driver/nostdlib.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=311923=311922=311923=diff
==
--- cfe/trunk/test/Driver/nostdlib.c (original)
+++ cfe/trunk/test/Driver/nostdlib.c Mon Aug 28 13:29:52 2017
@@ 

[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 112951.
johannes added a comment.

use a specialized getStmtChildren to fix the order for CXXOperatorCallExpr


https://reviews.llvm.org/D37200

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RecursiveASTVisitor.h
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -21,42 +21,55 @@
 : public LexicallyOrderedRecursiveASTVisitor {
 public:
   LexicallyOrderedDeclVisitor(DummyMatchVisitor ,
-  const SourceManager , bool EmitIndices)
+  const SourceManager , bool EmitDeclIndices,
+  bool EmitStmtIndices)
   : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher),
-EmitIndices(EmitIndices) {}
+EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
 
   bool TraverseDecl(Decl *D) {
 TraversalStack.push_back(D);
 LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
 TraversalStack.pop_back();
 return true;
   }
 
+  bool TraverseStmt(Stmt *S);
+
   bool VisitNamedDecl(const NamedDecl *D);
+  bool VisitDeclRefExpr(const DeclRefExpr *D);
 
 private:
   DummyMatchVisitor 
-  bool EmitIndices;
+  bool EmitDeclIndices, EmitStmtIndices;
   unsigned Index = 0;
   llvm::SmallVector TraversalStack;
 };
 
 class DummyMatchVisitor : public ExpectedLocationVisitor {
-  bool EmitIndices;
+  bool EmitDeclIndices, EmitStmtIndices;
 
 public:
-  DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {}
+  DummyMatchVisitor(bool EmitDeclIndices = false, bool EmitStmtIndices = false)
+  : EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
   bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
 const ASTContext  = TU->getASTContext();
 const SourceManager  = Context.getSourceManager();
-LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices);
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitDeclIndices,
+   EmitStmtIndices);
 SubVisitor.TraverseDecl(TU);
 return false;
   }
 
-  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+  template  void match(StringRef Path, const T *D) {
+Match(Path, D->getLocStart());
+  }
 };
 
+bool LexicallyOrderedDeclVisitor::TraverseStmt(Stmt *S) {
+  Matcher.match("overridden TraverseStmt", S);
+  return LexicallyOrderedRecursiveASTVisitor::TraverseStmt(S);
+}
+
 bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
   std::string Path;
   llvm::raw_string_ostream OS(Path);
@@ -73,7 +86,16 @@
 if (isa(D) or isa(D))
   OS << "/";
   }
-  if (EmitIndices)
+  if (EmitDeclIndices)
+OS << "@" << Index++;
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+bool LexicallyOrderedDeclVisitor::VisitDeclRefExpr(const DeclRefExpr *D) {
+  std::string Name = D->getFoundDecl()->getNameAsString();
+  llvm::raw_string_ostream OS(Name);
+  if (EmitStmtIndices)
 OS << "@" << Index++;
   Matcher.match(OS.str(), D);
   return true;
@@ -151,13 +173,55 @@
 template  T f();
 template  class Class {};
 )";
-  DummyMatchVisitor Visitor(/*EmitIndices=*/true);
+  DummyMatchVisitor Visitor(/*EmitDeclIndices=*/true);
   Visitor.ExpectMatch("/f/T@0", 2, 11);
   Visitor.ExpectMatch("/f/f/@1", 2, 20);
   Visitor.ExpectMatch("/Class/U@2", 3, 11);
   Visitor.ExpectMatch("/Class/@3", 3, 20);
   Visitor.ExpectMatch("/Class/Class/@4", 3, 34);
   EXPECT_TRUE(Visitor.runOver(Source));
 }
 
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitCXXOperatorCallExpr) {
+  StringRef Source = R"(
+struct S {
+  S +(S&);
+  S *operator->();
+  S ++();
+  S operator++(int);
+  void operator()(int, int);
+  void operator[](int);
+  void f();
+};
+S a, b, c;
+
+void test() {
+  a = b + c;
+  a->f();
+  a(1, 2);
+  b[0];
+  ++a;
+  b++;
+}
+)";
+  DummyMatchVisitor Visitor(/*EmitDeclIndices=*/false,
+/*EmitStmtIndices=*/true);
+  // There are two overloaded operators that start at this point
+  // This makes sure they are both traversed using the overridden
+  // TraverseStmt, as the traversal is implemented by us for
+  // CXXOperatorCallExpr.
+  Visitor.ExpectMatch("overridden TraverseStmt", 14, 3, 2);
+  Visitor.ExpectMatch("a@0", 14, 3);
+  Visitor.ExpectMatch("operator=@1", 14, 5);
+  Visitor.ExpectMatch("b@2", 14, 7);
+  Visitor.ExpectMatch("operator+@3", 14, 9);
+  Visitor.ExpectMatch("c@4", 14, 11);
+  Visitor.ExpectMatch("operator->@6", 15, 4);
+  Visitor.ExpectMatch("operator()@8", 16, 4);
+  Visitor.ExpectMatch("operator[]@10", 17, 4);
+  Visitor.ExpectMatch("operator++@11", 18, 3);
+  Visitor.ExpectMatch("operator++@14", 19, 4);
+  

[PATCH] D37060: [clang-tidy] Improve hicpp-exception-baseclass to handle generic code better

2017-08-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I did not test this yet, but looks better :)




Comment at: test/clang-tidy/hicpp-exception-baseclass.cpp:26
   }
   throw non_derived_exception(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 
'non_derived_exception' is not derived from 'std::exception'

Could you please update the comments?
I find them misleading. What does this `bad` mean?
That this line is not handled correctly? Then please use `FIXME: wrong handling`
That this line is invalid? The `// CHECK-MESSAGES:` already states that...



Comment at: test/clang-tidy/hicpp-exception-baseclass.cpp:54-62
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 
'bad_generic_exception' is not derived from 'std::exception'
+// CHECK-MESSAGES: 71:1: note: type defined here
+// CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 
'bad_generic_exception' is not derived from 'std::exception'
+// CHECK-MESSAGES: 71:1: note: type defined here
+// CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 
'exotic_exception' is not derived from 'std::exception'
+// CHECK-MESSAGES: 74:1: note: type defined here
+// CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 
'int' is not derived from 'std::exception'

JonasToth wrote:
> these diagnostic come from the many instantiations of this function. 
> do you think, they should exist or rather not?
They definitively should exist.
But they also should ideally point to the origin of the `T`.


https://reviews.llvm.org/D37060



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


[PATCH] D37156: [SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer

2017-08-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@kcc I've disabled the relevant test on Mac in r311916, please revert my change 
once this CR goes through.


https://reviews.llvm.org/D37156



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


[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-08-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

It occurred to me that another approach for fixing the crash can be setting 
`IsTypeSpecifier` to `true` while we ParseCastExpression. According to

  cast-expression:
unary-expression
( type-id ) cast-expression
  type-id:
type-specifier-seq abstract-declarator[opt]

it looks reasonable to require `IsTypeSpecifier` during parsing part of cast 
expression inside parentheses.

What do you think? Is this approach worth pursuing? Does it sound better than 
the one offered initially?


https://reviews.llvm.org/D37089



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


[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-08-28 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

In https://reviews.llvm.org/D36915#854317, @ahatanak wrote:

> In https://reviews.llvm.org/D36915#849622, @faisalv wrote:
>
> > I don't think this approach is entirely correct for at least the following 
> > reasons:
> >
> > 1. in the lambda case the machinery that diagnoses capture failures should 
> > be the machinery erroring on the lambda (when the parameter is odr-used)
>
>
> Does this mean that it is OK to have a parameter or local variable appear in 
> a potentially-evaluated expression as long as it is not odr-used? I think 
> this is slightly different from the standard, which says a parameter or local 
> variable cannot appear as a potentially-evaluated expression in a default 
> argument.
>
> For example:
>
>   void foo2(int);
>  
>   void func() {
> const int a = 1;
> void foo1(S s = [](){ foo2(a); }); // "a" is not in an unevaluated 
> context and is not odr-used.
>   }
>  
>
>
> I think I need clarification as it will affect how or where we detect this 
> error.


'a' is not captured (and does not need to be captured) above, so I think that 
code should be ok.

But I also think the following code should be ok at local scope within func.
void foo(int = a);

I thought there was a DR against the standard-draft with the intent of making 
these valid (if they are not already so)?


https://reviews.llvm.org/D36915



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


Re: r311857 - Emit static constexpr member as available_externally definition

2017-08-28 Thread Hans Wennborg via cfe-commits
I reverted this in r311898 as it caused Chromium builds to fail with
an assertion; see PR34348.

On Sun, Aug 27, 2017 at 1:24 PM, Mehdi Amini via cfe-commits
 wrote:
> Author: mehdi_amini
> Date: Sun Aug 27 13:24:09 2017
> New Revision: 311857
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311857=rev
> Log:
> Emit static constexpr member as available_externally definition
>
> By exposing the constant initializer, the optimizer can fold many
> of these constructs.
>
> Differential Revision: https://reviews.llvm.org/D34992
>
> Added:
> cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=311857=311856=311857=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Aug 27 13:24:09 2017
> @@ -2437,6 +2437,28 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
>  D->getType().isConstant(Context) &&
>  isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
>GV->setSection(".cp.rodata");
> +
> +// Check if we a have a const declaration with an initializer, we may be
> +// able to emit it as available_externally to expose it's value to the
> +// optimizer.
> +if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() &&
> +D->getType().isConstQualified() && !GV->hasInitializer() &&
> +!D->hasDefinition() && D->hasInit() && !D->hasAttr()) 
> {
> +  const auto *Record =
> +  Context.getBaseElementType(D->getType())->getAsCXXRecordDecl();
> +  bool HasMutableFields = Record && Record->hasMutableFields();
> +  if (!HasMutableFields) {
> +const VarDecl *InitDecl;
> +const Expr *InitExpr = D->getAnyInitializer(InitDecl);
> +if (InitExpr) {
> +  GV->setConstant(true);
> +  GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
> +  ConstantEmitter emitter(*this);
> +  GV->setInitializer(emitter.tryEmitForInitializer(*InitDecl));
> +  emitter.finalize(GV);
> +}
> +  }
> +}
>}
>
>auto ExpectedAS =
>
> Added: cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp?rev=311857=auto
> ==
> --- cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp Sun Aug 27 13:24:09 
> 2017
> @@ -0,0 +1,55 @@
> +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | 
> FileCheck %s --check-prefix=CHECK --check-prefix=CXX11
> +// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | 
> FileCheck %s --check-prefix=CHECK --check-prefix=CXX17
> +
> +struct A {
> +  static const int Foo = 123;
> +};
> +// CHECK: @_ZN1A3FooE = constant i32 123, align 4
> +const int *p = ::Foo; // emit available_externally
> +const int A::Foo;   // convert to full definition
> +
> +struct Bar {
> +  int b;
> +};
> +
> +struct MutableBar {
> +  mutable int b;
> +};
> +
> +struct Foo {
> +  // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant 
> i32 42,
> +  // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
> +  static constexpr int ConstexprStaticMember = 42;
> +  // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 
> 43,
> +  static const int ConstStaticMember = 43;
> +
> +  // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally 
> constant %struct.Bar { i32 44 },
> +  // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant 
> %struct.Bar { i32 44 },
> +  static constexpr Bar ConstStaticStructMember = {44};
> +
> +  // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global 
> %struct.MutableBar,
> +  // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr 
> global %struct.MutableBar { i32 45 },
> +  static constexpr MutableBar ConstexprStaticMutableStructMember = {45};
> +};
> +// CHECK: @_ZL15ConstStaticexpr = internal constant i32 46,
> +static constexpr int ConstStaticexpr = 46;
> +// CHECK: @_ZL9ConstExpr = internal constant i32 46, align 4
> +static const int ConstExpr = 46;
> +
> +// CHECK: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar { i32 
> 47 },
> +static constexpr Bar ConstexprStaticStruct = {47};
> +
> +// CHECK: @_ZL28ConstexprStaticMutableStruct = internal global 
> %struct.MutableBar { i32 48 },
> +static constexpr MutableBar ConstexprStaticMutableStruct = {48};
> +
> +void use(const int &);
> +void foo() {
> +  use(Foo::ConstexprStaticMember);
> +  use(Foo::ConstStaticMember);
> +  

r311908 - [OPENMP] Remove unused header files, NFC.

2017-08-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Aug 28 12:26:54 2017
New Revision: 311908

URL: http://llvm.org/viewvc/llvm-project?rev=311908=rev
Log:
[OPENMP] Remove unused header files, NFC.

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=311908=311907=311908=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Aug 28 12:26:54 2017
@@ -22,10 +22,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
-#include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/OpenMPKinds.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"


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


[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@eugenis, thanks for the suggestion. I've found the problematic push (that 
attempts to move the wrong file) and filed https://reviews.llvm.org/D37226 for 
review.


Repository:
  rL LLVM

https://reviews.llvm.org/D26796



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


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D37122



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


r311905 - Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Aug 28 11:53:17 2017
New Revision: 311905

URL: http://llvm.org/viewvc/llvm-project?rev=311905=rev
Log:
Change Diagnostic Category size error from runtime to compiletime

Diagnostic Categories are fairly annoying, and are only enforced
by a runtime-debug-only assert. This puts in a touch more work
to get this all done at compile-time with static asserts

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/lib/Basic/DiagnosticIDs.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=311905=311904=311905=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Mon Aug 28 11:53:17 2017
@@ -26,19 +26,32 @@ namespace clang {
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + 
DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS
 };
 
 class CustomDiagInfo;

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=311905=311904=311905=diff
==
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Mon Aug 28 11:53:17 2017
@@ -68,6 +68,29 @@ struct StaticDiagInfoRec {
   }
 };
 
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   
\
+  static_assert(   
\
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  
\
+  static_cast(diag::DIAG_START_##NAME) + 
\
+  static_cast(diag::DIAG_SIZE_##NAME),   
\
+  STRINGIFY_NAME(  
\
+  DIAG_SIZE_##NAME) " is insufficient to contain all " 
\
+"diagnostics, it may need to be made larger in "   
\
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
+
 } // namespace anonymous
 
 static const StaticDiagInfoRec StaticDiagInfo[] = {
@@ -96,18 +119,6 @@ static const unsigned StaticDiagInfoSize
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // 

[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311905: Change Diagnostic Category size error from runtime 
to compiletime (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D37122?vs=112916=112931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37122

Files:
  cfe/trunk/include/clang/Basic/DiagnosticIDs.h
  cfe/trunk/lib/Basic/DiagnosticIDs.cpp

Index: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
===
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp
@@ -68,6 +68,29 @@
   }
 };
 
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   \
+  static_assert(   \
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  \
+  static_cast(diag::DIAG_START_##NAME) + \
+  static_cast(diag::DIAG_SIZE_##NAME),   \
+  STRINGIFY_NAME(  \
+  DIAG_SIZE_##NAME) " is insufficient to contain all " \
+"diagnostics, it may need to be made larger in "   \
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
+
 } // namespace anonymous
 
 static const StaticDiagInfoRec StaticDiagInfo[] = {
@@ -96,18 +119,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-assert(std::is_sorted(std::begin(StaticDiagInfo),
-  std::end(StaticDiagInfo)) &&
-   "Diag ID conflict, the enums at the start of clang::diag (in "
-   "DiagnosticIDs.h) probably need to be increased");
-IsFirst = false;
-  }
-#endif
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
===
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = 

[PATCH] D37038: Replace temp MD nodes with unique/distinct before cloning

2017-08-28 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGVTables.cpp:157
+  if (DebugInfo)
+DebugInfo->replaceTemporaryNodes();
+

probinson wrote:
> aprantl wrote:
> > Have you looked at what it would take to only finalize the nodes reachable 
> > via the function?
> > Otherwise — have you audited that this is always safe?
> I do not know how to find nodes reachable from a particular function, either 
> before or after they are finalized.
> 
> GenerateVarArgsThunk is called after we do EmitGlobalFunctionDefinition on 
> the function we are about to clone.  The ReplaceMap holds replaceable forward 
> type declarations, I think?  So I can imagine that codegen for a subsequent 
> function might need to create a complete type, even one that is reachable 
> from the function we are about to clone.
> 
> Of course I find the whole metadata memory management scheme pretty opaque, 
> but this is my best guess about the situation.
Alternatively, would it be possible to instruct CloneFunction to not clone any 
temporary MDNodes via one of the flags that are passed to ValueMapper?


https://reviews.llvm.org/D37038



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


[PATCH] D37005: [clang-diff] Initial implementation of patching

2017-08-28 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 112926.
johannes edited the summary of this revision.
johannes added a comment.

split to ASTDiff/ASTPatch


https://reviews.llvm.org/D37005

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTPatch.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  lib/Tooling/ASTDiff/ASTPatch.cpp
  lib/Tooling/ASTDiff/CMakeLists.txt
  test/Tooling/clang-diff-patch.test
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp
  unittests/Tooling/ASTDiffTest.cpp
  unittests/Tooling/CMakeLists.txt

Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -11,6 +11,7 @@
 endif()
 
 add_clang_unittest(ToolingTests
+  ASTDiffTest.cpp
   ASTSelectionTest.cpp
   CastExprTest.cpp
   CommentHandlerTest.cpp
@@ -43,4 +44,5 @@
   clangTooling
   clangToolingCore
   clangToolingRefactor
+  clangToolingASTDiff
   )
Index: unittests/Tooling/ASTDiffTest.cpp
===
--- /dev/null
+++ unittests/Tooling/ASTDiffTest.cpp
@@ -0,0 +1,86 @@
+//===- unittest/Tooling/ASTDiffTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/ASTDiff/ASTPatch.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+
+static std::string patchResult(std::array Codes) {
+  diff::SyntaxTree Trees[3];
+  std::unique_ptr ASTs[3];
+  std::vector Args = {};
+  for (int I = 0; I < 3; I++) {
+ASTs[I] = buildASTFromCode(Codes[I]);
+if (!ASTs[I]) {
+  llvm::errs() << "Failed to build AST from code:\n" << Codes[I] << "\n";
+  return "";
+}
+Trees[I] = diff::SyntaxTree(*ASTs[I]);
+  }
+
+  diff::ComparisonOptions Options;
+  std::string TargetDstCode;
+  llvm::raw_string_ostream OS(TargetDstCode);
+  if (!diff::patch(/*ModelSrc=*/Trees[0], /*ModelDst=*/Trees[1],
+   /*TargetSrc=*/Trees[2], Options, OS))
+return "";
+  return OS.str();
+}
+
+// abstract the EXPECT_EQ call so that the code snippets align properly
+// use macros for this to make test failures have proper line numbers
+#define PATCH(Preamble, ModelSrc, ModelDst, Target, Expected)  \
+  EXPECT_EQ(patchResult({{std::string(Preamble) + ModelSrc,\
+  std::string(Preamble) + ModelDst,\
+  std::string(Preamble) + Target}}),   \
+std::string(Preamble) + Expected)
+
+TEST(ASTDiff, TestDeleteArguments) {
+  PATCH(R"(void printf(const char *, ...);)",
+R"(void foo(int x) { printf("%d", x, x); })",
+R"(void foo(int x) { printf("%d", x); })",
+R"(void foo(int x) { printf("different string %d", x, x); })",
+R"(void foo(int x) { printf("different string %d", x); })");
+
+  PATCH(R"(void foo(...);)",
+R"(void test1() { foo ( 1 + 1); })",
+R"(void test1() { foo ( ); })",
+R"(void test2() { foo ( 1 + 1 ); })",
+R"(void test2() { foo (  ); })");
+
+  PATCH(R"(void foo(...);)",
+R"(void test1() { foo (1, 2 + 2); })",
+R"(void test1() { foo (2 + 2); })",
+R"(void test2() { foo (/*L*/ 0 /*R*/ , 2 + 2); })",
+R"(void test2() { foo (/*L*/  2 + 2); })");
+
+  PATCH(R"(void foo(...);)",
+R"(void test1() { foo (1, 2); })",
+R"(void test1() { foo (1); })",
+R"(void test2() { foo (0, /*L*/ 0 /*R*/); })",
+R"(void test2() { foo (0 /*R*/); })");
+}
+
+TEST(ASTDiff, TestDeleteDecls) {
+  PATCH(R"()",
+R"()",
+R"()",
+R"()",
+R"()");
+
+  PATCH(R"()",
+R"(void foo(){})",
+R"()",
+R"(int x; void foo() {;;} int y;)",
+R"(int x;  int y;)");
+}
Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/ASTDiff/ASTPatch.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -42,6 +43,12 @@
   cl::desc("Output a side-by-side diff in HTML."),
   cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt
+Patch("patch",
+  cl::desc("Try to apply the edit actions between the two input "
+   

[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-08-28 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> But I've never used the taint tracking mode, so I don't know what would be a 
> reasonable default for MaxComp.

that one is very experimental anyway. I'd just keep the functional changes to 
tain out of this patch and use the current default that taint uses.


https://reviews.llvm.org/D35450



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


[PATCH] D37156: [SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer

2017-08-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

I don't, but I can check whether tests pass.


https://reviews.llvm.org/D37156



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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2017-08-28 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Is this blocked on the same reasons as what was raised in 
https://reviews.llvm.org/D35109?


https://reviews.llvm.org/D35110



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


[PATCH] D37156: [SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer

2017-08-28 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a reviewer: george.karpenkov.
kcc added a comment.

+George, in case he knows about __attribute__((tls_model("initial-exec"))) on 
Mac




Comment at: 
compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc:218
+SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
+__attribute__((tls_model("initial-exec")))
+thread_local uintptr_t __sancov_lowest_stack;

I wonder if this going to work on Mac. 


https://reviews.llvm.org/D37156



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


[PATCH] D37156: [SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer

2017-08-28 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 112923.
morehouse added a comment.
Herald added a subscriber: kubamracek.

- Add weak definition of __sancov_lowest_stack to runtime.


https://reviews.llvm.org/D37156

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
  compiler-rt/test/fuzzer/deep-recursion.test
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
@@ -1,9 +1,9 @@
 ; This check verifies that stack depth instrumentation works correctly.
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 \
-; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s --enable-var-scope
+; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 \
 ; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \
-; RUN: -S | FileCheck %s --enable-var-scope
+; RUN: -S | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
@@ -14,13 +14,8 @@
 define i32 @foo() {
 entry:
 ; CHECK-LABEL: define i32 @foo
-; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
-; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[$intType:i[0-9]+]]
-; CHECK: [[lowest:%[^ \t]+]] = load [[$intType]], [[$intType]]* @__sancov_lowest_stack
-; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowest]]
-; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
-; CHECK: :[[ifLabel]]:
-; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* @__sancov_lowest_stack
+; CHECK-NOT: call i8* @llvm.frameaddress(i32 0)
+; CHECK-NOT: @__sancov_lowest_stack
 ; CHECK: ret i32 7
 
   ret i32 7
@@ -30,12 +25,12 @@
 entry:
 ; CHECK-LABEL: define i32 @bar
 ; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
-; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[$intType]]
-; CHECK: [[lowest:%[^ \t]+]] = load [[$intType]], [[$intType]]* @__sancov_lowest_stack
-; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowest]]
+; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[intType:i[0-9]+]]
+; CHECK: [[lowest:%[^ \t]+]] = load [[intType]], [[intType]]* @__sancov_lowest_stack
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[intType]] [[frameInt]], [[lowest]]
 ; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
 ; CHECK: :[[ifLabel]]:
-; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* @__sancov_lowest_stack
+; CHECK: store [[intType]] [[frameInt]], [[intType]]* @__sancov_lowest_stack
 ; CHECK: %call = call i32 @foo()
 ; CHECK: ret i32 %call
 
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -25,6 +25,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
@@ -200,13 +201,15 @@
  ArrayRef GepTraceTargets);
   void InjectTraceForSwitch(Function ,
 ArrayRef SwitchTraceTargets);
-  bool InjectCoverage(Function , ArrayRef AllBlocks);
+  bool InjectCoverage(Function , ArrayRef AllBlocks,
+  bool IsLeafFunc = true);
   GlobalVariable *CreateFunctionLocalArrayInSection(size_t NumElements,
 Function , Type *Ty,
 const char *Section);
   void CreateFunctionLocalArrays(Function , ArrayRef AllBlocks);
   void CreatePCArray(Function , ArrayRef AllBlocks);
-  void InjectCoverageAtBlock(Function , BasicBlock , size_t Idx);
+  void InjectCoverageAtBlock(Function , BasicBlock , size_t Idx,
+ bool IsLeafFunc = true);
   Function *CreateInitCallsForSections(Module , const char *InitFunctionName,
Type *Ty, const char *Section);
   std::pair
@@ -491,6 +494,7 @@
   (F).getDomTree();
   const PostDominatorTree *PDT =
   (F).getPostDomTree();
+  bool IsLeafFunc = true;
 
   for (auto  : F) {
 if (shouldInstrumentBlock(F, , DT, PDT, Options))
@@ -515,10 +519,14 @@
   if (Options.TraceGep)
 if (GetElementPtrInst *GEP = dyn_cast())
   GepTraceTargets.push_back(GEP);
-   }
+  if (Options.StackDepth)
+if (isa(Inst) ||
+(isa(Inst) && !isa(Inst)))
+  IsLeafFunc = false;
+}
   }
 
-  

[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-08-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D36915#849622, @faisalv wrote:

> I don't think this approach is entirely correct for at least the following 
> reasons:
>
> 1. in the lambda case the machinery that diagnoses capture failures should be 
> the machinery erroring on the lambda (when the parameter is odr-used)


Does this mean that it is OK to have a parameter or local variable appear in a 
potentially-evaluated expression as long as it is not odr-used? I think this is 
slightly different from the standard, which says a parameter or local variable 
cannot appear as a potentially-evaluated expression in a default argument.

For example:

  void foo2(int);
  
  void func() {
const int a = 1;
void foo1(S s = [](){ foo2(a); }); // "a" is not in an unevaluated context 
and is not odr-used.
  }

I think I need clarification as it will affect how or where we detect this 
error.


https://reviews.llvm.org/D36915



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


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 112916.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Moved static assert into a .cpp file, DiagnosticIDs.cpp seems like the one that 
makes the most sense.


https://reviews.llvm.org/D37122

Files:
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/DiagnosticIDs.cpp

Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -68,6 +68,29 @@
   }
 };
 
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   \
+  static_assert(   \
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  \
+  static_cast(diag::DIAG_START_##NAME) + \
+  static_cast(diag::DIAG_SIZE_##NAME),   \
+  STRINGIFY_NAME(  \
+  DIAG_SIZE_##NAME) " is insufficient to contain all " \
+"diagnostics, it may need to be made larger in "   \
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
+
 } // namespace anonymous
 
 static const StaticDiagInfoRec StaticDiagInfo[] = {
@@ -96,18 +119,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-assert(std::is_sorted(std::begin(StaticDiagInfo),
-  std::end(StaticDiagInfo)) &&
-   "Diag ID conflict, the enums at the start of clang::diag (in "
-   "DiagnosticIDs.h) probably need to be increased");
-IsFirst = false;
-  }
-#endif
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS
 };
 
 class CustomDiagInfo;
___
cfe-commits mailing list

r311899 - Fix inaccurate comment about -fdelayed-template-parsing and MSVC

2017-08-28 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Aug 28 10:59:24 2017
New Revision: 311899

URL: http://llvm.org/viewvc/llvm-project?rev=311899=rev
Log:
Fix inaccurate comment about -fdelayed-template-parsing and MSVC

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=311899=311898=311899=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Aug 28 10:59:24 2017
@@ -3846,8 +3846,10 @@ void Clang::ConstructJob(Compilation ,
 !IsWindowsMSVC || IsMSVC2015Compatible))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
-  // -fno-delayed-template-parsing is default, except for Windows where MSVC 
STL
-  // needs it.
+  // -fno-delayed-template-parsing is default, except when targetting MSVC.
+  // Many old Windows SDK versions require this to parse.
+  // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
+  // compiler. We should be able to disable this by default at some point.
   if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
 CmdArgs.push_back("-fdelayed-template-parsing");


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


[PATCH] D37104: [libc++] PR34298: Change std::function constructor and move assignment operator SFINAE checks to allow std::function with an incomplete return type

2017-08-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: 
test/libcxx/utilities/function.objects/func.require/incomplete_return_type.pass.cpp:17-19
+struct IncompleteReturnType {
+  std::function fn;
+};

Would it make sense to also check that this struct is copy-constructible? 
As-is, whether this test tests anything is entirely dependent on what amount to 
implementation details of the constructor.


Repository:
  rL LLVM

https://reviews.llvm.org/D37104



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


r311898 - Revert r311857 "Emit static constexpr member as available_externally definition"

2017-08-28 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug 28 10:53:00 2017
New Revision: 311898

URL: http://llvm.org/viewvc/llvm-project?rev=311898=rev
Log:
Revert r311857 "Emit static constexpr member as available_externally definition"

It caused PR759744.

> Emit static constexpr member as available_externally definition
>
> By exposing the constant initializer, the optimizer can fold many
> of these constructs.
>
> Differential Revision: https://reviews.llvm.org/D34992

Removed:
cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=311898=311897=311898=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 28 10:53:00 2017
@@ -2437,28 +2437,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 D->getType().isConstant(Context) &&
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
   GV->setSection(".cp.rodata");
-
-// Check if we a have a const declaration with an initializer, we may be
-// able to emit it as available_externally to expose it's value to the
-// optimizer.
-if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() &&
-D->getType().isConstQualified() && !GV->hasInitializer() &&
-!D->hasDefinition() && D->hasInit() && !D->hasAttr()) {
-  const auto *Record =
-  Context.getBaseElementType(D->getType())->getAsCXXRecordDecl();
-  bool HasMutableFields = Record && Record->hasMutableFields();
-  if (!HasMutableFields) {
-const VarDecl *InitDecl;
-const Expr *InitExpr = D->getAnyInitializer(InitDecl);
-if (InitExpr) {
-  GV->setConstant(true);
-  GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
-  ConstantEmitter emitter(*this);
-  GV->setInitializer(emitter.tryEmitForInitializer(*InitDecl));
-  emitter.finalize(GV);
-}
-  }
-}
   }
 
   auto ExpectedAS =

Removed: cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp?rev=311897=auto
==
--- cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp (removed)
@@ -1,55 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefix=CHECK --check-prefix=CXX11
-// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefix=CHECK --check-prefix=CXX17
-
-struct A {
-  static const int Foo = 123;
-};
-// CHECK: @_ZN1A3FooE = constant i32 123, align 4
-const int *p = ::Foo; // emit available_externally
-const int A::Foo;   // convert to full definition
-
-struct Bar {
-  int b;
-};
-
-struct MutableBar {
-  mutable int b;
-};
-
-struct Foo {
-  // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant 
i32 42,
-  // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
-  static constexpr int ConstexprStaticMember = 42;
-  // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 
43,
-  static const int ConstStaticMember = 43;
-
-  // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant 
%struct.Bar { i32 44 },
-  // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant 
%struct.Bar { i32 44 },
-  static constexpr Bar ConstStaticStructMember = {44};
-
-  // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global 
%struct.MutableBar,
-  // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr 
global %struct.MutableBar { i32 45 },
-  static constexpr MutableBar ConstexprStaticMutableStructMember = {45};
-};
-// CHECK: @_ZL15ConstStaticexpr = internal constant i32 46,
-static constexpr int ConstStaticexpr = 46;
-// CHECK: @_ZL9ConstExpr = internal constant i32 46, align 4
-static const int ConstExpr = 46;
-
-// CHECK: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar { i32 47 
},
-static constexpr Bar ConstexprStaticStruct = {47};
-
-// CHECK: @_ZL28ConstexprStaticMutableStruct = internal global 
%struct.MutableBar { i32 48 },
-static constexpr MutableBar ConstexprStaticMutableStruct = {48};
-
-void use(const int &);
-void foo() {
-  use(Foo::ConstexprStaticMember);
-  use(Foo::ConstStaticMember);
-  use(Foo::ConstStaticStructMember.b);
-  use(Foo::ConstexprStaticMutableStructMember.b);
-  use(ConstStaticexpr);
-  use(ConstExpr);
-  use(ConstexprStaticStruct.b);
-  use(ConstexprStaticMutableStruct.b);
-}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-28 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

In https://reviews.llvm.org/D26796#853446, @mgorny wrote:

> The problems:
>
> 1. 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/2140/steps/annotate/logs/stdio
>  -- purely this change,


This one still builds i686 libraries. Maybe it needs a clean cmake? Try 
"clobber" "1" in build properties.

[171/178] Linking CXX shared library 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/lib/clang/6.0.0/lib/linux/libclang_rt.asan-i686-android.so
[172/178] Linking CXX static library 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/lib/clang/6.0.0/lib/linux/libclang_rt.asan-i686-android.a

> 2. 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/2146/steps/run%20instrumented%20asan%20tests%20%5Bi686%2Ffugu-userdebug%2FN2G48C%5D/logs/stdio
>  -- after https://reviews.llvm.org/D26764.

This probably needs an update of 
zorg/buildbot/builders/sanitizers/buildbot_android.sh in the zorg repo.


Repository:
  rL LLVM

https://reviews.llvm.org/D26796



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


[PATCH] D37104: [libc++] PR34298: Change std::function constructor and move assignment operator SFINAE checks to allow std::function with an incomplete return type

2017-08-28 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: 
test/libcxx/utilities/function.objects/func.require/incomplete_return_type.pass.cpp:1
+//===--===//
+//

mclow.lists wrote:
> Is this file in the right place?
> If it's supposed to test functionality that is required by the standard, it 
> should go in `test/std` somewhere. 
> If it's supposed to test a libc++ extension, then it should go into 
> `test/libcxx`.
Never mind - I missed the "Non-standard extension" bit.



Repository:
  rL LLVM

https://reviews.llvm.org/D37104



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


[PATCH] D37104: [libc++] PR34298: Change std::function constructor and move assignment operator SFINAE checks to allow std::function with an incomplete return type

2017-08-28 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: 
test/libcxx/utilities/function.objects/func.require/incomplete_return_type.pass.cpp:1
+//===--===//
+//

Is this file in the right place?
If it's supposed to test functionality that is required by the standard, it 
should go in `test/std` somewhere. 
If it's supposed to test a libc++ extension, then it should go into 
`test/libcxx`.


Repository:
  rL LLVM

https://reviews.llvm.org/D37104



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


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/AllDiagnostics.h:37
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   
\
+  static_assert(   
\

I'd prefer it if we sank this into a .cpp file so that when it fails, it 
doesn't create a waterfall of colorful static_assert errors. :)


https://reviews.llvm.org/D37122



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-28 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In https://reviews.llvm.org/D36806#848246, @hintonda wrote:

> It's just too bad llvm::cantFail() doesn't take an optional string.
>  But the code is cleaner, so I won't comment further.


That's not a bad idea actually. Let me add an optional error message to 
cantFail for you.


https://reviews.llvm.org/D36806



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-08-28 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added inline comments.



Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:364
   if (symLHS && symRHS &&
-  (symLHS->computeComplexity() + symRHS->computeComplexity()) <  MaxComp)
+  (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp)
 return makeNonLoc(symLHS, Op, symRHS, ResultTy);

zaks.anna wrote:
> ddcc wrote:
> > zaks.anna wrote:
> > > As a follow up to the previous version of this patch, I do not think we 
> > > should set the default complexity limit to 1.
> > > 
> > > What is the relation between this limit and the limit in 
> > > VisitNonLocSymbolVal? If they are related, would it be worthwhile turning 
> > > these into an analyzer option?
> > To clarify, the current version of this patch does not modify the `MaxComp` 
> > parameter.
> > 
> > My understanding is that `MaxComp` is the upper bound for building a new 
> > `NonLoc` symbol from two children, based on the sum of the number of child 
> > symbols (complexity) across both children.
> > 
> > In contrast, the limit in `VisitNonLocSymbolVal` (@NoQ, correct me if I'm 
> > wrong), is the upper bound for recursively evaluating and inlining a 
> > `NonLoc` symbol, triggered from `simplifySVal` by `evalBinOpNN`. Note that 
> > these two latter functions indirectly call each other recursively (through 
> > `evalBinOp`), causing the previous runtime blowup. Furthermore, each call 
> > to `computeComplexity`will re-iterate through all child symbols of the 
> > current symbol, but only the first complexity check at the root symbol is 
> > actually necessary, because by definition the complexity of a child symbol 
> > at each recursive call is monotonically decreasing.
> > 
> > I think it'd be useful to allow both to be configurable, but I don't see a 
> > direct relationship between the two.
> > To clarify, the current version of this patch does not modify the MaxComp 
> > parameter.
> 
> I know. Also, currently, it is only used in the unsupported taint tracking 
> mode and only for tainted symbols. I would like a different smaller default 
> for all expressions.
Ok. I can make both configurable as part of this patch, with a new default of 
10 for `VisitNonLocSymbolVal`. But I've never used the taint tracking mode, so 
I don't know what would be a reasonable default for `MaxComp`.


https://reviews.llvm.org/D35450



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-08-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33852#854176, @Prazek wrote:

> In https://reviews.llvm.org/D33852#853982, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D33852#853410, @Prazek wrote:
> >
> > > Sorry for so late fixes, but it would be good to put it in 5.0
> >
> >
> > I do not think this should be in 5.0, as I believe we're only accepting 
> > regression fixes at this point.
>
>
> This is a regression. __declspec(selectany) works completely fine on linux 
> with 4.0. Without it clang-5.0 will be useless for any major windows project 
> compiled on linux.
>
> edit:
>  here is a regression: https://reviews.llvm.org/D32083


This is also adding new functionality that has had zero testing because it 
removes *all* target-specific checking for the attribute. Under the previous 
functionality (changed in https://reviews.llvm.org/D32083), this still required 
some mention of microsoft something (it went from requiring microsoft 
extensions to be enabled to instead require a Windows target) -- that's been 
entirely removed from this patch so now you can use this attribute for all 
target architectures, so it's not purely fixing a regression. Given how late we 
are in the release cycle, I am uncomfortable with this going in to 5.0, but I'd 
have no problems letting it bake for a bit and putting it into 5.1 (or 5.0.1, 
however we're naming bug releases these days).


https://reviews.llvm.org/D33852



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


[PATCH] D36802: AMDGPU: Cleanup most of the macros

2017-08-28 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: lib/Basic/Targets/AMDGPU.cpp:362
+Builder.defineMacro(Twine("__") + Twine(GPUName));
+Builder.defineMacro(Twine("__") + Twine(GPUName) + Twine("__"));
+  }

At the meeting we discussed defining every alias of the given GPU, rather than 
only the mcpu name.   Were we going to proceed with that?


https://reviews.llvm.org/D36802



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


[PATCH] D35133: [cmake] Use new GetSVN.cmake SOURCE_DIRS parameter

2017-08-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

Since the dependent patch landed, this LGTM too.


https://reviews.llvm.org/D35133



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-08-28 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D33852#853982, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33852#853410, @Prazek wrote:
>
> > Sorry for so late fixes, but it would be good to put it in 5.0
>
>
> I do not think this should be in 5.0, as I believe we're only accepting 
> regression fixes at this point.


This is a regression. __declspec(selectany) works completely fine on linux with 
4.0. Without it clang-5.0 will be useless for any major windows project 
compiled on linux.


https://reviews.llvm.org/D33852



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


[PATCH] D37203: [Bash-autocompletion] Follow up patch for D36782

2017-08-28 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Technically, this patch fixes your issue, but I don't think this is a good way 
of fixing it because `parse()` function now has an internal state which is not 
obvious to the user of the function. Can you review 
https://reviews.llvm.org/D37217? This is an alternative fix that doesn't use a 
static local variables.


https://reviews.llvm.org/D37203



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


[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I might be missing something but currently clang-tidy is not built at all when 
static analyzer is disabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D37188



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


[PATCH] D37142: clang-format: [JS] simplify template string wrapping.

2017-08-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1139
+
+  // On lines containing template strings, propagate NoLineBreak even for dict
+  // and array literals. This is to force wrapping an initial function call if

djasper wrote:
> mprobst wrote:
> > djasper wrote:
> > > This is not the right way to implement this:
> > > 
> > > - This is a static computation that we could do ahead of time. Doing it 
> > > inside the combinatorial exploration of solutions is a waste.
> > > - You are doing this always, even in code that doesn't have template 
> > > strings or isn't even JavaScript.
> > > - This can lead to unexpected behavior if the template string is in a 
> > > completely unrelated part of the statement. E.g.
> > > 
> > > 
> > >   someFunction(`test`, { ... });
> > > 
> > > will be formatted differently from
> > > 
> > >   someFunction('test', { ... });
> > Ack. Do you have suggestions?
> > 
> > I could introduce a `bool  ParenState::NoLineBreakMustPropagate;` that 
> > controls this behaviour.
> That, too, would create a significant memory and runtime overhead to everyone 
> just to fix this rather minor formatting detail.
> If we were to set MatchingParen correctly to match up "${" to "}", we could 
> measure the respective length and at a very early state (mustBreak()) decide 
> that we need a line break between "${" and the corresponding "}". Now setting 
> that correctly might be hard. Maybe it is ok, to linearly scan in that case 
> as we would only do that if we actually find a template string ending in "${" 
> and the distance to the "}" is usually short.
I cannot decide whether I must break in `mustBreak` - I need to just force 
wrapping after `${` if I need to wrap somewhere below, but if the code fits on 
the line, I don't want to wrap. So when I'm visiting `${` I cannot decide that, 
and when I'm at the object literal expression, the decision for `${` has 
already been made - right? Or am I missing something?


https://reviews.llvm.org/D37142



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-28 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h:23-37
+/// A common refactoring action rule interface.
+class RefactoringActionRule {
+public:
+  enum RuleKind { SourceChangeRefactoringRuleKind };
+
+  RuleKind getRuleKind() const { return Kind; }
+

arphaman wrote:
> klimek wrote:
> > Sorry for being late, was out on vacation.
> > Generally, why do we need this tag-based abstraction here instead of using 
> > the more typical OO double-dispatch where necessary?
> > (We do this in the AST a lot, but the AST is special, because there we want 
> > to implement a lot of different algorithms that rely on the node type, 
> > while I don't see how that applies here)
> Generally the clients will have to somehow distinguish between the types of 
> results that are produced by rules to figure out what to do (e.g. 
> AtomicChanges -> apply, SymbolOccurrences -> ask user, Continuation -> look 
> for more ASTs). So far I've thought that the LLVM based dynamic casts will 
> work well for this, e.g. 
> 
> ```
> if (auto *Action = dyn_cast()) {
>   Expected Changes = 
> Action->createSourceReplacements();
>   applyChanges(Changes);
> } else if (...) {
>   ...
> } else (...) {
>...
> }
> ```
> 
> But you're probably right, there might be a better way to do this rather than 
> the tag based approach. Something like a consumer class that clients can 
> implement that provides consumer functions that take in the specific results. 
> I reckon a single consumer will actually work better in the long-run when we 
> might Continuations that both return changes in the first TU and information 
> for searches in other TUs. I'll see if I can get a patch out that removes 
> this tag and uses the consumer approach.
Cool, looking forward to it :)


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

IIUC, these are the only clang-tidy tests that need static analyzer:

clang/tools/extra/test/clang-tidy/nolint.cpp
clang/tools/extra/test/clang-tidy/static-analyzer.cpp
clang/tools/extra/test/clang-tidy/static-analyzer-config.cpp
clang/tools/extra/test/clang-tidy/temporaries.cpp

as well as the mpi module and its tests:
clang/tools/extra/clang-tidy/mpi/*
clang/tools/extra/test/clang-tidy/mpi-buffer-deref.cpp
clang/tools/extra/test/clang-tidy/mpi-type-mismatch.cpp


Repository:
  rL LLVM

https://reviews.llvm.org/D37188



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h:23-37
+/// A common refactoring action rule interface.
+class RefactoringActionRule {
+public:
+  enum RuleKind { SourceChangeRefactoringRuleKind };
+
+  RuleKind getRuleKind() const { return Kind; }
+

klimek wrote:
> Sorry for being late, was out on vacation.
> Generally, why do we need this tag-based abstraction here instead of using 
> the more typical OO double-dispatch where necessary?
> (We do this in the AST a lot, but the AST is special, because there we want 
> to implement a lot of different algorithms that rely on the node type, while 
> I don't see how that applies here)
Generally the clients will have to somehow distinguish between the types of 
results that are produced by rules to figure out what to do (e.g. AtomicChanges 
-> apply, SymbolOccurrences -> ask user, Continuation -> look for more ASTs). 
So far I've thought that the LLVM based dynamic casts will work well for this, 
e.g. 

```
if (auto *Action = dyn_cast()) {
  Expected Changes = 
Action->createSourceReplacements();
  applyChanges(Changes);
} else if (...) {
  ...
} else (...) {
   ...
}
```

But you're probably right, there might be a better way to do this rather than 
the tag based approach. Something like a consumer class that clients can 
implement that provides consumer functions that take in the specific results. I 
reckon a single consumer will actually work better in the long-run when we 
might Continuations that both return changes in the first TU and information 
for searches in other TUs. I'll see if I can get a patch out that removes this 
tag and uses the consumer approach.


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer

2017-08-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

This could be done even more granularly, since clang-tidy only needs static 
analyzer to run clang-analyzer-* checks. But that would involve some careful 
#ifdef-ing of the parts of clang-tidy/ClangTidy.cpp, so I'll understand if you 
say you have little interest in this.


Repository:
  rL LLVM

https://reviews.llvm.org/D37188



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-28 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h:23-37
+/// A common refactoring action rule interface.
+class RefactoringActionRule {
+public:
+  enum RuleKind { SourceChangeRefactoringRuleKind };
+
+  RuleKind getRuleKind() const { return Kind; }
+

Sorry for being late, was out on vacation.
Generally, why do we need this tag-based abstraction here instead of using the 
more typical OO double-dispatch where necessary?
(We do this in the AST a lot, but the AST is special, because there we want to 
implement a lot of different algorithms that rely on the node type, while I 
don't see how that applies here)


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D37120: [analyzer] Fix modeling arithmetic

2017-08-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D37120



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


[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

The fact `TraverseCXXOperatorCallExpr` can't call its super 
`TraverseCXXOperatorCallExpr` makes the current solution kind of broken. The 
super implementation of `TraverseCXXOperatorCallExpr` is responsible for 
dispatch to WalkUp##STMT functions which actually call 
`VisitCXXOperatorCallExpr` which our current visitor will never call because of 
the custom "override". I would like to suggest an alternative approach that I 
think solves the problem more "elegantly":

Modify the `DEF_TRAVERSE_STMT` macro in RecursiveASTVisitor.h call to a wrapper 
function to get the children:

  class RecursiveASTVisitor {
  public:
  
Stmt::child_range getStmtChildren(Stmt *S) {
  return S->children();
}
   
  ...
  
  #define DEF_TRAVERSE_STMT(STMT, CODE) 
 \
template  
 \
bool RecursiveASTVisitor::Traverse##STMT(  
 \
STMT *S, DataRecursionQueue *Queue) {   
 \
  bool ShouldVisitChildren = true;  
 \
  bool ReturnValue = true;  
 \
  if (!getDerived().shouldTraversePostOrder())  
 \
TRY_TO(WalkUpFrom##STMT(S));
 \
  { CODE; } 
 \
  if (ShouldVisitChildren) {
 \
for (Stmt *SubStmt : getDerived().getStmtChildren(S)) { 
   \   // The only change is on this line.
  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); 
 \
}   
 \
  } 
 \
  if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder())  
 \
TRY_TO(WalkUpFrom##STMT(S));
 \
  return ReturnValue;   
 \
}
  
  ...
  
  };

Then you could provide an "override" in the 
`LexicallyOrderedRecursiveASTVisitor` that adjusts children just for 
`CXXOperatorCallExpr`. Something like this should work:

  class LexicallyOrderedRecursiveASTVisitor {
  public:
  ...
  
Stmt::child_range getStmtChildren(Stmt *S) {
  return S->children();
}
  
SmallVector getStmtChildren(CXXOperatorCallExpr *CE) {
  SmallVector Children(CE->children());
  bool Swap;
  // Switch the operator and the first operand for all infix and postfix
  // operations.
  switch (CE->getOperator()) {
  case OO_Arrow:
  case OO_Call:
  case OO_Subscript:
Swap = true;
break;
  case OO_PlusPlus:
  case OO_MinusMinus:
// These are postfix unless there is exactly one argument.
Swap = Children.size() != 2;
break;
  default:
Swap = CE->isInfixBinaryOp();
break;
  }
  if (Swap && Children.size() > 1)
std::swap(Children[0], Children[1]);
  return Children;
}
  
  ...
  };

WDYT?

Sorry about not seeing this earlier. Thanks for your patience!


https://reviews.llvm.org/D37200



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


[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 112894.
johannes added a comment.

detect prefix/postfix from number of arguments


https://reviews.llvm.org/D37200

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RecursiveASTVisitor.h
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -21,42 +21,55 @@
 : public LexicallyOrderedRecursiveASTVisitor {
 public:
   LexicallyOrderedDeclVisitor(DummyMatchVisitor ,
-  const SourceManager , bool EmitIndices)
+  const SourceManager , bool EmitDeclIndices,
+  bool EmitStmtIndices)
   : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher),
-EmitIndices(EmitIndices) {}
+EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
 
   bool TraverseDecl(Decl *D) {
 TraversalStack.push_back(D);
 LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
 TraversalStack.pop_back();
 return true;
   }
 
+  bool TraverseStmt(Stmt *S);
+
   bool VisitNamedDecl(const NamedDecl *D);
+  bool VisitDeclRefExpr(const DeclRefExpr *D);
 
 private:
   DummyMatchVisitor 
-  bool EmitIndices;
+  bool EmitDeclIndices, EmitStmtIndices;
   unsigned Index = 0;
   llvm::SmallVector TraversalStack;
 };
 
 class DummyMatchVisitor : public ExpectedLocationVisitor {
-  bool EmitIndices;
+  bool EmitDeclIndices, EmitStmtIndices;
 
 public:
-  DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {}
+  DummyMatchVisitor(bool EmitDeclIndices = false, bool EmitStmtIndices = false)
+  : EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
   bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
 const ASTContext  = TU->getASTContext();
 const SourceManager  = Context.getSourceManager();
-LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices);
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitDeclIndices,
+   EmitStmtIndices);
 SubVisitor.TraverseDecl(TU);
 return false;
   }
 
-  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+  template  void match(StringRef Path, const T *D) {
+Match(Path, D->getLocStart());
+  }
 };
 
+bool LexicallyOrderedDeclVisitor::TraverseStmt(Stmt *S) {
+  Matcher.match("overridden TraverseStmt", S);
+  return LexicallyOrderedRecursiveASTVisitor::TraverseStmt(S);
+}
+
 bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
   std::string Path;
   llvm::raw_string_ostream OS(Path);
@@ -73,7 +86,16 @@
 if (isa(D) or isa(D))
   OS << "/";
   }
-  if (EmitIndices)
+  if (EmitDeclIndices)
+OS << "@" << Index++;
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+bool LexicallyOrderedDeclVisitor::VisitDeclRefExpr(const DeclRefExpr *D) {
+  std::string Name = D->getFoundDecl()->getNameAsString();
+  llvm::raw_string_ostream OS(Name);
+  if (EmitStmtIndices)
 OS << "@" << Index++;
   Matcher.match(OS.str(), D);
   return true;
@@ -151,13 +173,55 @@
 template  T f();
 template  class Class {};
 )";
-  DummyMatchVisitor Visitor(/*EmitIndices=*/true);
+  DummyMatchVisitor Visitor(/*EmitDeclIndices=*/true);
   Visitor.ExpectMatch("/f/T@0", 2, 11);
   Visitor.ExpectMatch("/f/f/@1", 2, 20);
   Visitor.ExpectMatch("/Class/U@2", 3, 11);
   Visitor.ExpectMatch("/Class/@3", 3, 20);
   Visitor.ExpectMatch("/Class/Class/@4", 3, 34);
   EXPECT_TRUE(Visitor.runOver(Source));
 }
 
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitCXXOperatorCallExpr) {
+  StringRef Source = R"(
+struct S {
+  S +(S&);
+  S *operator->();
+  S ++();
+  S operator++(int);
+  void operator()(int, int);
+  void operator[](int);
+  void f();
+};
+S a, b, c;
+
+void test() {
+  a = b + c;
+  a->f();
+  a(1, 2);
+  b[0];
+  ++a;
+  b++;
+}
+)";
+  DummyMatchVisitor Visitor(/*EmitDeclIndices=*/false,
+/*EmitStmtIndices=*/true);
+  // There are two overloaded operators that start at this point
+  // This makes sure they are both traversed using the overridden
+  // TraverseStmt, as the traversal is implemented by us for
+  // CXXOperatorCallExpr.
+  Visitor.ExpectMatch("overridden TraverseStmt", 14, 3, 2);
+  Visitor.ExpectMatch("a@0", 14, 3);
+  Visitor.ExpectMatch("operator=@1", 14, 5);
+  Visitor.ExpectMatch("b@2", 14, 7);
+  Visitor.ExpectMatch("operator+@3", 14, 9);
+  Visitor.ExpectMatch("c@4", 14, 11);
+  Visitor.ExpectMatch("operator->@6", 15, 4);
+  Visitor.ExpectMatch("operator()@8", 16, 4);
+  Visitor.ExpectMatch("operator[]@10", 17, 4);
+  Visitor.ExpectMatch("operator++@11", 18, 3);
+  Visitor.ExpectMatch("operator++@14", 19, 4);
+  

[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:149
+  auto Offset = [&](Stmt *S) { return SM.getFileOffset(S->getLocStart()); 
};
+  Swap = Offset(Children[0]) > Offset(Children[1]);
+  break;

For `++` and `--` you can see whether its prefix or postfix by looking at the 
number of arguments. If there's one argument, then `++` and `--` are prefix. 
Otherwise, they're postfix.


https://reviews.llvm.org/D37200



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


[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

The previous version didn't call TraverseDecl of the derived class, this is 
fixed now.
The public getDerived.TraverseStmt() does not accept a DataRecursionQueue, so 
this also could not be used (I think)
 I used the wrapper TraverseStmtBase, which should behave exactly as the method 
that originally traverses CXXOperatorCallExpr




Comment at: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h:63
   using BaseType = RecursiveASTVisitor;
+  using typename BaseType::DataRecursionQueue;
 

arphaman wrote:
> Do you still need the using here?
removed it now as it's only used once


https://reviews.llvm.org/D37200



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


[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor

2017-08-28 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 112889.
johannes added a comment.

do call derived TraverseStmt for children of CXXOperatorCallExpr


https://reviews.llvm.org/D37200

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RecursiveASTVisitor.h
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -21,42 +21,55 @@
 : public LexicallyOrderedRecursiveASTVisitor {
 public:
   LexicallyOrderedDeclVisitor(DummyMatchVisitor ,
-  const SourceManager , bool EmitIndices)
+  const SourceManager , bool EmitDeclIndices,
+  bool EmitStmtIndices)
   : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher),
-EmitIndices(EmitIndices) {}
+EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
 
   bool TraverseDecl(Decl *D) {
 TraversalStack.push_back(D);
 LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
 TraversalStack.pop_back();
 return true;
   }
 
+  bool TraverseStmt(Stmt *S);
+
   bool VisitNamedDecl(const NamedDecl *D);
+  bool VisitDeclRefExpr(const DeclRefExpr *D);
 
 private:
   DummyMatchVisitor 
-  bool EmitIndices;
+  bool EmitDeclIndices, EmitStmtIndices;
   unsigned Index = 0;
   llvm::SmallVector TraversalStack;
 };
 
 class DummyMatchVisitor : public ExpectedLocationVisitor {
-  bool EmitIndices;
+  bool EmitDeclIndices, EmitStmtIndices;
 
 public:
-  DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {}
+  DummyMatchVisitor(bool EmitDeclIndices = false, bool EmitStmtIndices = false)
+  : EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
   bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
 const ASTContext  = TU->getASTContext();
 const SourceManager  = Context.getSourceManager();
-LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices);
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitDeclIndices,
+   EmitStmtIndices);
 SubVisitor.TraverseDecl(TU);
 return false;
   }
 
-  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+  template  void match(StringRef Path, const T *D) {
+Match(Path, D->getLocStart());
+  }
 };
 
+bool LexicallyOrderedDeclVisitor::TraverseStmt(Stmt *S) {
+  Matcher.match("overridden TraverseStmt", S);
+  return LexicallyOrderedRecursiveASTVisitor::TraverseStmt(S);
+}
+
 bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
   std::string Path;
   llvm::raw_string_ostream OS(Path);
@@ -73,7 +86,16 @@
 if (isa(D) or isa(D))
   OS << "/";
   }
-  if (EmitIndices)
+  if (EmitDeclIndices)
+OS << "@" << Index++;
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+bool LexicallyOrderedDeclVisitor::VisitDeclRefExpr(const DeclRefExpr *D) {
+  std::string Name = D->getFoundDecl()->getNameAsString();
+  llvm::raw_string_ostream OS(Name);
+  if (EmitStmtIndices)
 OS << "@" << Index++;
   Matcher.match(OS.str(), D);
   return true;
@@ -151,13 +173,55 @@
 template  T f();
 template  class Class {};
 )";
-  DummyMatchVisitor Visitor(/*EmitIndices=*/true);
+  DummyMatchVisitor Visitor(/*EmitDeclIndices=*/true);
   Visitor.ExpectMatch("/f/T@0", 2, 11);
   Visitor.ExpectMatch("/f/f/@1", 2, 20);
   Visitor.ExpectMatch("/Class/U@2", 3, 11);
   Visitor.ExpectMatch("/Class/@3", 3, 20);
   Visitor.ExpectMatch("/Class/Class/@4", 3, 34);
   EXPECT_TRUE(Visitor.runOver(Source));
 }
 
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitCXXOperatorCallExpr) {
+  StringRef Source = R"(
+struct S {
+  S +(S&);
+  S *operator->();
+  S ++();
+  S operator++(int);
+  void operator()(int, int);
+  void operator[](int);
+  void f();
+};
+S a, b, c;
+
+void test() {
+  a = b + c;
+  a->f();
+  a(1, 2);
+  b[0];
+  ++a;
+  b++;
+}
+)";
+  DummyMatchVisitor Visitor(/*EmitDeclIndices=*/false,
+/*EmitStmtIndices=*/true);
+  // There are two overloaded operators that start at this point
+  // This makes sure they are both traversed using the overridden
+  // TraverseStmt, as the traversal is implemented by us for
+  // CXXOperatorCallExpr.
+  Visitor.ExpectMatch("overridden TraverseStmt", 14, 3, 2);
+  Visitor.ExpectMatch("a@0", 14, 3);
+  Visitor.ExpectMatch("operator=@1", 14, 5);
+  Visitor.ExpectMatch("b@2", 14, 7);
+  Visitor.ExpectMatch("operator+@3", 14, 9);
+  Visitor.ExpectMatch("c@4", 14, 11);
+  Visitor.ExpectMatch("operator->@6", 15, 4);
+  Visitor.ExpectMatch("operator()@8", 16, 4);
+  Visitor.ExpectMatch("operator[]@10", 17, 4);
+  Visitor.ExpectMatch("operator++@11", 18, 3);
+  Visitor.ExpectMatch("operator++@14", 19, 4);
+  

  1   2   >