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

2017-08-17 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:308
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";

You can flip the condition to do early continue.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:319-320
 OS << ", Values);\n";
 OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
 OS << " \"Couldn't add values to OptTable!\");\n";
   }

Can you split the string after each "\n"? It seems the current way of splitting 
is somewhat arbitrary.


https://reviews.llvm.org/D36820



___
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-17 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111611.
yamaguchi marked 3 inline comments as done.
yamaguchi added a comment.

Update diff.


https://reviews.llvm.org/D36820

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


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -307,10 +307,11 @@
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";
+  OS << "bool ValuesWereAdded;\n";
   OS << R.getValueAsString("ValuesCode");
   OS << "\n";
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";
 std::string S = (Pref + R.getValueAsString("Name")).str();
 write_cstring(OS, S);
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/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: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,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: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -307,10 +307,11 @@
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";
+  OS << "bool ValuesWereAdded;\n";
   OS << R.getValueAsString("ValuesCode");
   OS << "\n";
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";
 std::string S = (Pref + R.getValueAsString("Name")).str();
 write_cstring(OS, S);
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/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: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,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">;
___
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-17 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added inline comments.



Comment at: include/clang/Sema/Sema.h:5466
 
+  /// ActOnLambdaTemplateParameterList - This is called after parsing
+  /// the explicit template parameter list (if it exists) in C++2a.

Avoid listing the name of the function: replace a w a \brief comment.



Comment at: lib/Parse/ParseExprCXX.cpp:1112
 
+  ParseScope TemplateParamScope(this, Scope::TemplateParamScope);
+  if (getLangOpts().CPlusPlus2a && Tok.is(tok::less)) {

We always create a template parameter scope here - but it's only the right 
scope if we have explicit template parameters, correct?

What I think we should do here is :
  - factor out (preferably as a separate patch) the post 
explicit-template-parameter-list parsing into a separate function (F1) which is 
then called from here.
  - then in this patch factor out the explicit template-parameter-list parsing 
also into a separate function that then either calls the function above ('F1'), 
or sequenced these statements before a call to 'F1'
  - also since gcc has had explicit template parameters on their generic 
lambdas for a while, can we find out under what options they have it enabled, 
and consider enabling it under those options for our gcc emulation mode? (or 
add a fixme for it?)
  - should we enable these explicit template parameters for pre-C++2a modes and 
emit extension/compatibility warnings where appropriate?




Comment at: lib/Parse/ParseExprCXX.cpp:1123
+  Diag(RAngleLoc,
+   diag::err_expected_lambda_template_parameter_list);
+}

I think it might be more user friendly if you used a different error message 
for the <> case here - along the lines of: empty template parameter list is not 
allowed 


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] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-17 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.

This is a minimally intrusive change, which I've verified works for both x86 
and x64.

The idea is to add another bool data member, `IsDevDivInternal`. (This could be 
unified with `IsVS2017OrNewer`, since it's a 3-way setting. Either a build is 
DevDiv-internal, released VS 2017 or newer, or released VS 2015 or older. I can 
easily make such a change if desired.) When looking at the directory structure, 
if instead of `"VC"` we see `"x86ret"`, `"x86chk"`, `"amd64ret"`, or 
`"amd64chk"`, we recognize this as a DevDiv-internal build.

After we get past the directory structure validation, we use this knowledge to 
regenerate paths appropriately. `llvmArchToDevDivInternalArch()` knows how we 
use `"i386"` subdirectories, and `MSVCToolChain::getSubDirectoryPath()` uses 
that. It also knows that DevDiv-internal builds have an `"inc"` subdirectory 
instead of `"include"`.

This may still not be the "right" fix in any sense, but I believe that it's 
non-intrusive in the sense that if the special directory names aren't found, 
`IsDevDivInternal` remains `false` and no codepaths are affected. I searched 
for all references to `IsVS2017OrNewer`, which are places where Clang cares 
about VS's directory structure, and the only one that isn't being patched is 
some logic to deal with cross-compilation. I'm fine with that not working for 
DevDiv-internal builds for the moment (we typically test the native compilers).

Is there still time to get a patch like this into 5.0.0, or is it too late?


https://reviews.llvm.org/D36860

Files:
  lib/Driver/ToolChains/MSVC.cpp
  lib/Driver/ToolChains/MSVC.h

Index: lib/Driver/ToolChains/MSVC.h
===
--- lib/Driver/ToolChains/MSVC.h
+++ lib/Driver/ToolChains/MSVC.h
@@ -131,6 +131,7 @@
 private:
   std::string VCToolChainPath;
   bool IsVS2017OrNewer = false;
+  bool IsDevDivInternal = false;
   CudaInstallationDetector CudaInstallation;
 };
 
Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -76,7 +76,8 @@
 
 // Check various environment variables to try and find a toolchain.
 static bool findVCToolChainViaEnvironment(std::string ,
-  bool ) {
+  bool ,
+  bool ) {
   // These variables are typically set by vcvarsall.bat
   // when launching a developer command prompt.
   if (llvm::Optional VCToolsInstallDir =
@@ -138,6 +139,13 @@
   Path = ParentPath;
   IsVS2017OrNewer = false;
   return true;
+} else if (llvm::sys::path::filename(ParentPath) == "x86ret"
+|| llvm::sys::path::filename(ParentPath) == "x86chk"
+|| llvm::sys::path::filename(ParentPath) == "amd64ret"
+|| llvm::sys::path::filename(ParentPath) == "amd64chk") {
+  Path = ParentPath;
+  IsDevDivInternal = true;
+  return true;
 }
 
   } else {
@@ -677,7 +685,7 @@
   // what they want to use.
   // Failing that, just try to find the newest Visual Studio version we can
   // and use its default VC toolchain.
-  findVCToolChainViaEnvironment(VCToolChainPath, IsVS2017OrNewer) ||
+  findVCToolChainViaEnvironment(VCToolChainPath, IsVS2017OrNewer, IsDevDivInternal) ||
   findVCToolChainViaSetupConfig(VCToolChainPath, IsVS2017OrNewer) ||
   findVCToolChainViaRegistry(VCToolChainPath, IsVS2017OrNewer);
 }
@@ -766,6 +774,21 @@
   }
 }
 
+// Similar to the above function, but for DevDiv internal builds.
+static const char *llvmArchToDevDivInternalArch(llvm::Triple::ArchType Arch) {
+  using ArchType = llvm::Triple::ArchType;
+  switch (Arch) {
+  case ArchType::x86:
+return "i386";
+  case ArchType::x86_64:
+return "amd64";
+  case ArchType::arm:
+return "arm";
+  default:
+return "";
+  }
+}
+
 // Get the path to a specific subdirectory in the current toolchain for
 // a given target architecture.
 // VS2017 changed the VC toolchain layout, so this should be used instead
@@ -776,7 +799,9 @@
   llvm::SmallString<256> Path(VCToolChainPath);
   switch (Type) {
   case SubDirectoryType::Bin:
-if (IsVS2017OrNewer) {
+if (IsDevDivInternal) {
+  llvm::sys::path::append(Path, "bin", llvmArchToDevDivInternalArch(TargetArch));
+} else if (IsVS2017OrNewer) {
   bool HostIsX64 =
   llvm::Triple(llvm::sys::getProcessTriple()).isArch64Bit();
   llvm::sys::path::append(Path, "bin", (HostIsX64 ? "HostX64" : "HostX86"),
@@ -787,12 +812,20 @@
 }
 break;
   case SubDirectoryType::Include:
-llvm::sys::path::append(Path, "include");
+if (IsDevDivInternal) {
+  llvm::sys::path::append(Path, "inc");
+} else {
+  llvm::sys::path::append(Path, "include");
+}
 break;
   case SubDirectoryType::Lib:
-

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-17 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 111606.
euhlmann marked an inline comment as done.
euhlmann edited the summary of this revision.
euhlmann added a comment.

Eliminated redundancy in tests by fixing test::messUp which was incorrectly 
merging lines.

Fixing the issue Mark brought up regarding comments before indented 
preprocessor lines appears to be a major change and I believe it's too much 
complexity for this patch.


https://reviews.llvm.org/D35955

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestUtils.h

Index: unittests/Format/FormatTestUtils.h
===
--- unittests/Format/FormatTestUtils.h
+++ unittests/Format/FormatTestUtils.h
@@ -25,19 +25,21 @@
   bool InComment = false;
   bool InPreprocessorDirective = false;
   bool JustReplacedNewline = false;
+  bool JustPassedNewline = false;
   for (unsigned i = 0, e = MessedUp.size() - 1; i != e; ++i) {
 if (MessedUp[i] == '/' && MessedUp[i + 1] == '/') {
   if (JustReplacedNewline)
 MessedUp[i - 1] = '\n';
   InComment = true;
-} else if (MessedUp[i] == '#' && (JustReplacedNewline || i == 0)) {
+} else if (MessedUp[i] == '#' && (JustPassedNewline || i == 0)) {
   if (i != 0)
 MessedUp[i - 1] = '\n';
   InPreprocessorDirective = true;
 } else if (MessedUp[i] == '\\' && MessedUp[i + 1] == '\n') {
   MessedUp[i] = ' ';
   MessedUp[i + 1] = ' ';
 } else if (MessedUp[i] == '\n') {
+  JustPassedNewline = true;
   if (InComment) {
 InComment = false;
   } else if (InPreprocessorDirective) {
@@ -48,6 +50,7 @@
   }
 } else if (MessedUp[i] != ' ') {
   JustReplacedNewline = false;
+  JustPassedNewline = false;
 }
   }
   std::string WithoutWhitespace;
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2286,8 +2286,176 @@
getLLVMStyleWithColumns(11));
 }
 
-TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
-  EXPECT_EQ("{\n  {\n#define A\n  }\n}", format("{{\n#define A\n}}"));
+TEST_F(FormatTest, IndentPreprocessorDirectives) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef _WIN32\n"
+   "#define A 0\n"
+   "#ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#endif\n"
+   "#else\n"
+   "#define A 1\n"
+   "#endif",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef _WIN32\n"
+   "#  define A 0\n"
+   "#  ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#  endif\n"
+   "#else\n"
+   "#  define A 1\n"
+   "#endif",
+   Style);
+  // Comments before include guard.
+  verifyFormat("// file comment\n"
+   "// file comment\n"
+   "#ifndef HEADER_H\n"
+   "#define HEADER_H\n"
+   "code();\n"
+   "#endif",
+   Style);
+  // Test with include guards.
+  // EXPECT_EQ is used because verifyFormat() calls messUp() which incorrectly
+  // merges lines.
+  verifyFormat("#ifndef HEADER_H\n"
+   "#define HEADER_H\n"
+   "code();\n"
+   "#endif",
+   Style);
+  // Include guards must have a #define with the same variable immediately
+  // after #ifndef.
+  verifyFormat("#ifndef NOT_GUARD\n"
+   "#  define FOO\n"
+   "code();\n"
+   "#endif",
+   Style);
+
+  // Include guards must cover the entire file.
+  verifyFormat("code();\n"
+   "code();\n"
+   "#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif",
+   Style);
+  verifyFormat("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif\n"
+   "code();",
+   Style);

[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-08-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Well, we don't currently have a concept of a non-canonical qualifier, but I 
think it probably wouldn't be difficult to support; you would just need 
ASTContext::getQualifiedType to be aware of it.


https://reviews.llvm.org/D35082



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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

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

Thanks! Agreed, your wording is better than mine :)


https://reviews.llvm.org/D36855

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -803,7 +802,7 @@
 
   const-qualified pointers to members
   http://wg21.link/p0704r1;>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]
Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void (X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : Extension<
+  "invoking a pointer to a 'const &' member function on an rvalue is a C++2a extension">,
+  InGroup, SFINAEFailure;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "pointer-to-member function for const& member function on rvalues is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -169,6 +169,9 @@
 def CXXPre1zCompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
[CXXPre1zCompat]>;
 
+// Warnings for C++2a code which is not compatible with prior C++ standards.
+def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
+
 def CXX98CompatBindToTemporaryCopy :
   DiagGroup<"c++98-compat-bind-to-temporary-copy">;
 def CXX98CompatLocalTypeTemplateArgs :
@@ -180,7 +183,8 @@
 [CXX98CompatLocalTypeTemplateArgs,
  CXX98CompatUnnamedTypeTemplateArgs,
  CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
@@ -211,7 +215,8 @@
 

[PATCH] D36642: [Lexer] Report more precise skipped regions (PR34166)

2017-08-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:570
+  // We'll warn about reaching the end of file later.
+  if (C == '\0' || C == '\r' || C == '\n')
+break;

efriedma wrote:
> This doesn't really handle backslash-escaped newlines correctly.  (Not likely 
> to matter, I guess, but better to get it right while we're messing with it.)
> 
> Could we use CurPPLexer->getSourceLocation() or something like that, instead 
> of trying to scan the line ourselves?
Thanks again for the catch! CurPPLexer->getSourceLocation() does the job. I 
couldn't find an efficient solution which places the end of the skipped range 
at the end of the line containing the #endif. With getSourceLocation(), we 
always set the end location to the first column of the line after the #endif. I 
think this is OK (at least, it shouldn't affect coverage rendering).


https://reviews.llvm.org/D36642



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


[PATCH] D36642: [Lexer] Report more precise skipped regions (PR34166)

2017-08-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 111596.
vsk marked an inline comment as done.
vsk added a comment.

- Address Eli's comment.


https://reviews.llvm.org/D36642

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPDirectives.cpp
  test/CoverageMapping/preprocessor.c
  test/Index/skipped-ranges.c

Index: test/Index/skipped-ranges.c
===
--- test/Index/skipped-ranges.c
+++ test/Index/skipped-ranges.c
@@ -20,6 +20,6 @@
 #endif // cool
 
 // RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test -test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
-// CHECK: Skipping: [5:2 - 6:7]
-// CHECK: Skipping: [8:2 - 12:7]
-// CHECK: Skipping: [14:2 - 20:7]
+// CHECK: Skipping: [5:1 - 7:1]
+// CHECK: Skipping: [8:1 - 13:1]
+// CHECK: Skipping: [14:1 - 21:1]
Index: test/CoverageMapping/preprocessor.c
===
--- test/CoverageMapping/preprocessor.c
+++ test/CoverageMapping/preprocessor.c
@@ -3,36 +3,69 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+2]]:2 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
   int x = i;
 #endif
 }
 
-#if 0
-  int g = 0;
-
-  void bar() { }
-#endif
-
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4]]:2 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0
   if(i == 0) {
 i = 1;
   }
-#endif
+#  endif // Mark me skipped!
 
 #if 1
  // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0
   if(i == 0) {   // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+5]]:2 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+#\
+  if 0
+#\
+  endif // also skipped
+
+#if 1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+#\
+  elif 0
+#endif
+
+#if 1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+#\
+  else
+#endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+#\
+  ifdef NOT_DEFINED
+#\
+  endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+#\
+  ifndef __FILE__
+#\
+  endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
+#\
+  ifdef NOT_DEFINED
+#\
+  \
+   \
+endif // also skipped
+
   return 0;
 }
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -79,7 +79,8 @@
 }
 
 /// \brief Read and discard all tokens remaining on the current line until
