Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-03-14 Thread Serge Pavlov via cfe-commits
sepavloff added a subscriber: sepavloff.
sepavloff added a comment.

On Windows (VS2015 update1) two unit tests fail:

  [ RUN  ] ImportExpr.ImportGNUNullExpr
  input.cc:1:23: warning: expression result unused [-Wunused-value]
  void declToImport() { __null; }
^~
  G:\arbeit\llvm2\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(149):
  error: Value of: testImport("void declToImport() { __null; }", Lang_CXX,
  "", Lang_CXX,
  Verifier, functionDecl( hasBody( compoundStmt( has( gnuNullExpr( hasType(
  asString("long"
Actual: false (Could not find match)
  Expected: true
  [  FAILED  ] ImportExpr.ImportGNUNullExpr (61 ms)



  [ RUN  ] ImportExpr.ImportParenListExpr
  G:\arbeit\llvm2\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(284):
  error: Value of: testImport( "  template class declToImport {"
  "void f(
  ) { declToImport X(*this); } }; ", Lang_CXX, "", Lang_CXX, Verifier,
  classTemplateDecl( has( cxxRecordDecl( hasMethod( allOf( hasName("f"),
  hasBody( compoundStm
  t( has( declStmt( hasSingleDecl( varDecl( hasInitializer( parenListExpr(
  has( unaryOperator( hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())
  ))
  ))
Actual: false (Could not find match)
  Expected: true
  [  FAILED  ] ImportExpr.ImportParenListExpr (59 ms)



  [  FAILED  ] 2 tests, listed below:
  [  FAILED  ] ImportExpr.ImportGNUNullExpr
  [  FAILED  ] ImportExpr.ImportParenListExpr
  
   2 FAILED TESTS

Thanks,
--Serge


http://reviews.llvm.org/D14286



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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-03-14 Thread Serge Pavlov via cfe-commits
On Windows (VS2015 update1) two unit tests fail:

```
[ RUN  ] ImportExpr.ImportGNUNullExpr
input.cc:1:23: warning: expression result unused [-Wunused-value]
void declToImport() { __null; }
  ^~
G:\arbeit\llvm2\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(149):
error: Value of: testImport("void declToImport() { __null; }", Lang_CXX,
"", Lang_CXX,
Verifier, functionDecl( hasBody( compoundStmt( has( gnuNullExpr( hasType(
asString("long"
  Actual: false (Could not find match)
Expected: true
[  FAILED  ] ImportExpr.ImportGNUNullExpr (61 ms)
```

```
[ RUN  ] ImportExpr.ImportParenListExpr
G:\arbeit\llvm2\llvm\tools\clang\unittests\AST\ASTImporterTest.cpp(284):
error: Value of: testImport( "  template class declToImport {"
"void f(
) { declToImport X(*this); } }; ", Lang_CXX, "", Lang_CXX, Verifier,
classTemplateDecl( has( cxxRecordDecl( hasMethod( allOf( hasName("f"),
hasBody( compoundStm
t( has( declStmt( hasSingleDecl( varDecl( hasInitializer( parenListExpr(
has( unaryOperator( hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())
))
))
  Actual: false (Could not find match)
Expected: true
[  FAILED  ] ImportExpr.ImportParenListExpr (59 ms)
```

```
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] ImportExpr.ImportGNUNullExpr
[  FAILED  ] ImportExpr.ImportParenListExpr

 2 FAILED TESTS
```

Thanks,
--Serge

2016-03-10 16:02 GMT+06:00 Aleksei Sidorin :

> a.sidorin added a comment.
>
> Serge: BTW, tests for CXXBoolLiteralExpr are presented in this patch.
> There is no test //exactly// for it but at least one test uses bool literal
> and matches it successfully with cxxBoolLiteral() matcher.
>
>
> http://reviews.llvm.org/D14286
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-14 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

ping.


http://reviews.llvm.org/D15332



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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-03-14 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

ping


http://reviews.llvm.org/D13126



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


r263412 - Temporarily make discard value names depend on whether or not we're

2016-03-14 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Mar 14 03:10:47 2016
New Revision: 263412

URL: http://llvm.org/viewvc/llvm-project?rev=263412&view=rev
Log:
Temporarily make discard value names depend on whether or not we're
trying to track origins in the memory sanitizer since the backend
instrumentation pass currently takes names from the Instruction.

Fixes all of the origin tracking tests in compiler-rt after the
-discard-value-name option was added.

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

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263412&r1=263411&r2=263412&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 03:10:47 2016
@@ -541,7 +541,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.DisableFPElim =
   (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
-  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
   if (Arg *A = Args.getLastArg(OPT_meabi)) {
@@ -794,6 +793,12 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  // DiscardValueNames is set here so that it can depend (perhaps temporarily)
+  // on other options.
+  // We check SanitizeMemoryTrackOrigins here because the backend pass depends
+  // on the name of the alloca in order to print out names.
+  Opts.DiscardValueNames =
+  Args.hasArg(OPT_discard_value_names) && !Opts.SanitizeMemoryTrackOrigins;
   return Success;
 }
 


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


Re: r263394 - Remove compile time PreserveName in favor of a runtime cc1 -discard-value-names option

2016-03-14 Thread Eric Christopher via cfe-commits
Hi Mehdi,

Just letting you know that I committed a bit of a workaround for
-fsanitize-memory-track-origins after this, the backend instrumentation
pass was depending on the name of the alloca as a way of getting the name
of the variable. I figured though that reverting was probably a bit
overkill here so I added the workaround in r263412 and am letting Evgeniy
and Kostya know :)

-eric


On Sun, Mar 13, 2016 at 2:10 PM Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mehdi_amini
> Date: Sun Mar 13 16:05:23 2016
> New Revision: 263394
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263394&view=rev
> Log:
> Remove compile time PreserveName in favor of a runtime cc1
> -discard-value-names option
>
> Summary:
> This flag is enabled by default in the driver when NDEBUG is set. It
> is forwarded on the LLVMContext to discard all value names (but
> GlobalValue) for performance purpose.
>
> This an improved version of D18024
>
> Reviewers: echristo, chandlerc
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D18127
>
> From: Mehdi Amini 
>
> Added:
> cfe/trunk/test/CodeGenCXX/discard-name-values.cpp
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/CGBuilder.h
> cfe/trunk/lib/CodeGen/CGCall.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/CodeGen/mips-byval-arg.c
> cfe/trunk/test/CodeGen/mips-vector-arg.c
> cfe/trunk/test/CodeGen/mips-zero-sized-struct.c
> cfe/trunk/test/CodeGen/mips64-class-return.cpp
> cfe/trunk/test/CodeGen/mips64-padding-arg.c
> cfe/trunk/test/CodeGenCXX/debug-info-class.cpp
> cfe/trunk/test/CodeGenCXX/stack-reuse.cpp
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=263394&r1=263393&r2=263394&view=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Sun Mar 13 16:05:23 2016
> @@ -367,6 +367,8 @@ def code_completion_brief_comments : Fla
>HelpText<"Include brief documentation comments in code-completion
> results.">;
>  def disable_free : Flag<["-"], "disable-free">,
>HelpText<"Disable freeing of memory on exit">;
> +def discard_value_names : Flag<["-"], "discard-value-names">,
> +  HelpText<"Discard value names in LLVM IR">;
>  def load : Separate<["-"], "load">, MetaVarName<"">,
>HelpText<"Load the named plugin (dynamic shared object)">;
>  def plugin : Separate<["-"], "plugin">, MetaVarName<"">,
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=263394&r1=263393&r2=263394&view=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Sun Mar 13
> 16:05:23 2016
> @@ -43,6 +43,7 @@ CODEGENOPT(DataSections  , 1, 0) ///
>  CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for -funique-section-names.
>  CODEGENOPT(DisableFPElim , 1, 0) ///< Set when -fomit-frame-pointer
> is enabled.
>  CODEGENOPT(DisableFree   , 1, 0) ///< Don't free memory.
> +CODEGENOPT(DiscardValueNames , 1, 0) ///< Discard Value Names from the IR
> (LLVMContext flag)
>  CODEGENOPT(DisableGCov   , 1, 0) ///< Don't run the GCov pass, for
> testing.
>  CODEGENOPT(DisableLLVMOpts   , 1, 0) ///< Don't run any optimizations,
> for use in
>   ///< getting .bc files that
> correspond to the
>
> Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=263394&r1=263393&r2=263394&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
> +++ cfe/trunk/lib/CodeGen/CGBuilder.h Sun Mar 13 16:05:23 2016
> @@ -23,9 +23,7 @@ class CodeGenFunction;
>  /// \brief This is an IRBuilder insertion helper that forwards to
>  /// CodeGenFunction::InsertHelper, which adds necessary metadata to
>  /// instructions.
> -template 
> -class CGBuilderInserter
> -: protected llvm::IRBuilderDefaultInserter {
> +class CGBuilderInserter : protected llvm::IRBuilderDefaultInserter {
>  public:
>CGBuilderInserter() = default;
>explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
> @@ -39,17 +37,10 @@ private:
>CodeGenFunction *CGF = nullptr;
>  };
>
> -// Don't preserve names on values in an optimized build.
> -#ifdef NDEBUG
> -#d

Re: [PATCH] D12834: add gcc abi_tag support

2016-03-14 Thread Dmitry Polukhin via cfe-commits
Hi Pavel,

Code review is not a good place to discuss such type of things. There is no
really good workaround for this issue if you already have libraries built
with C++ 11 and GCC configured to use abi_tag. But if you are doing it only
for testing and you are willing to build Clang yourself, you could try to
get top of the tree Clang and apply this http://reviews.llvm.org/D18035. If
you do so, please report any issues with abi_tag to the patch or to me
directly. I tested patch http://reviews.llvm.org/D18035 on tests and small
things only so testing on something bigger will be helpful.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12834: add gcc abi_tag support

2016-03-14 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Hi Pavel,

Code review is not a good place to discuss such type of things. There is no
really good workaround for this issue if you already have libraries built
with C++ 11 and GCC configured to use abi_tag. But if you are doing it only
for testing and you are willing to build Clang yourself, you could try to
get top of the tree Clang and apply this http://reviews.llvm.org/D18035. If
you do so, please report any issues with abi_tag to the patch or to me
directly. I tested patch http://reviews.llvm.org/D18035 on tests and small
things only so testing on something bigger will be helpful.


Repository:
  rL LLVM

http://reviews.llvm.org/D12834



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread Marina Yatsina via cfe-commits
myatsina added a comment.

In http://reviews.llvm.org/D18123#374170, @hintonda wrote:

> LookupResult's copy ctor and assignment operator are used in 
> Sema::LookupInlineAsmField().  Looks like these were added back in December.
>
> I'll remove the defaults, from this patch, but not sure how to handle 
> LookupInlineAsmField().  Will add author of that change.
>
> OTOH, UnresolvedSetImpl requires an assignment operator since it's a base to 
> UnresolvedSet which has an implicit assignment operator, so I think that 
> change is correct.


I can change my code to avoid the copy ctor and assignment operator of 
LookupResult - In every iteration I only need to access 2 members of the 
previous LookupResult (isSingleResult() and getFoundDecl()), I can keep only 
them instead of the whole object.
Do you want me to upload a patch with this change?


http://reviews.llvm.org/D18123



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


Re: [PATCH] D17453: [Driver] Enable --rtlib option for MSVC target

2016-03-14 Thread Andrey Turetskiy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263422: [Driver] Enable --rtlib option for MSVC target 
(authored by aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D17453?vs=50260&id=50579#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17453

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/msvc-compiler-rt.c
  cfe/trunk/test/Driver/nostdlib.c

Index: cfe/trunk/test/Driver/nostdlib.c
===
--- cfe/trunk/test/Driver/nostdlib.c
+++ cfe/trunk/test/Driver/nostdlib.c
@@ -22,6 +22,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
 //
+// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt 
-### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib 
-### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+//
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
+// CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
Index: cfe/trunk/test/Driver/msvc-compiler-rt.c
===
--- cfe/trunk/test/Driver/msvc-compiler-rt.c
+++ cfe/trunk/test/Driver/msvc-compiler-rt.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -### %s 2>&1 
| FileCheck %s -check-prefix MSVC-COMPILER-RT
+// RUN: not %clang %s -target x86_64-pc-windows-msvc --rtlib=libgcc 2>&1 | 
FileCheck %s -check-prefix CHECK-ERROR
+
+// MSVC-COMPILER-RT: "{{.*}}clang_rt.builtins{{.*}}"
+// CHECK-ERROR: unsupported runtime library 'libgcc' for platform 'MSVC'
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8948,7 +8948,16 @@
 }
 break;
   case ToolChain::RLT_Libgcc:
-AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
+// Make sure libgcc is not used under MSVC environment by default
+if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+  // Issue error diagnostic if libgcc is explicitly specified
+  // through command line as --rtlib option argument.
+  if (Args.hasArg(options::OPT_rtlib_EQ)) {
+TC.getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
+<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC";
+  }
+} else
+  AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
 break;
   }
 }
@@ -9754,6 +9763,12 @@
 }
   }
 
+  // Add compiler-rt lib in case if it was explicitly
+  // specified as an argument for --rtlib option.
+  if (!Args.hasArg(options::OPT_nostdlib)) {
+AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {


Index: cfe/trunk/test/Driver/nostdlib.c
===
--- cfe/trunk/test/Driver/nostdlib.c
+++ cfe/trunk/test/Driver/nostdlib.c
@@ -22,6 +22,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
 //
+// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+//
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
+// CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt'
Index: cfe/trunk/test/Driver/msvc-compiler-rt.c
===
--- cfe/trunk/test/Driver/msvc-compiler-rt.c
+++ cfe/trunk/test/Driver/msvc-compiler-rt.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix MSVC-COMPILER-RT
+// RUN: not %clang %s -target x86_64-pc-windows-msvc --rtlib=libgcc 2>&1 | FileCheck %s -check-prefix CHECK-ERROR
+
+// MSVC-COMPILER-RT: "{{.*}}clang_rt.builtins{{.*}}"
+// CHECK-ERROR: unsupported runtime library 'libgcc' for platform 'MSVC'
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cf

r263422 - [Driver] Enable --rtlib option for MSVC target

2016-03-14 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Mon Mar 14 06:19:43 2016
New Revision: 263422

URL: http://llvm.org/viewvc/llvm-project?rev=263422&view=rev
Log:
[Driver] Enable --rtlib option for MSVC target

This enables "--rtlib compiler-rt" option under MSVC environment.

Patch by Roman Shirokiy.

Differential Revision: http://reviews.llvm.org/D17453

Added:
cfe/trunk/test/Driver/msvc-compiler-rt.c   (with props)
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/nostdlib.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263422&r1=263421&r2=263422&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 14 06:19:43 2016
@@ -8948,7 +8948,16 @@ static void AddRunTimeLibs(const ToolCha
 }
 break;
   case ToolChain::RLT_Libgcc:
-AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
+// Make sure libgcc is not used under MSVC environment by default
+if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+  // Issue error diagnostic if libgcc is explicitly specified
+  // through command line as --rtlib option argument.
+  if (Args.hasArg(options::OPT_rtlib_EQ)) {
+TC.getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
+<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC";
+  }
+} else
+  AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
 break;
   }
 }
@@ -9754,6 +9763,12 @@ void visualstudio::Linker::ConstructJob(
 }
   }
 
+  // Add compiler-rt lib in case if it was explicitly
+  // specified as an argument for --rtlib option.
+  if (!Args.hasArg(options::OPT_nostdlib)) {
+AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {

Added: cfe/trunk/test/Driver/msvc-compiler-rt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-compiler-rt.c?rev=263422&view=auto
==
--- cfe/trunk/test/Driver/msvc-compiler-rt.c (added)
+++ cfe/trunk/test/Driver/msvc-compiler-rt.c Mon Mar 14 06:19:43 2016
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -### %s 2>&1 
| FileCheck %s -check-prefix MSVC-COMPILER-RT
+// RUN: not %clang %s -target x86_64-pc-windows-msvc --rtlib=libgcc 2>&1 | 
FileCheck %s -check-prefix CHECK-ERROR
+
+// MSVC-COMPILER-RT: "{{.*}}clang_rt.builtins{{.*}}"
+// CHECK-ERROR: unsupported runtime library 'libgcc' for platform 'MSVC'

Propchange: cfe/trunk/test/Driver/msvc-compiler-rt.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/Driver/msvc-compiler-rt.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/Driver/msvc-compiler-rt.c
--
svn:mime-type = text/plain

Modified: cfe/trunk/test/Driver/nostdlib.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=263422&r1=263421&r2=263422&view=diff
==
--- cfe/trunk/test/Driver/nostdlib.c (original)
+++ cfe/trunk/test/Driver/nostdlib.c Mon Mar 14 06:19:43 2016
@@ -22,6 +22,10 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
 //
+// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt 
-### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib 
-### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+//
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
+// CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'


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


Re: [PATCH] D18141: [clang-tidy] Fix "Name is not a simple identifier" assertion in `modernize-loop-convert` check.

2016-03-14 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good.


Repository:
  rL LLVM

http://reviews.llvm.org/D18141



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


Re: [PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-03-14 Thread Olga Chupina via cfe-commits
olga.a.chupina added a comment.

Reid, cloud you please review the patch.


http://reviews.llvm.org/D17709



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread don hinton via cfe-commits
hintonda added a comment.

Sure, that would be great.  Thanks.


http://reviews.llvm.org/D18123



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


r263425 - Recommitted r261634 "Supporting all entities declared in lexical scope in LLVM debug info."

2016-03-14 Thread Amjad Aboud via cfe-commits
Author: aaboud
Date: Mon Mar 14 07:03:55 2016
New Revision: 263425

URL: http://llvm.org/viewvc/llvm-project?rev=263425&view=rev
Log:
Recommitted r261634 "Supporting all entities declared in lexical scope in LLVM 
debug info."
After fixing PR26715 at r263379.

Added:
cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
  - copied unchanged from r261669, 
cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=263425&r1=263424&r2=263425&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Mar 14 07:03:55 2016
@@ -831,15 +831,18 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
   llvm::DIFile *Unit) {
+  TypedefNameDecl *TD = Ty->getDecl();
   // We don't set size information, but do specify where the typedef was
   // declared.
-  SourceLocation Loc = Ty->getDecl()->getLocation();
+  SourceLocation Loc = TD->getLocation();
+
+  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));
 
   // Typedefs are derived from some other type.
   return DBuilder.createTypedef(
   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(Ty->getDecl()));
+  TDContext);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1472,6 +1475,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   return T;
 }
 
+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
+  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
+ "D is already mapped to lexical block scope");
+  if (!LexicalBlockStack.empty())
+LexicalBlockMap[&D] = LexicalBlockStack.back();
+}
+
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
+   QualType Ty) {
+  auto I = LexicalBlockMap.find(&D);
+  if (I != LexicalBlockMap.end()) {
+RetainedTypes.push_back(Ty.getAsOpaquePtr());
+return I->second;
+  }
+  return getDeclContextDescriptor(cast(&D));
+}
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
@@ -2057,7 +2077,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
 // entered into the ReplaceMap: finalize() will replace the first
 // FwdDecl with the second and then replace the second with
 // complete type.
-llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
+llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
 llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
 llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@@ -2101,7 +2121,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
+  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
   llvm::DIType *ClassTy =
   ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@@ -2362,7 +2382,7 @@ llvm::DICompositeType *CGDebugInfo::Crea
   unsigned Line = getLineNumber(RD->getLocation());
   StringRef RDName = getClassName(RD);
 
-  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
+  llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));
 
   // If we ended up creating the type during the context chain construction,
   // just return that.
@@ -2509,8 +2529,15 @@ void CGDebugInfo::collectVarDeclProps(co
   if (DC->isRecord())
 DC = CGM.getContext().getTranslationUnitDecl();
 
- llvm::DIScope *Mod = getParentModuleOrNull(VD);
- VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
+  if (VD->isStaticLocal()) {
+// Get context for static locals (that are technically globals) the same 
way
+// we do for "local" locals -- by using current lexical block.
+assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack 
empty!");
+VDContext = LexicalBlockStack.back();
+  } else {
+llvm::DIScope *Mod = getParentModuleOrNull(VD);
+VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
+  }
 }
 
 llvm::DISubprogram *

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?re

Re: [PATCH] D14146: Introduction of -miamcu option

2016-03-14 Thread Andrey Turetskiy via cfe-commits
aturetsk abandoned this revision.
aturetsk added a comment.

The patch will be completely reworked and extended to support compilation for 
MCU.


http://reviews.llvm.org/D14146



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


Re: [PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-03-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.


Comment at: lib/Parse/ParseDecl.cpp:4811
@@ -4810,2 +4810,3 @@
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||

MSDN suggests that __unaligned is only valid on a pointer declaration. Is there 
something this is expected to support, or does MSVC just happen to silently 
accept the keyword in this position?


http://reviews.llvm.org/D17709



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


[clang-tools-extra] r263426 - [clang-tidy] Fix "Name is not a simple identifier" assertion in `modernize-loop-convert` check.

2016-03-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Mar 14 07:41:24 2016
New Revision: 263426

URL: http://llvm.org/viewvc/llvm-project?rev=263426&view=rev
Log:
[clang-tidy] Fix "Name is not a simple identifier" assertion in 
`modernize-loop-convert` check.

Summary:
Fix assertion failure: "Name is not a simple identifier".

`Decl::GetName` assumes the name should be an identifier. When the check
processes the function calling statement with speciail key name like
'it.operator->()', it will trigger the assert in `GetName`.

Rather than using `Decl::GetName`, we use `getNameAsString` which works
with special key names in C++.

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D18141

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=263426&r1=263425&r2=263426&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Mon Mar 
14 07:41:24 2016
@@ -391,8 +391,8 @@ static bool isAliasDecl(ASTContext *Cont
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
 const auto *MDecl = MemCall->getMethodDecl();
-if (MDecl && !isa(MDecl) && MDecl->getName() == "at" &&
-MemCall->getNumArgs() == 1) {
+if (MDecl && !isa(MDecl) &&
+MDecl->getNameAsString() == "at" && MemCall->getNumArgs() == 1) {
   return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar);
 }
 return false;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=263426&r1=263425&r2=263426&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Mon Mar 14 07:41:24 2016
@@ -320,6 +320,10 @@ void f() {
   // CHECK-FIXES: for (auto & It : Uu)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
+  for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
+Val* a = It.operator->();
+  }
+
   U::iterator A;
   for (U::iterator I = Uu.begin(), E = Uu.end(); I != E; ++I)
 int K = A->X + I->X;


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


Re: [PATCH] D18141: [clang-tidy] Fix "Name is not a simple identifier" assertion in `modernize-loop-convert` check.

2016-03-14 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263426: [clang-tidy] Fix "Name is not a simple identifier" 
assertion in `modernize… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D18141?vs=50580&id=50582#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18141

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -391,8 +391,8 @@
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
 const auto *MDecl = MemCall->getMethodDecl();
-if (MDecl && !isa(MDecl) && MDecl->getName() == "at" &&
-MemCall->getNumArgs() == 1) {
+if (MDecl && !isa(MDecl) &&
+MDecl->getNameAsString() == "at" && MemCall->getNumArgs() == 1) {
   return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar);
 }
 return false;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -320,6 +320,10 @@
   // CHECK-FIXES: for (auto & It : Uu)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
+  for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
+Val* a = It.operator->();
+  }
+
   U::iterator A;
   for (U::iterator I = Uu.begin(), E = Uu.end(); I != E; ++I)
 int K = A->X + I->X;


Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -391,8 +391,8 @@
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
 const auto *MDecl = MemCall->getMethodDecl();
-if (MDecl && !isa(MDecl) && MDecl->getName() == "at" &&
-MemCall->getNumArgs() == 1) {
+if (MDecl && !isa(MDecl) &&
+MDecl->getNameAsString() == "at" && MemCall->getNumArgs() == 1) {
   return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar);
 }
 return false;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -320,6 +320,10 @@
   // CHECK-FIXES: for (auto & It : Uu)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
+  for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
+Val* a = It.operator->();
+  }
+
   U::iterator A;
   for (U::iterator I = Uu.begin(), E = Uu.end(); I != E; ++I)
 int K = A->X + I->X;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Mar 14 08:23:58 2016
New Revision: 263429

URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
Log:
[Frontend] Disable value name discarding for all sanitizers.

ASan also relies on names on allocas and will emit unhelpful output if
they're not present. Just force-enable value names for now. Should
unbreak release builds of asan.

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

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58 2016
@@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.DisableFPElim =
   (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
+  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
   if (Arg *A = Args.getLastArg(OPT_meabi)) {
@@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
-  // DiscardValueNames is set here so that it can depend (perhaps temporarily)
-  // on other options.
-  // We check SanitizeMemoryTrackOrigins here because the backend pass depends
-  // on the name of the alloca in order to print out names.
-  Opts.DiscardValueNames =
-  Args.hasArg(OPT_discard_value_names) && !Opts.SanitizeMemoryTrackOrigins;
   return Success;
 }
 
@@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   Res.getLangOpts()->ObjCExceptions = 1;
   }
+
+  // FIXME: Override value name discarding when sanitizers are used because the
+  // backend passes depend on the name of the alloca in order to print out
+  // names.
+  Res.getCodeGenOpts().DiscardValueNames &= 
Res.getLangOpts()->Sanitize.empty();
+
   // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of
   // PCH file and find the original header name. Remove the need to do that in
   // ParsePreprocessorArgs and remove the FileManager


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


Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread Chandler Carruth via cfe-commits
A long time ago I argued that the sanitizers should be using debug info
instead of alloca names for this, and I really thought that they had
implemented this... Is that not the case?

It is really bad that the sanitizers are relying on this stuff...

On Mon, Mar 14, 2016 at 2:28 PM Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Mon Mar 14 08:23:58 2016
> New Revision: 263429
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
> Log:
> [Frontend] Disable value name discarding for all sanitizers.
>
> ASan also relies on names on allocas and will emit unhelpful output if
> they're not present. Just force-enable value names for now. Should
> unbreak release builds of asan.
>
> Modified:
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58 2016
> @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
>Opts.DisableFPElim =
>(Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
>Opts.DisableFree = Args.hasArg(OPT_disable_free);
> +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
>Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
>Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
>if (Arg *A = Args.getLastArg(OPT_meabi)) {
> @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
>Opts.CudaGpuBinaryFileNames =
>Args.getAllArgValues(OPT_fcuda_include_gpubinary);
>
> -  // DiscardValueNames is set here so that it can depend (perhaps
> temporarily)
> -  // on other options.
> -  // We check SanitizeMemoryTrackOrigins here because the backend pass
> depends
> -  // on the name of the alloca in order to print out names.
> -  Opts.DiscardValueNames =
> -  Args.hasArg(OPT_discard_value_names) &&
> !Opts.SanitizeMemoryTrackOrigins;
>return Success;
>  }
>
> @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
>  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
>Res.getLangOpts()->ObjCExceptions = 1;
>}
> +
> +  // FIXME: Override value name discarding when sanitizers are used
> because the
> +  // backend passes depend on the name of the alloca in order to print out
> +  // names.
> +  Res.getCodeGenOpts().DiscardValueNames &=
> Res.getLangOpts()->Sanitize.empty();
> +
>// FIXME: ParsePreprocessorArgs uses the FileManager to read the
> contents of
>// PCH file and find the original header name. Remove the need to do
> that in
>// ParsePreprocessorArgs and remove the FileManager
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-14 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:24
@@ +23,3 @@
+
+  // C++ constructor..
+  Finder->addMatcher(cxxConstructorDecl().bind("Ctor"), this);

Extra `.` at the end.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:124
@@ +123,3 @@
+void NonConstParameterCheck::diagnoseNonConstParameters() {
+  for (auto It : Parameters) {
+const ParmVarDecl *Par = It.first;

const auto &It


Comment at: clang-tidy/readability/NonConstParameterCheck.h:53
@@ +52,3 @@
+  /// and CanNotBeConst is true the Parameter is marked as not-const.
+  /// The CanNotBeConst are updated as sub expressions are visited.
+  void markCanNotBeConst(const Expr *E, bool CanNotBeConst);

s/are/is


Comment at: docs/clang-tidy/checks/readability-non-const-parameter.rst:6
@@ +5,3 @@
+
+Finds function parameters that should be const. When const is used properly,
+many mistakes can be avoided. Advantages when using const properly:

Looks like what the document says isn't consistent with the check, since the 
check only finds non-const pointer parameter. 


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:3
@@ +2,3 @@
+
+// Currently the checker only warns about pointer arguments.
+//

It makes sense to move this document to the `rst`, I think.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:15
@@ +14,3 @@
+
+// CHECK-MESSAGES: :[[@LINE+1]]:29: warning: parameter 'last' can be const 
[readability-non-const-parameter]
+void warn1(int *first, int *last) {

Just keep the whole warning message in the first CHECK-MESSAGE.
And remove `[readability-non-const-parameter]` in others CHECK-MESSAGE for 
keeping the line short. 


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:219
@@ +218,3 @@
+public:
+  C(int *p) : p(p) {}
+private:

Please add a test case:

```
class C {
public:
  C(int *p) : p(p) {}
private:
  const int *p;
};
```

BTW, does the check support class method?


http://reviews.llvm.org/D15332



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


Re: [PATCH] D18136: boost-use-to-string check

2016-03-14 Thread Haojian Wu via cfe-commits
hokein added a subscriber: hokein.
hokein added a comment.

> Is there any better solution for the basic_string problem?


The current solution looks fine to me. I don't have a better solution. Maybe 
@alexfh has.



Comment at: docs/clang-tidy/checks/boost-use-to-string.rst:6
@@ +5,2 @@
+
+FIXME: Describe what patterns does the check detect and why. Give examples.

Please update the document.


Comment at: test/clang-tidy/boost-use-to-string.cpp:30
@@ +29,3 @@
+  std::string y = boost::lexical_cast(xa);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use std::to_string instead of 
boost::lexical_cast [boost-use-to-string]
+// CHECK-FIXES: std::string y = std::to_string(xa);

Normally you only need to check the whole warning message in the first line.
For others, use prefix message to keep the line short.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-14 Thread Eric Liu via cfe-commits
Friendly PING.

@klimek
Hi Manuel, what do you think about the return type for
groupReplacementsByFile?
Daniel suggests that instead of "std::map", it
returns "std::vector".

On Sun, Mar 6, 2016 at 9:32 PM Eric Liu  wrote:

> ioeric added inline comments.
>
> 
> Comment at: include/clang/Tooling/Core/Replacement.h:230
> @@ +229,3 @@
> +
> +typedef std::map
> +FileToReplacementsMap;
> 
> djasper wrote:
> > ioeric wrote:
> > > djasper wrote:
> > > > I think the key type in a map is always const, so no need for
> "const".
> > > I think "const" is needed since the `Entry` passed to map's `[]`
> operator is of type `const FileEntry *` in
> `FileToReplaces[Entry].push_back(Replace)`. The code didn't compile without
> the "const" qualifier.
> > Well, now it's a string and the strings are copied anyway. I am pretty
> sure it will compile after removing "const".
> Ooops! I was on another git branch! Yes, it definitely compiles for
> `string`. Sorry about that.
>
>
> http://reviews.llvm.org/D17852
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263435 - Fix some more tests with CLANG_DEFAULT_CXX_STDLIB

2016-03-14 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Mon Mar 14 09:34:10 2016
New Revision: 263435

URL: http://llvm.org/viewvc/llvm-project?rev=263435&view=rev
Log:
Fix some more tests with CLANG_DEFAULT_CXX_STDLIB

Also use -stdlib=platform instead of -stdlib=libstdc++ when testing if Clang
chooses the correct default for the given platform.

Modified:
cfe/trunk/test/Driver/bitrig.c
cfe/trunk/test/Driver/darwin-iphone-defaults.m
cfe/trunk/test/Driver/darwin-objc-gc.m
cfe/trunk/test/Driver/darwin-sanitizer-ld.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/test/Driver/bitrig.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/bitrig.c?rev=263435&r1=263434&r2=263435&view=diff
==
--- cfe/trunk/test/Driver/bitrig.c (original)
+++ cfe/trunk/test/Driver/bitrig.c Mon Mar 14 09:34:10 2016
@@ -3,7 +3,7 @@
 // CHECK-LD-C: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
 // CHECK-LD-C: ld{{.*}}" {{.*}} "-lc" "-lclang_rt.amd64"
 
-// RUN: %clangxx -no-canonical-prefixes -target amd64-pc-bitrig %s -### 2>&1 \
+// RUN: %clangxx -stdlib=platform -no-canonical-prefixes -target 
amd64-pc-bitrig %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-CXX-STDLIB %s
 // CHECK-LD-CXX-STDLIB: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
 // CHECK-LD-CXX-STDLIB: ld{{.*}}" {{.*}} "-lc++" "-lc++abi" "-lpthread" "-lm" 
"-lc" "-lclang_rt.amd64"

Modified: cfe/trunk/test/Driver/darwin-iphone-defaults.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-iphone-defaults.m?rev=263435&r1=263434&r2=263435&view=diff
==
--- cfe/trunk/test/Driver/darwin-iphone-defaults.m (original)
+++ cfe/trunk/test/Driver/darwin-iphone-defaults.m Mon Mar 14 09:34:10 2016
@@ -1,4 +1,4 @@
-// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch 
armv7 -stdlib=libstdc++ -flto -S -o - %s | FileCheck %s
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch 
armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s
 
 // CHECK: @f0() [[F0:#[0-9]+]]
 // CHECK: @__f0_block_invoke

Modified: cfe/trunk/test/Driver/darwin-objc-gc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-objc-gc.m?rev=263435&r1=263434&r2=263435&view=diff
==
--- cfe/trunk/test/Driver/darwin-objc-gc.m (original)
+++ cfe/trunk/test/Driver/darwin-objc-gc.m Mon Mar 14 09:34:10 2016
@@ -1,6 +1,6 @@
 // Check that we warn, but accept, -fobjc-gc for iPhone OS.
 
-// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 
-stdlib=libstdc++ -fobjc-gc -flto -S -o %t %s 2> %t.err
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 
-stdlib=platform -fobjc-gc -flto -S -o %t %s 2> %t.err
 // RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_LL %s < %t 
 // RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_STDERR %s < %t.err
 

Modified: cfe/trunk/test/Driver/darwin-sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sanitizer-ld.c?rev=263435&r1=263434&r2=263435&view=diff
==
--- cfe/trunk/test/Driver/darwin-sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-sanitizer-ld.c Mon Mar 14 09:34:10 2016
@@ -1,7 +1,7 @@
 // Test sanitizer link flags on Darwin.
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -stdlib=libstdc++ -fsanitize=address %s -o %t.o 2>&1 \
+// RUN:   -stdlib=platform -fsanitize=address %s -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN %s
 
 // CHECK-ASAN: "{{.*}}ld{{(.exe)?}}"
@@ -21,7 +21,7 @@
 // CHECK-DYN-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -stdlib=libstdc++ -fsanitize=undefined %s -o %t.o 2>&1 \
+// RUN:   -stdlib=platform -fsanitize=undefined %s -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN %s
 
 // CHECK-UBSAN: "{{.*}}ld{{(.exe)?}}"
@@ -57,8 +57,8 @@
 // CHECK-DYN-BOUNDS-NOT: ubsan_osx
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
+// RUN:   -stdlib=platform -fsanitize=address -mios-simulator-version-min=7.0 \
+// RUN:   %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
 
 // CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ASAN-IOSSIM: lc++
@@ -67,7 +67,8 @@
 // CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -fsanitize=address -mtvos-simulator-version-min=8.3.0 %s -o %t.o 
2>&1 \
+// RUN:   -stdlib=platform -fsanitize=address \
+// RUN:   -mtvos-simulator-version-min=8.3.0 %s -o %t.o 2>&1 \
 // RUN:   | FileCheck

Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-03-14 Thread Jonas Hahnfeld via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263434: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB 
(authored by Hahnfeld).

Changed prior to commit:
  http://reviews.llvm.org/D17286?vs=49459&id=50592#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17286

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/test/Driver/freebsd.cpp
  cfe/trunk/test/Driver/netbsd.cpp

Index: cfe/trunk/test/Driver/netbsd.cpp
===
--- cfe/trunk/test/Driver/netbsd.cpp
+++ cfe/trunk/test/Driver/netbsd.cpp
@@ -1,93 +1,93 @@
 // RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=X86_64 %s
 // RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd7.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=X86_64-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd6.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=X86_64-6 %s
 // RUN: %clangxx -no-canonical-prefixes -target arm--netbsd6.0.0-eabi \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=ARM %s
 // RUN: %clangxx -no-canonical-prefixes -target arm--netbsd7.0.0-eabi \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=ARM-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target aarch64--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=AARCH64 %s
 // RUN: %clangxx -no-canonical-prefixes -target aarch64--netbsd7.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=AARCH64-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc--netbsd6.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC-6 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc--netbsd7.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc64--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC64 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc64--netbsd6.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC64-6 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc64--netbsd7.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC64-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target powerpc--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=POWERPC %s
 // RUN: %clangxx -no-canonical-prefixes -target powerpc64--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=POWERPC64 %s
 
 // RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd -static \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-X86_64 %s
 // RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd7.0.0 -static \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: -stdlib=platform --sysroot=%

r263434 - Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-03-14 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Mon Mar 14 09:34:04 2016
New Revision: 263434

URL: http://llvm.org/viewvc/llvm-project?rev=263434&view=rev
Log:
Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

Also introduce -stdlib=platform to override the configured value
and use it to make the tests always pass.

Differential Revision: http://reviews.llvm.org/D17286

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/freebsd.cpp
cfe/trunk/test/Driver/netbsd.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=263434&r1=263433&r2=263434&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Mar 14 09:34:04 2016
@@ -555,16 +555,23 @@ static bool ParseCXXStdlibType(const Str
 ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) 
const{
   ToolChain::CXXStdlibType Type;
   bool HasValidType = false;
+  bool ForcePlatformDefault = false;
 
   const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
   if (A) {
-HasValidType = ParseCXXStdlibType(A->getValue(), Type);
-if (!HasValidType)
+StringRef Value = A->getValue();
+HasValidType = ParseCXXStdlibType(Value, Type);
+
+// Only use in tests to override CLANG_DEFAULT_CXX_STDLIB!
+if (Value == "platform")
+  ForcePlatformDefault = true;
+else if (!HasValidType)
   getDriver().Diag(diag::err_drv_invalid_stdlib_name)
 << A->getAsString(Args);
   }
 
-  if (!HasValidType && !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type))
+  if (!HasValidType && (ForcePlatformDefault ||
+  !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type)))
 Type = GetDefaultCXXStdlibType();
 
   return Type;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=263434&r1=263433&r2=263434&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Mar 14 09:34:04 2016
@@ -3106,16 +3106,7 @@ FreeBSD::FreeBSD(const Driver &D, const
 getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
-ToolChain::CXXStdlibType FreeBSD::GetCXXStdlibType(const ArgList &Args) const {
-  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
-StringRef Value = A->getValue();
-if (Value == "libstdc++")
-  return ToolChain::CST_Libstdcxx;
-if (Value == "libc++")
-  return ToolChain::CST_Libcxx;
-
-getDriver().Diag(diag::err_drv_invalid_stdlib_name) << 
A->getAsString(Args);
-  }
+ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
   if (getTriple().getOSMajorVersion() >= 10)
 return ToolChain::CST_Libcxx;
   return ToolChain::CST_Libstdcxx;
@@ -3258,17 +3249,7 @@ Tool *NetBSD::buildAssembler() const {
 
 Tool *NetBSD::buildLinker() const { return new tools::netbsd::Linker(*this); }
 
-ToolChain::CXXStdlibType NetBSD::GetCXXStdlibType(const ArgList &Args) const {
-  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
-StringRef Value = A->getValue();
-if (Value == "libstdc++")
-  return ToolChain::CST_Libstdcxx;
-if (Value == "libc++")
-  return ToolChain::CST_Libcxx;
-
-getDriver().Diag(diag::err_drv_invalid_stdlib_name) << 
A->getAsString(Args);
-  }
-
+ToolChain::CXXStdlibType NetBSD::GetDefaultCXXStdlibType() const {
   unsigned Major, Minor, Micro;
   getTriple().getOSVersion(Major, Minor, Micro);
   if (Major >= 7 || Major == 0) {

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=263434&r1=263433&r2=263434&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon Mar 14 09:34:04 2016
@@ -728,7 +728,7 @@ public:
   bool IsMathErrnoDefault() const override { return false; }
   bool IsObjCNonFragileABIDefault() const override { return true; }
 
-  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const 
override;
+  CXXStdlibType GetDefaultCXXStdlibType() const override;
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
@@ -756,7 +756,7 @@ public:
   bool IsMathErrnoDefault() const override { return false; }
   bool IsObjCNonFragileABIDefault() const override { return true; }
 
-  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const 
override;
+  CXXStdlibType GetDefaultCXXStdlibType() const override;
 
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,

Modified: cfe/trunk/test/Driver/freebsd.cpp
URL: 
http://llvm.org/viewvc/llvm-

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-14 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:237
@@ +236,3 @@
+/// related to the same file entry are put into the same vector.
+FileToReplacementsMap groupReplacementsByFile(const Replacements &Replaces,
+  FileManager &Files);

ioeric wrote:
> djasper wrote:
> > Hm... I am not sure here. I think I would implement this entirely without 
> > FileManager or FileEntries, just based on the names of the file. I guess 
> > you are worried about different paths leading to the same FileEntry?
> You are right. Getting rid of `FileManger` would make more sense for users. 
> And yes, I was worrying about different names leading to the same entry. Do 
> we need to worry about this case? Or we can assume Replacements for the same 
> file always have the same file path? 
I like a map-based interface slightly better here, mainly because I think it's 
a bit harder to write buggy code against it, it's less work if the user wants 
to apply some kind of sharding (threads can just hand around the vectors 
without the need to loop over the vector yet again to split it, or hand indices 
around), and (to me at least) it is slightly easier to grasp the function's 
contract.

Regarding the FileEntries, I'm not overly worried about file entries leading to 
the same file (I believe this is not too hard to handle one level higher if 
necessary), and the interface would seem significantly simpler without the 
FileManager.


Comment at: include/clang/Tooling/ReplacementsFormat.h:40
@@ +39,3 @@
+   Rewriter &Rewrite,
+   const format::FormatStyle &Style);
+

djasper wrote:
> This is probably a pre-existing issue in formatReplacements, but I think 
> conceptually it might be wrong to hand in the Style. I think it might be a 
> better idea to use clang::format::getStyle() with the filename stored inside 
> of the replacement to get the style that should actually be used for any 
> given change. Not sure whether we'd also want the capability to overwrite 
> this. Manuel, what do you think?
(not sure whether that's still unresolved, as I think I talked about this with 
Eric already)
I believe that is what style=file is for, right? I'm fine with a convenience 
method with style=file, but it seems like the generic one makes sense to have, 
too.


http://reviews.llvm.org/D17852



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


r263436 - Revert "Recommitted r261634 "Supporting all entities declared in lexical scope in LLVM debug info." After fixing PR26715 at r263379."

2016-03-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Mar 14 09:58:28 2016
New Revision: 263436

URL: http://llvm.org/viewvc/llvm-project?rev=263436&view=rev
Log:
Revert "Recommitted r261634 "Supporting all entities declared in lexical scope 
in LLVM debug info." After fixing PR26715 at r263379."

This reverts commit r263425. Breaks self-host.

Removed:
cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=263436&r1=263435&r2=263436&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Mar 14 09:58:28 2016
@@ -831,18 +831,15 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
   llvm::DIFile *Unit) {
-  TypedefNameDecl *TD = Ty->getDecl();
   // We don't set size information, but do specify where the typedef was
   // declared.
-  SourceLocation Loc = TD->getLocation();
-
-  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));
+  SourceLocation Loc = Ty->getDecl()->getLocation();
 
   // Typedefs are derived from some other type.
   return DBuilder.createTypedef(
   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  TDContext);
+  getDeclContextDescriptor(Ty->getDecl()));
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1475,23 +1472,6 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   return T;
 }
 
-void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
-  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
- "D is already mapped to lexical block scope");
-  if (!LexicalBlockStack.empty())
-LexicalBlockMap[&D] = LexicalBlockStack.back();
-}
-
-llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
-   QualType Ty) {
-  auto I = LexicalBlockMap.find(&D);
-  if (I != LexicalBlockMap.end()) {
-RetainedTypes.push_back(Ty.getAsOpaquePtr());
-return I->second;
-  }
-  return getDeclContextDescriptor(cast(&D));
-}
-
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
@@ -2077,7 +2057,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
 // entered into the ReplaceMap: finalize() will replace the first
 // FwdDecl with the second and then replace the second with
 // complete type.
-llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
+llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
 llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
 llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@@ -2121,7 +2101,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
+  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
   llvm::DIType *ClassTy =
   ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@@ -2382,7 +2362,7 @@ llvm::DICompositeType *CGDebugInfo::Crea
   unsigned Line = getLineNumber(RD->getLocation());
   StringRef RDName = getClassName(RD);
 
-  llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));
+  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 
   // If we ended up creating the type during the context chain construction,
   // just return that.
@@ -2529,15 +2509,8 @@ void CGDebugInfo::collectVarDeclProps(co
   if (DC->isRecord())
 DC = CGM.getContext().getTranslationUnitDecl();
 
-  if (VD->isStaticLocal()) {
-// Get context for static locals (that are technically globals) the same 
way
-// we do for "local" locals -- by using current lexical block.
-assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack 
empty!");
-VDContext = LexicalBlockStack.back();
-  } else {
-llvm::DIScope *Mod = getParentModuleOrNull(VD);
-VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
-  }
+ llvm::DIScope *Mod = getParentModuleOrNull(VD);
+ VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
 }
 
 llvm::DISubprogram *

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=263436&r1=263435&r2=263436

Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread David Blaikie via cfe-commits
Yeah - how are they relying on them in a non-asserts build anyway? (were we
naming certain things regardless of +/-Asserts? (well, I know we were
naming some things, but mostly down in LLVM, I thought Clang generally used
the IRBuilder & thus didn't name things in non-Asserts builds))

On Mon, Mar 14, 2016 at 6:36 AM, Chandler Carruth via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> A long time ago I argued that the sanitizers should be using debug info
> instead of alloca names for this, and I really thought that they had
> implemented this... Is that not the case?
>
> It is really bad that the sanitizers are relying on this stuff...
>
> On Mon, Mar 14, 2016 at 2:28 PM Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: d0k
>> Date: Mon Mar 14 08:23:58 2016
>> New Revision: 263429
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
>> Log:
>> [Frontend] Disable value name discarding for all sanitizers.
>>
>> ASan also relies on names on allocas and will emit unhelpful output if
>> they're not present. Just force-enable value names for now. Should
>> unbreak release builds of asan.
>>
>> Modified:
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>
>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58 2016
>> @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
>>Opts.DisableFPElim =
>>(Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
>>Opts.DisableFree = Args.hasArg(OPT_disable_free);
>> +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
>>Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
>>Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
>>if (Arg *A = Args.getLastArg(OPT_meabi)) {
>> @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
>>Opts.CudaGpuBinaryFileNames =
>>Args.getAllArgValues(OPT_fcuda_include_gpubinary);
>>
>> -  // DiscardValueNames is set here so that it can depend (perhaps
>> temporarily)
>> -  // on other options.
>> -  // We check SanitizeMemoryTrackOrigins here because the backend pass
>> depends
>> -  // on the name of the alloca in order to print out names.
>> -  Opts.DiscardValueNames =
>> -  Args.hasArg(OPT_discard_value_names) &&
>> !Opts.SanitizeMemoryTrackOrigins;
>>return Success;
>>  }
>>
>> @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
>>  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
>>Res.getLangOpts()->ObjCExceptions = 1;
>>}
>> +
>> +  // FIXME: Override value name discarding when sanitizers are used
>> because the
>> +  // backend passes depend on the name of the alloca in order to print
>> out
>> +  // names.
>> +  Res.getCodeGenOpts().DiscardValueNames &=
>> Res.getLangOpts()->Sanitize.empty();
>> +
>>// FIXME: ParsePreprocessorArgs uses the FileManager to read the
>> contents of
>>// PCH file and find the original header name. Remove the need to do
>> that in
>>// ParsePreprocessorArgs and remove the FileManager
>>
>>
>> ___
>> 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
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r261372 - [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a single

2016-03-14 Thread Argyrios Kyrtzidis via cfe-commits
If not addressing the issue with '-fmodule-name' could you revert removal of 
original ‘-fmodule-implementation-of’ since we are depending on it ?

> On Mar 3, 2016, at 6:13 PM, Argyrios Kyrtzidis via cfe-commits 
>  wrote:
> 
> Hey Richard,
> 
> -fmodule-name emits bogus warnings about “include of non-modular header 
> inside framework module”, while trying to include a header in the 
> implementation file.
> This is not new behavior but we noticed it now that we tried to use it as 
> replacement of -fmodule-implementation-of.
> 
> Could you take a look ? The test case is attached. Unzip and run:
> 
> $ clang -fsyntax-only /tmp/test-frame/boo.m -fmodules 
> -fmodules-cache-path=/tmp/mcp -F /tmp/test-frame -fmodule-name=boo 
> -Werror=non-modular-include-in-framework-module
> /tmp/test-frame/boo.m:2:9: error: include of non-modular header inside 
> framework module 'boo' [-Werror,-Wnon-modular-include-in-framework-module]
> #import "blah.h"
> ^
> 1 error generated.
> 
> 
> 
>> On Mar 3, 2016, at 5:28 AM, Richard Smith via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> On 3 Mar 2016 3:18 a.m., "Argyrios Kyrtzidis via cfe-commits" 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> >
>> > Mind if we keep -fmodule-implementation-of as an alias so that we can 
>> > gradually transition to -fmodule-name ?
>> 
>> Sure, no problem.
>> 
>> > > On Feb 19, 2016, at 2:25 PM, Richard Smith via cfe-commits 
>> > > mailto:cfe-commits@lists.llvm.org>> wrote:
>> > >
>> > > Author: rsmith
>> > > Date: Fri Feb 19 16:25:36 2016
>> > > New Revision: 261372
>> > >
>> > > URL: http://llvm.org/viewvc/llvm-project?rev=261372&view=rev 
>> > > 
>> > > Log:
>> > > [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a 
>> > > single
>> > > option. Previously these options could both be used to specify that you 
>> > > were
>> > > compiling the implementation file of a module, with a different set of 
>> > > minor
>> > > bugs in each case.
>> > >
>> > > This change removes -fmodule-implementation-of, and instead tracks a 
>> > > flag to
>> > > determine whether we're currently building a module. -fmodule-name now 
>> > > behaves
>> > > the same way that -fmodule-implementation-of previously did.
>> > >
>> > > Modified:
>> > >cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>> > >cfe/trunk/include/clang/Basic/LangOptions.def
>> > >cfe/trunk/include/clang/Basic/LangOptions.h
>> > >cfe/trunk/include/clang/Driver/CC1Options.td
>> > >cfe/trunk/include/clang/Driver/Options.td
>> > >cfe/trunk/include/clang/Lex/ModuleMap.h
>> > >cfe/trunk/lib/Basic/LangOptions.cpp
>> > >cfe/trunk/lib/Driver/Tools.cpp
>> > >cfe/trunk/lib/Frontend/ASTUnit.cpp
>> > >cfe/trunk/lib/Frontend/CompilerInstance.cpp
>> > >cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> > >cfe/trunk/lib/Frontend/FrontendActions.cpp
>> > >cfe/trunk/lib/Lex/ModuleMap.cpp
>> > >cfe/trunk/lib/Lex/PPDirectives.cpp
>> > >cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> > >cfe/trunk/lib/Lex/Preprocessor.cpp
>> > >cfe/trunk/lib/Sema/SemaDecl.cpp
>> > >cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> > >cfe/trunk/test/Modules/Inputs/explicit-build/a.h
>> > >cfe/trunk/test/Modules/explicit-build.cpp
>> > >cfe/trunk/test/Modules/implementation-of-module.m
>> > >cfe/trunk/test/Modules/import-self.m
>> > >
>> > > Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>> > > URL: 
>> > > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=261372&r1=261371&r2=261372&view=diff
>> > >  
>> > > 
>> > > ==
>> > > --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
>> > > +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Feb 19 
>> > > 16:25:36 2016
>> > > @@ -210,10 +210,6 @@ def err_test_module_file_extension_versi
>> > >   "test module file extension '%0' has different version (%1.%2) than 
>> > > expected "
>> > >   "(%3.%4)">;
>> > >
>> > > -def err_conflicting_module_names : Error<
>> > > -  "conflicting module names specified: '-fmodule-name=%0' and "
>> > > -  "'-fmodule-implementation-of %1'">;
>> > > -
>> > > def err_missing_vfs_overlay_file : Error<
>> > >   "virtual filesystem overlay file '%0' not found">, DefaultFatal;
>> > > def err_invalid_vfs_overlay : Error<
>> > >
>> > > Modified: cfe/trunk/include/clang/Basic/LangOptions.def
>> > > URL: 
>> > > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=261372&r1=261371&r2=261372&view=diff
>> > >  
>> > > 
>> > > ==

Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-03-14 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Ping?..


http://reviews.llvm.org/D17815



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


Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread Benjamin Kramer via cfe-commits
On Mon, Mar 14, 2016 at 3:59 PM, David Blaikie  wrote:
> Yeah - how are they relying on them in a non-asserts build anyway? (were we
> naming certain things regardless of +/-Asserts? (well, I know we were naming
> some things, but mostly down in LLVM, I thought Clang generally used the
> IRBuilder & thus didn't name things in non-Asserts builds))

Allocas used to always have names as a debugging feature, see r246991.

> On Mon, Mar 14, 2016 at 6:36 AM, Chandler Carruth via cfe-commits
>  wrote:
>>
>> A long time ago I argued that the sanitizers should be using debug info
>> instead of alloca names for this, and I really thought that they had
>> implemented this... Is that not the case?
>>
>> It is really bad that the sanitizers are relying on this stuff...
>>
>> On Mon, Mar 14, 2016 at 2:28 PM Benjamin Kramer via cfe-commits
>>  wrote:
>>>
>>> Author: d0k
>>> Date: Mon Mar 14 08:23:58 2016
>>> New Revision: 263429
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
>>> Log:
>>> [Frontend] Disable value name discarding for all sanitizers.
>>>
>>> ASan also relies on names on allocas and will emit unhelpful output if
>>> they're not present. Just force-enable value names for now. Should
>>> unbreak release builds of asan.
>>>
>>> Modified:
>>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>>
>>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58
>>> 2016
>>> @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
>>>Opts.DisableFPElim =
>>>(Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
>>>Opts.DisableFree = Args.hasArg(OPT_disable_free);
>>> +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
>>>Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
>>>Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
>>>if (Arg *A = Args.getLastArg(OPT_meabi)) {
>>> @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
>>>Opts.CudaGpuBinaryFileNames =
>>>Args.getAllArgValues(OPT_fcuda_include_gpubinary);
>>>
>>> -  // DiscardValueNames is set here so that it can depend (perhaps
>>> temporarily)
>>> -  // on other options.
>>> -  // We check SanitizeMemoryTrackOrigins here because the backend pass
>>> depends
>>> -  // on the name of the alloca in order to print out names.
>>> -  Opts.DiscardValueNames =
>>> -  Args.hasArg(OPT_discard_value_names) &&
>>> !Opts.SanitizeMemoryTrackOrigins;
>>>return Success;
>>>  }
>>>
>>> @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
>>>  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
>>>Res.getLangOpts()->ObjCExceptions = 1;
>>>}
>>> +
>>> +  // FIXME: Override value name discarding when sanitizers are used
>>> because the
>>> +  // backend passes depend on the name of the alloca in order to print
>>> out
>>> +  // names.
>>> +  Res.getCodeGenOpts().DiscardValueNames &=
>>> Res.getLangOpts()->Sanitize.empty();
>>> +
>>>// FIXME: ParsePreprocessorArgs uses the FileManager to read the
>>> contents of
>>>// PCH file and find the original header name. Remove the need to do
>>> that in
>>>// ParsePreprocessorArgs and remove the FileManager
>>>
>>>
>>> ___
>>> 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
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-03-14 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

LGTM.  I don't know if that's good enough for a submit though :)

In my opinion, requiring heap allocation during an exception is one of the 
worst parts of the Itanium ABI.  At least this particular path isn't triggered 
for platforms with true thread_local support.


http://reviews.llvm.org/D17815



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


Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread Evgenii Stepanov via cfe-commits
On Mon, Mar 14, 2016 at 8:48 AM, Benjamin Kramer  wrote:
> On Mon, Mar 14, 2016 at 3:59 PM, David Blaikie  wrote:
>> Yeah - how are they relying on them in a non-asserts build anyway? (were we
>> naming certain things regardless of +/-Asserts? (well, I know we were naming
>> some things, but mostly down in LLVM, I thought Clang generally used the
>> IRBuilder & thus didn't name things in non-Asserts builds))
>
> Allocas used to always have names as a debugging feature, see r246991.
>
>> On Mon, Mar 14, 2016 at 6:36 AM, Chandler Carruth via cfe-commits
>>  wrote:
>>>
>>> A long time ago I argued that the sanitizers should be using debug info
>>> instead of alloca names for this, and I really thought that they had
>>> implemented this... Is that not the case?
>>>
>>> It is really bad that the sanitizers are relying on this stuff...

We've never implemented this though I think Alexey looked into it at
one point. We'd need to refactor the handling of debug options
(-g/-gline-tables-only) so that debug metadata is emitted with ASan
even without -g and then discarded in the backend.

>>>
>>> On Mon, Mar 14, 2016 at 2:28 PM Benjamin Kramer via cfe-commits
>>>  wrote:

 Author: d0k
 Date: Mon Mar 14 08:23:58 2016
 New Revision: 263429

 URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
 Log:
 [Frontend] Disable value name discarding for all sanitizers.

 ASan also relies on names on allocas and will emit unhelpful output if
 they're not present. Just force-enable value names for now. Should
 unbreak release builds of asan.

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

 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff

 ==
 --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
 +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58
 2016
 @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
Opts.DisableFPElim =
(Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
Opts.DisableFree = Args.hasArg(OPT_disable_free);
 +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
if (Arg *A = Args.getLastArg(OPT_meabi)) {
 @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
Opts.CudaGpuBinaryFileNames =
Args.getAllArgValues(OPT_fcuda_include_gpubinary);

 -  // DiscardValueNames is set here so that it can depend (perhaps
 temporarily)
 -  // on other options.
 -  // We check SanitizeMemoryTrackOrigins here because the backend pass
 depends
 -  // on the name of the alloca in order to print out names.
 -  Opts.DiscardValueNames =
 -  Args.hasArg(OPT_discard_value_names) &&
 !Opts.SanitizeMemoryTrackOrigins;
return Success;
  }

 @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
Res.getLangOpts()->ObjCExceptions = 1;
}
 +
 +  // FIXME: Override value name discarding when sanitizers are used
 because the
 +  // backend passes depend on the name of the alloca in order to print
 out
 +  // names.
 +  Res.getCodeGenOpts().DiscardValueNames &=
 Res.getLangOpts()->Sanitize.empty();
 +
// FIXME: ParsePreprocessorArgs uses the FileManager to read the
 contents of
// PCH file and find the original header name. Remove the need to do
 that in
// ParsePreprocessorArgs and remove the FileManager


 ___
 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
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-03-14 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

I think it's hard to write this simpler as logic is quite complicated. But we 
can definitely improve understanding with comments!

Btw, regarding tests to cover case 2, could we also add test with types in 
which CV qualifiers differ. May be just at least one. No need to test every 
possible combination.



Comment at: lib/AST/ASTContext.cpp:7613
@@ +7612,3 @@
+if (getLangOpts().OpenCL) {
+  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())

Do you think we should check the types here? I was thinking we should do the 
check exactly as below apart from AS specific part.


Comment at: lib/Sema/SemaExpr.cpp:6168
@@ -6168,3 +6167,3 @@
   QualType CompositeTy = S.Context.mergeTypes(lhptee, rhptee);
 
   if (CompositeTy.isNull()) {

Could we instead add a comment explaining different cases with AS we can have 
here i.e. 1(a-c)&2(a-c)!

And may be we could refer to each case by adding comments in code below.


Comment at: lib/Sema/SemaExpr.cpp:6175
@@ +6174,3 @@
+if (S.getLangOpts().OpenCL) {
+  // OpenCL v1.1 s6.5 - A pointer to address space A can only be assigned
+  // to a pointer to the same address space A. Casting a pointer to address

Could we write it shorter? For example: Conversion between pointers to distinct 
address spaces is disallowed...



Comment at: lib/Sema/SemaExpr.cpp:6220-6232
@@ -6186,7 +6219,15 @@
 ResultTy = S.Context.getBlockPointerType(ResultTy);
-  else
+  else {
+auto ResultAddrSpace = ResultTy.getQualifiers().getAddressSpace();
+LHSCastKind = lhQual.getAddressSpace() == ResultAddrSpace
+  ? CK_BitCast
+  : CK_AddressSpaceConversion;
+RHSCastKind = rhQual.getAddressSpace() == ResultAddrSpace
+  ? CK_BitCast
+  : CK_AddressSpaceConversion;
 ResultTy = S.Context.getPointerType(ResultTy);
+  }
 
-  LHS = S.ImpCastExprToType(LHS.get(), ResultTy, CK_BitCast);
-  RHS = S.ImpCastExprToType(RHS.get(), ResultTy, CK_BitCast);
+  LHS = S.ImpCastExprToType(LHS.get(), ResultTy, LHSCastKind);
+  RHS = S.ImpCastExprToType(RHS.get(), ResultTy, RHSCastKind);
   return ResultTy;

There are still blocks in ObjC, we shouldn't change!


Comment at: lib/Sema/SemaExpr.cpp:6222-6227
@@ -6188,1 +6221,8 @@
+auto ResultAddrSpace = ResultTy.getQualifiers().getAddressSpace();
+LHSCastKind = lhQual.getAddressSpace() == ResultAddrSpace
+  ? CK_BitCast
+  : CK_AddressSpaceConversion;
+RHSCastKind = rhQual.getAddressSpace() == ResultAddrSpace
+  ? CK_BitCast
+  : CK_AddressSpaceConversion;
 ResultTy = S.Context.getPointerType(ResultTy);

pxli168 wrote:
> What will mergetypes return?
> It seems the LHS and RHS are compatibel here, and may be they did not need 
> bitcast?
I think we always need a cast here, because types are not exactly the same at 
this point!


Comment at: lib/Sema/SemaExpr.cpp:6231
@@ -6189,3 +6230,3 @@
 
-  LHS = S.ImpCastExprToType(LHS.get(), ResultTy, CK_BitCast);
-  RHS = S.ImpCastExprToType(RHS.get(), ResultTy, CK_BitCast);
+  LHS = S.ImpCastExprToType(LHS.get(), ResultTy, LHSCastKind);
+  RHS = S.ImpCastExprToType(RHS.get(), ResultTy, RHSCastKind);

Btw, could we do the same thing with {LHS/RHS}CastKind variables in abode code. 
It looks cleaner I think.


Comment at: test/SemaOpenCL/condition-operator-cl2.0.cl:19
@@ +18,3 @@
+
+void test_conversion(global int *arg_glob, local int *arg_loc,
+ constant int *arg_const, private int *arg_priv,

May be we could rename it to test_ternary and also merge with 
test/SemaOpenCL/address-spaces-conversions-cl2.0.cl?


Comment at: test/SemaOpenCL/condition-operator-cl2.0.cl:20
@@ +19,3 @@
+void test_conversion(global int *arg_glob, local int *arg_loc,
+ constant int *arg_const, private int *arg_priv,
+ generic int *arg_gen, global char *arg_glob_ch,

Too many arguments. Could we move some into local variables instead?


Comment at: test/SemaOpenCL/condition-operator-cl2.0.cl:33
@@ +32,3 @@
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands 
of type  ('__constant int *' and '__local int *') which are pointers to 
non-overlapping address spaces}}
+#elif defined(GLOBAL)

You can combine these two errors into 1 using regex. See examples in function 
test_conversion of test/SemaOpenCL/address-spaces-conversions-cl2.0.cl


Comment at: test/SemaOpenCL/condition-operator-cl2.0.cl:57
@@ +56,3 @@
+
+  void *var_void_gen;
+  constant void*var_void_c

r263442 - [OpenMP] Replace offloading option that start with -o with -fo.

2016-03-14 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Mon Mar 14 10:57:41 2016
New Revision: 263442

URL: http://llvm.org/viewvc/llvm-project?rev=263442&view=rev
Log:
[OpenMP] Replace offloading option that start with -o with -fo.

Summary:
The current offloading implementation is using -omptargets and 
-omp-host-ir-file-path options in the frontend. This causes the user a lot of 
trouble due to to the conflicts with the -o option. E.g. if the user misspells  
omptargets he will end up with a file with a weird name.

This patches replaces these two options with  -fomptargets and 
-fomp-host-ir-file-path to avoid these issues, and it is also more consistent 
with the other options like -fopenmp.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: cfe-commits, caomhin, fraggamuffin

Differential Revision: http://reviews.llvm.org/D18112

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/OpenMP/distribute_codegen.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_codegen_global_capture.cpp
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp
cfe/trunk/test/OpenMP/target_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_messages.cpp
cfe/trunk/test/OpenMP/teams_codegen.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_private_codegen.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=263442&r1=263441&r2=263442&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Mar 14 10:57:41 2016
@@ -704,7 +704,7 @@ def fcuda_allow_variadic_functions : Fla
 
 def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
   HelpText<"Generate code only for an OpenMP target device.">;
-def omp_host_ir_file_path : Separate<["-"], "omp-host-ir-file-path">,
+def fomp_host_ir_file_path : Separate<["-"], "fomp-host-ir-file-path">,
   HelpText<"Path to the IR file produced by the frontend for the host.">;
   
 } // let Flags = [CC1Option]

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=263442&r1=263441&r2=263442&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Mar 14 10:57:41 2016
@@ -1680,7 +1680,7 @@ def nostdlib : Flag<["-"], "nostdlib">;
 def object : Flag<["-"], "object">;
 def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, 
CC1Option, CC1AsOption]>,
   HelpText<"Write output to ">, MetaVarName<"">;
-def omptargets_EQ : CommaJoined<["-"], "omptargets=">, Flags<[DriverOption, 
CC1Option]>,
+def fomptargets_EQ : CommaJoined<["-"], "fomptargets=">, Flags<[DriverOption, 
CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">;
 def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, 
Flags<[Unsupported]>;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263442&r1=263441&r2=263442&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 10:57:41 2016
@@ -1884,7 +1884,7 @@ static void ParseLangArgs(LangOptions &O
   }
 
   // Get the OpenMP target triples if any.
-  if (Arg *A = Args.getLastArg(options::OPT_omptargets_EQ)) {
+  if (Arg *A = Args.getLastArg(options::OPT_fomptargets_EQ)) {
 
 for (unsigned i = 0; i < A->getNumValues(); ++i) {
   llvm::Triple TT(A->getValue(i));
@@ -1898,7 +1898,7 @@ static void ParseLangArgs(LangOptions &O
 
   // Get OpenMP host file path if any and report if a non existent file is
   // found
-  if (Arg *A = Args.getLastArg(options::OPT_omp_host_ir_file_path)) {
+  if (Arg *A = Args.getLastArg(options::OPT_fomp_host_ir_file_path)) {
 Opts.OMPHostIRFile = A->getValue();
 if (!llvm::sys::fs::exists(Opts.OMPHostIRFile))
   Diags.Report(clang::diag::err_drv_omp_host_ir_file_not_found)

Modified: cfe/trunk/test/OpenMP/distribute_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_codegen.cpp?rev=263442&r1=263441&r2=263442&view=diff
==
--- cfe/trunk/test/OpenMP/distribute_codegen.cpp (origi

Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-14 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.



> $ du -cksh bin/clang-tidy.exe bin/clang.exe

>  21M bin/clang-tidy.exe

>  47M bin/clang.exe

>  68M total


This is a huge difference. I didn't expect dependencies to bring so much code.
I'm not a fan of having an empty statement and increasing false positives ratio.
Would it be possible to skip whole declarations with asm-stm, and flag them as 
"ignored / not parsable"?

> Also, should we do this for all Clang tools?


I would prefer a generic solution for every tools. I saw different cases where 
developers fix this issue differently.

> where the one who builds the binary knows for sure that it won't be used for 
> MS targets


We could gate this code under a define. I'm not a fan of define, but it seems 
to be a compromise for the size.

Something like: LIBTOOLING_ENABLE_INLINE_ASM_PARSER

If we decide to pursue that direction, then it should probably be for every 
tools.


http://reviews.llvm.org/D17981



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


Re: [PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-03-14 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Unless there is a compelling example of Microsoft or a popular third-party 
header relying on this behavior, I don't think we should implement it.



Comment at: lib/Parse/ParseDecl.cpp:4813
@@ -4812,1 +4812,3 @@
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||
+  (Tok.getKind() == tok::kw___unaligned)) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());

This will allow __unaligned in a variety of other locations where we shouldn't 
accept it.


http://reviews.llvm.org/D17709



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


Re: [PATCH] D18136: boost-use-to-string check

2016-03-14 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.


Comment at: clang-tidy/boost/BoostTidyModule.cpp:21
@@ -19,3 +20,3 @@
 
 class ModernizeModule : public ClangTidyModule {
 public:

This should be `BoostModule`, not `ModernizeModule`.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:24
@@ +23,3 @@
+  // returning type of className.
+  auto getMatcher = [](std::string className) {
+return callExpr(

`getMatcher` doesn't reveal the intent here; the name should reveal what is 
matched without me having to reverse engineer that information from it's 
defintiion.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:33
@@ +32,3 @@
+  Finder->addMatcher(
+  getMatcher("class std::__cxx11::basic_string").bind("to_string"),
+  this);

Why do we need to match something that is implementation specific?  This seems 
really fragile.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:40
@@ +39,3 @@
+  Finder->addMatcher(
+  getMatcher("class std::__cxx11::basic_string").bind("to_wstring"),
+  this);

Ditto


Comment at: clang-tidy/boost/UseToStringCheck.cpp:55-58
@@ +54,6 @@
+
+static const std::string toStringMSG =
+"use std::to_string instead of boost::lexical_cast";
+static const std::string toWStringMSG =
+"use std::to_wstring instead of boost::lexical_cast";
+

Why do we need variables for these strings?  They are used only once and the 
introduced variable name doesn't reveal more intent.


Comment at: docs/clang-tidy/checks/list.rst:90
@@ -88,2 +89,3 @@
modernize-use-override
+   modernize-use-using
performance-faster-string-find

Why was this added?  It seems unrelated to this changeset.


Comment at: test/clang-tidy/boost-use-to-string.cpp:4-10
@@ +3,9 @@
+
+namespace std {
+
+template  class basic_string {};
+
+using string = basic_string;
+using wstring = basic_string;
+}
+

Isn't there an existing stub header file providing std::{w,}string?


Comment at: test/clang-tidy/boost-use-to-string.cpp:76-81
@@ +75,8 @@
+// CHECK-FIXES: fun(std::to_string(f));
+  fun(boost::lexical_cast(g));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string instead of 
boost::lexical_cast [boost-use-to-string]
+// CHECK-FIXES: fun(std::to_string(g));
+  fun(boost::lexical_cast(h));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string instead of 
boost::lexical_cast [boost-use-to-string]
+// CHECK-FIXES: fun(std::to_string(h));
+  fun(boost::lexical_cast(i));

Do we know that the semantics are the same for floating-point types?


http://reviews.llvm.org/D18136



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


Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread David Blaikie via cfe-commits
On Mon, Mar 14, 2016 at 8:55 AM, Evgenii Stepanov 
wrote:

> On Mon, Mar 14, 2016 at 8:48 AM, Benjamin Kramer 
> wrote:
> > On Mon, Mar 14, 2016 at 3:59 PM, David Blaikie 
> wrote:
> >> Yeah - how are they relying on them in a non-asserts build anyway?
> (were we
> >> naming certain things regardless of +/-Asserts? (well, I know we were
> naming
> >> some things, but mostly down in LLVM, I thought Clang generally used the
> >> IRBuilder & thus didn't name things in non-Asserts builds))
> >
> > Allocas used to always have names as a debugging feature, see r246991.
> >
> >> On Mon, Mar 14, 2016 at 6:36 AM, Chandler Carruth via cfe-commits
> >>  wrote:
> >>>
> >>> A long time ago I argued that the sanitizers should be using debug info
> >>> instead of alloca names for this, and I really thought that they had
> >>> implemented this... Is that not the case?
> >>>
> >>> It is really bad that the sanitizers are relying on this stuff...
>
> We've never implemented this though I think Alexey looked into it at
> one point. We'd need to refactor the handling of debug options
> (-g/-gline-tables-only) so that debug metadata is emitted with ASan
> even without -g and then discarded in the backend.
>

We have some precedent for this with the optimizer remark functionality, if
I recall correctly. Might work for non-gmlt-like stuff too.


>
> >>>
> >>> On Mon, Mar 14, 2016 at 2:28 PM Benjamin Kramer via cfe-commits
> >>>  wrote:
> 
>  Author: d0k
>  Date: Mon Mar 14 08:23:58 2016
>  New Revision: 263429
> 
>  URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
>  Log:
>  [Frontend] Disable value name discarding for all sanitizers.
> 
>  ASan also relies on names on allocas and will emit unhelpful output if
>  they're not present. Just force-enable value names for now. Should
>  unbreak release builds of asan.
> 
>  Modified:
>  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> 
>  Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>  URL:
> 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff
> 
> 
> ==
>  --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>  +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58
>  2016
>  @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
> Opts.DisableFPElim =
> (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
> Opts.DisableFree = Args.hasArg(OPT_disable_free);
>  +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
> Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
> Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
> if (Arg *A = Args.getLastArg(OPT_meabi)) {
>  @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
> Opts.CudaGpuBinaryFileNames =
> Args.getAllArgValues(OPT_fcuda_include_gpubinary);
> 
>  -  // DiscardValueNames is set here so that it can depend (perhaps
>  temporarily)
>  -  // on other options.
>  -  // We check SanitizeMemoryTrackOrigins here because the backend
> pass
>  depends
>  -  // on the name of the alloca in order to print out names.
>  -  Opts.DiscardValueNames =
>  -  Args.hasArg(OPT_discard_value_names) &&
>  !Opts.SanitizeMemoryTrackOrigins;
> return Success;
>   }
> 
>  @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
>   if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
> Res.getLangOpts()->ObjCExceptions = 1;
> }
>  +
>  +  // FIXME: Override value name discarding when sanitizers are used
>  because the
>  +  // backend passes depend on the name of the alloca in order to
> print
>  out
>  +  // names.
>  +  Res.getCodeGenOpts().DiscardValueNames &=
>  Res.getLangOpts()->Sanitize.empty();
>  +
> // FIXME: ParsePreprocessorArgs uses the FileManager to read the
>  contents of
> // PCH file and find the original header name. Remove the need to
> do
>  that in
> // ParsePreprocessorArgs and remove the FileManager
> 
> 
>  ___
>  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
> >>>
> >>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-14 Thread Richard Smith via cfe-commits
On 14 Mar 2016 6:28 a.m., "Benjamin Kramer via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>
> Author: d0k
> Date: Mon Mar 14 08:23:58 2016
> New Revision: 263429
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263429&view=rev
> Log:
> [Frontend] Disable value name discarding for all sanitizers.
>
> ASan also relies on names on allocas and will emit unhelpful output if
> they're not present. Just force-enable value names for now. Should
> unbreak release builds of asan.
>
> Modified:
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429&r1=263428&r2=263429&view=diff
>
==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58 2016
> @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
>Opts.DisableFPElim =
>(Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
>Opts.DisableFree = Args.hasArg(OPT_disable_free);
> +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
>Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
>Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
>if (Arg *A = Args.getLastArg(OPT_meabi)) {
> @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
>Opts.CudaGpuBinaryFileNames =
>Args.getAllArgValues(OPT_fcuda_include_gpubinary);
>
> -  // DiscardValueNames is set here so that it can depend (perhaps
temporarily)
> -  // on other options.
> -  // We check SanitizeMemoryTrackOrigins here because the backend pass
depends
> -  // on the name of the alloca in order to print out names.
> -  Opts.DiscardValueNames =
> -  Args.hasArg(OPT_discard_value_names) &&
!Opts.SanitizeMemoryTrackOrigins;
>return Success;
>  }
>
> @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
>  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
>Res.getLangOpts()->ObjCExceptions = 1;
>}
> +
> +  // FIXME: Override value name discarding when sanitizers are used
because the
> +  // backend passes depend on the name of the alloca in order to print
out
> +  // names.
> +  Res.getCodeGenOpts().DiscardValueNames &=
Res.getLangOpts()->Sanitize.empty();

This should not be applied to all sanitizers. UBSan checks have no need of
this (there is no backend pass).

>// FIXME: ParsePreprocessorArgs uses the FileManager to read the
contents of
>// PCH file and find the original header name. Remove the need to do
that in
>// ParsePreprocessorArgs and remove the FileManager
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 50611.
hintonda added a comment.

Add move ctor and assignment operator defauls to match
UnresolvedSetImpl's contained SmallVector.

Add FIXME note to LookupResult.  Will address FIXME once Marina's
pending change to Sema::LookupInlineAsmField() is available.


http://reviews.llvm.org/D18123

Files:
  include/clang/AST/UnresolvedSet.h
  include/clang/Sema/Lookup.h

Index: include/clang/Sema/Lookup.h
===
--- include/clang/Sema/Lookup.h
+++ include/clang/Sema/Lookup.h
@@ -185,6 +185,11 @@
   Shadowed(false)
   {}
 
+  // FIXME: Change these to delete once Sema::LookupInlineAsmField is fixed to
+  // not use them.
+  LookupResult(const LookupResult &) = default;
+  LookupResult & operator=(const LookupResult &) = default;
+
   ~LookupResult() {
 if (Diagnose) diagnose();
 if (Paths) deletePaths(Paths);
Index: include/clang/AST/UnresolvedSet.h
===
--- include/clang/AST/UnresolvedSet.h
+++ include/clang/AST/UnresolvedSet.h
@@ -59,8 +59,11 @@
   // UnresolvedSet.
 private:
   template  friend class UnresolvedSet;
-  UnresolvedSetImpl() {}
-  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
+  UnresolvedSetImpl() = default;
+  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
+  UnresolvedSetImpl& operator=(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl& operator=(UnresolvedSetImpl &&) = default;
 
 public:
   // We don't currently support assignment through this iterator, so we might


Index: include/clang/Sema/Lookup.h
===
--- include/clang/Sema/Lookup.h
+++ include/clang/Sema/Lookup.h
@@ -185,6 +185,11 @@
   Shadowed(false)
   {}
 
+  // FIXME: Change these to delete once Sema::LookupInlineAsmField is fixed to
+  // not use them.
+  LookupResult(const LookupResult &) = default;
+  LookupResult & operator=(const LookupResult &) = default;
+
   ~LookupResult() {
 if (Diagnose) diagnose();
 if (Paths) deletePaths(Paths);
Index: include/clang/AST/UnresolvedSet.h
===
--- include/clang/AST/UnresolvedSet.h
+++ include/clang/AST/UnresolvedSet.h
@@ -59,8 +59,11 @@
   // UnresolvedSet.
 private:
   template  friend class UnresolvedSet;
-  UnresolvedSetImpl() {}
-  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
+  UnresolvedSetImpl() = default;
+  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
+  UnresolvedSetImpl& operator=(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl& operator=(UnresolvedSetImpl &&) = default;
 
 public:
   // We don't currently support assignment through this iterator, so we might
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Aside from the missing attribute documentation, looks good to me.


http://reviews.llvm.org/D17865



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Thanks for your comments.

It works like this, e.g.

$ cat prog.ll
declare i32 @foo()

define void @use_foo() {

  %a = call i32 @foo()
  ret void

}

$ cat lib_common.ll
define linkonce_odr i32 @foo() {

  ret i32 1;

}

$ cat lib_opt.ll
define linkonce_odr i32 @foo() {

  ret i32 2;

}

$ llvm-link prog.ll lib_common.ll -override lib_opt.ll -S
; ModuleID = 'llvm-link'

define void @use_foo() {

  %a = call i32 @foo()
  ret void

}

define linkonce_odr i32 @foo() {

  ret i32 2

}

We can put all common functions in lib_common.ll, then only put a subset in 
lib_opt.ll. Functions in lib_opt.ll will override functions in lib_common.ll. 
For different GPUs we provide different lib_opt.ll. Each GPU may override 
different subset of lib_common.ll.

We use __attribute__((linkonce_odr_linkage)) by following the precedence of 
__attribute__((internal_linkage)) which exposes the LLVM internal_linkage to 
C/C++ programmers. We would like to accept suggestions for a better way to 
expose the linkonce_odr linkage.


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-14 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D18025



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


r263449 - [modules] Don't diagnose non-modular includes from modular files that are

2016-03-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar 14 12:52:37 2016
New Revision: 263449

URL: http://llvm.org/viewvc/llvm-project?rev=263449&view=rev
Log:
[modules] Don't diagnose non-modular includes from modular files that are
implementation units of modules rather than interface units.

Added:
cfe/trunk/test/Modules/Inputs/non-module.h
cfe/trunk/test/Modules/include-own-headers.m
Modified:
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=263449&r1=263448&r2=263449&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Mon Mar 14 12:52:37 2016
@@ -313,12 +313,18 @@ public:
   ///
   /// \param RequestingModule The module including a file.
   ///
+  /// \param RequestingModuleIsModuleInterface \c true if the inclusion is in
+  ///the interface of RequestingModule, \c false if it's in the
+  ///implementation of RequestingModule. Value is ignored and
+  ///meaningless if RequestingModule is nullptr.
+  ///
   /// \param FilenameLoc The location of the inclusion's filename.
   ///
   /// \param Filename The included filename as written.
   ///
   /// \param File The included file.
   void diagnoseHeaderInclusion(Module *RequestingModule,
+   bool RequestingModuleIsModuleInterface,
SourceLocation FilenameLoc, StringRef Filename,
const FileEntry *File);
 

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=263449&r1=263448&r2=263449&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon Mar 14 12:52:37 2016
@@ -239,6 +239,7 @@ static Module *getTopLevelOrNull(Module
 }
 
 void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
+bool RequestingModuleIsModuleInterface,
 SourceLocation FilenameLoc,
 StringRef Filename,
 const FileEntry *File) {
@@ -301,7 +302,7 @@ void ModuleMap::diagnoseHeaderInclusion(
   if (LangOpts.ModulesStrictDeclUse) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
 << RequestingModule->getFullModuleName() << Filename;
-  } else if (RequestingModule) {
+  } else if (RequestingModule && RequestingModuleIsModuleInterface) {
 diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
 diag::warn_non_modular_include_in_framework_module :
 diag::warn_non_modular_include_in_module;

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=263449&r1=263448&r2=263449&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Mar 14 12:52:37 2016
@@ -609,6 +609,7 @@ const FileEntry *Preprocessor::LookupFil
 ModuleMap::KnownHeader *SuggestedModule,
 bool SkipCache) {
   Module *RequestingModule = getModuleForLocation(FilenameLoc); 
+  bool RequestingModuleIsModuleInterface = 
!SourceMgr.isInMainFile(FilenameLoc);
 
   // If the header lookup mechanism may be relative to the current inclusion
   // stack, record the parent #includes.
@@ -683,7 +684,8 @@ const FileEntry *Preprocessor::LookupFil
   if (FE) {
 if (SuggestedModule && !LangOpts.AsmPreprocessor)
   HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
-  RequestingModule, FilenameLoc, Filename, FE);
+  RequestingModule, RequestingModuleIsModuleInterface, FilenameLoc,
+  Filename, FE);
 return FE;
   }
 
@@ -699,7 +701,8 @@ const FileEntry *Preprocessor::LookupFil
 SuggestedModule))) {
 if (SuggestedModule && !LangOpts.AsmPreprocessor)
   HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
-  RequestingModule, FilenameLoc, Filename, FE);
+  RequestingModule, RequestingModuleIsModuleInterface, FilenameLoc,
+  Filename, FE);
 return FE;
   }
 }
@@ -714,7 +717,8 @@ const FileEntry *Preprocessor::LookupFil
 RequestingModule, SuggestedModule))) {
   if (SuggestedModule && !LangOpts.AsmPreprocessor)
 HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
-RequestingModule, FilenameLoc, Filename, FE);
+RequestingModule, RequestingModuleIsModuleInterface,
+FilenameLoc, Filen

Re: r261372 - [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a single

2016-03-14 Thread Richard Smith via cfe-commits
Sorry for the delay, the past couple of weeks have been crazy with C++
committee stuff. Should be fixed in r263449.

On Mon, Mar 14, 2016 at 8:00 AM, Argyrios Kyrtzidis via cfe-commits
 wrote:
> If not addressing the issue with '-fmodule-name' could you revert removal of
> original ‘-fmodule-implementation-of’ since we are depending on it ?
>
> On Mar 3, 2016, at 6:13 PM, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>
> Hey Richard,
>
> -fmodule-name emits bogus warnings about “include of non-modular header
> inside framework module”, while trying to include a header in the
> implementation file.
> This is not new behavior but we noticed it now that we tried to use it as
> replacement of -fmodule-implementation-of.
>
> Could you take a look ? The test case is attached. Unzip and run:
>
> $ clang -fsyntax-only /tmp/test-frame/boo.m -fmodules
> -fmodules-cache-path=/tmp/mcp -F /tmp/test-frame -fmodule-name=boo
> -Werror=non-modular-include-in-framework-module
> /tmp/test-frame/boo.m:2:9: error: include of non-modular header inside
> framework module 'boo' [-Werror,-Wnon-modular-include-in-framework-module]
> #import "blah.h"
> ^
> 1 error generated.
>
> 
>
> On Mar 3, 2016, at 5:28 AM, Richard Smith via cfe-commits
>  wrote:
>
> On 3 Mar 2016 3:18 a.m., "Argyrios Kyrtzidis via cfe-commits"
>  wrote:
>>
>> Mind if we keep -fmodule-implementation-of as an alias so that we can
>> gradually transition to -fmodule-name ?
>
> Sure, no problem.
>
>> > On Feb 19, 2016, at 2:25 PM, Richard Smith via cfe-commits
>> >  wrote:
>> >
>> > Author: rsmith
>> > Date: Fri Feb 19 16:25:36 2016
>> > New Revision: 261372
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=261372&view=rev
>> > Log:
>> > [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a
>> > single
>> > option. Previously these options could both be used to specify that you
>> > were
>> > compiling the implementation file of a module, with a different set of
>> > minor
>> > bugs in each case.
>> >
>> > This change removes -fmodule-implementation-of, and instead tracks a
>> > flag to
>> > determine whether we're currently building a module. -fmodule-name now
>> > behaves
>> > the same way that -fmodule-implementation-of previously did.
>> >
>> > Modified:
>> >cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>> >cfe/trunk/include/clang/Basic/LangOptions.def
>> >cfe/trunk/include/clang/Basic/LangOptions.h
>> >cfe/trunk/include/clang/Driver/CC1Options.td
>> >cfe/trunk/include/clang/Driver/Options.td
>> >cfe/trunk/include/clang/Lex/ModuleMap.h
>> >cfe/trunk/lib/Basic/LangOptions.cpp
>> >cfe/trunk/lib/Driver/Tools.cpp
>> >cfe/trunk/lib/Frontend/ASTUnit.cpp
>> >cfe/trunk/lib/Frontend/CompilerInstance.cpp
>> >cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> >cfe/trunk/lib/Frontend/FrontendActions.cpp
>> >cfe/trunk/lib/Lex/ModuleMap.cpp
>> >cfe/trunk/lib/Lex/PPDirectives.cpp
>> >cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> >cfe/trunk/lib/Lex/Preprocessor.cpp
>> >cfe/trunk/lib/Sema/SemaDecl.cpp
>> >cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> >cfe/trunk/test/Modules/Inputs/explicit-build/a.h
>> >cfe/trunk/test/Modules/explicit-build.cpp
>> >cfe/trunk/test/Modules/implementation-of-module.m
>> >cfe/trunk/test/Modules/import-self.m
>> >
>> > Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=261372&r1=261371&r2=261372&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
>> > +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Feb 19
>> > 16:25:36 2016
>> > @@ -210,10 +210,6 @@ def err_test_module_file_extension_versi
>> >   "test module file extension '%0' has different version (%1.%2) than
>> > expected "
>> >   "(%3.%4)">;
>> >
>> > -def err_conflicting_module_names : Error<
>> > -  "conflicting module names specified: '-fmodule-name=%0' and "
>> > -  "'-fmodule-implementation-of %1'">;
>> > -
>> > def err_missing_vfs_overlay_file : Error<
>> >   "virtual filesystem overlay file '%0' not found">, DefaultFatal;
>> > def err_invalid_vfs_overlay : Error<
>> >
>> > Modified: cfe/trunk/include/clang/Basic/LangOptions.def
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=261372&r1=261371&r2=261372&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
>> > +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Feb 19 16:25:36
>> > 2016
>> > @@ -127,6 +127,7 @@ BENIGN_LANGOPT(EmitAllDecls  , 1, 0,
>> > LANGOPT(MathErrno , 1, 1, "errno support for math functions")
>> > BENIGN_LANGOPT(HeinousExtensions , 1, 0, "Extensions that we really

Re: [PATCH] D18136: boost-use-to-string check

2016-03-14 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

There is also big issue here - I don't check if the type of argument is 
builtinType. I don't know why but matcher "builtinType" didn't work when I 
tried to use it. (like I wrote in another email)



Comment at: clang-tidy/boost/UseToStringCheck.cpp:33
@@ +32,3 @@
+  Finder->addMatcher(
+  getMatcher("class std::__cxx11::basic_string").bind("to_string"),
+  this);

LegalizeAdulthood wrote:
> Why do we need to match something that is implementation specific?  This 
> seems really fragile.
Yes it is, but the problem here is that I can't find better solution:
For example better solution would be to use 
CXXRecordDecl(hasName("std::basic_string")), because it looks through 
namespaces, and it doesn't care where std::string was defined. The problem is 
that I don't know if I can move easly from QualType to CXXRecordDecl - at least 
I coudn't find it in docs.




Comment at: docs/clang-tidy/checks/list.rst:90
@@ -88,2 +89,3 @@
modernize-use-override
+   modernize-use-using
performance-faster-string-find

LegalizeAdulthood wrote:
> Why was this added?  It seems unrelated to this changeset.
Yep, I was making to check in the same time. I will split it.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D18136: boost-use-to-string check

2016-03-14 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: test/clang-tidy/boost-use-to-string.cpp:76-81
@@ +75,8 @@
+// CHECK-FIXES: fun(std::to_string(f));
+  fun(boost::lexical_cast(g));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string instead of 
boost::lexical_cast [boost-use-to-string]
+// CHECK-FIXES: fun(std::to_string(g));
+  fun(boost::lexical_cast(h));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string instead of 
boost::lexical_cast [boost-use-to-string]
+// CHECK-FIXES: fun(std::to_string(h));
+  fun(boost::lexical_cast(i));

LegalizeAdulthood wrote:
> Do we know that the semantics are the same for floating-point types?
I will check it.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-03-14 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:217-218
@@ -216,2 +216,4 @@
   raw_ostream &Out;
+  bool NullOut = false;
+  bool DisableDerivedAbiTags = false;
 

Please add a comment describe this state.


Comment at: lib/AST/ItaniumMangle.cpp:329
@@ +328,3 @@
+
+bool LinkActive{ false };
+

Please use = instead of list initialization.


Comment at: lib/AST/ItaniumMangle.cpp:332
@@ +331,3 @@
+  public:
+explicit AbiTagState(AbiTagState *&linkHead) : LinkHead(linkHead) {
+  Parent = LinkHead;

Variables start with an uppercase letter.


Comment at: lib/AST/ItaniumMangle.cpp:339-340
@@ +338,4 @@
+// no copy, no move
+AbiTagState(AbiTagState const &) = delete;
+AbiTagState &operator=(AbiTagState const &) = delete;
+

const typically goes before the type.


Comment at: lib/AST/ItaniumMangle.cpp:363
@@ +362,3 @@
+
+  if (dyn_cast(ND) || dyn_cast(ND)) {
+// assert(AdditionalAbiTags && "function and variables need a list of

Don't use dyn_cast if you aren't going to use the value, use isa instead.


Comment at: lib/AST/ItaniumMangle.cpp:364-365
@@ +363,4 @@
+  if (dyn_cast(ND) || dyn_cast(ND)) {
+// assert(AdditionalAbiTags && "function and variables need a list of
+// additional abi tags");
+  } else {

commented out code?


Comment at: lib/AST/ItaniumMangle.cpp:394
@@ +393,3 @@
+  if (std::find(TagList.begin(), TagList.end(), Tag) == TagList.end()) 
{
+// don't insert duplicates
+TagList.push_back(Tag);

Sentences in LLVM comments start with a capital letter and end with a period.


Comment at: lib/AST/ItaniumMangle.cpp:427
@@ +426,3 @@
+  AbiTagState *AbiTags = nullptr;
+  AbiTagState AbiTagsRoot{ AbiTags };
+

Is this clang-format'd?


Comment at: lib/AST/ItaniumMangle.cpp:670-671
@@ +669,4 @@
+  const AbiTagList *AdditionalAbiTags) {
+  assert(AbiTags && "require AbiTagState");
+  if (AbiTags)
+AbiTags->write(Out, ND,

Why do you have an assert and check for that the pointer is not null?


Comment at: lib/AST/ItaniumMangle.cpp:824
@@ +823,3 @@
+  if (!ExcludeUnqualifiedName) {
+if (const VarDecl *VD = dyn_cast(ND)) {
+  AbiTagList VariableAdditionalAbiTags = makeAdditionalTagsForVariable(VD);

Use `const auto *` if the type is obvious from the RHS.


Comment at: lib/AST/ItaniumMangle.cpp:1447
@@ +1446,3 @@
+  {
+AbiTagState localAbiTags(AbiTags);
+

Variables start with an upper case letter.


Comment at: lib/AST/ItaniumMangle.cpp:4641-4642
@@ -4218,2 +4640,4 @@
   CXXNameMangler Mangler(*this, Out);
+  // GCC 5.3.0 doesn't emit derived abi tags for but that seems to be a bug
+  // that is fixed in trunk.
   Mangler.getStream() << "_ZGV";

I think a noun is missing between "for" and "but".


http://reviews.llvm.org/D18035



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


[libcxx] r263450 - Implement LWG#2566: Requirements on the first template parameter of container adaptors

2016-03-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Mar 14 12:58:11 2016
New Revision: 263450

URL: http://llvm.org/viewvc/llvm-project?rev=263450&view=rev
Log:
Implement LWG#2566: Requirements on the first template parameter of container 
adaptors

Modified:
libcxx/trunk/include/queue
libcxx/trunk/include/stack

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/queue
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/queue?rev=263450&r1=263449&r2=263450&view=diff
==
--- libcxx/trunk/include/queue (original)
+++ libcxx/trunk/include/queue Mon Mar 14 12:58:11 2016
@@ -198,6 +198,7 @@ public:
 typedef typename container_type::reference   reference;
 typedef typename container_type::const_reference const_reference;
 typedef typename container_type::size_type   size_type;
+static_assert((is_same<_Tp, value_type>::value), "" );
 
 protected:
 container_type c;
@@ -392,6 +393,7 @@ public:
 typedef typename container_type::reference   reference;
 typedef typename container_type::const_reference const_reference;
 typedef typename container_type::size_type   size_type;
+static_assert((is_same<_Tp, value_type>::value), "" );
 
 protected:
 container_type c;

Modified: libcxx/trunk/include/stack
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stack?rev=263450&r1=263449&r2=263450&view=diff
==
--- libcxx/trunk/include/stack (original)
+++ libcxx/trunk/include/stack Mon Mar 14 12:58:11 2016
@@ -112,7 +112,8 @@ public:
 typedef typename container_type::reference   reference;
 typedef typename container_type::const_reference const_reference;
 typedef typename container_type::size_type   size_type;
-
+static_assert((is_same<_Tp, value_type>::value), "" );
+
 protected:
 container_type c;
 

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.pass.cpp?rev=263450&r1=263449&r2=263450&view=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.pass.cpp
 Mon Mar 14 12:58:11 2016
@@ -48,13 +48,13 @@ struct C
 
 int main()
 {
-static_assert((std::is_same::container_type, 
std::vector >::value), "");
-static_assert((std::is_same 
>::container_type, std::deque >::value), "");
-static_assert((std::is_same 
>::value_type, int>::value), "");
-static_assert((std::is_same::reference, 
std::vector::reference>::value), "");
-static_assert((std::is_same::const_reference, 
std::vector::const_reference>::value), "");
-static_assert((std::is_same::size_type, 
std::vector::size_type>::value), "");
-static_assert((std::uses_allocator, 
std::allocator >::value), "");
+static_assert(( std::is_same::container_type, 
std::vector >::value), "");
+static_assert(( std::is_same 
>::container_type, std::deque >::value), "");
+static_assert(( std::is_same 
>::value_type, int>::value), "");
+static_assert(( std::is_same::reference, 
std::vector::reference>::value), "");
+static_assert(( std::is_same::const_reference, 
std::vector::const_reference>::value), "");
+static_assert(( std::is_same::size_type, 
std::vector::size_type>::value), "");
+static_assert(( std::uses_allocator, 
std::allocator >::value), "");
 static_assert((!std::uses_allocator, 
std::allocator >::value), "");
 test t;
 }

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp?rev=263450&r1=263449&r2=263450&view=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
 Mon Mar 14 12:58:11 2016
@@ -46,13 +46,13 @@ struct C
 
 int main()
 {
-static_assert((std::is_same::container_type, 
std::deque >::value), "");
-static_assert((std::is_same 
>::container_type, std::vector >::value), "");
-static_assert((std::is_same 
>::value_type, int>::value), "");
-static_assert((std::is_same::reference, 
std::deque::reference>::value), "");
-static_assert((std::is

[libcxx] r263451 - Add failing tests that I forgot to add to the last commit

2016-03-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Mar 14 12:58:54 2016
New Revision: 263451

URL: http://llvm.org/viewvc/llvm-project?rev=263451&view=rev
Log:
Add failing tests that I forgot to add to the last commit

Added:

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.fail.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp

Added: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.fail.cpp?rev=263451&view=auto
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/types.fail.cpp
 Mon Mar 14 12:58:54 2016
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template ,
+//   class Compare = less>
+// class priority_queue
+// {
+// public:
+// typedef Containercontainer_type;
+// typedef typename container_type::value_type  value_type;
+// typedef typename container_type::reference   reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type   size_type;
+//
+// protected:
+// container_type c;
+// Compare comp;
+
+#include 
+#include 
+#include 
+
+int main()
+{
+//  LWG#2566 says that the first template param must match the second one's 
value type
+   std::priority_queue> t;
+}

Added: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp?rev=263451&view=auto
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp
 Mon Mar 14 12:58:54 2016
@@ -0,0 +1,20 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+#include 
+#include 
+#include 
+
+int main()
+{
+//  LWG#2566 says that the first template param must match the second one's 
value type
+   std::queue> t;
+}

Added: 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp?rev=263451&view=auto
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp
 Mon Mar 14 12:58:54 2016
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template ,
+//   class Compare = less>
+// class priority_queue
+// {
+// public:
+// typedef Containercontainer_type;
+// typedef typename container_type::value_type  value_type;
+// typedef typename container_type::reference   reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type   size_type;
+//
+// protected:
+// container_type c;
+// Compare comp;
+
+#include 
+#include 
+#include 
+
+int main()
+{
+//  LWG#2566 says that the first template param must match the second one's 
value type
+   std::stack> t;
+}


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


Re: [libcxx] r263036 - Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)

2016-03-14 Thread Marshall Clow via cfe-commits
On Fri, Mar 11, 2016 at 7:32 AM, Nico Weber  wrote:

> I reverted this in 263246 for now. I think the right fix is just to
> add _LIBCPP_INLINE_VISIBILITY to the new constructor, but I'm not 100% sure.
>
> On Thu, Mar 10, 2016 at 10:21 AM, Nico Weber  wrote:
>
>> I think this is ABI-breaking. On OS X, new libc++ headers must work with
>> old system libc++.dylibs. When I build in this setup with this change, I get
>>
>> Undefined symbols for architecture x86_64:
>>   "std::__1::basic_string,
>> std::__1::allocator >::basic_string(std::__1::basic_string> std::__1::char_traits, std::__1::allocator > const&, unsigned
>> long, std::__1::allocator const&)", referenced from:
>>
>> The new function probably needs that always_inline treatment that many
>> other functions have?
>>
>
Thanks

I'll re-submit with the inline stuff after this week.

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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread Richard Smith via cfe-commits
On Mon, Mar 14, 2016 at 10:45 AM, Yaxun Liu via cfe-commits
 wrote:
> yaxunl added a comment.
>
> Thanks for your comments.
>
> It works like this, e.g.
>
> $ cat prog.ll
> declare i32 @foo()
>
> define void @use_foo() {
>
>   %a = call i32 @foo()
>   ret void
>
> }
>
> $ cat lib_common.ll
> define linkonce_odr i32 @foo() {
>
>   ret i32 1;
>
> }
>
> $ cat lib_opt.ll
> define linkonce_odr i32 @foo() {
>
>   ret i32 2;
>
> }
>
> $ llvm-link prog.ll lib_common.ll -override lib_opt.ll -S
> ; ModuleID = 'llvm-link'
>
> define void @use_foo() {
>
>   %a = call i32 @foo()
>   ret void
>
> }
>
> define linkonce_odr i32 @foo() {
>
>   ret i32 2
>
> }
>
> We can put all common functions in lib_common.ll, then only put a subset in 
> lib_opt.ll. Functions in lib_opt.ll will override functions in lib_common.ll. 
> For different GPUs we provide different lib_opt.ll. Each GPU may override 
> different subset of lib_common.ll.
>
> We use __attribute__((linkonce_odr_linkage)) by following the precedence of 
> __attribute__((internal_linkage)) which exposes the LLVM internal_linkage to 
> C/C++ programmers. We would like to accept suggestions for a better way to 
> expose the linkonce_odr linkage.

The above is not an appropriate use for linkonce_odr linkage, because
the different definitions do not have the same semantics. It sounds
like you just want a weak symbol, which you can already get with
__attribute__((weak)).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread John McCall via cfe-commits
rjmccall added a comment.

Your use case violates the "ODR" restriction on linkonce_odr.

Do you maybe just want __attribute__((weak))?


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


Re: [PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types

2016-03-14 Thread Erik Pilkington via cfe-commits
erik.pilkington updated this revision to Diff 50617.
erik.pilkington added a comment.

Fix the ill-generated diff. Would someone mind taking a look at this?


http://reviews.llvm.org/D17451

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/conditional-expr.cpp

Index: test/SemaCXX/conditional-expr.cpp
===
--- test/SemaCXX/conditional-expr.cpp
+++ test/SemaCXX/conditional-expr.cpp
@@ -384,3 +384,12 @@
 int &test() { return b_ ? i_ : throw 1; }
   };
 }
+
+namespace PR26448 {
+struct Base {};
+struct Derived : Base {};
+Base b;
+Derived d;
+typedef decltype(true ? static_cast(b) : static_cast(d)) x;
+typedef Base &&x;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4672,7 +4672,7 @@
   return Result;
 }
 
-/// \brief Try to convert a type to another according to C++0x 5.16p3.
+/// \brief Try to convert a type to another according to C++11 5.16p3.
 ///
 /// This is part of the parameter validation for the ? operator. If either
 /// value operand is a class type, the two operands are attempted to be
@@ -4688,17 +4688,21 @@
 
   InitializationKind Kind = InitializationKind::CreateCopy(To->getLocStart(),
SourceLocation());
-  // C++0x 5.16p3
+  // C++11 5.16p3
   //   The process for determining whether an operand expression E1 of type T1
   //   can be converted to match an operand expression E2 of type T2 is defined
   //   as follows:
-  //   -- If E2 is an lvalue:
-  bool ToIsLvalue = To->isLValue();
-  if (ToIsLvalue) {
-//   E1 can be converted to match E2 if E1 can be implicitly converted to
-//   type "lvalue reference to T2", subject to the constraint that in the
-//   conversion the reference must bind directly to E1.
-QualType T = Self.Context.getLValueReferenceType(ToType);
+  //   -- If E2 is an lvalue: E1 can be converted to match E2 if E1 can be
+  //  implicitly converted to type "lvalue reference to T2", subject to the
+  //  constraint that in the conversion the reference must bind directly to
+  //  E1.
+  //   -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be
+  //  implicitly conveted to the type "rvalue reference to R2", subject to
+  //  the constraint that the reference must bind directly.
+  if (To->isLValue() || To->isXValue()) {
+QualType T = To->isLValue() ? Self.Context.getLValueReferenceType(ToType)
+: Self.Context.getRValueReferenceType(ToType);
+
 InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
 
 InitializationSequence InitSeq(Self, Entity, Kind, From);


Index: test/SemaCXX/conditional-expr.cpp
===
--- test/SemaCXX/conditional-expr.cpp
+++ test/SemaCXX/conditional-expr.cpp
@@ -384,3 +384,12 @@
 int &test() { return b_ ? i_ : throw 1; }
   };
 }
+
+namespace PR26448 {
+struct Base {};
+struct Derived : Base {};
+Base b;
+Derived d;
+typedef decltype(true ? static_cast(b) : static_cast(d)) x;
+typedef Base &&x;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4672,7 +4672,7 @@
   return Result;
 }
 
-/// \brief Try to convert a type to another according to C++0x 5.16p3.
+/// \brief Try to convert a type to another according to C++11 5.16p3.
 ///
 /// This is part of the parameter validation for the ? operator. If either
 /// value operand is a class type, the two operands are attempted to be
@@ -4688,17 +4688,21 @@
 
   InitializationKind Kind = InitializationKind::CreateCopy(To->getLocStart(),
SourceLocation());
-  // C++0x 5.16p3
+  // C++11 5.16p3
   //   The process for determining whether an operand expression E1 of type T1
   //   can be converted to match an operand expression E2 of type T2 is defined
   //   as follows:
-  //   -- If E2 is an lvalue:
-  bool ToIsLvalue = To->isLValue();
-  if (ToIsLvalue) {
-//   E1 can be converted to match E2 if E1 can be implicitly converted to
-//   type "lvalue reference to T2", subject to the constraint that in the
-//   conversion the reference must bind directly to E1.
-QualType T = Self.Context.getLValueReferenceType(ToType);
+  //   -- If E2 is an lvalue: E1 can be converted to match E2 if E1 can be
+  //  implicitly converted to type "lvalue reference to T2", subject to the
+  //  constraint that in the conversion the reference must bind directly to
+  //  E1.
+  //   -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be
+  //  implicitly conveted to the type "rvalue reference to R2", subject to
+  //  the constraint that the reference must bind directly.
+  if (To->isLValue() || To

Re: [PATCH] D18071: CodeGen: Mark functions used in vtables as unnamed_addr.

2016-03-14 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

In http://reviews.llvm.org/D18071#373687, @pcc wrote:

> Done (this also affects `_purecall` in the MS ABI; I don't think this change 
> should break anything there, but someone working on that might want to 
> comment). Since this patch is now specific to virtual tables anyway, I've 
> incorporated another relevant change, which is to mark virtual function 
> declarations as `unnamed_addr`.


That shouldn't matter. Virtual member functions are wrapped with a thunk, so 
comparisons won't actually involve pointers to __purecall.


http://reviews.llvm.org/D18071



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

My last example is not proper. In real cases, the functions are overridden by 
functions with the same name and semantics but optimized for speed.

Besides, we want unused library functions in lib_common.ll and lib_opt.ll to be 
dropped, weak attribute does not achieve that.


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-14 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

In http://reviews.llvm.org/D17741#372098, @weimingz wrote:

> rebased


ping~


http://reviews.llvm.org/D17741



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


Re: [PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-03-14 Thread Faisal Vali via cfe-commits
faisalv updated this revision to Diff 50621.
faisalv added a comment.

Add warnings and extension diagnostics for C++1z, and refactor the codegen 
portion, simplifying it further.
Thanks!


http://reviews.llvm.org/D18139

Files:
  include/clang/AST/LambdaCapture.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/Lambda.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/ExprCXX.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenCXX/cxx1z-lambda-star-this.cpp
  test/SemaCXX/cxx1z-lambda-star-this.cpp

Index: test/SemaCXX/cxx1z-lambda-star-this.cpp
===
--- /dev/null
+++ test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -emit-llvm-only %s
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING
+
+
+namespace test_star_this {
+namespace ns1 {
+class A {
+  int x = 345;
+  auto foo() {
+(void) [*this, this] { };  //expected-error{{'this' can appear only once}}
+(void) [this] { ++x; };
+(void) [*this] { ++x; };  //expected-error{{read-only variable}}
+(void) [*this] () mutable { ++x; };
+(void) [=] { return x; };
+(void) [&, this] { return x; };
+(void) [=, *this] { return x; };
+(void) [&, *this] { return x; };
+  }
+};
+} // end ns1
+
+namespace ns2 {
+  class B {
+B(const B&) = delete; //expected-note{{deleted here}}
+int *x = (int *) 456;
+void foo() {
+  (void)[this] { return x; };
+  (void)[*this] { return x; }; //expected-error{{call to deleted}}
+}
+  };
+} // end ns2
+namespace ns3 {
+  class B {
+B(const B&) = delete; //expected-note2{{deleted here}}
+
+int *x = (int *) 456;
+public: 
+template
+void foo() {
+  (void)[this] { return x; };
+  (void)[*this] { return x; }; //expected-error2{{call to deleted}}
+}
+
+B() = default;
+  } b;
+  B *c = (b.foo(), nullptr); //expected-note{{in instantiation}}
+} // end ns3
+
+namespace ns4 {
+template
+class B {
+  B(const B&) = delete; //expected-note{{deleted here}}
+  double d = 3.14;
+  public: 
+  template
+  auto foo() {
+const auto &L = [*this] (auto a) mutable { //expected-error{{call to deleted}}
+  d += a; 
+  return [this] (auto b) { return d +=b; }; 
+}; 
+  }
+  
+  B() = default;
+};
+void main() {
+  B b;
+  b.foo(); //expected-note{{in instantiation}}
+} // end main  
+} // end ns4
+} //end ns test_star_this
Index: test/CodeGenCXX/cxx1z-lambda-star-this.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cxx1z-lambda-star-this.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - | FileCheck %s
+//CHECK: %[[A_LAMBDA:.*]] = type { %struct.A }
+//CHECK: %[[B_LAMBDA:.*]] = type { %struct.B* }
+struct A {
+  double a = 111;
+  auto foo() { return [*this] { return a; }; }
+};
+
+namespace ns1 {
+int X = A{}.foo()();
+} //end ns1
+
+//CHECK: @"\01?foo@A@@QAE?A?@@XZ"(%struct.A* %this, %class.anon* noalias sret %[[A_LAMBDA_RETVAL:.*]])
+// get the first object with the closure type, which is of type 'struct.A'
+//CHECK: %0 = getelementptr inbounds %[[A_LAMBDA]], %[[A_LAMBDA]]* %[[A_LAMBDA_RETVAL]], i32 0, i32 0
+//CHECK: %1 = bitcast %struct.A* %0 to i8*
+//CHECK: %2 = bitcast %struct.A* %this1 to i8*
+// copy the contents ...
+//CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 8, i1 false)
+
+struct B {
+  double b = 222;
+  auto bar() { return [this] { return b; }; };
+};
+
+namespace ns2 {
+int X = B{}.bar()();
+}
+//CHECK: @"\01?bar@B@@QAE?A?@@XZ"(%struct.B* %this, %class.anon.0* noalias sret %agg.result)
+//CHECK: %0 = getelementptr inbounds %class.anon.0, %class.anon.0* %agg.result, i32 0, i32 0
+//CHECK: store %struct.B* %this1, %struct.B** %0, align 4
\ No newline at end of file
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5631,6 +5631,7 @@
   Record.push_back(Capture.isImplicit());
   Record.push_back(Capture.getCaptureKind());
   switch (Capture.getCaptureKind()) {
+  case LCK_StarThis:
   case LCK_This:
   case LCK_VLAType:
 break;
Index: lib/Serialization/ASTReaderDecl.cpp
==

Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-03-14 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 50623.
jbcoe marked 15 inline comments as done.
jbcoe added a comment.

Apply requested fixes from review.

Thanks for taking time to review this, the patch is much improved for the 
attention.


http://reviews.llvm.org/D16962

Files:
  clang-tidy/readability/AvoidStdBindCheck.cpp
  clang-tidy/readability/AvoidStdBindCheck.h
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-avoid-std-bind.rst
  test/clang-tidy/readability-avoid-std-bind.cpp

Index: test/clang-tidy/readability-avoid-std-bind.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-std-bind.cpp
@@ -0,0 +1,81 @@
+// RUN: %check_clang_tidy %s readability-avoid-std-bind %t -- -- -std=c++14
+
+namespace std {
+inline namespace impl {
+template 
+class bind_rt {};
+
+template 
+bind_rt bind(Fp&&, Arguments&& ...);
+}
+}
+
+int add(int x, int y) { return x + y; }
+
+void f()
+{
+  auto clj = std::bind(add,2,2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+
+// CHECK-FIXES: auto clj = [] { return add(2, 2); };
+
+void g()
+{
+  int x = 2;
+  int y = 2;
+  auto clj = std::bind(add,x,y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+
+// CHECK-FIXES: auto clj = [=] { return add(x, y); };
+
+struct placeholder {};
+placeholder _1;
+placeholder _2;
+
+void h()
+{
+  int x = 2;
+  auto clj = std::bind(add,x,_1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+
+// CHECK-FIXES: auto clj = [=](auto && arg1) { return add(x, arg1); };
+
+struct A;
+struct B;
+bool ABTest(const A&, const B&);
+
+void i()
+{
+  auto BATest = std::bind(ABTest, _2, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+
+// CHECK-FIXES: auto BATest = [](auto && arg1, auto && arg2) { return ABTest(arg2, arg1); };
+
+void j()
+{
+  auto clj = std::bind(add, 2, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+// No fix is applied for argument mismatches.
+// CHECK-FIXES: auto clj = std::bind(add, 2, 2, 2);
+
+void k()
+{
+  auto clj = std::bind(add, _1, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+// No fix is applied for reused placeholders.
+// CHECK-FIXES: auto clj = std::bind(add, _1, _1);
+
+void m()
+{
+  auto clj = std::bind(add, 1, add(2, 5));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+}
+// No fix is applied for nested calls.
+// CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
+
Index: docs/clang-tidy/checks/readability-avoid-std-bind.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-avoid-std-bind.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - readability-avoid-std-bind
+
+readability-avoid-std-bind
+==
+
+Find uses of ``std::bind``. Replace simple uses of ``std::bind`` with lambdas.
+Lambdas will use value-capture where required.
+
+Right now it only handles free functions not member functions.
+
+Fixits are only generated for simple uses of ``std::bind``.
+
+``std::bind`` can be hard to read and can result in larger object files and
+binaries due to type information that will not be produced by equivalent
+lambdas.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -88,6 +88,7 @@
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
+   readability-avoid-std-bind
readability-braces-around-statements
readability-container-size-empty
readability-else-after-return
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidStdBindCheck.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
 #include "ElseAfterReturnCheck.h"
@@ -32,6 +33,8 @@
 class ReadabilityModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"readability-avoid-std-bind");
 CheckFactories.registerCheck(
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
Index: clang-tidy/readabilit

Re: [PATCH] D18071: CodeGen: Mark functions used in vtables as unnamed_addr.

2016-03-14 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263464: CodeGen: Mark functions used in vtables as 
unnamed_addr. (authored by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D18071?vs=50500&id=50622#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18071

Files:
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp
  cfe/trunk/test/CodeGenCXX/vtt-layout.cpp

Index: cfe/trunk/test/CodeGenCXX/vtt-layout.cpp
===
--- cfe/trunk/test/CodeGenCXX/vtt-layout.cpp
+++ cfe/trunk/test/CodeGenCXX/vtt-layout.cpp
@@ -84,3 +84,5 @@
 // CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, 
i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 
x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] 
 // CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, 
i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 
x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, 
i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x 
i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 
0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x 
i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 
0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x 
i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr 
inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* 
bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, 
i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], 
[19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, 
i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* 
@_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)] 
 // CHECK: @_ZTTN5Test41DE = linkonce_odr unnamed_addr constant [19 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, 
i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], 
[11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 
0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 
0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x 
i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 
0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x 
i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 
0, i64 18) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x 
i8*]* @_ZTVN5Test41DE, i64 0, i64 17) to i8*), i8* bitcast (i8** getelementptr 
inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 20) to i8*), i8* 
bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, 
i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*], 
[25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, i64 1, i64 0) 
to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* 
@_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 3) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, 
i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 4) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 
0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 10) to i8*)] 
+// CHECK: declare void @__cxa_pure_virtual() unnamed_addr
+// CHECK: declare void @__cxa_deleted_virtual() unnamed_addr
Index: cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp
==

r263464 - CodeGen: Mark functions used in vtables as unnamed_addr.

2016-03-14 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Mar 14 13:41:59 2016
New Revision: 263464

URL: http://llvm.org/viewvc/llvm-project?rev=263464&view=rev
Log:
CodeGen: Mark functions used in vtables as unnamed_addr.

This marks virtual function declarations, as well as runtime library functions
__cxa_pure_virtual, __cxa_deleted_virtual and _purecall, as unnamed_addr. This
will allow us to correctly form relative references to them from vtables in
the relative vtable ABI.

Differential Revision: http://reviews.llvm.org/D18071

Added:
cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/vtt-layout.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=263464&r1=263463&r2=263464&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Mon Mar 14 13:41:59 2016
@@ -607,6 +607,8 @@ llvm::Constant *CodeGenVTables::CreateVT
 llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
   StringRef PureCallName = CGM.getCXXABI().GetPureVirtualCallName();
   PureVirtualFn = CGM.CreateRuntimeFunction(Ty, PureCallName);
+  if (auto *F = dyn_cast(PureVirtualFn))
+F->setUnnamedAddr(true);
   PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn,
  CGM.Int8PtrTy);
 }
@@ -618,6 +620,8 @@ llvm::Constant *CodeGenVTables::CreateVT
   StringRef DeletedCallName =
 CGM.getCXXABI().GetDeletedVirtualCallName();
   DeletedVirtualFn = CGM.CreateRuntimeFunction(Ty, DeletedCallName);
+  if (auto *F = dyn_cast(DeletedVirtualFn))
+F->setUnnamedAddr(true);
   DeletedVirtualFn = llvm::ConstantExpr::getBitCast(DeletedVirtualFn,
  CGM.Int8PtrTy);
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=263464&r1=263463&r2=263464&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Mar 14 13:41:59 2016
@@ -906,12 +906,6 @@ void CodeGenModule::SetLLVMFunctionAttri
 F->removeFnAttr(llvm::Attribute::InlineHint);
   }
 
-  if (isa(D) || isa(D))
-F->setUnnamedAddr(true);
-  else if (const auto *MD = dyn_cast(D))
-if (MD->isVirtual())
-  F->setUnnamedAddr(true);
-
   unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
   if (alignment)
 F->setAlignment(alignment);
@@ -1079,6 +1073,12 @@ void CodeGenModule::SetFunctionAttribute
 F->addAttribute(llvm::AttributeSet::FunctionIndex,
 llvm::Attribute::NoBuiltin);
 
+  if (isa(FD) || isa(FD))
+F->setUnnamedAddr(true);
+  else if (const auto *MD = dyn_cast(FD))
+if (MD->isVirtual())
+  F->setUnnamedAddr(true);
+
   CreateFunctionBitSetEntry(FD, F);
 }
 

Added: cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp?rev=263464&view=auto
==
--- cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp Mon Mar 14 13:41:59 
2016
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+
+class A {
+  virtual void f();
+  virtual void g();
+  virtual ~A();
+};
+
+void A::f() {}
+
+// CHECK: define void @_ZN1A1fEv({{.*}}) unnamed_addr
+// CHECK: declare void @_ZN1A1gEv({{.*}}) unnamed_addr
+// CHECK: declare void @_ZN1AD1Ev({{.*}}) unnamed_addr
+// CHECK: declare void @_ZN1AD0Ev({{.*}}) unnamed_addr

Modified: cfe/trunk/test/CodeGenCXX/vtt-layout.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtt-layout.cpp?rev=263464&r1=263463&r2=263464&view=diff
==
--- cfe/trunk/test/CodeGenCXX/vtt-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtt-layout.cpp Mon Mar 14 13:41:59 2016
@@ -84,3 +84,5 @@ namespace Test6 {
 // CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, 
i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 
x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] 
 // CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, 
i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds 

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread John McCall via cfe-commits
rjmccall added a comment.

linkonce_odr would allow them to be dropped if unused by the library.  In fact, 
we don't normally emit IR for functions that are linkonce and not used.

Do you actually want code in lib_common to e.g. inline the common 
implementation instead of calling the optimized one if present?  Because that 
is also allowed by linkonce_odr.


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Yes we want the overriding functions to be allowed to be inlined.


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


r263469 - CodeGen: Use 32-bit gep offsets to address vtable address points.

2016-03-14 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Mar 14 14:07:10 2016
New Revision: 263469

URL: http://llvm.org/viewvc/llvm-project?rev=263469&view=rev
Log:
CodeGen: Use 32-bit gep offsets to address vtable address points.

The relative vtable ABI will use a struct rather than an array as the type
of a vtable. LLVM only allows 32-bit integers as struct indices, so we need
to use 32-bit integers to get addresses of address points. In order to keep
the code simple, we might as well do that unconditionally.

It's probably a reasonable implementation limit to support no more than 2
billion virtual functions per class.

This change causes quite a bit of churn in the test suite, so I'm making
it separately.

Differential Revision: http://reviews.llvm.org/D18113

Modified:
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
cfe/trunk/test/CodeGenCXX/constructor-init.cpp
cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp
cfe/trunk/test/CodeGenCXX/microsoft-interface.cpp
cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
cfe/trunk/test/CodeGenCXX/vtable-pointer-initialization.cpp
cfe/trunk/test/CodeGenCXX/vtt-layout.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=263469&r1=263468&r2=263469&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Mon Mar 14 14:07:10 2016
@@ -44,7 +44,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
   const CXXRecordDecl *RD) {
   VTTBuilder Builder(CGM.getContext(), RD, /*GenerateDefinition=*/true);
 
-  llvm::Type *Int8PtrTy = CGM.Int8PtrTy, *Int64Ty = CGM.Int64Ty;
+  llvm::Type *Int8PtrTy = CGM.Int8PtrTy, *Int32Ty = CGM.Int32Ty;
   llvm::ArrayType *ArrayType = 
 llvm::ArrayType::get(Int8PtrTy, Builder.getVTTComponents().size());
 
@@ -75,8 +75,8 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 }
 
  llvm::Value *Idxs[] = {
-   llvm::ConstantInt::get(Int64Ty, 0),
-   llvm::ConstantInt::get(Int64Ty, AddressPoint)
+   llvm::ConstantInt::get(Int32Ty, 0),
+   llvm::ConstantInt::get(Int32Ty, AddressPoint)
  };
 
  llvm::Constant *Init = llvm::ConstantExpr::getInBoundsGetElementPtr(

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=263469&r1=263468&r2=263469&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Mar 14 14:07:10 2016
@@ -1529,8 +1529,8 @@ ItaniumCXXABI::getVTableAddressPoint(Bas
   .getVTableLayout(VTableClass)
   .getAddressPoint(Base);
   llvm::Value *Indices[] = {
-llvm::ConstantInt::get(CGM.Int64Ty, 0),
-llvm::ConstantInt::get(CGM.Int64Ty, AddressPoint)
+llvm::ConstantInt::get(CGM.Int32Ty, 0),
+llvm::ConstantInt::get(CGM.Int32Ty, AddressPoint)
   };
 
   return llvm::ConstantExpr::getInBoundsGetElementPtr(VTable->getValueType(),

Modified: cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp?rev=263469&r1=263468&r2=263469&view=diff
==
--- cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp Mon Mar 14 14:07:10 2016
@@ -343,13 +343,13 @@ namespace VirtualMembers {
 constexpr E() : B(3), c{'b','y','e'} {}
 char c[3];
   };
-  // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, 
double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr 
inbounds ([11 x i8*], [11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), 
double 1.00e+00, i32 64, i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.00e+00, [5 x i8] 
c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* 
@_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.00e+00, [5 x i8] 
c"world", [3 x i8] c"bye" }
+  // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, 
double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr 
inbounds ([11 x i8*], [11 x i8*]* @_ZTVN14VirtualMembers1EE, i32 0, i32 2), 
double 1.00e+00, i32 64, i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTVN14VirtualMembers1EE, i32 0, i32 5), double 2.00e+00, [5 x i8] 
c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* 
@_ZTVN14VirtualMembers1EE, 

Re: [PATCH] D18113: CodeGen: Use 32-bit gep offsets to address vtable address points.

2016-03-14 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263469: CodeGen: Use 32-bit gep offsets to address vtable 
address points. (authored by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D18113?vs=50506&id=50626#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18113

Files:
  cfe/trunk/lib/CodeGen/CGVTT.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
  cfe/trunk/test/CodeGenCXX/constructor-init.cpp
  cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
  cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-interface.cpp
  cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
  cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
  cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
  cfe/trunk/test/CodeGenCXX/vtable-pointer-initialization.cpp
  cfe/trunk/test/CodeGenCXX/vtt-layout.cpp

Index: cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
===
--- cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
+++ cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
@@ -27,7 +27,7 @@
 // CHECK1-LABEL: define void @_ZN5test14fooAEv()
 // CHECK1: call void @_ZN5test11AC1Ev(%"struct.test1::A"*
 // CHECK1: %[[VTABLE:.*]] = load i8**, i8*** %{{.*}}
-// CHECK1: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11AE, i64 0, i64 2)
+// CHECK1: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11AE, i32 0, i32 2)
 // CHECK1: call void @llvm.assume(i1 %[[CMP]])
 // CHECK1-LABEL: }
 
@@ -39,7 +39,7 @@
 // CHECK1-LABEL: define void @_ZN5test14fooBEv()
 // CHECK1: call void @_ZN5test11BC1Ev(%"struct.test1::B"* %{{.*}})
 // CHECK1: %[[VTABLE:.*]] = load i8**, i8*** %{{.*}}
-// CHECK1: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11BE, i64 0, i64 2)
+// CHECK1: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11BE, i32 0, i32 2)
 // CHECK1: call void @llvm.assume(i1 %[[CMP]])
 // CHECK1-LABEL: }
 
@@ -73,14 +73,14 @@
 // CHECK2-LABEL: define void @_ZN5test24testEv()
 // CHECK2: call void @_ZN5test21CC1Ev(%"struct.test2::C"*
 // CHECK2: %[[VTABLE:.*]] = load i8**, i8*** {{.*}}
-// CHECK2: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTVN5test21CE, i64 0, i64 2)
+// CHECK2: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTVN5test21CE, i32 0, i32 2)
 // CHECK2: call void @llvm.assume(i1 %[[CMP]])
 
 // CHECK2: %[[V2:.*]] = bitcast %"struct.test2::C"* %{{.*}} to i8*
 // CHECK2: %[[ADD_PTR:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 8
 // CHECK2: %[[V3:.*]] = bitcast i8* %[[ADD_PTR]] to i8***
 // CHECK2: %[[VTABLE2:.*]] = load i8**, i8*** %[[V3]]
-// CHECK2: %[[CMP2:.*]] = icmp eq i8** %[[VTABLE2]], getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTVN5test21CE, i64 0, i64 5)
+// CHECK2: %[[CMP2:.*]] = icmp eq i8** %[[VTABLE2]], getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTVN5test21CE, i32 0, i32 5)
 // CHECK2: call void @llvm.assume(i1 %[[CMP2]])
 
 // CHECK2: call void @_ZN5test21gEPNS_1AE(
@@ -111,7 +111,7 @@
 
 // CHECK3-LABEL: define void @_ZN5test34testEv()
 // CHECK3: call void @_ZN5test31CC1Ev(%"struct.test3::C"*
-// CHECK3: %[[CMP:.*]] = icmp eq i8** %{{.*}}, getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTVN5test31CE, i64 0, i64 3)
+// CHECK3: %[[CMP:.*]] = icmp eq i8** %{{.*}}, getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTVN5test31CE, i32 0, i32 3)
 // CHECK3: call void @llvm.assume(i1 %[[CMP]])
 // CHECK3-LABLEL: }
 void test() {
@@ -140,11 +140,11 @@
 // CHECK4-LABEL: define void @_ZN5test44testEv()
 // CHECK4: call void @_ZN5test41CC1Ev(%"struct.test4::C"*
 // CHECK4: %[[VTABLE:.*]] = load i8**, i8*** %{{.*}}
-// CHECK4: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5test41CE, i64 0, i64 4)
+// CHECK4: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5test41CE, i32 0, i32 4)
 // CHECK4: call void @llvm.assume(i1 %[[CMP]]
 
 // CHECK4: %[[VTABLE2:.*]] = load i8**, i8*** %{{.*}}
-// CHECK4: %[[CMP2:.*]] = icmp eq i8** %[[VTABLE2]], getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5test41CE, i64 0, i64 4)
+// CHECK4: %[[CMP2:.*]] = icmp eq i8** %[[VTABLE2]], getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5test41CE, i32 0, i32 4)
 // CHECK4: call void @llvm.assume(i1 %[[CMP2]])
 // CHECK4-LABEL: }
 
Index: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -166,13 +166,13 @@
 
 
 // CHECK-CTORS: %[[THIS10:.*]] = bitcast %struct.DynamicDerivedMult

Re: [PATCH] D17910: clang-format: [JS] Handle certain cases of ASI.

2016-03-14 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Looks good.



Comment at: lib/Format/UnwrappedLineParser.cpp:667
@@ +666,3 @@
+return true;
+  // FIXME(martinprobst): This returns true for C/C++ keywords like 'struct'.
+  return FormatTok->is(tok::identifier) &&

We don't usually put usernames into FIXMEs


http://reviews.llvm.org/D17910



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 50627.
ioeric marked 10 inline comments as done.
ioeric added a comment.

- renamed calculateChangedRangesInFile to calculateChangedRanges; removed const 
from FileToReplacementsMap key type.


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,71 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"
+ "g(iii, 0, "
+ "jjj,\n"
+ "  0, kkk, 0, "
+ "mmm);\n"
+ "int  bad = format   ;";
+  std::string Expected =
+  "auto a = new MyType012345678901234567890123456789();\n"
+  "g(iii, nullptr,\n"
+  "  jjj, nullptr,\n"
+  "  kkk, nullptr,\n"
+  "  mmm);\n"
+  "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 38, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 40),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 43),
+  1, "nullptr"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ(Expected, Context.getRewrittenText(ID));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -426,7 +492,7 @@
   Replaces.insert(Replacement("foo", 10, 1, "zz"));
   Replaces.insert(Replacement("foo", 11, 0, ""));
 
-  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+  std::vector Ranges = calculateChangedRanges(Replaces);
 
   EXPECT_EQ(3ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.t

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread John McCall via cfe-commits
rjmccall added a comment.

Well, your overriding definitions will be strong definitions.  The question is 
whether you want to allow inning of the weak definitions, i.e. the 
possibly-overridden ones, and there I would assume not.


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


Re: [PATCH] D18071: CodeGen: Mark functions used in vtables as unnamed_addr.

2016-03-14 Thread John McCall via cfe-commits
rjmccall added a comment.

Member function comparisons of virtual functions aren't required to work 
anyway.  Itanium just happens to implement them in a way that kindof gets it 
right (for simple cases).


Repository:
  rL LLVM

http://reviews.llvm.org/D18071



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


r263470 - clang-format: [JS] Handle certain cases of ASI.

2016-03-14 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Mar 14 14:21:36 2016
New Revision: 263470

URL: http://llvm.org/viewvc/llvm-project?rev=263470&view=rev
Log:
clang-format: [JS] Handle certain cases of ASI.

Automatic Semicolon Insertion can only be properly handled by parsing
source code. However conservatively catching just a few, common
situations prevents breaking code during development, which greatly
improves usability.

JS code should still use semicolons, and ASI code should be flagged by
a compiler or linter.

Patch by Martin Probst. Thank you.

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=263470&r1=263469&r2=263470&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Mar 14 14:21:36 2016
@@ -660,6 +660,72 @@ static bool tokenCanStartNewLine(const c
  Tok.isNot(tok::kw_noexcept);
 }
 
+static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
+ const FormatToken *FormatTok) {
+  if (FormatTok->Tok.isLiteral())
+return true;
+  // FIXME: This returns true for C/C++ keywords like 'struct'.
+  return FormatTok->is(tok::identifier) &&
+ (FormatTok->Tok.getIdentifierInfo() == nullptr ||
+  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of,
+  Keywords.kw_finally, Keywords.kw_function,
+  Keywords.kw_import, Keywords.kw_is,
+  Keywords.kw_let, Keywords.kw_var,
+  Keywords.kw_abstract, Keywords.kw_extends,
+  Keywords.kw_implements, Keywords.kw_instanceof,
+  Keywords.kw_interface, Keywords.kw_throws));
+}
+
+// isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
+// when encountered after a value (see mustBeJSIdentOrValue).
+static bool isJSDeclOrStmt(const AdditionalKeywords &Keywords,
+   const FormatToken *FormatTok) {
+  return FormatTok->isOneOf(
+  tok::kw_return,
+  // conditionals
+  tok::kw_if, tok::kw_else,
+  // loops
+  tok::kw_for, tok::kw_while, tok::kw_do, tok::kw_continue, tok::kw_break,
+  // switch/case
+  tok::kw_switch, tok::kw_case,
+  // exceptions
+  tok::kw_throw, tok::kw_try, tok::kw_catch, Keywords.kw_finally,
+  // declaration
+  tok::kw_const, tok::kw_class, Keywords.kw_var, Keywords.kw_let,
+  Keywords.kw_function);
+}
+
+// readTokenWithJavaScriptASI reads the next token and terminates the current
+// line if JavaScript Automatic Semicolon Insertion must
+// happen between the current token and the next token.
+//
+// This method is conservative - it cannot cover all edge cases of JavaScript,
+// but only aims to correctly handle certain well known cases. It *must not*
+// return true in speculative cases.
+void UnwrappedLineParser::readTokenWithJavaScriptASI() {
+  FormatToken *Previous = FormatTok;
+  readToken();
+  FormatToken *Next = FormatTok;
+
+  bool IsOnSameLine =
+  CommentsBeforeNextToken.empty()
+  ? Next->NewlinesBefore == 0
+  : CommentsBeforeNextToken.front()->NewlinesBefore == 0;
+  if (IsOnSameLine)
+return;
+
+  bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+  if (Next->is(tok::exclaim) && PreviousMustBeValue)
+addUnwrappedLine();
+  bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
+  if (NextMustBeValue && (PreviousMustBeValue ||
+  Previous->isOneOf(tok::r_square, tok::r_paren,
+tok::plusplus, tok::minusminus)))
+addUnwrappedLine();
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
+addUnwrappedLine();
+}
+
 void UnwrappedLineParser::parseStructuralElement() {
   assert(!FormatTok->is(tok::l_brace));
   if (Style.Language == FormatStyle::LK_TableGen &&
@@ -936,6 +1002,7 @@ void UnwrappedLineParser::parseStructura
 return;
   }
 
+  // See if the following token should start a new unwrapped line.
   StringRef Text = FormatTok->TokenText;
   nextToken();
   if (Line->Tokens.size() == 1 &&
@@ -1898,7 +1965,10 @@ void UnwrappedLineParser::nextToken() {
 return;
   flushComments(isOnNewLine(*FormatTok));
   pushToken(FormatTok);
-  readToken();
+  if (Style.Language != FormatStyle::LK_JavaScript)
+readToken();
+  else
+readTokenWithJavaScriptASI();
 }
 
 const FormatToken *UnwrappedLineParser::getPreviousToken() {

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=263470&r1=26

Re: [PATCH] D17910: clang-format: [JS] Handle certain cases of ASI.

2016-03-14 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Submitted as r263470.


http://reviews.llvm.org/D17910



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread don hinton via cfe-commits
hintonda added a comment.

Btw, what do you think about making -Wdeprecated the default for llvm/clang 
builds?

With this change, llvm/clang will be clean.  However, libcxx and libcxxabi have 
a bunch of throw warnings.


http://reviews.llvm.org/D18123



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-14 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

we can turn off inlining when we build lib_common.ll, then do optimization and 
inlining after linking with lib_common.ll and lib_opt.ll. Even if linkonce_odr 
allows inlining, it is still OK.


Repository:
  rL LLVM

http://reviews.llvm.org/D18095



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


r263477 - Relax test introduced in r263464 to accept ARM ABI output.

2016-03-14 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Mar 14 15:13:59 2016
New Revision: 263477

URL: http://llvm.org/viewvc/llvm-project?rev=263477&view=rev
Log:
Relax test introduced in r263464 to accept ARM ABI output.

Should fix ARM bots.

Modified:
cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp

Modified: cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp?rev=263477&r1=263476&r2=263477&view=diff
==
--- cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp Mon Mar 14 15:13:59 
2016
@@ -10,5 +10,5 @@ void A::f() {}
 
 // CHECK: define void @_ZN1A1fEv({{.*}}) unnamed_addr
 // CHECK: declare void @_ZN1A1gEv({{.*}}) unnamed_addr
-// CHECK: declare void @_ZN1AD1Ev({{.*}}) unnamed_addr
+// CHECK: declare {{.*}} @_ZN1AD1Ev({{.*}}) unnamed_addr
 // CHECK: declare void @_ZN1AD0Ev({{.*}}) unnamed_addr


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


r263483 - [CMake] Updating Apple Clang CMake caches

2016-03-14 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon Mar 14 15:23:21 2016
New Revision: 263483

URL: http://llvm.org/viewvc/llvm-project?rev=263483&view=rev
Log:
[CMake] Updating Apple Clang CMake caches

This is a big update that gets the public configurations more in line with the 
ones we're actually using internally to ship Clang in Xcode.

From here forward I expect most of the changes in these files to be incremental 
as the changes get made internally.

Modified:
cfe/trunk/cmake/caches/Apple-stage1.cmake
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage1.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage1.cmake?rev=263483&r1=263482&r2=263483&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage1.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage1.cmake Mon Mar 14 15:23:21 2016
@@ -16,15 +16,35 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
 set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
 set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(CLANG_BOOTSTRAP_PASSTHROUGH
+  CMAKE_OSX_ARCHITECTURES
+  CACHE STRING "")
 
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-set(PACKAGE_VERSION 7.1.0 CACHE STRING "")
 
 # LIBCXX Settings
 set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "")
 set(LIBCXX_OVERRIDE_DARWIN_INSTALL ON CACHE BOOL "")
 
+set(CLANG_BOOTSTRAP_TARGETS
+  generate-order-file
+  check-all
+  check-llvm
+  check-clang
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
 #bootstrap
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_CMAKE_ARGS

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=263483&r1=263482&r2=263483&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Mon Mar 14 15:23:21 2016
@@ -3,22 +3,37 @@
 
 set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") 
 set(CLANG_VENDOR Apple CACHE STRING "")
-set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
-set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
-set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
-set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(CLANG_TOOL_SCAN_BUILD_BUILD OFF CACHE BOOL "")
+set(CLANG_TOOL_SCAN_VIEW_BUILD OFF CACHE BOOL "")
 set(CLANG_LINKS_TO_CREATE clang++ cc c++ CACHE STRING "")
+set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
+set(LLVM_ENABLE_TIMESTAMPS OFF CACHE BOOL "Don't time-stamp shipping builds - 
this makes builds reproducible")
+
+# Make unit tests (if present) part of the ALL target
+set(LLVM_BUILD_TESTS ON CACHE BOOL "")
+# Don't build or run the compiler-rt tests
+set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
 
-set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" CACHE 
STRING "")
-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" 
CACHE STRING "")
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common 
-Wno-profile-instr-unprofiled" CACHE STRING "")
+set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common 
-Wno-profile-instr-unprofiled" CACHE STRING "")
+set(CMAKE_EXE_LINKER_FLAGS "-fno-pie" CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-set(PACKAGE_VERSION 7.1.0 CACHE STRING "")
 
 set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
+set(LIBCXX_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_LTO_VERSION_OFFSET 3000 CACHE STRING "")
 
 # setup toolchain
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
@@ -27,4 +42,18 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cov
   llvm-dwarfdump
   llvm-profdata
+  llvm-objdump
+  llvm-nm
+  llvm-size
   CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  LTO
+  clang-format
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
+
+# test args
+

Re: r263464 - CodeGen: Mark functions used in vtables as unnamed_addr.

2016-03-14 Thread Renato Golin via cfe-commits
On 14 March 2016 at 18:42, Peter Collingbourne via cfe-commits
 wrote:
> Author: pcc
> Date: Mon Mar 14 13:41:59 2016
> New Revision: 263464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263464&view=rev
> Log:
> CodeGen: Mark functions used in vtables as unnamed_addr.
>
> This marks virtual function declarations, as well as runtime library functions
> __cxa_pure_virtual, __cxa_deleted_virtual and _purecall, as unnamed_addr. This
> will allow us to correctly form relative references to them from vtables in
> the relative vtable ABI.

Hi Peter,

You probably have seen, but just in case...

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/10698

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/10737

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


Re: r263464 - CodeGen: Mark functions used in vtables as unnamed_addr.

2016-03-14 Thread Peter Collingbourne via cfe-commits
Yes, and r263477 was the fix.

Peter
On Mar 14, 2016 13:59, "Renato Golin"  wrote:

> On 14 March 2016 at 18:42, Peter Collingbourne via cfe-commits
>  wrote:
> > Author: pcc
> > Date: Mon Mar 14 13:41:59 2016
> > New Revision: 263464
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=263464&view=rev
> > Log:
> > CodeGen: Mark functions used in vtables as unnamed_addr.
> >
> > This marks virtual function declarations, as well as runtime library
> functions
> > __cxa_pure_virtual, __cxa_deleted_virtual and _purecall, as
> unnamed_addr. This
> > will allow us to correctly form relative references to them from vtables
> in
> > the relative vtable ABI.
>
> Hi Peter,
>
> You probably have seen, but just in case...
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/10698
>
> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/10737
>
> cheers,
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263491 - [ThinLTO] Clang side of renaming of function index (NFC)

2016-03-14 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Mon Mar 14 16:06:06 2016
New Revision: 263491

URL: http://llvm.org/viewvc/llvm-project?rev=263491&view=rev
Log:
[ThinLTO] Clang side of renaming of function index (NFC)

This is the companion to an LLVM patch that renamed the function index
data structures and files to use the more general module summary index.

Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=263491&r1=263490&r2=263491&view=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Mon Mar 14 16:06:06 2016
@@ -11,7 +11,7 @@
 #define LLVM_CLANG_CODEGEN_BACKENDUTIL_H
 
 #include "clang/Basic/LLVM.h"
-#include "llvm/IR/FunctionInfo.h"
+#include "llvm/IR/ModuleSummaryIndex.h"
 #include 
 
 namespace llvm {

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=263491&r1=263490&r2=263491&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Mar 14 16:06:06 2016
@@ -74,8 +74,8 @@ CODEGENOPT(LessPreciseFPMAD  , 1, 0) ///
  ///< be generated.
 CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
  ///< compile step.
-CODEGENOPT(EmitFunctionSummary, 1, 0) ///< Set when -flto=thin is enabled on 
the
-  ///< compile step.
+CODEGENOPT(EmitSummaryIndex, 1, 0)   ///< Set when -flto=thin is enabled on the
+ ///< compile step.
 CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which 
can
   ///< be used with an incremental
   ///< linker.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=263491&r1=263490&r2=263491&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Mar 14 16:06:06 2016
@@ -22,13 +22,13 @@
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
 #include "llvm/IR/DataLayout.h"
-#include "llvm/IR/FunctionInfo.h"
+#include "llvm/IR/ModuleSummaryIndex.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/MC/SubtargetFeature.h"
-#include "llvm/Object/FunctionIndexObjectFile.h"
+#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -98,7 +98,7 @@ private:
 return PerFunctionPasses;
   }
 
-  void CreatePasses(FunctionInfoIndex *FunctionIndex);
+  void CreatePasses(ModuleSummaryIndex *ModuleSummary);
 
   /// Generates the TargetMachine.
   /// Returns Null if it is unable to create the target machine.
@@ -279,7 +279,7 @@ static void addSymbolRewriterPass(const
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
-void EmitAssemblyHelper::CreatePasses(FunctionInfoIndex *FunctionIndex) {
+void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -326,16 +326,16 @@ void EmitAssemblyHelper::CreatePasses(Fu
   PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime;
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
-  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitFunctionSummary;
+  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
   legacy::PassManager *MPM = getPerModulePasses();
 
   // If we are performing a ThinLTO importing compile, invoke the LTO
-  // pipeline and pass down the in-memory function index.
-  if (FunctionIndex) {
-PMBuilder.FunctionIndex = FunctionIndex;
+  // pipeline and pass down the in-memory module summary index.
+  if (ModuleSummary) {
+PMBuilder.ModuleSummary = ModuleSummary;
 PMBuilder.populateThinLTOPassManager(*MPM);
 return;
   }
@@ -643,24 +643,24 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   // If we are performing a ThinLTO importing compile, load the function
   // index i

r263494 - Revert "[ThinLTO] Clang side of renaming of function index (NFC)"

2016-03-14 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Mon Mar 14 16:18:17 2016
New Revision: 263494

URL: http://llvm.org/viewvc/llvm-project?rev=263494&view=rev
Log:
Revert "[ThinLTO] Clang side of renaming of function index (NFC)"

This reverts commit r263491. Missed a file on the LLVM side.

Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=263494&r1=263493&r2=263494&view=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Mon Mar 14 16:18:17 2016
@@ -11,7 +11,7 @@
 #define LLVM_CLANG_CODEGEN_BACKENDUTIL_H
 
 #include "clang/Basic/LLVM.h"
-#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/FunctionInfo.h"
 #include 
 
 namespace llvm {

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=263494&r1=263493&r2=263494&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Mar 14 16:18:17 2016
@@ -74,8 +74,8 @@ CODEGENOPT(LessPreciseFPMAD  , 1, 0) ///
  ///< be generated.
 CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
  ///< compile step.
-CODEGENOPT(EmitSummaryIndex, 1, 0)   ///< Set when -flto=thin is enabled on the
- ///< compile step.
+CODEGENOPT(EmitFunctionSummary, 1, 0) ///< Set when -flto=thin is enabled on 
the
+  ///< compile step.
 CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which 
can
   ///< be used with an incremental
   ///< linker.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=263494&r1=263493&r2=263494&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Mar 14 16:18:17 2016
@@ -22,13 +22,13 @@
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
 #include "llvm/IR/DataLayout.h"
-#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/FunctionInfo.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/MC/SubtargetFeature.h"
-#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
+#include "llvm/Object/FunctionIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -98,7 +98,7 @@ private:
 return PerFunctionPasses;
   }
 
-  void CreatePasses(ModuleSummaryIndex *ModuleSummary);
+  void CreatePasses(FunctionInfoIndex *FunctionIndex);
 
   /// Generates the TargetMachine.
   /// Returns Null if it is unable to create the target machine.
@@ -279,7 +279,7 @@ static void addSymbolRewriterPass(const
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
-void EmitAssemblyHelper::CreatePasses(ModuleSummaryIndex *ModuleSummary) {
+void EmitAssemblyHelper::CreatePasses(FunctionInfoIndex *FunctionIndex) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -326,16 +326,16 @@ void EmitAssemblyHelper::CreatePasses(Mo
   PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime;
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
-  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex;
+  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitFunctionSummary;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
   legacy::PassManager *MPM = getPerModulePasses();
 
   // If we are performing a ThinLTO importing compile, invoke the LTO
-  // pipeline and pass down the in-memory module summary index.
-  if (ModuleSummary) {
-PMBuilder.ModuleSummary = ModuleSummary;
+  // pipeline and pass down the in-memory function index.
+  if (FunctionIndex) {
+PMBuilder.FunctionIndex = FunctionIndex;
 PMBuilder.populateThinLTOPassManager(*MPM);
 return;
   }
@@ -643,24 +643,24 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   // If we are performing a ThinLTO importing compile, load the function
   // index into memory and pass it into CreatePasses, which will add it
   // to the 

Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-14 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D17981#374553, @etienneb wrote:

> This is a huge difference. I didn't expect dependencies to bring so much code.
>  I'm not a fan of having an empty statement and increasing false positives 
> ratio.
>  Would it be possible to skip whole declarations with asm-stm, and flag them 
> as "ignored / not parsable"?


I don't actually think there are that many false positives, but I wanted to 
hear from Alex in case I'm wrong. I was hoping he had better ideas on how to 
suppress a diagnostic error in clang and run the clang-tidy checks anyway. My 
best idea is that we make this diagnostic a default-error warning and then 
build with -Wno-unparseable-assembly or something. That's not a very good 
solution, though. =\

> We could gate this code under a define. I'm not a fan of define, but it seems 
> to be a compromise for the size.

> 

> Something like: LIBTOOLING_ENABLE_INLINE_ASM_PARSER

> 

> If we decide to pursue that direction, then it should probably be for every 
> tools.


I'd really rather not do that.


http://reviews.llvm.org/D17981



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread David Blaikie via cfe-commits
UNresolvedSetImpl isn't copy constructible, so should it really be copy
assignable? (it looks like it only needs to be so because of LookupResult -
so once LookupResult is fixed, UnresolvedSetImpl can go back to the way it
was)

Perhaps we should just wait for the fix for LookupResult copying in
SemaStmtAsm from Marina?

Are you planning to cleanup -Wdeprecated in libcxx and libcxxabi too?

I did most of the -Wdeprecated cleanup late last year - but when I tried to
turn it on I hit issues in various stdlibs, etc. It'd be great to finish
the cleanup, or suppress it in system headers, etc, and get it turned on.

On Mon, Mar 14, 2016 at 12:29 PM, don hinton via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> hintonda added a comment.
>
> Btw, what do you think about making -Wdeprecated the default for
> llvm/clang builds?
>
> With this change, llvm/clang will be clean.  However, libcxx and libcxxabi
> have a bunch of throw warnings.
>
>
> http://reviews.llvm.org/D18123
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-14 Thread Pete Cooper via cfe-commits
pete updated this revision to Diff 50651.
pete added a comment.

Thanks for the example John.  I understand what you mean now.

I've added this piece to the test case which verifies that the following IR has 
the correct bit cast in it.  Similarly added cases for alloc and autorelease.

@class A;
@interface B

- (A*) retain;

@end

A* test_retain_class_ptr(B *b) {

  return [b retain];

}

define %1* @test_retain_class_ptr(%2* %b) #0 {
entry:

  %b.addr = alloca %2*, align 8
  store %2* %b, %2** %b.addr, align 8
  %0 = load %2*, %2** %b.addr, align 8
  %1 = bitcast %2* %0 to i8*
  %2 = call i8* @objc_retain(i8* %1) #2
  %3 = bitcast i8* %2 to %1*
  ret %1* %3

}


http://reviews.llvm.org/D14737

Files:
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,7 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fobjc-convert-messages-to-runtime-calls -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -fobjc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE: "-fno-objc-convert-messages-to-runtime-calls"
+// ENABLE-NOT: "-fno-objc-convert-messages-to-runtime-calls"
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Make sure we don't do calls to retain/release when using GC.
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-gc | FileCheck %s --check-prefix=GC
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+
+@interface NSObject
++ (id)alloc;
++ (id)alloc2;
+- (id)init;
+- (id)retain;
+- (void)release;
+- (id)autorelease;
+@end
+
+@interface NSString : NSObject
++ (void)retain_self;
+- (void)retain_super;
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+void test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS: {{call.*@objc_release}}
+  // CALLS: {{call.*@objc_autorelease}}
+  // GC: {{call.*@objc_alloc}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  [NSObject alloc];
+  [x retain];
+  [x release];
+  [x autorelease];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2() {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // Make sure alloc has the correct name and number of types.
+  [NSObject alloc2];
+}
+
+@class A;
+@interface B
++ (A*) alloc;
+- (A*) retain;
+- (A*) autorelease;
+@end
+
+// Make sure we get a bitcast on the return type as the
+// call will return i8* which we have to cast to A*
+// CHECK-LABEL: define {{.*}}void @test_alloc_class_ptr
+A* test_alloc_class_ptr() {
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS-NEXT: bitcast i8*
+  // CALLS-NEXT: ret
+  return [B alloc];
+}
+
+// Make sure we get a bitcast on the return type as the
+// call will return i8* which we have to cast to A*
+// CHECK-LABEL: define {{.*}}void @test_retain_class_ptr
+A* test_retain_class_ptr(B *b) {
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS-NEXT: b

Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-14 Thread Mike Spertus via cfe-commits
mspertus closed this revision.
mspertus added a comment.

Committed as revision 262933


http://reviews.llvm.org/D17908



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


Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-14 Thread Manman Ren via cfe-commits
manmanren added a comment.

In http://reviews.llvm.org/D17865#374659, @aaron.ballman wrote:

> Aside from the missing attribute documentation, looks good to me.


Hi Aaron,

Which document are you referring to? "include/clang/Basic/AttrDocs.td"?
We don't have a section for DeprecatedAttr, should I start one?

Cheers,
Manman


http://reviews.llvm.org/D17865



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


Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D17865#374939, @manmanren wrote:

> In http://reviews.llvm.org/D17865#374659, @aaron.ballman wrote:
>
> > Aside from the missing attribute documentation, looks good to me.
>
>
> Hi Aaron,
>
> Which document are you referring to? "include/clang/Basic/AttrDocs.td"?


Yes, AttrDocs.td that you then reference in to Attr.td.

> We don't have a section for DeprecatedAttr, should I start one?


Yes, please! We used to get away with relying on GCC to document the attribute, 
so now that we're adding Clang-specific behavior, we should bite the bullet and 
document the attribute properly. :-)

Thanks!


http://reviews.llvm.org/D17865



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread don hinton via cfe-commits
UnresolvedSetImpl isn't even constructible, much less copy constructible,
but it is a public base class to UnresolvedSet, it it is -- at least until
we turn it off by deleting the copy ctor.

template  class UnresolvedSet :
public UnresolvedSetImpl {
  SmallVector Decls;
};

But I'm not sure why we would need to since all it does is contain a
SmallVector, and it supports all that behavior.  The problem here is that
making UnresolvedSetImpl's ctor private and defining it, means you have to
do something with the other ones as well.  I'm happy to turn the all off,
but didn't see a good reason to do so.

As for libcxx and libcxxabi, they are 2 separate repos (at least in git).
Fixing libcxx is easy since it already defines a macro for
throw()/noexcept.  Unfortunately, libcxxapi doesn't, though it's easy
enough to define.

On Mon, Mar 14, 2016 at 5:33 PM, David Blaikie  wrote:

> UNresolvedSetImpl isn't copy constructible, so should it really be copy
> assignable? (it looks like it only needs to be so because of LookupResult -
> so once LookupResult is fixed, UnresolvedSetImpl can go back to the way it
> was)
>
> Perhaps we should just wait for the fix for LookupResult copying in
> SemaStmtAsm from Marina?
>
> Are you planning to cleanup -Wdeprecated in libcxx and libcxxabi too?
>
> I did most of the -Wdeprecated cleanup late last year - but when I tried
> to turn it on I hit issues in various stdlibs, etc. It'd be great to finish
> the cleanup, or suppress it in system headers, etc, and get it turned on.
>
> On Mon, Mar 14, 2016 at 12:29 PM, don hinton via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> hintonda added a comment.
>>
>> Btw, what do you think about making -Wdeprecated the default for
>> llvm/clang builds?
>>
>> With this change, llvm/clang will be clean.  However, libcxx and
>> libcxxabi have a bunch of throw warnings.
>>
>>
>> http://reviews.llvm.org/D18123
>>
>>
>>
>> ___
>> 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] D18163: Add visualizers for more clang types. Create more C++-like visualizations for existing Clang types

2016-03-14 Thread Mike Spertus via cfe-commits
mspertus created this revision.
mspertus added reviewers: aaron.ballman, zturner.
mspertus added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This adds visualizers for PointerType and TemplateTypeParmType. 

As I have been using these visualizers, I have found the DisplayStrings to be 
too verbose to cleanly see in the Locals Window, so I have changed the Display 
Strings to display in a more C++-like style. For example, instead of a 
SubstTemplateTypeParmType displaying as

  SubstTemplateTypeParmType: {Identifier (("T"))} => Record (25), {Identifier 
(("A"))}

it now displays more readably as

  SubstTemplateTypeParmType: {typename T <= struct A} 

The `` sections still can be used for all the gory details if necessary


http://reviews.llvm.org/D18163

Files:
  clang.natvis

Index: clang.natvis
===
--- clang.natvis
+++ clang.natvis
@@ -6,46 +6,91 @@
 or create a symbolic link so it updates automatically.
 -->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
+
   
-{(clang::Type::TypeClass)TypeBits.TC, en}
-Builtin Type={*(clang::BuiltinType *)this}
-Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
-{*(clang::SubstTemplateTypeParmType *)this}
-{*(clang::RecordType *)this}
-{(clang::Type::TypeClass)TypeBits.TC, en}
-
-  (clang::Type::TypeClass)TypeBits.TC
-  TypeBits
-  CanonicalType
-  *(clang::BuiltinType *)this
-  (clang::SubstTemplateTypeParmType *)this
-  (clang::RecordType *)this
+
+{(clang::Type::TypeClass)TypeBits.TC, en}Type
+
+{*(clang::BuiltinType *)this}
+{*(clang::PointerType *)this}
+{*(clang::AttributedType *)this}
+{*(clang::TemplateTypeParmType *)this}
+{*(clang::SubstTemplateTypeParmType *)this}
+{*(clang::RecordType *)this}
+{*this,view(poly)}
+{*this,view(cmn)}" 
+{*this,view(cmn)}  {{{*this,view(poly)}}}
+
+  (clang::Type::TypeClass)TypeBits.TC
+  TypeBits
+  CanonicalType
+  *(clang::BuiltinType *)this
+  *(clang::PointerType *)this
+  *(clang::AttributedType *)this
+  (clang::TemplateTypeParmType *)this
+  (clang::SubstTemplateTypeParmType *)this
+  (clang::RecordType *)this
+
+  
+  
+{PointeeType, view(poly)} *
+
+  *(clang::Type *)this, view(cmn)
+  PointeeType
 
   
+  
+{ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
+  
+  
+{Name,view(cpp)}
+{Name}
+  
+  
+struct {Name,view(cpp)}
+interface {Name,view(cpp)}
+union {Name,view(cpp)}
+class {Name,view(cpp)}
+enum {Name,view(cpp)}
+  
   
 {*decl}
 
+  *(clang::Type *)this, view(cmn)
   decl
 
   
   
-{*(clang::Type *)this, view(BaseOnly)}, {*(clang::TagType *)this}
+{*(clang::TagType *)this}
 
   *(clang::TagType *)this
 
   
+
   
-{*(clang::Type *)this, view(BaseOnly)}: {*Replaced} => {CanonicalType}
+{*Replaced,view(cpp)} <= {CanonicalType,view(cpp)}
 
-  *(clang::Type *)this, view(BaseOnly)
+  *(clang::Type *)this, view(cmn)
   *Replaced
 
   
   
-{*TTPDecl}
+typename {*TTPDecl,view(cpp)}
   
   
 
+{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType,view(poly)}
+{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType,view(cpp)}
 {*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType}
 
   *((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType
@@ -70,22 +115,21 @@
   (clang::BuiltinType::Kind)BuiltinTypeBits.Kind
 
   
-  
-{Name}
-  
+
   
 {(clang::TemplateDecl *)((Template.Storage.Val.Val.Value >> 2) << 2)}
 {Template.Storage}
   
   
-({((llvm::StringMapEntry*)Entry)+1,s})
+{((llvm::StringMapEntry*)Entry)+1,sb}
 
   ((llvm::StringMapEntry*)Entry)+1,s
   (clang::tok::TokenKind)TokenID
 
   
   
 Empty
+{*(clang::IdentifierInfo *)(Ptr & ~PtrMask)}
 {{Identifier ({*(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}
 {{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}
 {{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread David Blaikie via cfe-commits
On Mon, Mar 14, 2016 at 3:07 PM, don hinton  wrote:

> UnresolvedSetImpl isn't even constructible, much less copy constructible,
> but it is a public base class to UnresolvedSet, it it is -- at least until
> we turn it off by deleting the copy ctor.
>
> template  class UnresolvedSet :
> public UnresolvedSetImpl {
>   SmallVector Decls;
> };
>
> But I'm not sure why we would need to since all it does is contain a
> SmallVector, and it supports all that behavior.  The problem here is that
> making UnresolvedSetImpl's ctor private and defining it, means you have to
> do something with the other ones as well.  I'm happy to turn the all off,
> but didn't see a good reason to do so.
>

Fair - I'm not too fussed, there, to be sure. If we're going to do it,
perhaps we should = default in the move ops too? (except those aren't
implicitly defaultible in MSVC... blah)

Maybe best to just wait until there's a need for them? I'm not sure. *shrug*


> As for libcxx and libcxxabi, they are 2 separate repos (at least in git).
>

Yep, wasn't expecting the fixes to go in the same code review or anything -
just wondering about direction.


>   Fixing libcxx is easy since it already defines a macro for
> throw()/noexcept.  Unfortunately, libcxxapi doesn't, though it's easy
> enough to define.
>

*nod*


>
> On Mon, Mar 14, 2016 at 5:33 PM, David Blaikie  wrote:
>
>> UNresolvedSetImpl isn't copy constructible, so should it really be copy
>> assignable? (it looks like it only needs to be so because of LookupResult -
>> so once LookupResult is fixed, UnresolvedSetImpl can go back to the way it
>> was)
>>
>> Perhaps we should just wait for the fix for LookupResult copying in
>> SemaStmtAsm from Marina?
>>
>> Are you planning to cleanup -Wdeprecated in libcxx and libcxxabi too?
>>
>> I did most of the -Wdeprecated cleanup late last year - but when I tried
>> to turn it on I hit issues in various stdlibs, etc. It'd be great to finish
>> the cleanup, or suppress it in system headers, etc, and get it turned on.
>>
>> On Mon, Mar 14, 2016 at 12:29 PM, don hinton via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> hintonda added a comment.
>>>
>>> Btw, what do you think about making -Wdeprecated the default for
>>> llvm/clang builds?
>>>
>>> With this change, llvm/clang will be clean.  However, libcxx and
>>> libcxxabi have a bunch of throw warnings.
>>>
>>>
>>> http://reviews.llvm.org/D18123
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread don hinton via cfe-commits
On Mon, Mar 14, 2016 at 6:24 PM, David Blaikie  wrote:

>
>
> On Mon, Mar 14, 2016 at 3:07 PM, don hinton  wrote:
>
>> UnresolvedSetImpl isn't even constructible, much less copy constructible,
>> but it is a public base class to UnresolvedSet, it it is -- at least until
>> we turn it off by deleting the copy ctor.
>>
>> template  class UnresolvedSet :
>> public UnresolvedSetImpl {
>>   SmallVector Decls;
>> };
>>
>> But I'm not sure why we would need to since all it does is contain a
>> SmallVector, and it supports all that behavior.  The problem here is that
>> making UnresolvedSetImpl's ctor private and defining it, means you have to
>> do something with the other ones as well.  I'm happy to turn the all off,
>> but didn't see a good reason to do so.
>>
>
> Fair - I'm not too fussed, there, to be sure. If we're going to do it,
> perhaps we should = default in the move ops too? (except those aren't
> implicitly defaultible in MSVC... blah)
>

Yes, I included the move ops, move ctor and move assignment.


>
> Maybe best to just wait until there's a need for them? I'm not sure.
> *shrug*
>

Sure, that's fine.  However, I think we should delete them in LookupResult,
right?  The implicit copy and assignment ops are wrong and leak otherwise.


>
>
>> As for libcxx and libcxxabi, they are 2 separate repos (at least in git).
>>
>
> Yep, wasn't expecting the fixes to go in the same code review or anything
> - just wondering about direction.
>
>
>>   Fixing libcxx is easy since it already defines a macro for
>> throw()/noexcept.  Unfortunately, libcxxapi doesn't, though it's easy
>> enough to define.
>>
>
> *nod*
>
>
>>
>> On Mon, Mar 14, 2016 at 5:33 PM, David Blaikie 
>> wrote:
>>
>>> UNresolvedSetImpl isn't copy constructible, so should it really be copy
>>> assignable? (it looks like it only needs to be so because of LookupResult -
>>> so once LookupResult is fixed, UnresolvedSetImpl can go back to the way it
>>> was)
>>>
>>> Perhaps we should just wait for the fix for LookupResult copying in
>>> SemaStmtAsm from Marina?
>>>
>>> Are you planning to cleanup -Wdeprecated in libcxx and libcxxabi too?
>>>
>>> I did most of the -Wdeprecated cleanup late last year - but when I tried
>>> to turn it on I hit issues in various stdlibs, etc. It'd be great to finish
>>> the cleanup, or suppress it in system headers, etc, and get it turned on.
>>>
>>> On Mon, Mar 14, 2016 at 12:29 PM, don hinton via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 hintonda added a comment.

 Btw, what do you think about making -Wdeprecated the default for
 llvm/clang builds?

 With this change, llvm/clang will be clean.  However, libcxx and
 libcxxabi have a bunch of throw warnings.


 http://reviews.llvm.org/D18123



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

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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread David Blaikie via cfe-commits
On Mon, Mar 14, 2016 at 3:30 PM, don hinton  wrote:

>
>
> On Mon, Mar 14, 2016 at 6:24 PM, David Blaikie  wrote:
>
>>
>>
>> On Mon, Mar 14, 2016 at 3:07 PM, don hinton  wrote:
>>
>>> UnresolvedSetImpl isn't even constructible, much less copy
>>> constructible, but it is a public base class to UnresolvedSet, it it is --
>>> at least until we turn it off by deleting the copy ctor.
>>>
>>> template  class UnresolvedSet :
>>> public UnresolvedSetImpl {
>>>   SmallVector Decls;
>>> };
>>>
>>> But I'm not sure why we would need to since all it does is contain a
>>> SmallVector, and it supports all that behavior.  The problem here is that
>>> making UnresolvedSetImpl's ctor private and defining it, means you have to
>>> do something with the other ones as well.  I'm happy to turn the all off,
>>> but didn't see a good reason to do so.
>>>
>>
>> Fair - I'm not too fussed, there, to be sure. If we're going to do it,
>> perhaps we should = default in the move ops too? (except those aren't
>> implicitly defaultible in MSVC... blah)
>>
>
> Yes, I included the move ops, move ctor and move assignment.
>
>
>>
>> Maybe best to just wait until there's a need for them? I'm not sure.
>> *shrug*
>>
>
> Sure, that's fine.  However, I think we should delete them in
> LookupResult, right?  The implicit copy and assignment ops are wrong and
> leak otherwise.
>

Yep. But I'm happy enough to wait for the correct fix from Marina there.


>
>
>>
>>
>>> As for libcxx and libcxxabi, they are 2 separate repos (at least in git).
>>>
>>
>> Yep, wasn't expecting the fixes to go in the same code review or anything
>> - just wondering about direction.
>>
>>
>>>   Fixing libcxx is easy since it already defines a macro for
>>> throw()/noexcept.  Unfortunately, libcxxapi doesn't, though it's easy
>>> enough to define.
>>>
>>
>> *nod*
>>
>>
>>>
>>> On Mon, Mar 14, 2016 at 5:33 PM, David Blaikie 
>>> wrote:
>>>
 UNresolvedSetImpl isn't copy constructible, so should it really be copy
 assignable? (it looks like it only needs to be so because of LookupResult -
 so once LookupResult is fixed, UnresolvedSetImpl can go back to the way it
 was)

 Perhaps we should just wait for the fix for LookupResult copying in
 SemaStmtAsm from Marina?

 Are you planning to cleanup -Wdeprecated in libcxx and libcxxabi too?

 I did most of the -Wdeprecated cleanup late last year - but when I
 tried to turn it on I hit issues in various stdlibs, etc. It'd be great to
 finish the cleanup, or suppress it in system headers, etc, and get it
 turned on.

 On Mon, Mar 14, 2016 at 12:29 PM, don hinton via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> hintonda added a comment.
>
> Btw, what do you think about making -Wdeprecated the default for
> llvm/clang builds?
>
> With this change, llvm/clang will be clean.  However, libcxx and
> libcxxabi have a bunch of throw warnings.
>
>
> http://reviews.llvm.org/D18123
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-03-14 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:268-290
@@ -265,1 +267,25 @@
 
+  // abi_tag is a gcc attribute, taking one or more strings called "tags".
+  //
+  // The goal is to annotate against which version of a library an object was
+  // build and to be able to provide backwards compatibility ("dual abi").
+  //
+  // For this the emitted mangled names have to be different, while you don't
+  // want the user to have to use different names in the source.
+  //
+  // The abi_tag can be present on Struct, Var and Function  declarations as
+  // "explicit" tag, and on inline Namespace as "implicit" tag. Explicit tags
+  // are always emitted after the unqualified name, and (implicit) tags on
+  // namespace are not.
+  //
+  // For functions and variables there is a set of "implicitly available"
+  // tags. These tags are: all tags from the namespace/structs the name is
+  // embedded in, all tags from any template arguments of the name, and, for
+  // functions, alls tags used anywhere in the  (i.e.
+  // parameters and sometimes the return type).
+  //
+  // For functions this is basically the list of all tags from the signature
+  // without the unqualified name and usually without the return type of the
+  // function. In `operator Type()` Type is NOT part of that list, as it is
+  // part of the unqualified name!
+  //

I think it would be a valuable exercise to write up something more concrete 
than this in a .rst file in docs/. I think part of the reason why this patch 
has languished so long is because there is no specification or documentation to 
speak of. This new abi_tag is a major departure from the wonderful *standard* 
Itanium C++ ABI that Unix has enjoyed. On Windows, we suffer greatly from 
having to follow each and every implementation detail that Microsoft 
accidentally baked into their ABI. It would be good if we could put together a 
document that we could send back to someone who works on GCC, so that they can 
verify that that is how abi_tag is intended to work, even if GCC deviates from 
it in some places.


Comment at: test/SemaCXX/attr-abi-tag.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple x86_64-unknown-linux -emit-llvm < 
%s | FileCheck %s
+

This doesn't seem like a Sema test. Maybe fold it into the mangling test?


http://reviews.llvm.org/D18035



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


Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-14 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 50667.
pcc marked 3 inline comments as done.
pcc added a comment.

- Address review comments


http://reviews.llvm.org/D17893

Files:
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.h
  include/clang/Driver/Options.td
  include/clang/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/Basic/LangOptions.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/Driver/funstable-cxx-abi.cpp
  test/SemaCXX/Inputs/unstable-abi-list-global1.txt
  test/SemaCXX/Inputs/unstable-abi-list-global2.txt
  test/SemaCXX/Inputs/unstable-abi-list.txt
  test/SemaCXX/attr-stability.cpp
  test/SemaCXX/unstable-cxx-abi-global1.cpp
  test/SemaCXX/unstable-cxx-abi-global2.cpp
  test/SemaCXX/unstable-cxx-abi-warning.cpp
  test/SemaCXX/unstable-cxx-abi.cpp

Index: test/SemaCXX/unstable-cxx-abi.cpp
===
--- /dev/null
+++ test/SemaCXX/unstable-cxx-abi.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list.txt -Wstable-c++-abi
+
+struct stable { // expected-note 3{{base 'stable' uses the stable ABI}} expected-warning {{stable C++ ABI was inferred for class 'stable'}} expected-note-re {{add the global namespace to file {{.*}} to silence this warning}}
+  virtual void f();
+};
+struct [[clang::unstable_abi]] unstable { // expected-note 3{{base 'unstable' uses the unstable ABI}}
+  virtual void f();
+};
+
+struct
+[[clang::stable_abi]] // expected-note {{stable ABI specified by attribute}}
+[[clang::unstable_abi]] // expected-note {{unstable ABI specified by attribute}}
+bistable { // expected-error {{inconsistent ABI for class 'bistable'}}
+  virtual void f();
+};
+
+struct mixed_bases : stable, unstable {}; // expected-error {{inconsistent ABI for class 'mixed_bases'}}
+struct mixed_base_vbase : stable, virtual unstable {}; // expected-error {{inconsistent ABI for class 'mixed_base_vbase'}}
+
+struct
+[[clang::unstable_abi]] // expected-note {{unstable ABI specified by attribute}}
+mixed_attr_base : stable { // expected-error {{inconsistent ABI for class 'mixed_attr_base'}}
+};
+
+struct
+[[clang::stable_abi]] // expected-note {{stable ABI specified by attribute}}
+mixed_attr_base2 : unstable { // expected-error {{inconsistent ABI for class 'mixed_attr_base2'}}
+};
+
+namespace std {
+
+struct unstable {
+  virtual void f();
+};
+
+}
+
+namespace std {
+
+namespace {
+
+struct unstable2 {
+  virtual void f();
+};
+
+namespace foo {
+
+struct unstable {
+  virtual void f();
+};
+
+}
+
+}
+
+namespace bar {
+
+struct stable { // expected-warning {{stable C++ ABI was inferred for class 'stable'}} expected-note-re {{add namespace 'std::bar' to file {{.*}} to silence this warning}}
+  virtual void f();
+};
+
+}
+
+struct non_dynamic {
+  struct unstable3 {
+virtual void f();
+  };
+  void mf() {
+struct unstable4 {
+  virtual void f();
+};
+struct unstable_derived : unstable, unstable4 {};
+  }
+};
+
+void f() {
+  struct unstable5 {
+virtual void f();
+  };
+  struct unstable_derived : unstable, unstable5 {};
+}
+
+}
+
+struct stable2 : std::non_dynamic { // expected-warning {{stable C++ ABI was inferred for class 'stable2'}}  expected-note-re {{add the global namespace to file {{.*}} to silence this warning}}
+  virtual void f();
+};
+
+struct unstable_derived : unstable, std::unstable2, std::foo::unstable,
+  std::non_dynamic::unstable3 {};
+struct stable_derived : stable, std::bar::stable, stable2 {};
Index: test/SemaCXX/unstable-cxx-abi-warning.cpp
===
--- /dev/null
+++ test/SemaCXX/unstable-cxx-abi-warning.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -Wstable-c++-abi
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -Wstable-c++-abi -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list.txt -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list-global1.txt
+
+namespace ns {
+
+class non_dynamic {};
+
+class dynamic { // expected-warning {{stable C++ ABI was inferred for class 'dynamic'}} expected-note {{add attribute clang::unstable_abi or clang::stable_abi to silence this warning}}
+  virtual void f();
+};
+
+}
Index: test/SemaCXX/unstable-cxx-abi-global2.cpp
===
--- /dev/null
+++ test/SemaCXX/unstable-cxx-abi-global2.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -funstable-c++-abi-classes
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list-global2.txt
+
+namespace foo {
+
+struct unstable { // expected-note {{base 'unstable' uses the unstable ABI}}
+  virtual void f

Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-14 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

> Missing some attribute-related tests like attaching the attribute to 
> something other than a record, or passing arguments to the attribute.


Added.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8345
@@ +8344,3 @@
+def note_add_unstable_abi_attr : Note<
+  "add attribute clang::unstable_abi or clang::stable_abi to silence this 
warning">;
+

aaron.ballman wrote:
> Should this also be a %select, or can you really add either attribute to 
> silence the warning?
The latter. I gave this a better name to make things clear.


Comment at: lib/Sema/SemaDeclCXX.cpp:4896
@@ +4895,3 @@
+
+  // No need to do this for non-dynamic classes.
+  if (!Record->isDynamicClass())

aaron.ballman wrote:
> Since the attributes do nothing for a non-dynamic class, should the user get 
> a warning if the place the attribute on one (so they know it does nothing)?
I suppose so; done.


http://reviews.llvm.org/D17893



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


Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-14 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 50668.
pcc added a comment.

- Add a test for passing arguments to the attribute


http://reviews.llvm.org/D17893

Files:
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.h
  include/clang/Driver/Options.td
  include/clang/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/Basic/LangOptions.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/Driver/funstable-cxx-abi.cpp
  test/SemaCXX/Inputs/unstable-abi-list-global1.txt
  test/SemaCXX/Inputs/unstable-abi-list-global2.txt
  test/SemaCXX/Inputs/unstable-abi-list.txt
  test/SemaCXX/attr-stability.cpp
  test/SemaCXX/unstable-cxx-abi-global1.cpp
  test/SemaCXX/unstable-cxx-abi-global2.cpp
  test/SemaCXX/unstable-cxx-abi-warning.cpp
  test/SemaCXX/unstable-cxx-abi.cpp

Index: test/SemaCXX/unstable-cxx-abi.cpp
===
--- /dev/null
+++ test/SemaCXX/unstable-cxx-abi.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list.txt -Wstable-c++-abi
+
+struct stable { // expected-note 3{{base 'stable' uses the stable ABI}} expected-warning {{stable C++ ABI was inferred for class 'stable'}} expected-note-re {{add the global namespace to file {{.*}} to silence this warning}}
+  virtual void f();
+};
+struct [[clang::unstable_abi]] unstable { // expected-note 3{{base 'unstable' uses the unstable ABI}}
+  virtual void f();
+};
+
+struct
+[[clang::stable_abi]] // expected-note {{stable ABI specified by attribute}}
+[[clang::unstable_abi]] // expected-note {{unstable ABI specified by attribute}}
+bistable { // expected-error {{inconsistent ABI for class 'bistable'}}
+  virtual void f();
+};
+
+struct mixed_bases : stable, unstable {}; // expected-error {{inconsistent ABI for class 'mixed_bases'}}
+struct mixed_base_vbase : stable, virtual unstable {}; // expected-error {{inconsistent ABI for class 'mixed_base_vbase'}}
+
+struct
+[[clang::unstable_abi]] // expected-note {{unstable ABI specified by attribute}}
+mixed_attr_base : stable { // expected-error {{inconsistent ABI for class 'mixed_attr_base'}}
+};
+
+struct
+[[clang::stable_abi]] // expected-note {{stable ABI specified by attribute}}
+mixed_attr_base2 : unstable { // expected-error {{inconsistent ABI for class 'mixed_attr_base2'}}
+};
+
+namespace std {
+
+struct unstable {
+  virtual void f();
+};
+
+}
+
+namespace std {
+
+namespace {
+
+struct unstable2 {
+  virtual void f();
+};
+
+namespace foo {
+
+struct unstable {
+  virtual void f();
+};
+
+}
+
+}
+
+namespace bar {
+
+struct stable { // expected-warning {{stable C++ ABI was inferred for class 'stable'}} expected-note-re {{add namespace 'std::bar' to file {{.*}} to silence this warning}}
+  virtual void f();
+};
+
+}
+
+struct non_dynamic {
+  struct unstable3 {
+virtual void f();
+  };
+  void mf() {
+struct unstable4 {
+  virtual void f();
+};
+struct unstable_derived : unstable, unstable4 {};
+  }
+};
+
+void f() {
+  struct unstable5 {
+virtual void f();
+  };
+  struct unstable_derived : unstable, unstable5 {};
+}
+
+}
+
+struct stable2 : std::non_dynamic { // expected-warning {{stable C++ ABI was inferred for class 'stable2'}}  expected-note-re {{add the global namespace to file {{.*}} to silence this warning}}
+  virtual void f();
+};
+
+struct unstable_derived : unstable, std::unstable2, std::foo::unstable,
+  std::non_dynamic::unstable3 {};
+struct stable_derived : stable, std::bar::stable, stable2 {};
Index: test/SemaCXX/unstable-cxx-abi-warning.cpp
===
--- /dev/null
+++ test/SemaCXX/unstable-cxx-abi-warning.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -Wstable-c++-abi
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -Wstable-c++-abi -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list.txt -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list-global1.txt
+
+namespace ns {
+
+class non_dynamic {};
+
+class dynamic { // expected-warning {{stable C++ ABI was inferred for class 'dynamic'}} expected-note {{add attribute clang::unstable_abi or clang::stable_abi to silence this warning}}
+  virtual void f();
+};
+
+}
Index: test/SemaCXX/unstable-cxx-abi-global2.cpp
===
--- /dev/null
+++ test/SemaCXX/unstable-cxx-abi-global2.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -funstable-c++-abi-classes
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -funstable-c++-abi-classes=%S/Inputs/unstable-abi-list-global2.txt
+
+namespace foo {
+
+struct unstable { // expected-note {{base 'unstable' uses the unstable ABI}}
+  virtual void f();
+};
+
+}

Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-14 Thread don hinton via cfe-commits
> Sure, that's fine.  However, I think we should delete them in
>> LookupResult, right?  The implicit copy and assignment ops are wrong and
>> leak otherwise.
>>
>
> Yep. But I'm happy enough to wait for the correct fix from Marina there.
>

Sounds good, just wanted to get the diff out there.  thanks again...
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-03-14 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/LambdaCapture.h:41
@@ -41,3 +40,3 @@
   SourceLocation EllipsisLoc;
-
+  bool IsStarThis : 1;
   friend class ASTStmtReader;

I'm not a fan of this representation. Please use `Capture_ByCopy` to indicate a 
by-copy capture of `*this`. It's probably time to clean up `DeclAndBits` a 
little. Something like this should work:

  struct LLVM_ALIGNAS(4) OpaqueCapturedEntity {};
  llvm::PointerIntPair CapturedEntityAndBits;
  static OpaqueCapturedEntity StarThis;
  static OpaqueCapturedEntity VLAType;

where the `void*` is either a `Decl*` or points to `StarThis` or `VLAType`.


Comment at: include/clang/Basic/Lambda.h:35
@@ -34,2 +34,3 @@
 enum LambdaCaptureKind {
   LCK_This,   ///< Capturing the \c this pointer
+  LCK_StarThis, /// < Capturing the \c *this object by value

-> Capturing the \c *this object by reference?


Comment at: include/clang/Sema/ScopeInfo.h:414-417
@@ -413,6 +413,6 @@
 // variables are captured by copy.
 enum CaptureKind {
   Cap_ByCopy, Cap_ByRef, Cap_Block, Cap_This
 };
-
+bool IsStarThis = false;
 /// The variable being captured (if we are not capturing 'this') and 
whether

Please try to integrate this into the existing code rather than adding it as a 
separate thing on the side. Again, we can model `this` and `*this` as capturing 
the same entity either by reference or by value, and we should do so.


Comment at: include/clang/Sema/ScopeInfo.h:455-468
@@ -453,12 +454,16 @@
 
 bool isThisCapture() const {
   return InitExprAndCaptureKind.getInt() == Cap_This;
 }
+bool isStarThisCapture() const {
+  return IsStarThis;
+}
 bool isVariableCapture() const {
-  return InitExprAndCaptureKind.getInt() != Cap_This && 
!isVLATypeCapture();
+  return !isThisCapture() && !isVLATypeCapture();
 }
 bool isCopyCapture() const {
-  return InitExprAndCaptureKind.getInt() == Cap_ByCopy &&
- !isVLATypeCapture();
+  return (InitExprAndCaptureKind.getInt() == Cap_ByCopy &&
+  !isVLATypeCapture()) ||
+ IsStarThis;
 }
 bool isReferenceCapture() const {

In particular: don't add `isStarThisCapture`, just use `isThisCapture` and 
`isCopyCapture`/`isReferenceCapture` to distinguish between `this` and `*this`.


Comment at: lib/AST/ExprCXX.cpp:894
@@ -892,2 +893,3 @@
+IsStarThis = true;
   case LCK_This:
 assert(!Var && "'this' capture cannot have a variable!");

Add // Fall through comment.


Comment at: lib/Parse/ParseExprCXX.cpp:850
@@ +849,3 @@
+
+if (Tok.is(tok::star) && NextToken().is(tok::kw_this)) {
+  Kind = LCK_StarThis;

You don't need lookahead for this; if the current token is `*`, you can consume 
that token then look for `this`. It's an error if something else comes next.


Comment at: lib/Parse/ParseExprCXX.cpp:857-860
@@ +856,6 @@
+  ConsumeToken();
+  Diag(Loc, !getLangOpts().CPlusPlus1z
+ ? diag::ext_star_this_lambda_capture_cxx1z
+ : 
diag::warn_cxx14_compat_star_this_lambda_capture);
+
+} else if (Tok.is(tok::kw_this)) {

We shouldn't produce this warning during disambiguation between a lambda and an 
Obj-C message send or designator. Please move the diagnostic into Sema instead.


Comment at: lib/Sema/SemaDecl.cpp:10994
@@ -10994,1 +10993,3 @@
+  S.getCurrentThisType(), /*Expr*/ nullptr,
+  !I->getType()->isPointerType());
 } else {

Use `C.getCaptureKind()` rather than querying the type of the field directly 
here.


Comment at: lib/Sema/SemaExpr.cpp:13256
@@ -13255,3 +13255,3 @@
 /// being captured.
-static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, VarDecl 
*Var,
+static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, VarDecl *,
 QualType FieldType, QualType DeclRefType,

Just delete this parameter? (As a separate change, though.)


Comment at: lib/Sema/SemaExprCXX.cpp:841-849
@@ -840,11 +840,11 @@
   }
   if (ThisTy.isNull()) {
 if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
 CurContext->getParent()->getParent()->isRecord()) {
   // This is a generic lambda call operator that is being instantiated
   // within a default initializer - so use the enclosing class as 'this'.
   // There is no enclosing member function to retrieve the 'this' pointer
   // from.
   QualType ClassTy = Context.getTypeDeclType(
   cast(CurContext->getParent()->getParent()));
   // There are no cv-qualifiers for 'this' within default initializers, 

(Only s

r263505 - clang/test/CodeGenCXX/virtual-function-attrs.cpp: Appease i686-mingw32 to expect x86_thiscallcc.

2016-03-14 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Mar 14 18:00:44 2016
New Revision: 263505

URL: http://llvm.org/viewvc/llvm-project?rev=263505&view=rev
Log:
clang/test/CodeGenCXX/virtual-function-attrs.cpp: Appease i686-mingw32 to 
expect x86_thiscallcc.

Modified:
cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp

Modified: cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp?rev=263505&r1=263504&r2=263505&view=diff
==
--- cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virtual-function-attrs.cpp Mon Mar 14 18:00:44 
2016
@@ -8,7 +8,7 @@ class A {
 
 void A::f() {}
 
-// CHECK: define void @_ZN1A1fEv({{.*}}) unnamed_addr
-// CHECK: declare void @_ZN1A1gEv({{.*}}) unnamed_addr
+// CHECK: define [[CC:(x86_thiscallcc )?]]void @_ZN1A1fEv({{.*}}) unnamed_addr
+// CHECK: declare [[CC]]void @_ZN1A1gEv({{.*}}) unnamed_addr
 // CHECK: declare {{.*}} @_ZN1AD1Ev({{.*}}) unnamed_addr
-// CHECK: declare void @_ZN1AD0Ev({{.*}}) unnamed_addr
+// CHECK: declare [[CC]]void @_ZN1AD0Ev({{.*}}) unnamed_addr


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


  1   2   >