-/// the tok::eod token is found.
+/// the tok::eod token is found. If the discarded tokens are in a skipped range,
+/// complete the range and pass it to the \c SourceRangeSkipped callback.
 void Preprocessor::DiscardUntilEndOfDirective() {
   Token Tmp;
   do {
@@ -350,7 +351,8 @@
 /// If ElseOk is true, then \#else directives are ok, if not, then we have
 /// already seen one so a \#else directive is a duplicate.  When this returns,
 /// the caller can lex the first valid token.
-void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
+void Preprocessor::SkipExcludedConditionalBlock(const Token ,
+SourceLocation IfTokenLoc,
 bool FoundNonSkipPortion,
 bool FoundElse,
 SourceLocation ElseLoc) {
@@ -558,10 +560,9 @@
   // the #if block.
   CurPPLexer->LexingRawMode = false;
 
-  if (Callbacks) {
-SourceLocation BeginLoc = ElseLoc.isValid() ? ElseLoc : IfTokenLoc;
-Callbacks->SourceRangeSkipped(SourceRange(BeginLoc, Tok.getLocation()));
-  }
+  if (Callbacks)
+Callbacks->SourceRangeSkipped(
+SourceRange(HashToken.getLocation(), CurPPLexer->getSourceLocation()));
 }
 
 void Preprocessor::PTHSkipExcludedConditionalBlock() {
@@ -949,15 +950,17 @@
 default: break;
 // C99 6.10.1 - Conditional Inclusion.
 case tok::pp_if:
-  return HandleIfDirective(Result, ReadAnyTokensBeforeDirective);
+  return HandleIfDirective(Result, SavedHash, ReadAnyTokensBeforeDirective);
 case tok::pp_ifdef:
-  return HandleIfdefDirective(Result, false, true/*not valid for miopt*/);
+  return HandleIfdefDirective(Result, SavedHash, false,
+  true /*not valid for miopt*/);
 case tok::pp_ifndef:
-  return HandleIfdefDirective(Result, true, 

[PATCH] D36771: AMDGPU: add missing amdgcn processors and tests

2017-08-17 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311141: AMDGPU: add missing amdgcn processors and tests 
(authored by kzhuravl).

Changed prior to commit:
  https://reviews.llvm.org/D36771?vs=111270=111595#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36771

Files:
  cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
  cfe/trunk/test/Driver/r600-mcpu.cl

Index: cfe/trunk/test/Driver/r600-mcpu.cl
===
--- cfe/trunk/test/Driver/r600-mcpu.cl
+++ cfe/trunk/test/Driver/r600-mcpu.cl
@@ -26,22 +26,6 @@
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=caicos %s -o - 2>&1 | FileCheck --check-prefix=CAICOS-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cayman %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=aruba %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kabini %s -o - 2>&1 | FileCheck --check-prefix=KABINI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=mullins %s -o - 2>&1 | FileCheck --check-prefix=MULLINS-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 | FileCheck --check-prefix=FIJI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 2>&1 | FileCheck --check-prefix=GFX900-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx901 %s -o - 2>&1 | FileCheck --check-prefix=GFX901-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -58,19 +42,71 @@
 // TURKS-CHECK: "-target-cpu" "turks"
 // CAICOS-CHECK: "-target-cpu" "caicos"
 // CAYMAN-CHECK: "-target-cpu" "cayman"
+
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx600 %s -o - 2>&1 | FileCheck --check-prefix=GFX600-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx601 %s -o - 2>&1 | FileCheck --check-prefix=GFX601-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hainan %s -o - 2>&1 | FileCheck --check-prefix=HAINAN-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx700 %s -o - 2>&1 | FileCheck --check-prefix=GFX700-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx701 %s -o - 2>&1 | FileCheck --check-prefix=GFX701-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx702 %s -o - 2>&1 | FileCheck --check-prefix=GFX702-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx703 %s -o - 2>&1 | FileCheck --check-prefix=GFX703-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S 

r311141 - AMDGPU: add missing amdgcn processors and tests

2017-08-17 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Thu Aug 17 18:13:39 2017
New Revision: 311141

URL: http://llvm.org/viewvc/llvm-project?rev=311141=rev
Log:
AMDGPU: add missing amdgcn processors and tests

  - gfx600
  - gfx601
  - gfx703
  - gfx902
  - gfx903

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

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/Driver/r600-mcpu.cl

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=311141=311140=311141=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Thu Aug 17 18:13:39 2017
@@ -256,34 +256,39 @@ AMDGPUTargetInfo::GPUKind AMDGPUTargetIn
 
 AMDGPUTargetInfo::GPUKind AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
   return llvm::StringSwitch(Name)
+  .Case("gfx600", GK_GFX6)
   .Case("tahiti", GK_GFX6)
+  .Case("gfx601", GK_GFX6)
   .Case("pitcairn", GK_GFX6)
   .Case("verde", GK_GFX6)
   .Case("oland", GK_GFX6)
   .Case("hainan", GK_GFX6)
+  .Case("gfx700", GK_GFX7)
   .Case("bonaire", GK_GFX7)
-  .Case("kabini", GK_GFX7)
   .Case("kaveri", GK_GFX7)
-  .Case("hawaii", GK_GFX7)
-  .Case("mullins", GK_GFX7)
-  .Case("gfx700", GK_GFX7)
   .Case("gfx701", GK_GFX7)
+  .Case("hawaii", GK_GFX7)
   .Case("gfx702", GK_GFX7)
-  .Case("tonga", GK_GFX8)
+  .Case("gfx703", GK_GFX7)
+  .Case("kabini", GK_GFX7)
+  .Case("mullins", GK_GFX7)
+  .Case("gfx800", GK_GFX8)
   .Case("iceland", GK_GFX8)
+  .Case("gfx801", GK_GFX8)
   .Case("carrizo", GK_GFX8)
+  .Case("gfx802", GK_GFX8)
+  .Case("tonga", GK_GFX8)
+  .Case("gfx803", GK_GFX8)
   .Case("fiji", GK_GFX8)
-  .Case("stoney", GK_GFX8)
   .Case("polaris10", GK_GFX8)
   .Case("polaris11", GK_GFX8)
-  .Case("gfx800", GK_GFX8)
-  .Case("gfx801", GK_GFX8)
-  .Case("gfx802", GK_GFX8)
-  .Case("gfx803", GK_GFX8)
   .Case("gfx804", GK_GFX8)
   .Case("gfx810", GK_GFX8)
+  .Case("stoney", GK_GFX8)
   .Case("gfx900", GK_GFX9)
   .Case("gfx901", GK_GFX9)
+  .Case("gfx902", GK_GFX9)
+  .Case("gfx903", GK_GFX9)
   .Default(GK_NONE);
 }
 

Modified: cfe/trunk/test/Driver/r600-mcpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/r600-mcpu.cl?rev=311141=311140=311141=diff
==
--- cfe/trunk/test/Driver/r600-mcpu.cl (original)
+++ cfe/trunk/test/Driver/r600-mcpu.cl Thu Aug 17 18:13:39 2017
@@ -26,22 +26,6 @@ t// Check that -mcpu works for all suppo
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=caicos %s -o - 2>&1 
| FileCheck --check-prefix=CAICOS-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cayman %s -o - 2>&1 
| FileCheck --check-prefix=CAYMAN-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=aruba %s -o - 2>&1 
| FileCheck --check-prefix=CAYMAN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 
2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 
2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 
2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 
2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 
2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kabini %s -o - 
2>&1 | FileCheck --check-prefix=KABINI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 
2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 
2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=mullins %s -o - 
2>&1 | FileCheck --check-prefix=MULLINS-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 
2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 
2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 
2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 
| FileCheck --check-prefix=FIJI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 
2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 
2>&1 | FileCheck 

Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-17 Thread Petr Hosek via cfe-commits
Thanks for a quick response, "#include " indeed helped.

On Thu, Aug 17, 2017 at 5:41 PM Richard Smith  wrote:

> On 17 August 2017 at 17:28, Petr Hosek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> We're seeing a build failure in WebKit which appears to be have been
>> introduced by this change:
>>
>> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
>> obj/apps/web_view/web_view_test.test_webview.o.d
>> -DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
>> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
>> -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
>> -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
>> -I../../third_party/webkit/Source/WebKit/fuchsia
>> -I../../third_party/boringssl/include -Igen/third_party/cairo
>> -I../../third_party/curl/include -Iobj/third_party/curl
>> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
>> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
>> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
>> -I../../third_party/libpng -I../../third_party/zlib
>> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
>> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
>> --target=x86_64-fuchsia -no-canonical-prefixes
>> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra
>> -Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture
>> -Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack
>> -fstack-protector-strong -Werror -Wno-error=deprecated-declarations
>> -fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
>> -Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
>> obj/apps/web_view/web_view_test.test_webview.o
>> In file included from ../../apps/web_view/test_webview.cpp:1:
>> In file included from
>> ../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
>> In file included from
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
>> error: implicit instantiation of undefined template
>> 'std::__2::basic_string> std::__2::allocator >'
>>
>> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
>>   ^
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
>> note: expanded from macro '_VSTD'
>> #define _VSTD std::_LIBCPP_NAMESPACE
>>   ^
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
>> note: in instantiation of exception specification for
>> '__invoke> std::__2::char_traits, std::__2::allocator > (const
>> std::__2::basic_string> std::__2::allocator > &)> &, const std::__2::basic_string> std::__2::char_traits, std::__2::allocator > &>' requested here
>> _VSTD::__invoke(_VSTD::declval<_Fp>(),
>> _VSTD::declval<_Args>()...));
>> ^
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
>> note: expanded from macro '_VSTD'
>> #define _VSTD std::_LIBCPP_NAMESPACE
>>   ^
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
>> note: in instantiation of template class 'std::__2::__invokable_r> std::__2::function> std::__2::char_traits, std::__2::allocator > (const
>> std::__2::basic_string> std::__2::allocator > &)> &, const std::__2::basic_string> std::__2::char_traits, std::__2::allocator > &>' requested here
>> __invokable<_Fp&, _ArgTypes...>::value>
>> ^
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
>> note: in instantiation of default argument for
>> '__callable> std::__2::char_traits, std::__2::allocator > (const
>> std::__2::basic_string> std::__2::allocator > &)> >' required here
>> __callable<_Fp>::value && !is_same<_Fp, function>::value
>> ^~~
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1628:5:
>> note: in instantiation of default argument for
>> 'function> std::__2::char_traits, std::__2::allocator > (const
>> std::__2::basic_string> std::__2::allocator > &)> >' required here
>> function(_Fp);
>> ^
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1588:28:
>> note: while substituting deduced template arguments into function template
>> 'function' [with _Fp 

[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

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

Oh, and you'll need an accompanying test case before this can be committed 
(look at the existing tests in test/SemaCXX for ideas).


https://reviews.llvm.org/D36855



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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

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

Thanks!




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4091
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : ExtWarn<
+  "pointer-to-member to const& function on an rvalue is a C++2a extension">,

I would be inclined to use an `Extension` rather than an `ExtWarn` for this. (I 
really don't see why we didn't move this as a DR -- it seems to be obviously a 
defect rather than an extension to me.)



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4092
+def ext_pointer_to_const_ref_member_on_rvalue : ExtWarn<
+  "pointer-to-member to const& function on an rvalue is a C++2a extension">,
+  InGroup;

Hmm, this seems hard to express clearly and concisely. How about something like:

"invoking a pointer to a 'const &' member function on an rvalue is a C++2a 
extension"



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4093
+  "pointer-to-member to const& function on an rvalue is a C++2a extension">,
+  InGroup;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<

Please mark this as `SFINAEFailure` too; if we're going to reject under 
`-pedantic-errors`, we should also treat it as SFINAEable.


https://reviews.llvm.org/D36855



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-08-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D35082#844620, @rjmccall wrote:

> The meaning we've agreed on for LangAS::Default is to be the address space of 
> local declarations, which corresponds quite well to __private in OpenCL.  I 
> think your concern about diagnostics is better addressed by changing the 
> pretty-printer than by changing Sema to give all local declarations qualified 
> type.


How about adding a ImplicitAddrSpace bit to Qualifier to indicate address space 
is implicit, then does not print the address space qualifier in AST printer if 
the bit is set.


https://reviews.llvm.org/D35082



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


Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-17 Thread Richard Smith via cfe-commits
On 17 August 2017 at 17:28, Petr Hosek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> We're seeing a build failure in WebKit which appears to be have been
> introduced by this change:
>
> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
> obj/apps/web_view/web_view_test.test_webview.o.d -DTOOLCHAIN_VERSION=
> 4e89c701396412a50a901115ab4a2a09145f3777 
> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
> -DCAIRO_HAS_FC_FONT=0 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0
> -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../..
> -Igen -I../../third_party/webkit/Source/WebKit/fuchsia
> -I../../third_party/boringssl/include -Igen/third_party/cairo
> -I../../third_party/curl/include -Iobj/third_party/curl
> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
> -I../../third_party/libpng -I../../third_party/zlib
> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-
> magenta/build-magenta-pc-x86-64/sysroot --target=x86_64-fuchsia
> -no-canonical-prefixes 
> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=.
> -Wall -Wextra -Wno-unused-parameter -Wno-enum-compare-switch
> -Wno-unused-lambda-capture -Wno-user-defined-warnings -fvisibility=hidden
> -g -Og -fsanitize=safe-stack -fstack-protector-strong -Werror
> -Wno-error=deprecated-declarations -fvisibility-inlines-hidden -std=c++14
> -fno-exceptions -fno-rtti -Wthread-safety -c 
> ../../apps/web_view/test_webview.cpp
> -o obj/apps/web_view/web_view_test.test_webview.o
> In file included from ../../apps/web_view/test_webview.cpp:1:
> In file included from ../../third_party/webkit/
> Source/WebKit/fuchsia/WebView.h:28:
> In file included from ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:484:
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/type_traits:4323:23: error: implicit instantiation of
> undefined template 'std::__2::basic_string std::__2::char_traits, std::__2::allocator >'
> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::
> forward<_Args>(__args)...))
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/__config:468:15: note: expanded from macro '_VSTD'
> #define _VSTD std::_LIBCPP_NAMESPACE
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/type_traits:4340:9: note: in instantiation of exception
> specification for '__invoke std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
> _VSTD::__invoke(_VSTD::declval<_Fp>(),
> _VSTD::declval<_Args>()...));
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/__config:468:15: note: expanded from macro '_VSTD'
> #define _VSTD std::_LIBCPP_NAMESPACE
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1601:33: note: in instantiation of template
> class 'std::__2::__invokable_r std::__2::function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
> __invokable<_Fp&, _ArgTypes...>::value>
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1626:9: note: in instantiation of default
> argument for '__callable std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
> __callable<_Fp>::value && !is_same<_Fp, function>::value
> ^~~
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1628:5: note: in instantiation of default
> argument for 'function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
> function(_Fp);
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1588:28: note: while substituting deduced
> template arguments into function template 'function' [with _Fp =
> std::__2::function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)>, $1 = (no 

[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-17 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete created this revision.

This patch allows pointer to const& member functions on rvalues for C++20, and 
as an extension for prior versions. This is P0704r1 
.


https://reviews.llvm.org/D36855

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -803,7 +802,7 @@
 
   const-qualified pointers to members
   http://wg21.link/p0704r1;>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : ExtWarn<
+  "pointer-to-member to const& function on an rvalue is a C++2a extension">,
+  InGroup;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "pointer-to-member function for const& member function on rvalues is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -169,6 +169,9 @@
 def CXXPre1zCompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
[CXXPre1zCompat]>;
 
+// Warnings for C++2a code which is not compatible with prior C++ standards.
+def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
+
 def CXX98CompatBindToTemporaryCopy :
   DiagGroup<"c++98-compat-bind-to-temporary-copy">;
 def CXX98CompatLocalTypeTemplateArgs :
@@ -180,7 +183,8 @@
 [CXX98CompatLocalTypeTemplateArgs,
  CXX98CompatUnnamedTypeTemplateArgs,
  CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
@@ -211,7 +215,8 @@
  CXX11CompatReservedUserDefinedLiteral,
  CXX11CompatDeprecatedWritableStr,
  CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
 [CXXPre14CompatPedantic,
@@ -784,9 +789,14 @@
 // earlier C++ versions.
 def CXX17 : DiagGroup<"c++17-extensions">;
 
+// A warning group for warnings about using C++2a features as extensions in
+// earlier 

Re: r311137 - GlobalISel (AArch64): fix ABI at border between GPRs and SP.

2017-08-17 Thread Tim Northover via cfe-commits
On 17 August 2017 at 16:14, Tim Northover via cfe-commits
 wrote:
> Author: tnorthover
> Date: Thu Aug 17 16:14:01 2017
> New Revision: 311137
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311137=rev
> Log:
> GlobalISel (AArch64): fix ABI at border between GPRs and SP.

Oops. Reverted in r311140. It went along with my GlobalISel fix accidentally.

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


r311140 - Revert r311137 (GlobalISel ABI commit).

2017-08-17 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Aug 17 17:33:24 2017
New Revision: 311140

URL: http://llvm.org/viewvc/llvm-project?rev=311140=rev
Log:
Revert r311137 (GlobalISel ABI commit).

It was committed by mistake since it was in the same monorepo as the
LLVM change I was working on.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=311140=311139=311140=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Thu Aug 17 17:33:24 2017
@@ -438,7 +438,7 @@ void arm::getARMTargetFeatures(const Too
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
-if (Triple.isOSBinFormatMachO() || Triple.isOSNetBSD()) {
+if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");


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


Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-17 Thread Petr Hosek via cfe-commits
Confirmed, this changes is harmless. The failure we're seeing seems to have
been introduced by Clang in r310983, sorry about the confusion.

On Thu, Aug 17, 2017 at 4:35 PM Shoaib Meenai  wrote:

> See Petr's follow-up. It doesn't look like this was the responsible change.
>
>
>
> *From: *Eric Fiselier 
> *Date: *Thursday, August 17, 2017 at 4:02 PM
> *To: *Petr Hosek 
> *Cc: *cfe-commits , Marshall Clow <
> mclow.li...@gmail.com>, Hans Wennborg , Shoaib Meenai <
> smee...@fb.com>
> *Subject: *Re: [libcxx] r309474 - [libc++] Hoist extern template above
> first use
>
>
>
> probably shouldn't merge this then.
>
>
>
> On Aug 17, 2017 4:54 PM, "Petr Hosek via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> This broke our build of WebKit with the following build failure:
>
>
>
> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
> obj/apps/web_view/web_view_test.test_webview.o.d
> -DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
> -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
> -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
> -I../../third_party/webkit/Source/WebKit/fuchsia
> -I../../third_party/boringssl/include -Igen/third_party/cairo
> -I../../third_party/curl/include -Iobj/third_party/curl
> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
> -I../../third_party/libpng -I../../third_party/zlib
> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
> --target=x86_64-fuchsia -no-canonical-prefixes
> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra
> -Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture
> -Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack
> -fstack-protector-strong -Werror -Wno-error=deprecated-declarations
> -fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
> -Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
> obj/apps/web_view/web_view_test.test_webview.o
>
> In file included from ../../apps/web_view/test_webview.cpp:1:
>
> In file included from
> ../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
>
> In file included from
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
>
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
> error: implicit instantiation of undefined template
> 'std::__2::basic_string std::__2::allocator >'
>
>
> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
>
>   ^
>
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
> note: expanded from macro '_VSTD'
>
> #define _VSTD std::_LIBCPP_NAMESPACE
>
>   ^
>
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
> note: in instantiation of exception specification for
> '__invoke std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
>
> _VSTD::__invoke(_VSTD::declval<_Fp>(),
> _VSTD::declval<_Args>()...));
>
> ^
>
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
> note: expanded from macro '_VSTD'
>
> #define _VSTD std::_LIBCPP_NAMESPACE
>
>   ^
>
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
> note: in instantiation of template class 'std::__2::__invokable_r std::__2::function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
>
> __invokable<_Fp&, _ArgTypes...>::value>
>
> ^
>
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
> note: in instantiation of default argument for
> '__callable std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
>
> __callable<_Fp>::value && !is_same<_Fp, function>::value
>
> ^~~
>
> 

Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-17 Thread Petr Hosek via cfe-commits
We're seeing a build failure in WebKit which appears to be have been
introduced by this change:

../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
obj/apps/web_view/web_view_test.test_webview.o.d
-DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
-DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
-I../../third_party/webkit/Source/WebKit/fuchsia
-I../../third_party/boringssl/include -Igen/third_party/cairo
-I../../third_party/curl/include -Iobj/third_party/curl
-Iobj/third_party/curl/curl -I../../third_party/freetype2/include
-I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
-I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
-I../../third_party/libpng -I../../third_party/zlib
-I../../third_party/libxml2/include -I../../third_party/sqlite -g
--sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
--target=x86_64-fuchsia -no-canonical-prefixes
-fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra
-Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture
-Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack
-fstack-protector-strong -Werror -Wno-error=deprecated-declarations
-fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
-Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
obj/apps/web_view/web_view_test.test_webview.o
In file included from ../../apps/web_view/test_webview.cpp:1:
In file included from
../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
In file included from
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
error: implicit instantiation of undefined template
'std::__2::basic_string'
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
note: in instantiation of exception specification for
'__invoke (const
std::__2::basic_string &)> &, const std::__2::basic_string &>' requested here
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
note: in instantiation of template class 'std::__2::__invokable_r (const
std::__2::basic_string &)> &, const std::__2::basic_string &>' requested here
__invokable<_Fp&, _ArgTypes...>::value>
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
note: in instantiation of default argument for
'__callable (const
std::__2::basic_string &)> >' required here
__callable<_Fp>::value && !is_same<_Fp, function>::value
^~~
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1628:5:
note: in instantiation of default argument for
'function (const
std::__2::basic_string &)> >' required here
function(_Fp);
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1588:28:
note: while substituting deduced template arguments into function template
'function' [with _Fp = std::__2::function (const
std::__2::basic_string &)>, $1 = (no value)]
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
   ^
../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:48:7: note: while
declaring the implicit copy constructor for 'WebView'
class WebView {
  ^

[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.

2017-08-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

This is the same assertion as in https://reviews.llvm.org/D25206 that is
triggered when RecordLayoutBuilder tries to compute the size of a field
(for capture "typo_boo" in the test case) whose type hasn't been
deduced.

The fix is to add CorrectDelayedTyposInExpr call to the case when we
aren't disambiguating between an Obj-C message send and a lambda
expression. Also added assertion to catch similar problems closer to
lambda parsing.

rdar://problem/31760839


https://reviews.llvm.org/D36853

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp


Index: clang/test/SemaCXX/cxx1y-init-captures.cpp
===
--- clang/test/SemaCXX/cxx1y-init-captures.cpp
+++ clang/test/SemaCXX/cxx1y-init-captures.cpp
@@ -206,3 +206,10 @@
   find(weight); // expected-note {{in instantiation of function template 
specialization}}
 }
 }
+
+namespace init_capture_undeclared_identifier {
+  auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}}
+
+  int typo_foo; // expected-note {{'typo_foo' declared here}}
+  auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 
'typo_boo'; did you mean 'typo_foo'}}
+}
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -716,6 +716,8 @@
 Expr *) {
   // Create an 'auto' or 'auto&' TypeSourceInfo that we can use to
   // deduce against.
+  assert(!isa(Init) &&
+ "Typo correction should be done before type deduction");
   QualType DeductType = Context.getAutoDeductType();
   TypeLocBuilder TLB;
   TLB.pushTypeSpec(DeductType).setNameLoc(Loc);
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -876,6 +876,8 @@
 
 if (!SkippedInits) {
   Init = ParseInitializer();
+  if (!Init.isInvalid())
+Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 } else if (Tok.is(tok::l_brace)) {
   BalancedDelimiterTracker Braces(*this, tok::l_brace);
   Braces.consumeOpen();


Index: clang/test/SemaCXX/cxx1y-init-captures.cpp
===
--- clang/test/SemaCXX/cxx1y-init-captures.cpp
+++ clang/test/SemaCXX/cxx1y-init-captures.cpp
@@ -206,3 +206,10 @@
   find(weight); // expected-note {{in instantiation of function template specialization}}
 }
 }
+
+namespace init_capture_undeclared_identifier {
+  auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}}
+
+  int typo_foo; // expected-note {{'typo_foo' declared here}}
+  auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}}
+}
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -716,6 +716,8 @@
 Expr *) {
   // Create an 'auto' or 'auto&' TypeSourceInfo that we can use to
   // deduce against.
+  assert(!isa(Init) &&
+ "Typo correction should be done before type deduction");
   QualType DeductType = Context.getAutoDeductType();
   TypeLocBuilder TLB;
   TLB.pushTypeSpec(DeductType).setNameLoc(Loc);
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -876,6 +876,8 @@
 
 if (!SkippedInits) {
   Init = ParseInitializer();
+  if (!Init.isInvalid())
+Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 } else if (Tok.is(tok::l_brace)) {
   BalancedDelimiterTracker Braces(*this, tok::l_brace);
   Braces.consumeOpen();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36851: [analyzer] Fix modeling of ctors

2017-08-17 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.



  >One alternative we discussed was performing this logic in RegionStore 
instead and skipping the default binding there 
  >if we saw that the base region was empty. What do you think of that 
approach? (We would have to be careful for exactly the reasons described in 
your FIXME)

yeah, i thought about this option as well, i can update my diff to try that and 
see how it works.


Repository:
  rL LLVM

https://reviews.llvm.org/D36851



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


[PATCH] D36851: [analyzer] Fix modeling of ctors

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

Thanks for the patch!

@NoQ and I were discussing this approach this morning. One alternative we 
discussed was performing this logic in RegionStore instead and skipping the 
default binding there if we saw that the base region was empty. What do you 
think of that approach? (We would have to be careful for exactly the reasons 
described in your FIXME).


Repository:
  rL LLVM

https://reviews.llvm.org/D36851



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


Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-17 Thread Shoaib Meenai via cfe-commits
See Petr's follow-up. It doesn't look like this was the responsible change.

From: Eric Fiselier 
Date: Thursday, August 17, 2017 at 4:02 PM
To: Petr Hosek 
Cc: cfe-commits , Marshall Clow 
, Hans Wennborg , Shoaib Meenai 

Subject: Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

probably shouldn't merge this then.

On Aug 17, 2017 4:54 PM, "Petr Hosek via cfe-commits" 
> wrote:
This broke our build of WebKit with the following build failure:

../../buildtools/linux-x64/clang/bin/clang++ -MD -MF 
obj/apps/web_view/web_view_test.test_webview.o.d 
-DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777 
-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0 
-DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION 
-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen 
-I../../third_party/webkit/Source/WebKit/fuchsia 
-I../../third_party/boringssl/include -Igen/third_party/cairo 
-I../../third_party/curl/include -Iobj/third_party/curl 
-Iobj/third_party/curl/curl -I../../third_party/freetype2/include 
-I../../third_party/harfbuzz/src -I../../third_party/icu/source/common 
-I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo 
-I../../third_party/libpng -I../../third_party/zlib 
-I../../third_party/libxml2/include -I../../third_party/sqlite -g 
--sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
 --target=x86_64-fuchsia -no-canonical-prefixes 
-fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra 
-Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture 
-Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack 
-fstack-protector-strong -Werror -Wno-error=deprecated-declarations 
-fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti 
-Wthread-safety -c ../../apps/web_view/test_webview.cpp -o 
obj/apps/web_view/web_view_test.test_webview.o
In file included from ../../apps/web_view/test_webview.cpp:1:
In file included from 
../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
In file included from 
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
 error: implicit instantiation of undefined template 
'std::__2::basic_string'
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
 note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
 note: in instantiation of exception specification for 
'__invoke (const 
std::__2::basic_string &)> &, const std::__2::basic_string &>' requested here
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
 note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
 note: in instantiation of template class 'std::__2::__invokable_r (const std::__2::basic_string &)> &, const 
std::__2::basic_string &>' requested here
__invokable<_Fp&, _ArgTypes...>::value>
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
 note: in instantiation of default argument for 
'__callable (const 
std::__2::basic_string &)> >' required here
__callable<_Fp>::value && !is_same<_Fp, function>::value
^~~
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1628:5:
 note: in instantiation of default argument for 
'function (const 
std::__2::basic_string &)> >' required here
function(_Fp);
^

[PATCH] D36851: [analyzer] Fix modeling of ctors

2017-08-17 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
Herald added a subscriber: xazax.hun.

This diff attempts to fixe analyzer's crash (triggered assert) on the newly 
added test case.
The assert being discussed is assert(!B.lookup(R, BindingKey::Direct)) in 
lib/StaticAnalyzer/Core/RegionStore.cpp,
however the root cause appears to be different.
For classes with empty bases the offsets might be tricky.
For example, let's assume we have

  struct S: NonEmptyBase, EmptyBase {
 ...
  };

In this case Clang applies empty base class optimization and the offset of 
EmptyBase will be 0
(it can be verified via clang -cc1 -x c++ -v -fdump-record-layouts main.cpp 
-emit-llvm -o /dev/null).
When the analyzer tries to do zero initialization of EmptyBase it will hit the 
assert because that region has already been
"written" by the constructor of  NonEmptyBase.

Test plan:
make check-all


Repository:
  rL LLVM

https://reviews.llvm.org/D36851

Files:
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/ctor.mm


Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -704,3 +704,20 @@
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -297,7 +297,17 @@
   ExplodedNodeSet PreInitialized;
   {
 StmtNodeBuilder Bldr(DstPreVisit, PreInitialized, *currBldrCtx);
-if (CE->requiresZeroInitialization()) {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer this from offsets/alignments
+// seems to be error-prone and tricky because of the trailing padding.
+// As a temporary mitigation we don't create a binding for empty bases.
+if (CE->requiresZeroInitialization() &&
+!CE->getConstructor()->getParent()->isEmpty()) {
   // Type of the zero doesn't matter.
   SVal ZeroVal = svalBuilder.makeZeroVal(getContext().CharTy);
 


Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -704,3 +704,20 @@
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -297,7 +297,17 @@
   ExplodedNodeSet PreInitialized;
   {
 StmtNodeBuilder Bldr(DstPreVisit, PreInitialized, *currBldrCtx);
-if (CE->requiresZeroInitialization()) {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer this from offsets/alignments
+// seems to be error-prone and tricky because of the trailing padding.
+// As a temporary mitigation we don't create a binding for empty bases.
+if (CE->requiresZeroInitialization() &&
+!CE->getConstructor()->getParent()->isEmpty()) {
   // Type of the zero doesn't matter.
   SVal ZeroVal = svalBuilder.makeZeroVal(getContext().CharTy);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311137 - GlobalISel (AArch64): fix ABI at border between GPRs and SP.

2017-08-17 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Aug 17 16:14:01 2017
New Revision: 311137

URL: http://llvm.org/viewvc/llvm-project?rev=311137=rev
Log:
GlobalISel (AArch64): fix ABI at border between GPRs and SP.

If a struct would end up half in GPRs and half on SP the ABI says it should
actually go entirely on the stack. We were getting this wrong in GlobalISel
before, causing compatibility issues.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=311137=311136=311137=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Thu Aug 17 16:14:01 2017
@@ -438,7 +438,7 @@ void arm::getARMTargetFeatures(const Too
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
-if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
+if (Triple.isOSBinFormatMachO() || Triple.isOSNetBSD()) {
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");


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


[clang-tools-extra] r311136 - [clang-tidy] Add modernize-use-equals-default.IgnoreMacros option

2017-08-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 17 16:07:59 2017
New Revision: 311136

URL: http://llvm.org/viewvc/llvm-project?rev=311136=rev
Log:
[clang-tidy] Add modernize-use-equals-default.IgnoreMacros option

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp?rev=311136=311135=311136=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp Thu 
Aug 17 16:07:59 2017
@@ -197,36 +197,46 @@ static bool bodyEmpty(const ASTContext *
   return !Invalid && std::strspn(Text.data(), " \t\r\n") == Text.size();
 }
 
+UseEqualsDefaultCheck::UseEqualsDefaultCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true) != 0) {}
+
+void UseEqualsDefaultCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
-  if (getLangOpts().CPlusPlus) {
-// Destructor.
-Finder->addMatcher(cxxDestructorDecl(isDefinition()).bind(SpecialFunction),
-   this);
-Finder->addMatcher(
-cxxConstructorDecl(
-isDefinition(),
-anyOf(
-// Default constructor.
-allOf(unless(hasAnyConstructorInitializer(isWritten())),
-  parameterCountIs(0)),
-// Copy constructor.
-allOf(isCopyConstructor(),
-  // Discard constructors that can be used as a copy
-  // constructor because all the other arguments have
-  // default values.
-  parameterCountIs(1
-.bind(SpecialFunction),
-this);
-// Copy-assignment operator.
-Finder->addMatcher(
-cxxMethodDecl(isDefinition(), isCopyAssignmentOperator(),
-  // isCopyAssignmentOperator() allows the parameter to be
-  // passed by value, and in this case it cannot be
-  // defaulted.
-  hasParameter(0, hasType(lValueReferenceType(
-.bind(SpecialFunction),
-this);
-  }
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // Destructor.
+  Finder->addMatcher(cxxDestructorDecl(isDefinition()).bind(SpecialFunction),
+ this);
+  Finder->addMatcher(
+  cxxConstructorDecl(
+  isDefinition(),
+  anyOf(
+  // Default constructor.
+  allOf(unless(hasAnyConstructorInitializer(isWritten())),
+parameterCountIs(0)),
+  // Copy constructor.
+  allOf(isCopyConstructor(),
+// Discard constructors that can be used as a copy
+// constructor because all the other arguments have
+// default values.
+parameterCountIs(1
+  .bind(SpecialFunction),
+  this);
+  // Copy-assignment operator.
+  Finder->addMatcher(
+  cxxMethodDecl(isDefinition(), isCopyAssignmentOperator(),
+// isCopyAssignmentOperator() allows the parameter to be
+// passed by value, and in this case it cannot be
+// defaulted.
+hasParameter(0, hasType(lValueReferenceType(
+  .bind(SpecialFunction),
+  this);
 }
 
 void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult ) {
@@ -236,6 +246,9 @@ void UseEqualsDefaultCheck::check(const
   const auto *SpecialFunctionDecl =
   Result.Nodes.getNodeAs(SpecialFunction);
 
+  if (IgnoreMacros && SpecialFunctionDecl->getLocation().isMacroID())
+return;
+
   // Discard explicitly deleted/defaulted special member functions and those
   // that are not user-provided (automatically generated).
   if (SpecialFunctionDecl->isDeleted() ||

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h?rev=311136=311135=311136=diff
==
--- 

Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-17 Thread Eric Fiselier via cfe-commits
probably shouldn't merge this then.

On Aug 17, 2017 4:54 PM, "Petr Hosek via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> This broke our build of WebKit with the following build failure:
>
> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
> obj/apps/web_view/web_view_test.test_webview.o.d -DTOOLCHAIN_VERSION=
> 4e89c701396412a50a901115ab4a2a09145f3777 
> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
> -DCAIRO_HAS_FC_FONT=0 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0
> -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../..
> -Igen -I../../third_party/webkit/Source/WebKit/fuchsia
> -I../../third_party/boringssl/include -Igen/third_party/cairo
> -I../../third_party/curl/include -Iobj/third_party/curl
> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
> -I../../third_party/libpng -I../../third_party/zlib
> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-
> magenta/build-magenta-pc-x86-64/sysroot --target=x86_64-fuchsia
> -no-canonical-prefixes 
> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=.
> -Wall -Wextra -Wno-unused-parameter -Wno-enum-compare-switch
> -Wno-unused-lambda-capture -Wno-user-defined-warnings -fvisibility=hidden
> -g -Og -fsanitize=safe-stack -fstack-protector-strong -Werror
> -Wno-error=deprecated-declarations -fvisibility-inlines-hidden -std=c++14
> -fno-exceptions -fno-rtti -Wthread-safety -c 
> ../../apps/web_view/test_webview.cpp
> -o obj/apps/web_view/web_view_test.test_webview.o
> In file included from ../../apps/web_view/test_webview.cpp:1:
> In file included from ../../third_party/webkit/
> Source/WebKit/fuchsia/WebView.h:28:
> In file included from ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:484:
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/type_traits:4323:23: error: implicit instantiation of
> undefined template 'std::__2::basic_string std::__2::char_traits, std::__2::allocator >'
> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::
> forward<_Args>(__args)...))
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/__config:468:15: note: expanded from macro '_VSTD'
> #define _VSTD std::_LIBCPP_NAMESPACE
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/type_traits:4340:9: note: in instantiation of exception
> specification for '__invoke std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
> _VSTD::__invoke(_VSTD::declval<_Fp>(),
> _VSTD::declval<_Args>()...));
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/__config:468:15: note: expanded from macro '_VSTD'
> #define _VSTD std::_LIBCPP_NAMESPACE
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1601:33: note: in instantiation of template
> class 'std::__2::__invokable_r std::__2::function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
> __invokable<_Fp&, _ArgTypes...>::value>
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1626:9: note: in instantiation of default
> argument for '__callable std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
> __callable<_Fp>::value && !is_same<_Fp, function>::value
> ^~~
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1628:5: note: in instantiation of default
> argument for 'function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
> function(_Fp);
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1588:28: note: while substituting deduced
> template arguments into function template 'function' [with _Fp =
> std::__2::function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)>, $1 = (no 

Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-17 Thread Shoaib Meenai via cfe-commits
Yeah, I spent some time scratching my head about how my change would be causing 
that issue :) Let me know if it turns out to be related in any way and I'll 
look into it more.

From: Petr Hosek 
Date: Thursday, August 17, 2017 at 4:04 PM
To: Hans Wennborg , Shoaib Meenai 
Cc: Marshall Clow , "cfe-commits@lists.llvm.org" 

Subject: Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

Actually nevermind, it seems like it was a different change and this one is 
harmless (I'm still bisecting libc++ to find out which is causing the error 
below).
On Thu, Aug 17, 2017 at 3:54 PM Petr Hosek 
> wrote:
This broke our build of WebKit with the following build failure:

../../buildtools/linux-x64/clang/bin/clang++ -MD -MF 
obj/apps/web_view/web_view_test.test_webview.o.d 
-DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777 
-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0 
-DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION 
-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen 
-I../../third_party/webkit/Source/WebKit/fuchsia 
-I../../third_party/boringssl/include -Igen/third_party/cairo 
-I../../third_party/curl/include -Iobj/third_party/curl 
-Iobj/third_party/curl/curl -I../../third_party/freetype2/include 
-I../../third_party/harfbuzz/src -I../../third_party/icu/source/common 
-I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo 
-I../../third_party/libpng -I../../third_party/zlib 
-I../../third_party/libxml2/include -I../../third_party/sqlite -g 
--sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
 --target=x86_64-fuchsia -no-canonical-prefixes 
-fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra 
-Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture 
-Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack 
-fstack-protector-strong -Werror -Wno-error=deprecated-declarations 
-fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti 
-Wthread-safety -c ../../apps/web_view/test_webview.cpp -o 
obj/apps/web_view/web_view_test.test_webview.o
In file included from ../../apps/web_view/test_webview.cpp:1:
In file included from 
../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
In file included from 
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
 error: implicit instantiation of undefined template 
'std::__2::basic_string'
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
 note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
 note: in instantiation of exception specification for 
'__invoke (const 
std::__2::basic_string &)> &, const std::__2::basic_string &>' requested here
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
 note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
 note: in instantiation of template class 'std::__2::__invokable_r (const std::__2::basic_string &)> &, const 
std::__2::basic_string &>' requested here
__invokable<_Fp&, _ArgTypes...>::value>
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
 note: in instantiation of default argument for 
'__callable (const 
std::__2::basic_string &)> >' required here
__callable<_Fp>::value && !is_same<_Fp, function>::value
^~~
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1628:5:
 note: in instantiation of default argument for 
'function (const 

Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-17 Thread Petr Hosek via cfe-commits
Actually nevermind, it seems like it was a different change and this one is
harmless (I'm still bisecting libc++ to find out which is causing the error
below).

On Thu, Aug 17, 2017 at 3:54 PM Petr Hosek  wrote:

> This broke our build of WebKit with the following build failure:
>
> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
> obj/apps/web_view/web_view_test.test_webview.o.d
> -DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
> -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
> -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
> -I../../third_party/webkit/Source/WebKit/fuchsia
> -I../../third_party/boringssl/include -Igen/third_party/cairo
> -I../../third_party/curl/include -Iobj/third_party/curl
> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
> -I../../third_party/libpng -I../../third_party/zlib
> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
> --target=x86_64-fuchsia -no-canonical-prefixes
> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra
> -Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture
> -Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack
> -fstack-protector-strong -Werror -Wno-error=deprecated-declarations
> -fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
> -Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
> obj/apps/web_view/web_view_test.test_webview.o
> In file included from ../../apps/web_view/test_webview.cpp:1:
> In file included from
> ../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
> In file included from
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
> error: implicit instantiation of undefined template
> 'std::__2::basic_string std::__2::allocator >'
>
> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
> note: expanded from macro '_VSTD'
> #define _VSTD std::_LIBCPP_NAMESPACE
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
> note: in instantiation of exception specification for
> '__invoke std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
> _VSTD::__invoke(_VSTD::declval<_Fp>(),
> _VSTD::declval<_Args>()...));
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
> note: expanded from macro '_VSTD'
> #define _VSTD std::_LIBCPP_NAMESPACE
>   ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
> note: in instantiation of template class 'std::__2::__invokable_r std::__2::function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> &, const std::__2::basic_string std::__2::char_traits, std::__2::allocator > &>' requested here
> __invokable<_Fp&, _ArgTypes...>::value>
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
> note: in instantiation of default argument for
> '__callable std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
> __callable<_Fp>::value && !is_same<_Fp, function>::value
> ^~~
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1628:5:
> note: in instantiation of default argument for
> 'function std::__2::char_traits, std::__2::allocator > (const
> std::__2::basic_string std::__2::allocator > &)> >' required here
> function(_Fp);
> ^
> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1588:28:
> note: while substituting deduced template arguments into function template
> 'function' [with _Fp = std::__2::function std::__2::char_traits, std::__2::allocator > (const
> 

Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-17 Thread Petr Hosek via cfe-commits
This broke our build of WebKit with the following build failure:

../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
obj/apps/web_view/web_view_test.test_webview.o.d
-DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
-DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
-I../../third_party/webkit/Source/WebKit/fuchsia
-I../../third_party/boringssl/include -Igen/third_party/cairo
-I../../third_party/curl/include -Iobj/third_party/curl
-Iobj/third_party/curl/curl -I../../third_party/freetype2/include
-I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
-I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
-I../../third_party/libpng -I../../third_party/zlib
-I../../third_party/libxml2/include -I../../third_party/sqlite -g
--sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
--target=x86_64-fuchsia -no-canonical-prefixes
-fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra
-Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture
-Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack
-fstack-protector-strong -Werror -Wno-error=deprecated-declarations
-fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
-Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
obj/apps/web_view/web_view_test.test_webview.o
In file included from ../../apps/web_view/test_webview.cpp:1:
In file included from
../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
In file included from
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
error: implicit instantiation of undefined template
'std::__2::basic_string'
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
note: in instantiation of exception specification for
'__invoke (const
std::__2::basic_string &)> &, const std::__2::basic_string &>' requested here
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
note: in instantiation of template class 'std::__2::__invokable_r (const
std::__2::basic_string &)> &, const std::__2::basic_string &>' requested here
__invokable<_Fp&, _ArgTypes...>::value>
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
note: in instantiation of default argument for
'__callable (const
std::__2::basic_string &)> >' required here
__callable<_Fp>::value && !is_same<_Fp, function>::value
^~~
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1628:5:
note: in instantiation of default argument for
'function (const
std::__2::basic_string &)> >' required here
function(_Fp);
^
../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1588:28:
note: while substituting deduced template arguments into function template
'function' [with _Fp = std::__2::function (const
std::__2::basic_string &)>, $1 = (no value)]
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
   ^
../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:48:7: note: while
declaring the implicit copy constructor for 'WebView'
class WebView {
  ^

[PATCH] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36839



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


[PATCH] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-17 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 111570.
morehouse added a comment.

- Extract shared condition.
- Add ATTRIBUTE_INTERFACE.
- Rename variable to __sancov_lowest_stack.
- Add driver test for -fsanitize-coverage=stack-depth.


https://reviews.llvm.org/D36839

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fsanitize-coverage.c
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cc
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Fuzzer/FuzzerTracePC.cpp
  llvm/lib/Fuzzer/FuzzerTracePC.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
@@ -0,0 +1,50 @@
+; 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: opt < %s -sancov -sanitizer-coverage-level=3 \
+; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \
+; RUN: -S | FileCheck %s --enable-var-scope
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: @__sancov_lowest_stack = thread_local global i64 -1
+@__sancov_lowest_stack = thread_local global i64 0, align 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: [[lowestPtr:%[^ \t]+]] = call [[$intType]]* @_ZTW21__sancov_lowest_stack
+; CHECK: [[lowestInt:%[^ \t]+]] = load [[$intType]], [[$intType]]* [[lowestPtr]]
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowestInt]]
+; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
+; CHECK: :[[ifLabel]]:
+; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* [[lowestPtr]]
+; CHECK: ret i32 7
+
+  ret i32 7
+}
+
+define i32 @bar() {
+entry:
+; CHECK-LABEL: define i32 @bar
+; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
+; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[$intType]]
+; CHECK: [[lowestPtr:%[^ \t]+]] = call [[$intType]]* @_ZTW21__sancov_lowest_stack
+; CHECK: [[lowestInt:%[^ \t]+]] = load [[$intType]], [[$intType]]* [[lowestPtr]]
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowestInt]]
+; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
+; CHECK: :[[ifLabel]]:
+; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* [[lowestPtr]]
+; CHECK: %call = call i32 @foo()
+; CHECK: ret i32 %call
+
+  %call = call i32 @foo()
+  ret i32 %call
+}
+
+define weak_odr hidden i64* @_ZTW21__sancov_lowest_stack() {
+  ret i64* @__sancov_lowest_stack
+}
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -17,12 +17,15 @@
 #include "llvm/Analysis/PostDominators.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/CallSite.h"
+#include "llvm/IR/Constant.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
@@ -73,6 +76,10 @@
 static const char *const SanCovCountersSectionName = "sancov_cntrs";
 static const char *const SanCovPCsSectionName = "sancov_pcs";
 
+static const char *const SanCovLowestStackName = "__sancov_lowest_stack";
+static const char *const SanCovLowestStackTLSWrapperName =
+"_ZTW21__sancov_lowest_stack";
+
 static cl::opt ClCoverageLevel(
 "sanitizer-coverage-level",
 cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, "
@@ -119,6 +126,10 @@
   cl::desc("Reduce the number of instrumented blocks"),
   cl::Hidden, cl::init(true));
 
+static cl::opt ClStackDepth("sanitizer-coverage-stack-depth",
+  cl::desc("max stack depth tracing"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) {
@@ -156,9 +167,11 @@
   Options.TracePCGuard |= ClTracePCGuard;
   Options.Inline8bitCounters |= ClInline8bitCounters;
   Options.PCTable |= ClCreatePCTable;
-  if 

[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

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

Other than my question above, this looks good to me.


https://reviews.llvm.org/D35216



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


[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

2017-08-17 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1104
+// expression classes separately.
+if (!isa(Ex))
+  for (auto Child : Ex->children()) {

What is special about ObjCBoxedExpr here? Naively I would have expected that 
we'd want to keep the old behavior for ObjCArrayLiteral and ObjCDictionary as 
well.


https://reviews.llvm.org/D35216



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


[PATCH] D36750: [analyzer] RetainCount: When diagnosing overrelease, mention if it's coming from a nested block.

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

I forgot to say this looks like a nice usability improvement!


https://reviews.llvm.org/D36750



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


ps4-buildslave2 will be disconnected from master

2017-08-17 Thread Victor Leschuk via cfe-commits
ps4-buildslave2 will be temporary disconnected from build master for
debugging purposes. It will be done approximately at 6:00 PM PDT 18, Aug
(Friday).

-- 
Best Regards,

Victor Leschuk | Software Engineer |Access Softek

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


[PATCH] D36848: [CodeGen] Use RefCntTimer to time IR generation

2017-08-17 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

Use the reference-counted timer abstraction from
https://reviews.llvm.org/D36847 instead of manually keeping track of the
number of times `startTimer()` and `stopTimer()` should be called.

Test plan:
Run `clang -ftime-report` and confirm the time measurements are roughly
the same before and after applying this patch.


https://reviews.llvm.org/D36848

Files:
  lib/CodeGen/CodeGenAction.cpp


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -59,8 +59,7 @@
 std::unique_ptr AsmOutStream;
 ASTContext *Context;
 
-Timer LLVMIRGeneration;
-unsigned LLVMIRGenerationRefCount;
+RefCntTimer LLVMIRGeneration;
 
 /// True if we've finished generating IR. This prevents us from generating
 /// additional LLVM IR after emitting output in HandleTranslationUnit. This
@@ -90,7 +89,6 @@
   CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
   AsmOutStream(std::move(OS)), Context(nullptr),
   LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
-  LLVMIRGenerationRefCount(0),
   Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
@@ -127,19 +125,13 @@
  "LLVM IR generation of declaration");
 
   // Recurse.
-  if (llvm::TimePassesIsEnabled) {
-LLVMIRGenerationRefCount += 1;
-if (LLVMIRGenerationRefCount == 1)
-  LLVMIRGeneration.startTimer();
-  }
+  if (llvm::TimePassesIsEnabled)
+LLVMIRGeneration.startTimer();
 
   Gen->HandleTopLevelDecl(D);
 
-  if (llvm::TimePassesIsEnabled) {
-LLVMIRGenerationRefCount -= 1;
-if (LLVMIRGenerationRefCount == 0)
-  LLVMIRGeneration.stopTimer();
-  }
+  if (llvm::TimePassesIsEnabled)
+LLVMIRGeneration.stopTimer();
 
   return true;
 }
@@ -195,19 +187,13 @@
 void HandleTranslationUnit(ASTContext ) override {
   {
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
-if (llvm::TimePassesIsEnabled) {
-  LLVMIRGenerationRefCount += 1;
-  if (LLVMIRGenerationRefCount == 1)
-LLVMIRGeneration.startTimer();
-}
+if (llvm::TimePassesIsEnabled)
+  LLVMIRGeneration.startTimer();
 
 Gen->HandleTranslationUnit(C);
 
-if (llvm::TimePassesIsEnabled) {
-  LLVMIRGenerationRefCount -= 1;
-  if (LLVMIRGenerationRefCount == 0)
-LLVMIRGeneration.stopTimer();
-}
+if (llvm::TimePassesIsEnabled)
+  LLVMIRGeneration.stopTimer();
 
IRGenFinished = true;
   }


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -59,8 +59,7 @@
 std::unique_ptr AsmOutStream;
 ASTContext *Context;
 
-Timer LLVMIRGeneration;
-unsigned LLVMIRGenerationRefCount;
+RefCntTimer LLVMIRGeneration;
 
 /// True if we've finished generating IR. This prevents us from generating
 /// additional LLVM IR after emitting output in HandleTranslationUnit. This
@@ -90,7 +89,6 @@
   CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
   AsmOutStream(std::move(OS)), Context(nullptr),
   LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
-  LLVMIRGenerationRefCount(0),
   Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
@@ -127,19 +125,13 @@
  "LLVM IR generation of declaration");
 
   // Recurse.
-  if (llvm::TimePassesIsEnabled) {
-LLVMIRGenerationRefCount += 1;
-if (LLVMIRGenerationRefCount == 1)
-  LLVMIRGeneration.startTimer();
-  }
+  if (llvm::TimePassesIsEnabled)
+LLVMIRGeneration.startTimer();
 
   Gen->HandleTopLevelDecl(D);
 
-  if (llvm::TimePassesIsEnabled) {
-LLVMIRGenerationRefCount -= 1;
-if (LLVMIRGenerationRefCount == 0)
-  LLVMIRGeneration.stopTimer();
-  }
+  if (llvm::TimePassesIsEnabled)
+LLVMIRGeneration.stopTimer();
 
   return true;
 }
@@ -195,19 +187,13 @@
 void HandleTranslationUnit(ASTContext ) override {
   {
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
-if (llvm::TimePassesIsEnabled) {
-  LLVMIRGenerationRefCount += 1;
-  if (LLVMIRGenerationRefCount == 1)
-LLVMIRGeneration.startTimer();
-}
+if (llvm::TimePassesIsEnabled)
+  LLVMIRGeneration.startTimer();
 
 

[PATCH] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-17 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: llvm/lib/Fuzzer/FuzzerTracePC.cpp:31
 
 ATTRIBUTE_INTERFACE
 uintptr_t __sancov_trace_pc_pcs[fuzzer::TracePC::kNumPCs];

vitalybuka wrote:
> Why this does not need ATTRIBUTE_INTERFACE?
Not sure why it works without it.  Maybe the default build doesn't use 
`-fvisibility=hidden`?  But seems like a good idea to add.



Comment at: llvm/lib/Fuzzer/FuzzerTracePC.cpp:35
+// Used by -fsanitize-coverage=stack-depth to track stack depth
+thread_local uintptr_t __sanitizer_cov_lowest_stack;
+

vitalybuka wrote:
> Should this be __sancov_lowest_stack or even __sancov_stack_depth?
It looks like the current convention is to use `__sancov_*` for variables and 
`__sanitizer_cov_*` for functions.  I'll modify the name here to reflect that.  
I think `__sancov_lowest_stack` would be the more descriptive choice since the 
"lowest stack" gets smaller as the "max stack depth" gets larger.


https://reviews.llvm.org/D36839



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


[PATCH] D36386: [clang] Remove unit test which uses reverse-iterate flag

2017-08-17 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 111557.
mgrang retitled this revision from "[clang] Remove unit test which uses 
reverse-iterate and fix a PointerLikeTypeTrait specialization" to "[clang] 
Remove unit test which uses reverse-iterate flag".
mgrang edited the summary of this revision.

https://reviews.llvm.org/D36386

Files:
  test/Rewriter/objc-modern-metadata-visibility2.mm


Index: test/Rewriter/objc-modern-metadata-visibility2.mm
===
--- test/Rewriter/objc-modern-metadata-visibility2.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-// REQUIRES: abi-breaking-checks
-// NOTE: This test has been split from objc-modern-metadata-visibility.mm in
-// order to test with -reverse-iterate as this flag is only present with
-// ABI_BREAKING_CHECKS.
-
-// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc 
%t.mm -mllvm -reverse-iterate -o - | FileCheck %s
-// rdar://11144048
-
-@class NSString;
-
-@interface NSObject {
-Class isa;
-}
-@end
-
-@interface Sub : NSObject {
-int subIvar;
-NSString *nsstring;
-@private
-id PrivateIvar;
-}
-@end
-
-@implementation Sub
-- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
-@end
-
-@interface NSString @end
-@implementation NSString @end
-
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long 
OBJC_IVAR_$_Sub$PrivateIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
-// CHECK: #pragma warning(disable:4273)
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int 
OBJC_IVAR_$_Sub$PrivateIvar
-// CHECK: extern "C" __declspec(dllimport) struct _class_t 
OBJC_METACLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
-// CHECK: extern "C" __declspec(dllimport) struct _class_t 
OBJC_CLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_CLASS_$_NSString;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_METACLASS_$_NSString
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_CLASS_$_NSString


Index: test/Rewriter/objc-modern-metadata-visibility2.mm
===
--- test/Rewriter/objc-modern-metadata-visibility2.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-// REQUIRES: abi-breaking-checks
-// NOTE: This test has been split from objc-modern-metadata-visibility.mm in
-// order to test with -reverse-iterate as this flag is only present with
-// ABI_BREAKING_CHECKS.
-
-// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -mllvm -reverse-iterate -o - | FileCheck %s
-// rdar://11144048
-
-@class NSString;
-
-@interface NSObject {
-Class isa;
-}
-@end
-
-@interface Sub : NSObject {
-int subIvar;
-NSString *nsstring;
-@private
-id PrivateIvar;
-}
-@end
-
-@implementation Sub
-- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
-@end
-
-@interface NSString @end
-@implementation NSString @end
-
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long OBJC_IVAR_$_Sub$PrivateIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
-// CHECK: #pragma warning(disable:4273)
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int OBJC_IVAR_$_Sub$PrivateIvar
-// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_METACLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
-// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_CLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_NSString
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString

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

2017-08-17 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:314
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";

yamaguchi wrote:
> ruiu wrote:
> > Why do you have to change this? The previous code looks nicer.
> Because I got an error that ValuesWereAdded are defined several times.
Okay, but I think at least you want to move the definition into the scope that 
line 310 defines, so that the scope of the variable ends at the code that line 
322 emits.


https://reviews.llvm.org/D36820



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


[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-17 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: clang/include/clang/Driver/CC1Options.td:104
+  ValuesCode<[{
+const char* Values =
+#define GET_CHECKERS

`const char* Values` -> `const char *Values`



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:308
+const Record  = *Opts[I];
+if (!isa(R.getValueInit("ValuesCode"))) {
+  OS << "{\n";

Maybe it is better to do early continue to reduce indentation depth.

  if (isa(R.getValueInit("ValuesCode")))
continue;



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:313-314
+  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+OS << "bool ValuesWereAdded = ";
+OS << "Opt.addValues(";
+std::string S = (Pref + R.getValueAsString("Name")).str();

You can combine these two lines:

  OS << "bool ValuesWereAdded = Opt.addValues(";



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:318-319
+OS << ", Values);\n";
+OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
+OS << " \"Couldn't add values to OptTable!\");\n";
+  }

It is more readable if you split it at a natural boundary:

  OS << "(void)ValuesWereAdded;\n";
  OS << "assert(ValuesWereAdded && \"Couldn't add values to OptTable!\");\n";


https://reviews.llvm.org/D36782



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


[PATCH] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-17 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

divtc3 and friends.


https://reviews.llvm.org/D36764



___
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-17 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:314
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";

ruiu wrote:
> Why do you have to change this? The previous code looks nicer.
Because I got an error that ValuesWereAdded are defined several times.


https://reviews.llvm.org/D36820



___
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-17 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111549.
yamaguchi marked 2 inline comments as done.
yamaguchi added a comment.

Update diff.


https://reviews.llvm.org/D36820

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


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -303,14 +303,15 @@
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
   OS << "// Option Values\n\n";
+  OS << "bool ValuesWereAdded;\n";
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";
   OS << R.getValueAsString("ValuesCode");
   OS << "\n";
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";
 std::string S = (Pref + R.getValueAsString("Name")).str();
 write_cstring(OS, S);
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/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: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,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: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -303,14 +303,15 @@
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
   OS << "// Option Values\n\n";
+  OS << "bool ValuesWereAdded;\n";
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";
   OS << R.getValueAsString("ValuesCode");
   OS << "\n";
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";
 std::string S = (Pref + R.getValueAsString("Name")).str();
 write_cstring(OS, S);
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/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: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,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">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-17 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111548.
yamaguchi added a comment.

const char* Values -> const char *Values


https://reviews.llvm.org/D36782

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/Option/OptTable.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -298,5 +298,30 @@
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
+
+  OS << "\n";
+  OS << "#ifdef OPTTABLE_ARG_INIT\n";
+  OS << "//\n";
+  OS << "// Option Values\n\n";
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record  = *Opts[I];
+if (!isa(R.getValueInit("ValuesCode"))) {
+  OS << "{\n";
+  OS << R.getValueAsString("ValuesCode");
+  OS << "\n";
+  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+OS << "bool ValuesWereAdded = ";
+OS << "Opt.addValues(";
+std::string S = (Pref + R.getValueAsString("Name")).str();
+write_cstring(OS, S);
+OS << ", Values);\n";
+OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
+OS << " \"Couldn't add values to OptTable!\");\n";
+  }
+  OS << "}\n";
+}
+  }
+  OS << "\n";
+  OS << "#endif // OPTTABLE_ARG_INIT\n";
 }
 } // end namespace llvm
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -196,7 +196,7 @@
 
 // Returns true if one of the Prefixes + In.Names matches Option
 static bool optionMatches(const OptTable::Info , StringRef Option) {
-  if (In.Values && In.Prefixes)
+  if (In.Prefixes)
 for (size_t I = 0; In.Prefixes[I]; I++)
   if (Option == std::string(In.Prefixes[I]) + In.Name)
 return true;
@@ -209,8 +209,9 @@
 std::vector
 OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
   // Search all options and return possible values.
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
-if (!optionMatches(In, Option))
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
+if (!In.Values || !optionMatches(In, Option))
   continue;
 
 SmallVector Candidates;
@@ -228,7 +229,8 @@
 std::vector
 OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
   std::vector Ret;
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
 if (!In.Prefixes || (!In.HelpText && !In.GroupID))
   continue;
 if (In.Flags & DisableFlags)
@@ -245,6 +247,17 @@
   return Ret;
 }
 
+bool OptTable::addValues(const char *Option, const char *Values) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+Info  = OptionInfos[I];
+if (optionMatches(In, Option)) {
+  In.Values = Values;
+  return true;
+}
+  }
+  return false;
+}
+
 Arg *OptTable::ParseOneArg(const ArgList , unsigned ,
unsigned FlagsToInclude,
unsigned FlagsToExclude) const {
@@ -256,8 +269,8 @@
   if (isInput(PrefixesUnion, Str))
 return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
 
-  const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
-  const Info *End = OptionInfos.end();
+  const Info *Start = OptionInfos.data() + FirstSearchableIndex;
+  const Info *End = OptionInfos.data() + OptionInfos.size();
   StringRef Name = StringRef(Str).ltrim(PrefixChars);
 
   // Search for the first next option which could be a prefix.
Index: llvm/include/llvm/Option/OptTable.h
===
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -57,8 +57,8 @@
   };
 
 private:
-  /// \brief The static option information table.
-  ArrayRef OptionInfos;
+  /// \brief The option information table.
+  std::vector OptionInfos;
   bool IgnoreCase;
 
   unsigned TheInputOptionID = 0;
@@ -143,6 +143,17 @@
   std::vector findByPrefix(StringRef Cur,
 unsigned short DisableFlags) const;
 
+  /// Add Values to Option's Values class
+  ///
+  /// \param [in] Option - Prefix + Name of the flag which Values will be
+  ///  changed. For example, "-analyzer-checker".
+  /// \param [in] Values - String of Values seperated by ",", such as
+  ///  "foo, bar..", where foo and bar is the argument which the Option flag
+  //  takes
+  ///
+  /// \return true in success, and false in fail.
+  bool addValues(const char *Option, const char 

[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-17 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111547.
yamaguchi marked 2 inline comments as done.
yamaguchi added a comment.

Update diff.


https://reviews.llvm.org/D36782

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/Option/OptTable.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -298,5 +298,30 @@
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
+
+  OS << "\n";
+  OS << "#ifdef OPTTABLE_ARG_INIT\n";
+  OS << "//\n";
+  OS << "// Option Values\n\n";
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record  = *Opts[I];
+if (!isa(R.getValueInit("ValuesCode"))) {
+  OS << "{\n";
+  OS << R.getValueAsString("ValuesCode");
+  OS << "\n";
+  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+OS << "bool ValuesWereAdded = ";
+OS << "Opt.addValues(";
+std::string S = (Pref + R.getValueAsString("Name")).str();
+write_cstring(OS, S);
+OS << ", Values);\n";
+OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
+OS << " \"Couldn't add values to OptTable!\");\n";
+  }
+  OS << "}\n";
+}
+  }
+  OS << "\n";
+  OS << "#endif // OPTTABLE_ARG_INIT\n";
 }
 } // end namespace llvm
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -196,7 +196,7 @@
 
 // Returns true if one of the Prefixes + In.Names matches Option
 static bool optionMatches(const OptTable::Info , StringRef Option) {
-  if (In.Values && In.Prefixes)
+  if (In.Prefixes)
 for (size_t I = 0; In.Prefixes[I]; I++)
   if (Option == std::string(In.Prefixes[I]) + In.Name)
 return true;
@@ -209,8 +209,9 @@
 std::vector
 OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
   // Search all options and return possible values.
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
-if (!optionMatches(In, Option))
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
+if (!In.Values || !optionMatches(In, Option))
   continue;
 
 SmallVector Candidates;
@@ -228,7 +229,8 @@
 std::vector
 OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
   std::vector Ret;
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
 if (!In.Prefixes || (!In.HelpText && !In.GroupID))
   continue;
 if (In.Flags & DisableFlags)
@@ -245,6 +247,17 @@
   return Ret;
 }
 
+bool OptTable::addValues(const char *Option, const char *Values) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+Info  = OptionInfos[I];
+if (optionMatches(In, Option)) {
+  In.Values = Values;
+  return true;
+}
+  }
+  return false;
+}
+
 Arg *OptTable::ParseOneArg(const ArgList , unsigned ,
unsigned FlagsToInclude,
unsigned FlagsToExclude) const {
@@ -256,8 +269,8 @@
   if (isInput(PrefixesUnion, Str))
 return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
 
-  const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
-  const Info *End = OptionInfos.end();
+  const Info *Start = OptionInfos.data() + FirstSearchableIndex;
+  const Info *End = OptionInfos.data() + OptionInfos.size();
   StringRef Name = StringRef(Str).ltrim(PrefixChars);
 
   // Search for the first next option which could be a prefix.
Index: llvm/include/llvm/Option/OptTable.h
===
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -57,8 +57,8 @@
   };
 
 private:
-  /// \brief The static option information table.
-  ArrayRef OptionInfos;
+  /// \brief The option information table.
+  std::vector OptionInfos;
   bool IgnoreCase;
 
   unsigned TheInputOptionID = 0;
@@ -143,6 +143,17 @@
   std::vector findByPrefix(StringRef Cur,
 unsigned short DisableFlags) const;
 
+  /// Add Values to Option's Values class
+  ///
+  /// \param [in] Option - Prefix + Name of the flag which Values will be
+  ///  changed. For example, "-analyzer-checker".
+  /// \param [in] Values - String of Values seperated by ",", such as
+  ///  "foo, bar..", where foo and bar is the argument which the Option flag
+  //  takes
+  ///
+  /// \return true in success, and false in fail.
+  bool addValues(const char 

[PATCH] D36771: AMDGPU: add missing amdgcn processors and tests

2017-08-17 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36771



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


r311115 - PR34161: support evaluation of 'void()' expressions in C++14 onwards.

2017-08-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 17 12:35:50 2017
New Revision: 35

URL: http://llvm.org/viewvc/llvm-project?rev=35=rev
Log:
PR34161: support evaluation of 'void()' expressions in C++14 onwards.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=35=34=35=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Aug 17 12:35:50 2017
@@ -9787,6 +9787,8 @@ public:
 
   bool Success(const APValue , const Expr *e) { return true; }
 
+  bool ZeroInitialization(const Expr *E) { return true; }
+
   bool VisitCastExpr(const CastExpr *E) {
 switch (E->getCastKind()) {
 default:

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=35=34=35=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Thu Aug 17 12:35:50 
2017
@@ -982,3 +982,9 @@ constexpr void PR28739(int n) { // expec
   int *p = 
   p += (__int128)(unsigned long)-1; // expected-note {{cannot refer to element 
18446744073709551615 of non-array object in a constant expression}}
 }
+
+constexpr void Void(int n) {
+  void(n + 1);
+  void();
+}
+constexpr int void_test = (Void(0), 1);


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


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-17 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

ping


https://reviews.llvm.org/D34158



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-08-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The meaning we've agreed on for LangAS::Default is to be the address space of 
local declarations, which corresponds quite well to __private in OpenCL.  I 
think your concern about diagnostics is better addressed by changing the 
pretty-printer than by changing Sema to give all local declarations qualified 
type.


https://reviews.llvm.org/D35082



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


[PATCH] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/Driver/SanitizerArgs.cpp:559
 
   // trace-pc w/o func/bb/edge implies edge.
   if ((CoverageFeatures &

Extract
if (!(CoverageFeatures & InsertionPointTypes)) {


}



Comment at: clang/lib/Driver/SanitizerArgs.cpp:673
 std::make_pair(CoverageTracePCGuard, "-fsanitize-coverage-trace-pc-guard"),
 std::make_pair(CoverageInline8bitCounters, 
"-fsanitize-coverage-inline-8bit-counters"),
 std::make_pair(CoveragePCTable, "-fsanitize-coverage-pc-table"),

Could you please  add new flag into tools/clang/test/Driver/fsanitize-coverage.c



Comment at: llvm/lib/Fuzzer/FuzzerTracePC.cpp:31
 
 ATTRIBUTE_INTERFACE
 uintptr_t __sancov_trace_pc_pcs[fuzzer::TracePC::kNumPCs];

Why this does not need ATTRIBUTE_INTERFACE?



Comment at: llvm/lib/Fuzzer/FuzzerTracePC.cpp:35
+// Used by -fsanitize-coverage=stack-depth to track stack depth
+thread_local uintptr_t __sanitizer_cov_lowest_stack;
+

Should this be __sancov_lowest_stack or even __sancov_stack_depth?


https://reviews.llvm.org/D36839



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


Re: [clang-tools-extra] r309936 - ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.

2017-08-17 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r311109.

On Thu, Aug 3, 2017 at 6:30 AM, NAKAMURA Takumi via cfe-commits
 wrote:
> Author: chapuni
> Date: Thu Aug  3 06:30:43 2017
> New Revision: 309936
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309936=rev
> Log:
> ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.
>
> Modified:
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>
> Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=309936=309935=309936=diff
> ==
> --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
> +++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Thu Aug  3 
> 06:30:43 2017
> @@ -455,7 +455,8 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
>CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
>   {"-xc++", "-target", "x86_64-linux-unknown",
> -  "-m64", "--gcc-toolchain=/randomusr"});
> +  "-m64", "--gcc-toolchain=/randomusr",
> +  "-stdlib=libstdc++"});
>ClangdServer Server(CDB, DiagConsumer, FS,
>/*RunSynchronously=*/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] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-17 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse created this revision.
Herald added subscribers: hiraditya, kubamracek.

Augment SanitizerCoverage to insert maximum stack depth tracing for
use by libFuzzer.  The new instrumentation is enabled by the flag
-fsanitize-coverage=stack-depth and is compatible with the existing
trace-pc-guard coverage.  The user must also declare the following
global variable in their code:

  thread_local uintptr_t __sanitizer_cov_lowest_stack


https://reviews.llvm.org/D36839

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cc
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Fuzzer/FuzzerTracePC.cpp
  llvm/lib/Fuzzer/FuzzerTracePC.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
@@ -0,0 +1,50 @@
+; 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: opt < %s -sancov -sanitizer-coverage-level=3 \
+; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \
+; RUN: -S | FileCheck %s --enable-var-scope
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: @__sanitizer_cov_lowest_stack = thread_local global i64 -1
+@__sanitizer_cov_lowest_stack = thread_local global i64 0, align 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: [[lowestPtr:%[^ \t]+]] = call [[$intType]]* @_ZTW28__sanitizer_cov_lowest_stack
+; CHECK: [[lowestInt:%[^ \t]+]] = load [[$intType]], [[$intType]]* [[lowestPtr]]
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowestInt]]
+; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
+; CHECK: :[[ifLabel]]:
+; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* [[lowestPtr]]
+; CHECK: ret i32 7
+
+  ret i32 7
+}
+
+define i32 @bar() {
+entry:
+; CHECK-LABEL: define i32 @bar
+; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
+; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[$intType]]
+; CHECK: [[lowestPtr:%[^ \t]+]] = call [[$intType]]* @_ZTW28__sanitizer_cov_lowest_stack
+; CHECK: [[lowestInt:%[^ \t]+]] = load [[$intType]], [[$intType]]* [[lowestPtr]]
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowestInt]]
+; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
+; CHECK: :[[ifLabel]]:
+; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* [[lowestPtr]]
+; CHECK: %call = call i32 @foo()
+; CHECK: ret i32 %call
+
+  %call = call i32 @foo()
+  ret i32 %call
+}
+
+define weak_odr hidden i64* @_ZTW28__sanitizer_cov_lowest_stack() {
+  ret i64* @__sanitizer_cov_lowest_stack
+}
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -17,12 +17,15 @@
 #include "llvm/Analysis/PostDominators.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/CallSite.h"
+#include "llvm/IR/Constant.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
@@ -73,6 +76,10 @@
 static const char *const SanCovCountersSectionName = "sancov_cntrs";
 static const char *const SanCovPCsSectionName = "sancov_pcs";
 
+static const char *const SanCovLowestStackName = "__sanitizer_cov_lowest_stack";
+static const char *const SanCovLowestStackTLSWrapperName =
+"_ZTW28__sanitizer_cov_lowest_stack";
+
 static cl::opt ClCoverageLevel(
 "sanitizer-coverage-level",
 cl::desc("Sanitizer Coverage. 0: none, 1: entry block, 2: all blocks, "
@@ -119,6 +126,10 @@
   cl::desc("Reduce the number of instrumented blocks"),
   cl::Hidden, cl::init(true));
 
+static cl::opt ClStackDepth("sanitizer-coverage-stack-depth",
+  cl::desc("max stack depth tracing"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 

Re: r310776 - PR34163: Don't cache an incorrect key function for a class if queried between

2017-08-17 Thread Hans Wennborg via cfe-commits
Merged in r311105.

On Mon, Aug 14, 2017 at 10:07 AM, Hans Wennborg  wrote:
> Sounds good to me. Let's give it another day and see how it goes.
>
> On Fri, Aug 11, 2017 at 6:48 PM, Richard Smith  wrote:
>> Hi Hans,
>>
>> I'd like to get this into Clang 5, but it's not entirely risk-free. Perhaps
>> we could leave it in the tree for a little while and then merge if it seems
>> OK?
>>
>> On 11 August 2017 at 18:46, Richard Smith via cfe-commits
>>  wrote:
>>>
>>> Author: rsmith
>>> Date: Fri Aug 11 18:46:03 2017
>>> New Revision: 310776
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310776=rev
>>> Log:
>>> PR34163: Don't cache an incorrect key function for a class if queried
>>> between
>>> the class becoming complete and its inline methods being parsed.
>>>
>>> This replaces the hack of using the "late parsed template" flag to track
>>> member
>>> functions with bodies we've not parsed yet; instead we now use the "will
>>> have
>>> body" flag, which carries the desired implication that the function
>>> declaration
>>> *is* a definition, and that we've just not parsed its body yet.
>>>
>>> Added:
>>> cfe/trunk/test/CodeGenCXX/pr34163.cpp
>>> Modified:
>>> cfe/trunk/include/clang/AST/Decl.h
>>> cfe/trunk/lib/AST/DeclCXX.cpp
>>> cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>>> cfe/trunk/test/SemaCUDA/function-overload.cu
>>> cfe/trunk/test/SemaCUDA/no-destructor-overload.cu
>>>
>>> Modified: cfe/trunk/include/clang/AST/Decl.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=310776=310775=310776=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>>> +++ cfe/trunk/include/clang/AST/Decl.h Fri Aug 11 18:46:03 2017
>>> @@ -1666,8 +1666,7 @@ private:
>>>unsigned HasSkippedBody : 1;
>>>
>>>/// Indicates if the function declaration will have a body, once we're
>>> done
>>> -  /// parsing it.  (We don't set it to false when we're done parsing, in
>>> the
>>> -  /// hopes this is simpler.)
>>> +  /// parsing it.
>>>unsigned WillHaveBody : 1;
>>>
>>>/// \brief End part of this FunctionDecl's source range.
>>>
>>> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=310776=310775=310776=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
>>> +++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Aug 11 18:46:03 2017
>>> @@ -1837,9 +1837,10 @@ bool CXXMethodDecl::hasInlineBody() cons
>>>const FunctionDecl *CheckFn = getTemplateInstantiationPattern();
>>>if (!CheckFn)
>>>  CheckFn = this;
>>> -
>>> +
>>>const FunctionDecl *fn;
>>> -  return CheckFn->hasBody(fn) && !fn->isOutOfLine();
>>> +  return CheckFn->isDefined(fn) && !fn->isOutOfLine() &&
>>> + (fn->doesThisDeclarationHaveABody() || fn->willHaveBody());
>>>  }
>>>
>>>  bool CXXMethodDecl::isLambdaStaticInvoker() const {
>>>
>>> Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=310776=310775=310776=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Fri Aug 11 18:46:03 2017
>>> @@ -166,20 +166,11 @@ NamedDecl *Parser::ParseCXXInlineMethodD
>>>}
>>>
>>>if (FnD) {
>>> -// If this is a friend function, mark that it's late-parsed so that
>>> -// it's still known to be a definition even before we attach the
>>> -// parsed body.  Sema needs to treat friend function definitions
>>> -// differently during template instantiation, and it's possible for
>>> -// the containing class to be instantiated before all its member
>>> -// function definitions are parsed.
>>> -//
>>> -// If you remove this, you can remove the code that clears the flag
>>> -// after parsing the member.
>>> -if (D.getDeclSpec().isFriendSpecified()) {
>>> -  FunctionDecl *FD = FnD->getAsFunction();
>>> -  Actions.CheckForFunctionRedefinition(FD);
>>> -  FD->setLateTemplateParsed(true);
>>> -}
>>> +FunctionDecl *FD = FnD->getAsFunction();
>>> +// Track that this function will eventually have a body; Sema needs
>>> +// to know this.
>>> +Actions.CheckForFunctionRedefinition(FD);
>>> +FD->setWillHaveBody(true);
>>>} else {
>>>  // If semantic analysis could not build a function declaration,
>>>  // just throw away the late-parsed declaration.
>>> @@ -559,10 +550,6 @@ void Parser::ParseLexedMethodDef(LexedMe
>>>
>>>ParseFunctionStatementBody(LM.D, 

[PATCH] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases

2017-08-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 111528.
erik.pilkington added a comment.

Ah, good point. This new patch does that.
Thanks,
Erik


https://reviews.llvm.org/D36777

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/unguarded-availability.m


Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,27 @@
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // 
expected-note 3 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // 
expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in 
enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  switch (a) {
+  case AK_Dodo...AK_CyborgCat: // expected-warning {{'AK_Dodo' is depr}}
+break;
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on 
macOS 10.12 or newer}} expected-note {{@available}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,10 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  // for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+  // to any useful diagnostics.
+  bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); 
}
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), 
PRE->getReceiverLocation());


Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,27 @@
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // expected-note 3 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  switch (a) {
+  case AK_Dodo...AK_CyborgCat: // expected-warning {{'AK_Dodo' is depr}}
+break;
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on macOS 10.12 or newer}} expected-note {{@available}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,10 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  // for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+  // to any useful diagnostics.
+  bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); }
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), PRE->getReceiverLocation());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310672 - [Sema][ObjC] Fix spurious -Wcast-qual warnings.

2017-08-17 Thread Hans Wennborg via cfe-commits
Okay, merged in r311095.

On Tue, Aug 15, 2017 at 11:50 AM, Akira Hatanaka  wrote:
> Hans, is it okay to merge this to 5.0?
>
>> On Aug 10, 2017, at 5:06 PM, Akira Hatanaka via cfe-commits 
>>  wrote:
>>
>> Author: ahatanak
>> Date: Thu Aug 10 17:06:49 2017
>> New Revision: 310672
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310672=rev
>> Log:
>> [Sema][ObjC] Fix spurious -Wcast-qual warnings.
>>
>> We do not meaningfully track object const-ness of Objective-C object
>> types. Silence the -Wcast-qual warning that is issued when casting to or
>> from Objective-C object types results in losing const qualification.
>>
>> rdar://problem/33807915
>>
>> Modified:
>>cfe/trunk/lib/Sema/SemaCast.cpp
>>cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m
>>
>> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=310672=310671=310672=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaCast.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaCast.cpp Thu Aug 10 17:06:49 2017
>> @@ -552,7 +552,14 @@ CastsAwayConstness(Sema , QualType
>> Qualifiers SrcQuals, DestQuals;
>> Self.Context.getUnqualifiedArrayType(UnwrappedSrcType, SrcQuals);
>> Self.Context.getUnqualifiedArrayType(UnwrappedDestType, DestQuals);
>> -
>> +
>> +// We do not meaningfully track object const-ness of Objective-C object
>> +// types. Remove const from the source type if either the source or
>> +// the destination is an Objective-C object type.
>> +if (UnwrappedSrcType->isObjCObjectType() ||
>> +UnwrappedDestType->isObjCObjectType())
>> +  SrcQuals.removeConst();
>> +
>> Qualifiers RetainedSrcQuals, RetainedDestQuals;
>> if (CheckCVR) {
>>   RetainedSrcQuals.setCVRQualifiers(SrcQuals.getCVRQualifiers());
>>
>> Modified: cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m?rev=310672=310671=310672=diff
>> ==
>> --- cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m (original)
>> +++ cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m Thu Aug 10 
>> 17:06:49 2017
>> @@ -1,8 +1,9 @@
>> -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks 
>> -verify %s
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks 
>> -Wcast-qual -verify %s
>> // rdar://10597832
>>
>> typedef const void *CFTypeRef;
>> typedef const struct __CFString *CFStringRef;
>> +@class NSString;
>>
>> @interface NSString
>> @end
>> @@ -18,7 +19,7 @@ NSString *CreateNSString();
>> void from_cf() {
>>   id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning 
>> {{'__bridge_transfer' casts have no effect when not using ARC}}
>>   id obj2 = (__bridge_transfer NSString*)CFCreateString(); // 
>> expected-warning {{'__bridge_transfer' casts have no effect when not using 
>> ARC}}
>> -  (__bridge int*)CFCreateSomething(); // expected-warning {{expression 
>> result unused}}
>> +  (__bridge int*)CFCreateSomething(); // expected-warning {{expression 
>> result unused}} expected-warning {{cast from 'const void *' to 'int *' drops 
>> const qualifier}}
>>   id obj3 = (__bridge id)CFGetSomething();
>>   id obj4 = (__bridge NSString*)CFGetString();
>> }
>> @@ -41,3 +42,15 @@ void to_cf_ignored(id obj) {
>>   CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // 
>> no-warning
>>   CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning
>> }
>> +
>> +// Check that clang doesn't warn about dropping const from Objective-C 
>> object
>> +// types.
>> +void test_wcast_qual() {
>> +  CFStringRef c;
>> +  NSString *n0 = (NSString *)c;
>> +  NSString **n1 = (NSString **)
>> +  const NSString *n2;
>> +  const NSString **n3;
>> +  void *p0 = (void *)n2;
>> +  void **p1 = (void **)n3;
>> +}
>>
>>
>> ___
>> 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] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-17 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In https://reviews.llvm.org/D36764#844486, @joerg wrote:

> Because PPC uses the TC variant.


Sorry, I don't understand this comment. What is the "TC variant"?


https://reviews.llvm.org/D36764



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


[PATCH] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-17 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Because PPC uses the TC variant.


https://reviews.llvm.org/D36764



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


[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]

2017-08-17 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM with a test for warnings. See test/Driver/mips-abicalls.c for reference.


Repository:
  rL LLVM

https://reviews.llvm.org/D35982



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


[PATCH] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-17 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In https://reviews.llvm.org/D36764#843778, @saugustine wrote:

> Anyone have any opinions on this?


I don't see an issue with providing these functions on PowerPC as there doesn't 
seem to be anything in the implementation that PowerPC would have an issue 
with. However, I'm not sure if there are precision specifications for these 
builtins. If so, it is quite possible that PowerPC's `long double` won't meet 
those specifications. For the time being, the PPC `long double` is not IEEE 754 
compliant - it's a pair of doubles.


https://reviews.llvm.org/D36764



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-08-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaType.cpp:6969
 
+  if (state.getSema().getLangOpts().OpenCL &&
+  !hasOpenCLAddressSpace && type.getAddressSpace() == 0 &&

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > yaxunl wrote:
> > > > Anastasia wrote:
> > > > > Would it be nicer to not append any address space at all neither here 
> > > > > nor down at the end of this function and keep it default instead 
> > > > > until the Codegen? If it's doable I would very much prefer that. It 
> > > > > seems like it would make the implementation potentially a bit cleaner 
> > > > > to understand and easier to improve semantical analysis. See one 
> > > > > example of improving original type printing in my comment to the test 
> > > > > below.
> > > > > 
> > > > > Also there are at least these 3 related bugs open currently:
> > > > > https://bugs.llvm.org//show_bug.cgi?id=33418
> > > > > https://bugs.llvm.org//show_bug.cgi?id=33419
> > > > > https://bugs.llvm.org//show_bug.cgi?id=33420
> > > > > 
> > > > > Does your change address any of those?
> > > > On the contrary, I think using default address space for automatic 
> > > > variable and function parameter will cause ambiguity and inconsistency 
> > > > in AST, making it more difficult to understand and process, and making 
> > > > some bug (e.g. https://bugs.llvm.org//show_bug.cgi?id=33419) unfixable. 
> > > > For example, `private int f(void)` and `int f(void)` will be identical 
> > > > in AST, therefore we cannot diagnose `private int f(void)`.
> > > > 
> > > > With current representation I am able to fix the 3 bugs. I will update 
> > > > the diff.
> > > I don't see why?
> > > 
> > > `private int f(void)` -> will have an address space attribute in AST as 
> > > it is provided explicitly.
> > > 
> > > `int f(void) ` -> will have no address space attribute because it's not 
> > > provided explicitly and not attached implicitly either.
> > > 
> > > All I was asking is  not to deduce the address space here if it's not 
> > > specified explicitly until later step when we need to put it in the IR.
> > Clang already deduce global and generic address spaces and use them in the 
> > diagnostic messages. I don't see why we can use deduced global and generic 
> > address space in diagnostics whereas cannot use deduced private address 
> > space in diagnostics. Why users can accept deduced global and generic 
> > address spaces but cannot accept deduced private address space?
> > 
> > Automatic variables and function parameters have private address space. 
> > This is the reality and as true as a global variable has global or constant 
> > address spaces. Not using private address space in diagnostics gives user 
> > illusion that automatic variables and function parameters do not have 
> > address space, which is not true.
> > 
> > Besides, allowing default address space to represent private address space 
> > in AST causes ambiguity in AST. Instead of just check if a type has private 
> > address space, now we need to check if a type has private or default 
> > address spaces. Also if an expression has default address space, it is not 
> > clear if it is an l-value or r-value. This will complicate semantic 
> > checking unnecessarily. Also I am not sure if it is acceptable to modify 
> > AST between Sema and CodeGen since it seems to change the paradigm of how 
> > clang does Sema/CodeGen now.
> > Clang already deduce global and generic address spaces and use them in the 
> > diagnostic messages. I don't see why we can use deduced global and generic 
> > address space in diagnostics whereas cannot use deduced private address 
> > space in diagnostics. Why users can accept deduced global and generic 
> > address spaces but cannot accept deduced private address space?
> 
> Yes, we did this initially as a workaround because there was no way to 
> distinguish the private and default address space. So now since we are adding 
> the private AS explicitly, it would be nice to remove the workaround if 
> that's possible. It's just a messy code which is hard to understand and we 
> had places in which we need to know if the address space was specified 
> explicitly or now. NULL pointer is one of them. There were also bugs 
> associated to this because it wasn't expected that the address space is 
> 'magically' attached during parsing. Even though most of the things are 
> solved now... I would prefer not to deduce any attributes at this place not 
> just private but global and default as well... 
> 
> > Besides, allowing default address space to represent private address space 
> > in AST causes ambiguity in AST. Instead of just check if a type has private 
> > address space, now we need to check if a type has private or default 
> > address spaces.
> 
> I don't see any ambiguity, this is a difference in OpenCL wrt C that we have 
> implicit address space which we have to 

[PATCH] D34992: Emit static constexpr member as available_externally definition

2017-08-17 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini marked an inline comment as done.
mehdi_amini added a comment.

Bi-weekly ping! (@rsmith)


https://reviews.llvm.org/D34992



___
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-17 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2254
+  ValuesCode<[{
+const char* Values =
+#define LANGSTANDARD(id, name, lang, desc, features) name ","

ruiu wrote:
> I think Raphael suggested indenting embedded code with at least 2 spaces. I 
> think you want to indent it with 4 spaces so that it looks better.
`const char* Values` -> `const char *Values`



Comment at: clang/include/clang/Driver/Options.td:2254-2258
+const char* Values =
+#define LANGSTANDARD(id, name, lang, desc, features) name ","
+#define LANGSTANDARD_ALIAS(id, alias) alias ","
+#include "clang/Frontend/LangStandards.def"
+;

I think Raphael suggested indenting embedded code with at least 2 spaces. I 
think you want to indent it with 4 spaces so that it looks better.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:314
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";

Why do you have to change this? The previous code looks nicer.


https://reviews.llvm.org/D36820



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


[PATCH] D36670: misc-misplaced-widening-cast: fix assertion

2017-08-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thank you for the fix!




Comment at: test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp:63
+  enum Type {};
+  static char *m_fn1() { char p = (Type)( - m_fn1()); }
+};

xazax.hun wrote:
> Isn't this testcase a bit overcomplicated to demonstrate the issue?
It's what creduce spat out a few hours after I had run it on a pretty large 
preprocessed source.  I wouldn't spend more time simplifying the case ;)


Repository:
  rL LLVM

https://reviews.llvm.org/D36670



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


[PATCH] D36822: [clang-tidy] Ignore statements inside a template instantiation.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311086: [clang-tidy] Ignore statements inside a template 
instantiation. (authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D36822

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
   
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
   Finder->addMatcher(
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,15 @@
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  t2.reset(new T);
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}


Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
   cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
   Finder->addMatcher(
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,15 @@
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  t2.reset(new T);
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36822: [clang-tidy] Ignore statements inside a template instantiation.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 111510.
hokein marked an inline comment as done.
hokein added a comment.

Remove the CHECK-MESSAGE-NOT.


https://reviews.llvm.org/D36822

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,15 @@
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  t2.reset(new T);
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
   
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
   Finder->addMatcher(
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,15 @@
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  t2.reset(new T);
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
   cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
   Finder->addMatcher(
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311088 - Unguarded availability diagnoser should use TraverseStmt instead of

2017-08-17 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Aug 17 07:22:27 2017
New Revision: 311088

URL: http://llvm.org/viewvc/llvm-project?rev=311088=rev
Log:
Unguarded availability diagnoser should use TraverseStmt instead of
Base::TraverseStmt when visiting the then/else branches of if statements

This ensures that the statement stack is correctly tracked and correct
multi-statement fixit is generated inside of an if (@available)

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/FixIt/fixit-availability.mm

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=311088=311087=311088=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Aug 17 07:22:27 2017
@@ -7695,8 +7695,7 @@ bool DiagnoseUnguardedAvailability::Trav
 // If we're using the '*' case here or if this check is redundant, then we
 // use the enclosing version to check both branches.
 if (CondVersion.empty() || CondVersion <= AvailabilityStack.back())
-  return Base::TraverseStmt(If->getThen()) &&
- Base::TraverseStmt(If->getElse());
+  return TraverseStmt(If->getThen()) && TraverseStmt(If->getElse());
   } else {
 // This isn't an availability checking 'if', we can just continue.
 return Base::TraverseIfStmt(If);

Modified: cfe/trunk/test/FixIt/fixit-availability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-availability.mm?rev=311088=311087=311088=diff
==
--- cfe/trunk/test/FixIt/fixit-availability.mm (original)
+++ cfe/trunk/test/FixIt/fixit-availability.mm Thu Aug 17 07:22:27 2017
@@ -108,6 +108,14 @@ void wrapDeclStmtUses() {
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:24-[[@LINE-2]]:24}:"\n} else {\n 
   // Fallback on earlier versions\n}"
   anotherFunction(y);
   anotherFunction(x);
+
+  if (@available(macOS 10.1, *)) {
+int z = function();
+(void)z;
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:5-[[@LINE-2]]:5}:"if (@available(macOS 
10.12, *)) {\n"
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:13-[[@LINE-2]]:13}:"\n} else {\n 
   // Fallback on earlier versions\n}"
+anotherFunction(x);
+  }
 }
 
 #define API_AVAILABLE(X) __attribute__((availability(macos, 
introduced=10.12))) // dummy macro


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


[clang-tools-extra] r311086 - [clang-tidy] Ignore statements inside a template instantiation.

2017-08-17 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Aug 17 07:12:38 2017
New Revision: 311086

URL: http://llvm.org/viewvc/llvm-project?rev=311086=rev
Log:
[clang-tidy] Ignore statements inside a template instantiation.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=311086=311085=311086=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Thu Aug 
17 07:12:38 2017
@@ -86,7 +86,8 @@ void MakeSmartPtrCheck::registerMatchers
   
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
@@ -94,7 +95,8 @@ void MakeSmartPtrCheck::registerMatchers
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=311086=311085=311086=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Thu Aug 
17 07:12:38 2017
@@ -451,3 +451,15 @@ class UniqueFoo : public std::unique_ptr
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  t2.reset(new T);
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}


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


[PATCH] D36822: [clang-tidy] Ignore statements inside a template instantiation.

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

LG with a nit.




Comment at: test/clang-tidy/modernize-make-unique.cpp:459
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  // CHECK-MESSAGE-NOT: warning:
+  t2.reset(new T);

The check_clang_tidy script specifies 
`-implicit-check-not='{{warning:|error:}}'`, so verifying the lack of messages 
is not necessary (there's no such thing for fixes, since they verify the end 
state, not the changes; but the lack of messages implies the lack of fixes).


https://reviews.llvm.org/D36822



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


r311085 - Print enum constant values using the original source formatting

2017-08-17 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Aug 17 06:41:55 2017
New Revision: 311085

URL: http://llvm.org/viewvc/llvm-project?rev=311085=rev
Log:
Print enum constant values using the original source formatting
if possible when creating "Declaration" nodes in XML comments

rdar://14765746

Added:

cfe/trunk/test/Index/comment-to-html-xml-conversion-with-original-literals.cpp
Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Index/CommentToXML.cpp

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=311085=311084=311085=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Thu Aug 17 06:41:55 2017
@@ -50,7 +50,8 @@ struct PrintingPolicy {
   UseVoidForZeroParams(!LO.CPlusPlus),
   TerseOutput(false), PolishForDeclaration(false),
   Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
-  IncludeNewlines(true), MSVCFormatting(false) { }
+  IncludeNewlines(true), MSVCFormatting(false),
+  ConstantsAsWritten(false) { }
 
   /// \brief Adjust this printing policy for cases where it's known that
   /// we're printing C++ code (for instance, if AST dumping reaches a
@@ -200,6 +201,24 @@ struct PrintingPolicy {
   /// prints anonymous namespaces as `anonymous namespace' and does not insert
   /// spaces after template arguments.
   bool MSVCFormatting : 1;
+
+  /// \brief Whether we should print the constant expressions as written in the
+  /// sources.
+  ///
+  /// This flag determines whether constants expressions like
+  ///
+  /// \code
+  /// 0x10
+  /// 2.5e3
+  /// \endcode
+  ///
+  /// will be printed as written or as follows:
+  ///
+  /// \code
+  /// 0x10
+  /// 2.5e3
+  /// \endcode
+  bool ConstantsAsWritten;
 };
 
 } // end namespace clang

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=311085=311084=311085=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Aug 17 06:41:55 2017
@@ -389,8 +389,8 @@ public:
   /// back to its original source language syntax.
   void dumpPretty(const ASTContext ) const;
   void printPretty(raw_ostream , PrinterHelper *Helper,
-   const PrintingPolicy ,
-   unsigned Indentation = 0) const;
+   const PrintingPolicy , unsigned Indentation = 0,
+   const ASTContext *Context = nullptr) const;
 
   /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz.  Only
   ///   works on systems with GraphViz (Mac OS X) or dot+gv installed.

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=311085=311084=311085=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Thu Aug 17 06:41:55 2017
@@ -28,6 +28,7 @@ namespace {
   class DeclPrinter : public DeclVisitor {
 raw_ostream 
 PrintingPolicy Policy;
+const ASTContext 
 unsigned Indentation;
 bool PrintInstantiation;
 
@@ -48,9 +49,10 @@ namespace {
 
   public:
 DeclPrinter(raw_ostream , const PrintingPolicy ,
-unsigned Indentation = 0, bool PrintInstantiation = false)
-  : Out(Out), Policy(Policy), Indentation(Indentation),
-PrintInstantiation(PrintInstantiation) { }
+const ASTContext , unsigned Indentation = 0,
+bool PrintInstantiation = false)
+: Out(Out), Policy(Policy), Context(Context), Indentation(Indentation),
+  PrintInstantiation(PrintInstantiation) {}
 
 void VisitDeclContext(DeclContext *DC, bool Indent = true);
 
@@ -115,7 +117,8 @@ void Decl::print(raw_ostream , unsig
 
 void Decl::print(raw_ostream , const PrintingPolicy ,
  unsigned Indentation, bool PrintInstantiation) const {
-  DeclPrinter Printer(Out, Policy, Indentation, PrintInstantiation);
+  DeclPrinter Printer(Out, Policy, getASTContext(), Indentation,
+  PrintInstantiation);
   Printer.Visit(const_cast(this));
 }
 
@@ -192,7 +195,7 @@ LLVM_DUMP_METHOD void DeclContext::dumpD
 DC = DC->getParent();
   
   ASTContext  = cast(DC)->getASTContext();
-  DeclPrinter Printer(llvm::errs(), Ctx.getPrintingPolicy(), 0);
+  DeclPrinter Printer(llvm::errs(), Ctx.getPrintingPolicy(), Ctx, 0);
   Printer.VisitDeclContext(const_cast(this), /*Indent=*/false);
 }
 
@@ -467,7 +470,7 @@ void DeclPrinter::VisitEnumConstantDecl(
   prettyPrintAttributes(D);
   if (Expr *Init = D->getInitExpr()) 

[PATCH] D36824: [mips] Rename getSupportedNanEncoding() to getIEEE754Standard() (NFC)

2017-08-17 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM with comment addressed.




Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:328
+mips::IEEE754Standard mips::getIEEE754Standard(StringRef ) {
+  // Strictly speaking, mips32r2 and mips64r2 are not in accordance to standard
+  // from 2008, it was first introduced in Release 3. However, other compilers 

"are not in accordance to standard from 2008, it was first introduced in 
Release 3."

This should read:

"do not conform to the IEEE754-2008 standard. Support for this standard was 
first introduced in Release 3."


Repository:
  rL LLVM

https://reviews.llvm.org/D36824



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


[PATCH] D36828: Updated a usage of createTemporaryFile that does not expect file to be created.

2017-08-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A change to llvm repository is here: https://reviews.llvm.org/D36827


https://reviews.llvm.org/D36828



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


[PATCH] D36828: Updated a usage of createTemporaryFile that does not expect file to be created.

2017-08-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

This fixes a usage of createTemporaryFile in clang repo after
a change in llvm repo.


https://reviews.llvm.org/D36828

Files:
  unittests/Tooling/ToolingTest.cpp


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -319,8 +319,8 @@
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {
   llvm::SmallString<32> DepFilePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createTemporaryFile("depfile", "d", DepFilePath));
+  ASSERT_FALSE(llvm::sys::fs::getPotentiallyUniqueTempFileName("depfile", "d",
+   DepFilePath));
   std::vector Args;
   Args.push_back("-MMD");
   Args.push_back("-MT");


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -319,8 +319,8 @@
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {
   llvm::SmallString<32> DepFilePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createTemporaryFile("depfile", "d", DepFilePath));
+  ASSERT_FALSE(llvm::sys::fs::getPotentiallyUniqueTempFileName("depfile", "d",
+   DepFilePath));
   std::vector Args;
   Args.push_back("-MMD");
   Args.push_back("-MT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35200: Don't use mmap on Windows

2017-08-17 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

The primary reason for using mmap is not so much performance, but reduced 
memory foot print.


https://reviews.llvm.org/D35200



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


[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]

2017-08-17 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 111492.
abeserminji added a comment.

On @atanasyan 's suggestion, part of the patch is separated here 
https://reviews.llvm.org/D36824.

Comments resolved.


Repository:
  rL LLVM

https://reviews.llvm.org/D35982

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.cpp
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/mips-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -4860,6 +4860,16 @@
 // RUN:   | FileCheck -match-full-lines -check-prefix NOMIPS-NAN2008 %s
 // NOMIPS-NAN2008-NOT:#define __mips_nan2008 1
 //
+// RUN: %clang_cc1 -target-cpu mips32r3 -target-feature +abs2008 \
+// RUN:   -E -dM -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-ABS2008 %s
+// MIPS-ABS2008:#define __mips_abs2008 1
+//
+// RUN: %clang_cc1 -target-cpu mips32r3 -target-feature -abs2008 \
+// RUN:   -E -dM -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix NOMIPS-ABS2008 %s
+// NOMIPS-ABS2008-NOT:#define __mips_abs2008 1
+//
 // RUN: %clang_cc1 -target-feature -fp64 \
 // RUN:   -E -dM -triple=mips-none-none < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefix MIPS32-MFP32 %s
Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -221,6 +221,31 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NANLEGACY %s
 // CHECK-NANLEGACY: "-target-feature" "-nan2008"
 //
+// -mabs=2008 on pre R2
+// RUN: %clang -target mips-linux-gnu -march=mips32 -### -c %s \
+// RUN: -mabs=2008 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABSLEGACY %s
+//
+// -mabs=2008
+// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
+// RUN: -mabs=2008 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABS2008 %s
+//
+// -mabs=legacy
+// RUN: %clang -target mips-linux-gnu -march=mips32r3 -### -c %s \
+// RUN: -mabs=legacy 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABSLEGACY %s
+//
+// -mabs=legacy on R6
+// RUN: %clang -target mips-linux-gnu -march=mips32r6 -### -c %s \
+// RUN: -mabs=legacy 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABS2008 %s
+//
+// CHECK-ABSLEGACY: "-target-feature" "-abs2008"
+// CHECK-ABSLEGACY-NOT: "-target-feature" "+abs2008"
+// CHECK-ABS2008: "-target-feature" "+abs2008"
+// CHECK-ABS2008-NOT: "-target-feature" "-abs2008"
+//
 // -mcompact-branches=never
 // RUN: %clang -target mips-linux-gnu -march=mips32r6 -### -c %s \
 // RUN: -mcompact-branches=never 2>&1 \
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -284,6 +284,28 @@
   << A->getOption().getName() << Val;
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mabs_EQ)) {
+StringRef Val = StringRef(A->getValue());
+if (Val == "2008") {
+  if(mips::getIEEE754Standard(CPUName) & mips::Std2008) {
+Features.push_back("+abs2008");
+  } else {
+Features.push_back("-abs2008");
+D.Diag(diag::warn_target_unsupported_abs2008) << CPUName;
+  }
+} else if (Val == "legacy") {
+  if(mips::getIEEE754Standard(CPUName) & mips::Legacy) {
+Features.push_back("-abs2008");
+  } else {
+Features.push_back("+abs2008");
+D.Diag(diag::warn_target_unsupported_abslegacy) << CPUName;
+  }
+} else {
+  D.Diag(diag::err_drv_unsupported_option_argument)
+<< A->getOption().getName() << Val;
+}
+  }
+
   AddTargetFeature(Args, Features, options::OPT_msingle_float,
options::OPT_mdouble_float, "single-float");
   AddTargetFeature(Args, Features, options::OPT_mips16, options::OPT_mno_mips16,
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -46,6 +46,7 @@
   bool IsMips16;
   bool IsMicromips;
   bool IsNan2008;
+  bool IsAbs2008;
   bool IsSingleFloat;
   bool IsNoABICalls;
   bool CanUseBSDABICalls;
@@ -61,9 +62,9 @@
 public:
   MipsTargetInfo(const llvm::Triple , const TargetOptions &)
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
-IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
-CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), DisableMadd4(false), HasFP64(false) {
+IsNan2008(false), IsAbs2008(false), IsSingleFloat(false),
+IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat),
+DspRev(NoDSP), HasMSA(false), 

[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-17 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:6342
+&& !isa(FD)) {
+  Args = Args.slice(1);
+}

nik wrote:
> bkramer wrote:
> > assert that FD is a static method.
> Just stumbled here because I was looking into 
> https://bugs.llvm.org/show_bug.cgi?id=34207
> Some observations
> * Slicing the first argument unconditionally in this branch (without the if 
> at 6340) fixes the issue.
> * The current revision/version of this change does not fix the issue.
> 
> In case the crash is adapted with this patch, fine. Otherwise I'll wait until 
> this one got in and look again at it.
"Slicing the first argument unconditionally in this branch" is not valid 
because constructors are affected (at least them) where this argument is needed


https://reviews.llvm.org/D36390



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


[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-17 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:6342
+&& !isa(FD)) {
+  Args = Args.slice(1);
+}

bkramer wrote:
> assert that FD is a static method.
Just stumbled here because I was looking into 
https://bugs.llvm.org/show_bug.cgi?id=34207
Some observations
* Slicing the first argument unconditionally in this branch (without the if at 
6340) fixes the issue.
* The current revision/version of this change does not fix the issue.

In case the crash is adapted with this patch, fine. Otherwise I'll wait until 
this one got in and look again at it.


https://reviews.llvm.org/D36390



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


[PATCH] D36824: Rename getSupportedNanEncoding() to getIEEE754Standard() (NFC)

2017-08-17 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji created this revision.

As function getSupportedNanEncoding() relies on IEEE 754 Standard, new 
suggested name is getIEEE754Standard() which is more convenient to use in 
decision non related to NaN encoding.


Repository:
  rL LLVM

https://reviews.llvm.org/D36824

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Arch/Mips.h

Index: lib/Driver/ToolChains/Arch/Mips.h
===
--- lib/Driver/ToolChains/Arch/Mips.h
+++ lib/Driver/ToolChains/Arch/Mips.h
@@ -24,15 +24,15 @@
 bool isMipsArch(llvm::Triple::ArchType Arch);
 
 namespace mips {
-typedef enum { NanLegacy = 1, Nan2008 = 2 } NanEncoding;
+typedef enum { Legacy = 1, Std2008 = 2 } IEEE754Standard;
 
 enum class FloatABI {
   Invalid,
   Soft,
   Hard,
 };
 
-NanEncoding getSupportedNanEncoding(StringRef );
+IEEE754Standard getIEEE754Standard(StringRef );
 bool hasCompactBranches(StringRef );
 void getMipsCPUAndABI(const llvm::opt::ArgList ,
   const llvm::Triple , StringRef ,
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -266,14 +266,14 @@
   if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) {
 StringRef Val = StringRef(A->getValue());
 if (Val == "2008") {
-  if (mips::getSupportedNanEncoding(CPUName) & mips::Nan2008)
+  if (mips::getIEEE754Standard(CPUName) & mips::Std2008)
 Features.push_back("+nan2008");
   else {
 Features.push_back("-nan2008");
 D.Diag(diag::warn_target_unsupported_nan2008) << CPUName;
   }
 } else if (Val == "legacy") {
-  if (mips::getSupportedNanEncoding(CPUName) & mips::NanLegacy)
+  if (mips::getIEEE754Standard(CPUName) & mips::Legacy)
 Features.push_back("-nan2008");
   else {
 Features.push_back("+nan2008");
@@ -324,27 +324,27 @@
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt");
 }
 
-mips::NanEncoding mips::getSupportedNanEncoding(StringRef ) {
-  // Strictly speaking, mips32r2 and mips64r2 are NanLegacy-only since Nan2008
-  // was first introduced in Release 3. However, other compilers have
-  // traditionally allowed it for Release 2 so we should do the same.
-  return (NanEncoding)llvm::StringSwitch(CPU)
-  .Case("mips1", NanLegacy)
-  .Case("mips2", NanLegacy)
-  .Case("mips3", NanLegacy)
-  .Case("mips4", NanLegacy)
-  .Case("mips5", NanLegacy)
-  .Case("mips32", NanLegacy)
-  .Case("mips32r2", NanLegacy | Nan2008)
-  .Case("mips32r3", NanLegacy | Nan2008)
-  .Case("mips32r5", NanLegacy | Nan2008)
-  .Case("mips32r6", Nan2008)
-  .Case("mips64", NanLegacy)
-  .Case("mips64r2", NanLegacy | Nan2008)
-  .Case("mips64r3", NanLegacy | Nan2008)
-  .Case("mips64r5", NanLegacy | Nan2008)
-  .Case("mips64r6", Nan2008)
-  .Default(NanLegacy);
+mips::IEEE754Standard mips::getIEEE754Standard(StringRef ) {
+  // Strictly speaking, mips32r2 and mips64r2 are not in accordance to standard
+  // from 2008, it was first introduced in Release 3. However, other compilers 
+  // have traditionally allowed it for Release 2 so we should do the same.
+  return (IEEE754Standard)llvm::StringSwitch(CPU)
+  .Case("mips1", Legacy)
+  .Case("mips2", Legacy)
+  .Case("mips3", Legacy)
+  .Case("mips4", Legacy)
+  .Case("mips5", Legacy)
+  .Case("mips32", Legacy)
+  .Case("mips32r2", Legacy | Std2008)
+  .Case("mips32r3", Legacy | Std2008)
+  .Case("mips32r5", Legacy | Std2008)
+  .Case("mips32r6", Std2008)
+  .Case("mips64", Legacy)
+  .Case("mips64r2", Legacy | Std2008)
+  .Case("mips64r3", Legacy | Std2008)
+  .Case("mips64r5", Legacy | Std2008)
+  .Case("mips64r6", Std2008)
+  .Default(Std2008);
 }
 
 bool mips::hasCompactBranches(StringRef ) {
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -77,7 +77,7 @@
 Triple.getOS() == llvm::Triple::OpenBSD;
   }
 
-  bool isNaN2008Default() const {
+  bool isIEEE754_2008Default() const {
 return CPU == "mips32r6" || CPU == "mips64r6";
   }
 
@@ -299,7 +299,7 @@
 DiagnosticsEngine ) override {
 IsMips16 = false;
 IsMicromips = false;
-IsNan2008 = isNaN2008Default();
+IsNan2008 = isIEEE754_2008Default();
 IsSingleFloat = false;
 FloatABI = HardFloat;
 DspRev = NoDSP;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases

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

Thanks! There are two issues that I see:




Comment at: lib/Sema/SemaDeclAttr.cpp:7519
+// to any useful diagnostics.
+for (Stmt *Child : llvm::drop_begin(CS->children(), 1))
+  if (!Base::TraverseStmt(Child))

GNU case statements can also have a RHS expression in a range. You should avoid 
using children completely and just traverse the sub stmt instead.



Comment at: lib/Sema/SemaDeclAttr.cpp:7520
+for (Stmt *Child : llvm::drop_begin(CS->children(), 1))
+  if (!Base::TraverseStmt(Child))
+return false;

You should call `TraverseStmt` instead because we have special logic for 
tracking the statement stack for a fixit. We can produce an incorrect 
multi-statement fixit if the case's sub statement is a compound statement when 
we call `Base::TraverseStmt`.


https://reviews.llvm.org/D36777



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


[PATCH] D36822: [clang-tidy] Ignore statements inside a template instantiation.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: xazax.hun, JDevlieghere.

https://reviews.llvm.org/D36822

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,17 @@
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  // CHECK-MESSAGE-NOT: warning:
+  t2.reset(new T);
+  // CHECK-MESSAGE-NOT: warning:
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
   
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
   Finder->addMatcher(
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -451,3 +451,17 @@
 // CHECK-FIXES: (*this) = std::make_unique();
   }
 };
+
+// Ignore statements inside a template instantiation.
+template
+void template_fun(T* t) {
+  std::unique_ptr t2 = std::unique_ptr(new T);
+  // CHECK-MESSAGE-NOT: warning:
+  t2.reset(new T);
+  // CHECK-MESSAGE-NOT: warning:
+}
+
+void invoke_template() {
+  Foo* foo;
+  template_fun(foo);
+}
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -86,15 +86,17 @@
   cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
  CanCallCtor)
-  .bind(NewExpression)))
+  .bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
   this);
 
   Finder->addMatcher(
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)))
+  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.cpp:295
+  std::string DEFAULT_SOURCE_EXTENSIONS[] = { ".cpp", ".c", ".cc", ".cxx",
+".c++", ".C", ".m", ".mm" };  
+  std::string DEFAULT_HEADER_EXTENSIONS[] = { ".h", ".hh", ".hpp", ".hxx",

ilya-biryukov wrote:
> We should check all extensions in both upper-case and lower-case, not just 
> `.c` and `.C`
> (ideally, we could use case-insensitive comparisons).
It turns out there's a very simple way to compare case-insetively. 
`StringRef(str).compare_lower(str2)`.
Could we use that instead of extension duplicates?



Comment at: clangd/ClangdServer.cpp:302
+
+  std::string pathDataRef = std::string(path.data());
+  bool isSourceFile = false, foundExtension = false;

ilya-biryukov wrote:
> `path` is already a `StringRef`, no need to convert it. 
> `std::string` is also implicitly convertible to `StringRef`, you could pass 
> `std::string` to every function that accepts a `StringRef`
I don't think this comment was addressed. Why do we need `pathDataRef` 
variable? 


https://reviews.llvm.org/D36150



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


[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311078: [clang-tidy] Don't generate fixes for 
initializer_list constructor in… (authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D36786

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -57,7 +57,8 @@
   void checkReset(SourceManager , const CXXMemberCallExpr *Member,
   const CXXNewExpr *New);
 
-  void replaceNew(DiagnosticBuilder , const CXXNewExpr *New,
+  /// Returns true when the fixes for replacing CXXNewExpr are generated.
+  bool replaceNew(DiagnosticBuilder , const CXXNewExpr *New,
   SourceManager );
   void insertHeader(DiagnosticBuilder , FileID FD);
 };
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -147,6 +147,10 @@
 return;
   }
 
+  if (!replaceNew(Diag, New, SM)) {
+return;
+  }
+
   // Find the location of the template's left angle.
   size_t LAngle = ExprStr.find("<");
   SourceLocation ConstructCallEnd;
@@ -179,7 +183,6 @@
 ")");
   }
 
-  replaceNew(Diag, New, SM);
   insertHeader(Diag, SM.getFileID(ConstructCallStart));
 }
 
@@ -214,6 +217,10 @@
 return;
   }
 
+  if (!replaceNew(Diag, New, SM)) {
+return;
+  }
+
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + MakeSmartPtrFunctionName + "<" +
@@ -223,11 +230,10 @@
   if (Expr->isArrow())
 Diag << FixItHint::CreateInsertion(ExprStart, "*");
 
-  replaceNew(Diag, New, SM);
   insertHeader(Diag, SM.getFileID(OperatorLoc));
 }
 
-void MakeSmartPtrCheck::replaceNew(DiagnosticBuilder ,
+bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder ,
const CXXNewExpr *New,
SourceManager& SM) {
   SourceLocation NewStart = New->getSourceRange().getBegin();
@@ -254,6 +260,22 @@
 break;
   }
   case CXXNewExpr::CallInit: {
+// FIXME: Add fixes for constructors with initializer-list parameters.
+// Unlike ordinal cases, braced list can not be deduced in
+// std::make_smart_ptr, we need to specify the type explicitly in the fixes:
+//   struct S { S(std::initializer_list, int); };
+//   smart_ptr(new S({1, 2, 3}, 1));  // C++98 call-style initialization
+//   smart_ptr(new S({}, 1));
+// The above samples have to be replaced with:
+//   std::make_smart_ptr(std::initializer_list({1, 2, 3}), 1);
+//   std::make_smart_ptr(std::initializer_list({}), 1);
+if (const auto *CE = New->getConstructExpr()) {
+  for (const auto *Arg : CE->arguments()) {
+if (llvm::isa(Arg)) {
+  return false;
+}
+  }
+}
 if (ArraySizeExpr.empty()) {
   SourceRange InitRange = New->getDirectInitRange();
   Diag << FixItHint::CreateRemoval(
@@ -274,19 +296,16 @@
 SourceRange InitRange;
 if (const auto *NewConstruct = New->getConstructExpr()) {
   if (NewConstruct->isStdInitListInitialization()) {
-// Direct Initialization with the initializer-list constructor.
-//   struct S { S(std::initializer_list); };
-//   smart_ptr(new S{1, 2, 3});
-//   smart_ptr(new S{}); // use initializer-list consturctor
-// The brace has to be kept, so this has to be replaced with:
-//   std::make_smart_ptr({1, 2, 3});
-//   std::make_smart_ptr({});
-unsigned NumArgs = NewConstruct->getNumArgs();
-if (NumArgs == 0) {
-  return;
-}
-InitRange = SourceRange(NewConstruct->getArg(0)->getLocStart(),
-NewConstruct->getArg(NumArgs - 1)->getLocEnd());
+// FIXME: Add fixes for direct initialization with the initializer-list
+// constructor. Similar to the above CallInit case, the type has to be
+// specified explicitly in the fixes.
+//   struct S { S(std::initializer_list); };
+//   smart_ptr(new S{1, 2, 3});  // C++11 direct list-initialization
+//   smart_ptr(new S{});  // use initializer-list consturctor
+// The above cases have to be replaced with:
+//   std::make_smart_ptr(std::initializer_list({1, 2, 3}));
+//   std::make_smart_ptr(std::initializer_list({}));
+return false;
   } else {
 // Direct 

[clang-tools-extra] r311078 - [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-17 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Aug 17 03:14:52 2017
New Revision: 311078

URL: http://llvm.org/viewvc/llvm-project?rev=311078=rev
Log:
[clang-tidy] Don't generate fixes for initializer_list constructor in 
make_unique check.

Summary:
The current fix will break the compilation -- because braced list is not
deducible in std::make_unique (with the use of forwarding) without
specifying the type explicitly.

We could support it in the future.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=311078=311077=311078=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Thu Aug 
17 03:14:52 2017
@@ -147,6 +147,10 @@ void MakeSmartPtrCheck::checkConstruct(S
 return;
   }
 
+  if (!replaceNew(Diag, New, SM)) {
+return;
+  }
+
   // Find the location of the template's left angle.
   size_t LAngle = ExprStr.find("<");
   SourceLocation ConstructCallEnd;
@@ -179,7 +183,6 @@ void MakeSmartPtrCheck::checkConstruct(S
 ")");
   }
 
-  replaceNew(Diag, New, SM);
   insertHeader(Diag, SM.getFileID(ConstructCallStart));
 }
 
@@ -214,6 +217,10 @@ void MakeSmartPtrCheck::checkReset(Sourc
 return;
   }
 
+  if (!replaceNew(Diag, New, SM)) {
+return;
+  }
+
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + MakeSmartPtrFunctionName + "<" +
@@ -223,11 +230,10 @@ void MakeSmartPtrCheck::checkReset(Sourc
   if (Expr->isArrow())
 Diag << FixItHint::CreateInsertion(ExprStart, "*");
 
-  replaceNew(Diag, New, SM);
   insertHeader(Diag, SM.getFileID(OperatorLoc));
 }
 
-void MakeSmartPtrCheck::replaceNew(DiagnosticBuilder ,
+bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder ,
const CXXNewExpr *New,
SourceManager& SM) {
   SourceLocation NewStart = New->getSourceRange().getBegin();
@@ -254,6 +260,22 @@ void MakeSmartPtrCheck::replaceNew(Diagn
 break;
   }
   case CXXNewExpr::CallInit: {
+// FIXME: Add fixes for constructors with initializer-list parameters.
+// Unlike ordinal cases, braced list can not be deduced in
+// std::make_smart_ptr, we need to specify the type explicitly in the 
fixes:
+//   struct S { S(std::initializer_list, int); };
+//   smart_ptr(new S({1, 2, 3}, 1));  // C++98 call-style initialization
+//   smart_ptr(new S({}, 1));
+// The above samples have to be replaced with:
+//   std::make_smart_ptr(std::initializer_list({1, 2, 3}), 1);
+//   std::make_smart_ptr(std::initializer_list({}), 1);
+if (const auto *CE = New->getConstructExpr()) {
+  for (const auto *Arg : CE->arguments()) {
+if (llvm::isa(Arg)) {
+  return false;
+}
+  }
+}
 if (ArraySizeExpr.empty()) {
   SourceRange InitRange = New->getDirectInitRange();
   Diag << FixItHint::CreateRemoval(
@@ -274,19 +296,16 @@ void MakeSmartPtrCheck::replaceNew(Diagn
 SourceRange InitRange;
 if (const auto *NewConstruct = New->getConstructExpr()) {
   if (NewConstruct->isStdInitListInitialization()) {
-// Direct Initialization with the initializer-list constructor.
-//   struct S { S(std::initializer_list); };
-//   smart_ptr(new S{1, 2, 3});
-//   smart_ptr(new S{}); // use initializer-list consturctor
-// The brace has to be kept, so this has to be replaced with:
-//   std::make_smart_ptr({1, 2, 3});
-//   std::make_smart_ptr({});
-unsigned NumArgs = NewConstruct->getNumArgs();
-if (NumArgs == 0) {
-  return;
-}
-InitRange = SourceRange(NewConstruct->getArg(0)->getLocStart(),
-NewConstruct->getArg(NumArgs - 
1)->getLocEnd());
+// FIXME: Add fixes for direct initialization with the initializer-list
+// constructor. Similar to the above CallInit case, the type has to be
+// specified explicitly in the fixes.
+//   struct S { S(std::initializer_list); };
+//   smart_ptr(new S{1, 2, 3});  // C++11 direct list-initialization
+//   smart_ptr(new S{});  // use initializer-list consturctor
+// The above cases have to be replaced with:
+//   std::make_smart_ptr(std::initializer_list({1, 2, 3}));
+//   

[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 111485.
hokein marked 2 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D36786

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -246,52 +246,75 @@
   std::unique_ptr PE1 = std::unique_ptr(new E{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PE1 = std::make_unique();
+  PE1.reset(new E{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PE1 = std::make_unique();
+
+  //
+  //  NOTE: For initlializer-list constructors, the check only gives warnings,
+  //  and no fixes are generated.
+  //
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
+  PE2.reset(new E{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PE2.reset(new E{1, 2});
 
   // Initialization with default constructor.
   std::unique_ptr PF1 = std::unique_ptr(new F());
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PF1 = std::make_unique();
+  PF1.reset(new F());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PF1 = std::make_unique();
 
   // Initialization with default constructor.
   std::unique_ptr PF2 = std::unique_ptr(new F{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PF2 = std::make_unique();
+  PF2.reset(new F());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PF2 = std::make_unique();
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF3 = std::unique_ptr(new F{1});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF3 = std::make_unique({1});
+  // CHECK-FIXES: std::unique_ptr PF3 = std::unique_ptr(new F{1});
+  PF3.reset(new F{1});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PF3.reset(new F{1});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF4 = std::unique_ptr(new F{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF4 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PF4 = std::unique_ptr(new F{1, 2});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF5 = std::unique_ptr(new F({1, 2}));
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF5 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PF5 = std::unique_ptr(new F({1, 2}));
 
   // Initialization with the initializer-list constructor as the default
   // constructor is not present.
   std::unique_ptr PG1 = std::unique_ptr(new G{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG1 = std::make_unique({});
+  // CHECK-FIXES: std::unique_ptr PG1 = std::unique_ptr(new G{});
+  PG1.reset(new G{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PG1.reset(new G{});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PG2 = std::unique_ptr(new G{1});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG2 = std::make_unique({1});
+  // CHECK-FIXES: std::unique_ptr PG2 = std::unique_ptr(new G{1});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PG3 = std::unique_ptr(new G{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG3 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PG3 = std::unique_ptr(new G{1, 2});
 
   std::unique_ptr FF = std::unique_ptr(new Foo());
   // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h

[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

Still LG with one comment.




Comment at: clang-tidy/modernize/MakeSmartPtrCheck.h:60
 
-  void replaceNew(DiagnosticBuilder , const CXXNewExpr *New,
+  /// Returns whether the fixes for replacing CXXNewExpr are generated.
+  bool replaceNew(DiagnosticBuilder , const CXXNewExpr *New,

I'd suggest using a less ambiguous phrase: instead of "Returns whether X." I 
write "Returns \c true when X".


https://reviews.llvm.org/D36786



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


[PATCH] D35200: Don't use mmap on Windows

2017-08-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D35200#844132, @yvvan wrote:

> The files might also be removed.
>  I checked that with qtcreator from git. Switching to the different branch 
> started reparse of some files.
>  When I frequently switched branches back and forth I got lock issues. With 
> mmap turned off this did not happen.


Renaming/removing memory mapped files also works fine.

What were those 'lock issues' specifically? `MemoryBuffer` code that uses the 
function you're changing seems to be doing the right thing by always allowing 
shared file access.
We definitely need a test case that realiably reproduces your issue.


https://reviews.llvm.org/D35200



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


[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: test/clang-tidy/modernize-make-unique.cpp:253
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2});
 

alexfh wrote:
> I'd leave CHECK-FIXES with the original text to ensure no unwanted 
> replacements are performed.
Indeed, this is a good suggestion, and it discovered an issue of this patch 
(there are unexpected replacements generated for these cases).

I have updated the patch which changes a bit more code, please take a look 
again. 


https://reviews.llvm.org/D36786



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


[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 111481.
hokein added a comment.

Add CHECK-FIXES, and fix an uncaught issue.


https://reviews.llvm.org/D36786

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -246,52 +246,75 @@
   std::unique_ptr PE1 = std::unique_ptr(new E{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PE1 = std::make_unique();
+  PE1.reset(new E{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PE1 = std::make_unique();
+
+  //
+  //  NOTE: For initlializer-list constructors, the check only gives warnings,
+  //  and no fixes are generated.
+  //
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
+  PE2.reset(new E{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PE2.reset(new E{1, 2});
 
   // Initialization with default constructor.
   std::unique_ptr PF1 = std::unique_ptr(new F());
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PF1 = std::make_unique();
+  PF1.reset(new F());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PF1 = std::make_unique();
 
   // Initialization with default constructor.
   std::unique_ptr PF2 = std::unique_ptr(new F{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PF2 = std::make_unique();
+  PF2.reset(new F());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PF2 = std::make_unique();
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF3 = std::unique_ptr(new F{1});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF3 = std::make_unique({1});
+  // CHECK-FIXES: std::unique_ptr PF3 = std::unique_ptr(new F{1});
+  PF3.reset(new F{1});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PF3.reset(new F{1});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF4 = std::unique_ptr(new F{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF4 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PF4 = std::unique_ptr(new F{1, 2});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF5 = std::unique_ptr(new F({1, 2}));
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF5 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PF5 = std::unique_ptr(new F({1, 2}));
 
   // Initialization with the initializer-list constructor as the default
   // constructor is not present.
   std::unique_ptr PG1 = std::unique_ptr(new G{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG1 = std::make_unique({});
+  // CHECK-FIXES: std::unique_ptr PG1 = std::unique_ptr(new G{});
+  PG1.reset(new G{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PG1.reset(new G{});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PG2 = std::unique_ptr(new G{1});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG2 = std::make_unique({1});
+  // CHECK-FIXES: std::unique_ptr PG2 = std::unique_ptr(new G{1});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PG3 = std::unique_ptr(new G{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG3 = std::make_unique({1, 2});
+  // CHECK-FIXES: std::unique_ptr PG3 = std::unique_ptr(new G{1, 2});
 
   std::unique_ptr FF = std::unique_ptr(new Foo());
   // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -57,7 +57,8 @@
   

[PATCH] D35200: Don't use mmap on Windows

2017-08-17 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

The files might also be removed.
I checked that with qtcreator from git. Switching to the different branch 
started reparse of some files.
When I frequently switched branches back and forth I got lock issues. With mmap 
turned off this did not happen.


https://reviews.llvm.org/D35200



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


[PATCH] D35200: Don't use mmap on Windows

2017-08-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This looks strange. AFAIK, memory mapping files in Windows does no 'locking' by 
itself. I've just written a small program to check that it's possible to modify 
the file, memory-mapped using Win32 API.
What is specific problem you ran into?


https://reviews.llvm.org/D35200



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


[PATCH] D36821: [libclang]: Honor LIBCLANG_NOTHREADS for clang_parseTranslationUnit*

2017-08-17 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik created this revision.

Looks like this one was forgotten for clang_parseTranslationUnit*, as
LIBCLANG_NOTHREADS is checked for/in:

  clang_saveTranslationUnit()
  clang_reparseTranslationUnit()
  clang_codeCompleteAt()
  clang_indexTranslationUnit()
  clang_indexSourceFile()


https://reviews.llvm.org/D36821

Files:
  tools/libclang/CIndex.cpp


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3504,6 +3504,12 @@
 CIdx, source_filename, command_line_args, num_command_line_args,
 llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU);
   };
+
+  if (getenv("LIBCLANG_NOTHREADS")) {
+ParseTranslationUnitImpl();
+return result;
+  }
+
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, ParseTranslationUnitImpl)) {


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3504,6 +3504,12 @@
 CIdx, source_filename, command_line_args, num_command_line_args,
 llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU);
   };
+
+  if (getenv("LIBCLANG_NOTHREADS")) {
+ParseTranslationUnitImpl();
+return result;
+  }
+
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, ParseTranslationUnitImpl)) {
___
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-17 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi created this revision.

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


https://reviews.llvm.org/D36820

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


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -303,14 +303,15 @@
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
   OS << "// Option Values\n\n";
+  OS << "bool ValuesWereAdded;\n";
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";
   OS << R.getValueAsString("ValuesCode");
   OS << "\n";
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";
 std::string S = (Pref + R.getValueAsString("Name")).str();
 write_cstring(OS, S);
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/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: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,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: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -303,14 +303,15 @@
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
   OS << "// Option Values\n\n";
+  OS << "bool ValuesWereAdded;\n";
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record  = *Opts[I];
 if (!isa(R.getValueInit("ValuesCode"))) {
   OS << "{\n";
   OS << R.getValueAsString("ValuesCode");
   OS << "\n";
   for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
+OS << "ValuesWereAdded = ";
 OS << "Opt.addValues(";
 std::string S = (Pref + R.getValueAsString("Name")).str();
 write_cstring(OS, S);
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/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: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,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">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r311070 - Fix undefined behavior that is caused by not always initializing a bool.

2017-08-17 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Aug 16 23:33:46 2017
New Revision: 311070

URL: http://llvm.org/viewvc/llvm-project?rev=311070=rev
Log:
Fix undefined behavior that is caused by not always initializing a bool.

The fix in r310994 is incomplete, as moveFromAndCancel can set the
pointer without initializing OldIsSpeculativelyEvaluating.

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=311070=311069=311070=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Aug 16 23:33:46 2017
@@ -984,6 +984,7 @@ namespace {
 void moveFromAndCancel(SpeculativeEvaluationRAII &) {
   Info = Other.Info;
   OldStatus = Other.OldStatus;
+  OldIsSpeculativelyEvaluating = Other.OldIsSpeculativelyEvaluating;
   Other.Info = nullptr;
 }
 


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