Re: [clang-tools-extra] r293217 - Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications.

2017-01-26 Thread Diana Picus via cfe-commits
Hi Don, Hi Aaron,

I had to revert this in r293267 because all the clang-tools-extra
buildbots were still broken many hours after it was committed.
See for instance
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1039

Eugene Zelenko also had some small fixes to
modernize-use-noexcept.rst, you might want to incorporate those as
well before recommitting (see r293234).

Regards,
Diana

On 27 January 2017 at 00:34, Aaron Ballman via cfe-commits
 wrote:
> Author: aaronballman
> Date: Thu Jan 26 16:34:24 2017
> New Revision: 293217
>
> URL: http://llvm.org/viewvc/llvm-project?rev=293217&view=rev
> Log:
> Implement a new clang-tidy check that suggests users replace dynamic 
> exception specifications with noexcept exception specifications.
>
> Patch by Don Hinton.
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=293217&r1=293216&r2=293217&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Jan 26 
> 16:34:24 2017
> @@ -20,6 +20,7 @@ add_clang_library(clangTidyModernizeModu
>UseEmplaceCheck.cpp
>UseEqualsDefaultCheck.cpp
>UseEqualsDeleteCheck.cpp
> +  UseNoexceptCheck.cpp
>UseNullptrCheck.cpp
>UseOverrideCheck.cpp
>UseTransparentFunctorsCheck.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=293217&r1=293216&r2=293217&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
> Jan 26 16:34:24 2017
> @@ -26,6 +26,7 @@
>  #include "UseEmplaceCheck.h"
>  #include "UseEqualsDefaultCheck.h"
>  #include "UseEqualsDeleteCheck.h"
> +#include "UseNoexceptCheck.h"
>  #include "UseNullptrCheck.h"
>  #include "UseOverrideCheck.h"
>  #include "UseTransparentFunctorsCheck.h"
> @@ -63,6 +64,7 @@ public:
>  
> CheckFactories.registerCheck("modernize-use-equals-default");
>  CheckFactories.registerCheck(
>  "modernize-use-equals-delete");
> +CheckFactories.registerCheck("modernize-use-noexcept");
>  CheckFactories.registerCheck("modernize-use-nullptr");
>  CheckFactories.registerCheck("modernize-use-override");
>  CheckFactories.registerCheck(
>
> Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=293217&view=auto
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp (added)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp Thu Jan 
> 26 16:34:24 2017
> @@ -0,0 +1,114 @@
> +//===--- UseNoexceptCheck.cpp - 
> clang-tidy-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--===//
> +
> +#include "UseNoexceptCheck.h"
> +#include "clang/AST/ASTContext.h"
> +#include "clang/Lex/Lexer.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace modernize {
> +
> +UseNoexceptCheck::UseNoexceptCheck(StringRef Name, ClangTidyContext *Context)
> +: ClangTidyCheck(Name, Context),
> +  NoexceptMacro(Options.get("ReplacementString", "")),
> +  UseNoexceptFalse(Options.get("UseNoexceptFalse", true)) {}
> +
> +void UseNoexceptCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
> +  Options.store(Opts, "ReplacementString", NoexceptMacro);
> +  Options.store(Opts, "UseNoexceptFalse", UseNoexceptFalse);
> +}
> +
> +void UseNoe

[clang-tools-extra] r293267 - Revert "Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications."

2017-01-26 Thread Diana Picus via cfe-commits
Author: rovka
Date: Fri Jan 27 01:19:22 2017
New Revision: 293267

URL: http://llvm.org/viewvc/llvm-project?rev=293267&view=rev
Log:
Revert "Implement a new clang-tidy check that suggests users replace dynamic 
exception specifications with noexcept exception specifications."

This reverts commit r293217, its follow-up 293218 and part of 293234 because it
broke all bots that build clang-tools-extra.

Removed:
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=293267&r1=293266&r2=293267&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Fri Jan 27 
01:19:22 2017
@@ -20,7 +20,6 @@ add_clang_library(clangTidyModernizeModu
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
-  UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseTransparentFunctorsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=293267&r1=293266&r2=293267&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Fri 
Jan 27 01:19:22 2017
@@ -26,7 +26,6 @@
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
-#include "UseNoexceptCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseTransparentFunctorsCheck.h"
@@ -64,7 +63,6 @@ public:
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
-CheckFactories.registerCheck("modernize-use-noexcept");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
 CheckFactories.registerCheck(

Removed: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=293266&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp (removed)
@@ -1,114 +0,0 @@
-//===--- UseNoexceptCheck.cpp - 
clang-tidy-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "UseNoexceptCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Lex/Lexer.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace modernize {
-
-UseNoexceptCheck::UseNoexceptCheck(StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  NoexceptMacro(Options.get("ReplacementString", "")),
-  UseNoexceptFalse(Options.get("UseNoexceptFalse", true)) {}
-
-void UseNoexceptCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
-  Options.store(Opts, "ReplacementString", NoexceptMacro);
-  Options.store(Opts, "UseNoexceptFalse", UseNoexceptFalse);
-}
-
-void UseNoexceptCheck::registerMatchers(MatchFinder *Finder) {
-  if (!getLangOpts().CPlusPlus11)
-return;
-
-  Finder->addMatcher(
-  functionDecl(
-  cxxMethodDecl(
-  hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec(,
-  anyOf(hasOverloadedOperatorName("delete[]"),
-hasOverloadedOperatorName("delete"), cxxDestructorDecl()))
-  .bind("del-dtor"))
-  .bind("funcDecl"),
-  this);
-
-  Finder->addMatcher(
-  functionDecl(
-  hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSp

[PATCH] D29151: [clang-tidy] Add misc-invalidated-iterators check.

2017-01-26 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

The static analyzer is definitely the place to go for bug detection that 
requires path sensitivity. It's also reasonably good for anything that needs 
flow-sensitivity. Although, most flow-sensitive analysis (such as liveness) now 
live in lib/Analysis/, which is used by both Sema and the Clang Static 
Analyzer. Both path-sensitive and flow-sensitive analysis are based on clang's 
CFG. I do not know of clang-tidy uses CFG or lib/Analysis/.

Here are the wikipedia definitions of sensitivity I am referring to:
//- A flow-sensitive analysis takes into account the order of statements in a 
program. For example, a flow-insensitive pointer alias analysis may determine 
"variables x and y may refer to the same location", while a flow-sensitive 
analysis may determine "after statement 20, variables x and y may refer to the 
same location".

- A path-sensitive analysis computes different pieces of analysis information 
dependent on the predicates at conditional branch instructions. For instance, 
if a branch contains a condition x>0, then on the fall-through path, the 
analysis would assume that x<=0 and on the target of the branch it would assume 
that indeed x>0 holds. //

There is work underway in the analyzer for adding IteratorPastEnd checker. The 
first commit was rather large and has been reviewed here 
https://reviews.llvm.org/D25660. That checker is very close to be moved out of 
alpha. Moving it out of alpha is pending evaluation on real codebases to ensure 
that the false positive rates are low and enhancements to error reporting.

> Other problem is that it would be probably a part 
>  of one of the alpha checks, that are not developed and I don't know if they 
> will ever be fully supported.

There seems to be a misconception about what the alpha checkers are. All 
checkers start in alpha package to allow in-tree incremental development. Once 
the checkers are complete, they should move out of alpha. The criteria is that 
the code should pass the review, the checker needs to have low false positive 
rates, finally, the error reports should be of good quality (some checks 
greatly benefit from extra path hints that can be implemented with a visitor). 
These are motivated by providing a good user experience to end users. (We do 
have several checkers that are "stuck in alpha". A lot of them are abandoned 
experiments that just need to be deleted; others could probably be made 
production quality with some extra effort.)


Repository:
  rL LLVM

https://reviews.llvm.org/D29151



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


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

2017-01-26 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D29209

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


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


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


[PATCH] D25402: [Driver] Pass -lunwind along with compiler-rt when necessary on Linux

2017-01-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.

This really needs a new driver flag (`-unwinder`?) similar to `-rtlib`, as 
there are multiple unwinders, and it is unclear which unwinder is the proper 
one on a given target.  This has been something on my TODO list for a while.  
Mixing and matching undwinders is not really possible, and it is perfectly 
valid to use compiler-rt with the gcc unwinder on Linux.


https://reviews.llvm.org/D25402



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


[PATCH] D29208: Prevent ICE in dllexport class with _Atomic() data member

2017-01-26 Thread Warren Ristow via Phabricator via cfe-commits
wristow added a comment.

When a class that has been tagged as dllexport (for an MSVC target) contains an 
atomic data member via the C11 '_Atomic' approach, the front end crashes with a 
null pointer dereference.
This patch fixes it by guarding the null dereference with the approach used by 
similar code in the same method.


https://reviews.llvm.org/D29208



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


Re: [libunwind] r292723 - X86: swap EBP, ESP on !APPLE

2017-01-26 Thread Saleem Abdulrasool via cfe-commits
I think that this is safe enough and does make libunwind work on x86 Linux,
so lets go for it.

On Thu, Jan 26, 2017 at 10:10 AM, Hans Wennborg  wrote:

> Michał suggested on the PR that this should be merged to the release
> branch.
>
> Saleem, what do you think?
>
> On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
>  wrote:
> > Author: compnerd
> > Date: Sat Jan 21 10:22:59 2017
> > New Revision: 292723
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=292723&view=rev
> > Log:
> > X86: swap EBP, ESP on !APPLE
> >
> > Restore the `libunwind.h` enumeration values back to the inverted
> > values.  This diverges from the DWARF definition of the register values.
> > However, this allows our header to be compatible with other unwind
> > implementations (e.g. HP, GNU Savannah, GCC).
> >
> > The register IDs are only swapped in the header and need to be unswapped
> > when accessing the unwind register file.  The flipped EBP and ESP only
> > applies on non-Apple x86 targets.
> >
> > When optimizations were enabled, EBP and ESP would no longer be
> > equivalent.  As a result, the incorrect access on Linux would manifest
> > as a failure to unwind the stack.  We can now unwind the stack with and
> > without FPO on Linux x86.
> >
> > Resolves PR30879!
> >
> > Modified:
> > libunwind/trunk/include/libunwind.h
> > libunwind/trunk/src/Registers.hpp
> >
> > Modified: libunwind/trunk/include/libunwind.h
> > URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/
> include/libunwind.h?rev=292723&r1=292722&r2=292723&view=diff
> > 
> ==
> > --- libunwind/trunk/include/libunwind.h (original)
> > +++ libunwind/trunk/include/libunwind.h Sat Jan 21 10:22:59 2017
> > @@ -165,13 +165,8 @@ enum {
> >UNW_X86_ECX = 1,
> >UNW_X86_EDX = 2,
> >UNW_X86_EBX = 3,
> > -#if defined(__CloudABI__) || defined(__FreeBSD__)
> > -  UNW_X86_ESP = 4,
> > -  UNW_X86_EBP = 5,
> > -#else
> >UNW_X86_EBP = 4,
> >UNW_X86_ESP = 5,
> > -#endif
> >UNW_X86_ESI = 6,
> >UNW_X86_EDI = 7
> >  };
> >
> > Modified: libunwind/trunk/src/Registers.hpp
> > URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/
> Registers.hpp?rev=292723&r1=292722&r2=292723&view=diff
> > 
> ==
> > --- libunwind/trunk/src/Registers.hpp (original)
> > +++ libunwind/trunk/src/Registers.hpp Sat Jan 21 10:22:59 2017
> > @@ -122,9 +122,17 @@ inline uint32_t Registers_x86::getRegist
> >  return _registers.__edx;
> >case UNW_X86_EBX:
> >  return _registers.__ebx;
> > +#if !defined(__APPLE__)
> > +  case UNW_X86_ESP:
> > +#else
> >case UNW_X86_EBP:
> > +#endif
> >  return _registers.__ebp;
> > +#if !defined(__APPLE__)
> > +  case UNW_X86_EBP:
> > +#else
> >case UNW_X86_ESP:
> > +#endif
> >  return _registers.__esp;
> >case UNW_X86_ESI:
> >  return _registers.__esi;
> > @@ -154,10 +162,18 @@ inline void Registers_x86::setRegister(i
> >case UNW_X86_EBX:
> >  _registers.__ebx = value;
> >  return;
> > +#if !defined(__APPLE__)
> > +  case UNW_X86_ESP:
> > +#else
> >case UNW_X86_EBP:
> > +#endif
> >  _registers.__ebp = value;
> >  return;
> > +#if !defined(__APPLE__)
> > +  case UNW_X86_EBP:
> > +#else
> >case UNW_X86_ESP:
> > +#endif
> >  _registers.__esp = value;
> >  return;
> >case UNW_X86_ESI:
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29208: Prevent ICE in dllexport class with _Atomic() data member

2017-01-26 Thread Warren Ristow via Phabricator via cfe-commits
wristow created this revision.

Guard against a null pointer dereference that caused Clang to crash
when processing a class containing an _Atomic() data member,
and that is tagged with 'dllexport'.


https://reviews.llvm.org/D29208

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/atomic-dllexport.cpp


Index: test/CodeGenCXX/atomic-dllexport.cpp
===
--- test/CodeGenCXX/atomic-dllexport.cpp
+++ test/CodeGenCXX/atomic-dllexport.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++11 
-fms-extensions -O0 -o - %s | FileCheck --check-prefix=M32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++11 
-fms-extensions -O0 -o - %s | FileCheck --check-prefix=M64 %s
+
+struct __declspec(dllexport) SomeStruct {
+  // Copy assignment operator should be produced, and exported:
+  // M32: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) 
%struct.SomeStruct* @"\01??4SomeStruct@@QAEAAU0@ABU0@@Z"
+  // M64: define weak_odr dllexportdereferenceable({{[0-9]+}}) 
%struct.SomeStruct* @"\01??4SomeStruct@@QEAAAEAU0@AEBU0@@Z"
+  _Atomic(int) mData;
+};
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1132,7 +1132,7 @@
 if (!RHS)
   return nullptr;
 MemberExpr *ME2 = dyn_cast(RHS);
-if (dyn_cast(ME2->getMemberDecl()) != Field)
+if (!ME2 || dyn_cast(ME2->getMemberDecl()) != Field)
   return nullptr;
 return Field;
   } else if (CXXMemberCallExpr *MCE = dyn_cast(S)) {


Index: test/CodeGenCXX/atomic-dllexport.cpp
===
--- test/CodeGenCXX/atomic-dllexport.cpp
+++ test/CodeGenCXX/atomic-dllexport.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++11 -fms-extensions -O0 -o - %s | FileCheck --check-prefix=M32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++11 -fms-extensions -O0 -o - %s | FileCheck --check-prefix=M64 %s
+
+struct __declspec(dllexport) SomeStruct {
+  // Copy assignment operator should be produced, and exported:
+  // M32: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.SomeStruct* @"\01??4SomeStruct@@QAEAAU0@ABU0@@Z"
+  // M64: define weak_odr dllexportdereferenceable({{[0-9]+}}) %struct.SomeStruct* @"\01??4SomeStruct@@QEAAAEAU0@AEBU0@@Z"
+  _Atomic(int) mData;
+};
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1132,7 +1132,7 @@
 if (!RHS)
   return nullptr;
 MemberExpr *ME2 = dyn_cast(RHS);
-if (dyn_cast(ME2->getMemberDecl()) != Field)
+if (!ME2 || dyn_cast(ME2->getMemberDecl()) != Field)
   return nullptr;
 return Field;
   } else if (CXXMemberCallExpr *MCE = dyn_cast(S)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libunwind] r292721 - DWARF: convert error logs to _LIBUNWIND_LOG

2017-01-26 Thread Saleem Abdulrasool via cfe-commits
Sorry, somehow I missed that.  Ive gone ahead and reverted this change for
now (SVN r293257).

On Thu, Jan 26, 2017 at 2:30 PM, Evgenii Stepanov  wrote:

> Actually, the bot has been red since Jan 21 with this exact error.
>
> On Thu, Jan 26, 2017 at 2:27 PM, Evgenii Stepanov
>  wrote:
> > Hi,
> >
> > I'm not sure why we only see this now, but this change is breaking
> > llvm bootstrap with -Werror:
> > http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux/builds/732/steps/bootstrap%20clang/logs/stdio
> >
> > llvm/projects/libunwind/src/config.h:90:41: error: token pasting of
> > ',' and __VA_ARGS__ is a GNU extension
> > [-Werror,-Wgnu-zero-variadic-macro-arguments]
> >   fprintf(stderr, "libunwind: " msg "\n", ##__VA_ARGS__)
> >
> > On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
> >  wrote:
> >> Author: compnerd
> >> Date: Sat Jan 21 10:22:55 2017
> >> New Revision: 292721
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=292721&view=rev
> >> Log:
> >> DWARF: convert error logs to _LIBUNWIND_LOG
> >>
> >> Use the `_LIBUNWIND_LOG` macro instead of the explicit `fprintf` call.
> >> NFC.
> >>
> >> Modified:
> >> libunwind/trunk/src/DwarfParser.hpp
> >> libunwind/trunk/src/config.h
> >>
> >> Modified: libunwind/trunk/src/DwarfParser.hpp
> >> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/
> DwarfParser.hpp?rev=292721&r1=292720&r2=292721&view=diff
> >> 
> ==
> >> --- libunwind/trunk/src/DwarfParser.hpp (original)
> >> +++ libunwind/trunk/src/DwarfParser.hpp Sat Jan 21 10:22:55 2017
> >> @@ -421,8 +421,7 @@ bool CFI_Parser::parseInstructions(A
> >>offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
> >>*
> cieInfo.dataAlignFactor;
> >>if (reg > kMaxRegisterNumber) {
> >> -fprintf(stderr,
> >> -"malformed DW_CFA_offset_extended DWARF unwind, reg
> too big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_offset_extended, reg
> too big");
> >>  return false;
> >>}
> >>results->savedRegisters[reg].location = kRegisterInCFA;
> >> @@ -436,9 +435,7 @@ bool CFI_Parser::parseInstructions(A
> >>reg = addressSpace.getULEB128(p, instructionsEnd);
> >>;
> >>if (reg > kMaxRegisterNumber) {
> >> -fprintf(
> >> -stderr,
> >> -"malformed DW_CFA_restore_extended DWARF unwind, reg too
> big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_restore_extended, reg
> too big");
> >>  return false;
> >>}
> >>results->savedRegisters[reg] = initialState.savedRegisters[reg];
> >> @@ -448,8 +445,7 @@ bool CFI_Parser::parseInstructions(A
> >>  case DW_CFA_undefined:
> >>reg = addressSpace.getULEB128(p, instructionsEnd);
> >>if (reg > kMaxRegisterNumber) {
> >> -fprintf(stderr,
> >> -"malformed DW_CFA_undefined DWARF unwind, reg too
> big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_undefined, reg too
> big");
> >>  return false;
> >>}
> >>results->savedRegisters[reg].location = kRegisterUnused;
> >> @@ -459,8 +455,7 @@ bool CFI_Parser::parseInstructions(A
> >>  case DW_CFA_same_value:
> >>reg = addressSpace.getULEB128(p, instructionsEnd);
> >>if (reg > kMaxRegisterNumber) {
> >> -fprintf(stderr,
> >> -"malformed DW_CFA_same_value DWARF unwind, reg too
> big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_same_value, reg too
> big");
> >>  return false;
> >>}
> >>//  DW_CFA_same_value unsupported
> >> @@ -477,13 +472,11 @@ bool CFI_Parser::parseInstructions(A
> >>reg = addressSpace.getULEB128(p, instructionsEnd);
> >>reg2 = addressSpace.getULEB128(p, instructionsEnd);
> >>if (reg > kMaxRegisterNumber) {
> >> -fprintf(stderr,
> >> -"malformed DW_CFA_register DWARF unwind, reg too
> big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg too big");
> >>  return false;
> >>}
> >>if (reg2 > kMaxRegisterNumber) {
> >> -fprintf(stderr,
> >> -"malformed DW_CFA_register DWARF unwind, reg2 too
> big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg2 too
> big");
> >>  return false;
> >>}
> >>results->savedRegisters[reg].location = kRegisterInRegister;
> >> @@ -525,7 +518,7 @@ bool CFI_Parser::parseInstructions(A
> >>reg = addressSpace.getULEB128(p, instructionsEnd);
> >>offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd);
> >>if (reg > kMaxRegisterNumber) {
> >> -fprintf(stderr, "malformed DW_CFA_def_cfa DWARF unwind, reg
> too big\n");
> >> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa, reg too big");
> >>  return false;
> >>  

[libunwind] r293257 - Revert "DWARF: convert error logs to _LIBUNWIND_LOG"

2017-01-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan 26 20:26:52 2017
New Revision: 293257

URL: http://llvm.org/viewvc/llvm-project?rev=293257&view=rev
Log:
Revert "DWARF: convert error logs to _LIBUNWIND_LOG"

This reverts SVN r292721.  Avoid the use of the GNU extension as the
preprocessor in C++11 mode requires at least one argument, and this
warning cannot be disabled, resulting in failing -Werror builds.

Modified:
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=293257&r1=293256&r2=293257&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Thu Jan 26 20:26:52 2017
@@ -416,7 +416,8 @@ bool CFI_Parser::parseInstructions(A
   offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
   * cieInfo.dataAlignFactor;
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_offset_extended, reg too big");
+fprintf(stderr,
+"malformed DW_CFA_offset_extended DWARF unwind, reg too 
big\n");
 return false;
   }
   results->savedRegisters[reg].location = kRegisterInCFA;
@@ -428,7 +429,9 @@ bool CFI_Parser::parseInstructions(A
 case DW_CFA_restore_extended:
   reg = addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_restore_extended, reg too big");
+fprintf(
+stderr,
+"malformed DW_CFA_restore_extended DWARF unwind, reg too big\n");
 return false;
   }
   results->savedRegisters[reg] = initialState.savedRegisters[reg];
@@ -437,7 +440,8 @@ bool CFI_Parser::parseInstructions(A
 case DW_CFA_undefined:
   reg = addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_undefined, reg too big");
+fprintf(stderr,
+"malformed DW_CFA_undefined DWARF unwind, reg too big\n");
 return false;
   }
   results->savedRegisters[reg].location = kRegisterUnused;
@@ -446,7 +450,8 @@ bool CFI_Parser::parseInstructions(A
 case DW_CFA_same_value:
   reg = addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_same_value, reg too big");
+fprintf(stderr,
+"malformed DW_CFA_same_value DWARF unwind, reg too big\n");
 return false;
   }
   //  DW_CFA_same_value unsupported
@@ -462,11 +467,13 @@ bool CFI_Parser::parseInstructions(A
   reg = addressSpace.getULEB128(p, instructionsEnd);
   reg2 = addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg too big");
+fprintf(stderr,
+"malformed DW_CFA_register DWARF unwind, reg too big\n");
 return false;
   }
   if (reg2 > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg2 too big");
+fprintf(stderr,
+"malformed DW_CFA_register DWARF unwind, reg2 too big\n");
 return false;
   }
   results->savedRegisters[reg].location = kRegisterInRegister;
@@ -505,7 +512,7 @@ bool CFI_Parser::parseInstructions(A
   reg = addressSpace.getULEB128(p, instructionsEnd);
   offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa, reg too big");
+fprintf(stderr, "malformed DW_CFA_def_cfa DWARF unwind, reg too 
big\n");
 return false;
   }
   results->cfaRegister = (uint32_t)reg;
@@ -516,7 +523,9 @@ bool CFI_Parser::parseInstructions(A
 case DW_CFA_def_cfa_register:
   reg = addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa_register, reg too big");
+fprintf(
+stderr,
+"malformed DW_CFA_def_cfa_register DWARF unwind, reg too big\n");
 return false;
   }
   results->cfaRegister = (uint32_t)reg;
@@ -541,7 +550,8 @@ bool CFI_Parser::parseInstructions(A
 case DW_CFA_expression:
   reg = addressSpace.getULEB128(p, instructionsEnd);
   if (reg > kMaxRegisterNumber) {
-_LIBUNWIND_LOG("malformed DWARF DW_CFA_expression, reg too big");
+fprintf(stderr,
+"malformed DW_CFA_expression DWARF unwind, reg too big\n");
 return false;
   }
   results->savedRegisters[reg].location = kRegisterAtExpression;
@@ -556,8 +566,9 @@ bool CFI_Parser::parseInstructions(A
 case DW_CFA_offset_extended_sf:
   reg = addressSpace.getULEB128(p, instru

[PATCH] D29198: clang-cl: Warn about /U flags that look like filenames (PR31662)

2017-01-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.

Thanks for adding this, diagnosing what was going on here the first time around 
took a little bit of thinking.


https://reviews.llvm.org/D29198



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


[PATCH] D26345: Extend small data threshold driver options to PPC target

2017-01-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

As of r293254, the `-G=` and `-msmall-data-threshold=` flags are just aliases 
of `-G`, so you don't need those parts of this patch any more. The PPC part 
looks fine, but please add a testcase.

In future, please add cfe-commits as a subscriber to Clang changes; otherwise 
mail doesn't get sent there and patches tend to get lost.


https://reviews.llvm.org/D26345



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


r293254 - [docs] Add help text and refine grouping for various options.

2017-01-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 26 20:08:37 2017
New Revision: 293254

URL: http://llvm.org/viewvc/llvm-project?rev=293254&view=rev
Log:
[docs] Add help text and refine grouping for various options.

Also accept -G= (and -msmall-data-threshold=) as an alias for -G on MIPS as 
well as Hexagon.

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=293254&r1=293253&r2=293254&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Jan 26 20:08:37 2017
@@ -18,30 +18,14 @@ GCC-compatible ``clang`` and ``clang++``
 
 
 .. program:: clang
-.. option:: -A, --assert , --assert=
-
-.. option:: -B, --prefix , --prefix=
+.. option:: -B, --prefix , --prefix=
 
-.. option:: -C, --comments
-
-.. option:: -CC, --comments-in-macros
+Add  to search path for binaries and object files used implicitly
 
 .. option:: -F
 
 Add directory to framework include search path
 
-.. option:: -G
-
-.. program:: clang1
-.. option:: -G=
-.. program:: clang
-
-.. option:: -H, --trace-includes
-
-Show header includes and nesting depth
-
-.. option:: -Mach
-
 .. option:: -ObjC
 
 Treat source input files as Objective-C inputs
@@ -52,14 +36,6 @@ Treat source input files as Objective-C
 
 Treat source input files as Objective-C++ inputs
 
-.. option:: -P, --no-line-commands
-
-Disable linemarker output in -E mode
-
-.. option:: -Q
-
-.. option:: -Qn
-
 .. option:: -Qunused-arguments
 
 Don't emit warning for unused driver arguments
@@ -70,26 +46,8 @@ Pass the comma separated arguments in 
 
-.. option:: -Wp,,...
-
-Pass the comma separated arguments in  to the preprocessor
-
-.. option:: -X
-
-.. program:: clang1
-.. option:: -X
-.. program:: clang
-
-.. option:: -Xanalyzer 
-
-Pass  to the static analyzer
-
 .. option:: -Xarch\_ 
 
-.. option:: -Xassembler 
-
-Pass  to the assembler
-
 .. option:: -Xcuda-fatbinary 
 
 Pass  to fatbinary invocation
@@ -98,10 +56,6 @@ Pass  to fatbinary invocation
 
 Pass  to the ptxas assembler
 
-.. option:: -Xpreprocessor 
-
-Pass  to the preprocessor
-
 .. option:: -Z
 
 .. option:: -a, --profile-blocks
@@ -150,10 +104,6 @@ Output path for the plist report
 .. option:: -bundle\_loader 
 .. program:: clang
 
-.. option:: -c, --compile
-
-Only run preprocess, compile, and assemble steps
-
 .. option:: -client\_name
 
 .. option:: -compatibility\_version
@@ -650,6 +600,10 @@ Only run the preprocessor
 
 Only run preprocess and compilation steps
 
+.. option:: -c, --compile
+
+Only run preprocess, compile, and assemble steps
+
 .. option:: -emit-llvm
 
 Use the LLVM representation for assembler and object files
@@ -678,9 +632,9 @@ Compilation flags
 Flags controlling the behavior of Clang during compilation. These flags have
 no effect during actions that do not perform compilation.
 
-.. option:: -D, --define-macro , --define-macro=
+.. option:: -Xassembler 
 
-.. option:: -U, --undefine-macro , --undefine-macro=
+Pass  to the assembler
 
 .. option:: -Xclang 
 
@@ -810,17 +764,56 @@ Turn on runtime checks for various forms
 
 Language standard to compile for
 
+Preprocessor flags
+~~
+
+Flags controlling the behavior of the Clang preprocessor.
+
+.. option:: -C, --comments
+
+Include comments in preprocessed output
+
+.. option:: -CC, --comments-in-macros
+
+Include comments from within macros in preprocessed output
+
+.. option:: -D=, --define-macro , --define-macro=
+
+Define  to  (or 1 if  omitted)
+
+.. option:: -H, --trace-includes
+
+Show header includes and nesting depth
+
+.. option:: -P, --no-line-commands
+
+Disable linemarker output in -E mode
+
+.. option:: -U, --undefine-macro , --undefine-macro=
+
+Undefine macro 
+
+.. option:: -Wp,,...
+
+Pass the comma separated arguments in  to the preprocessor
+
+.. option:: -Xpreprocessor 
+
+Pass  to the preprocessor
+
 Include path management
-~~~
+---
 
 Flags controlling how ``#include``\s are resolved to files.
 
-.. option:: -I, --include-directory , --include-directory=
+.. option:: -I, --include-directory , --include-directory=
 
 Add directory to include search path
 
 .. option:: -I-, --include-barrier
 
+Restrict all prior -I flags to double-quoted inclusion and remove current 
directory from include path
+
 .. option:: --cuda-path=
 
 CUDA installation path
@@ -936,7 +929,7 @@ Path to ptxas (used for compiling CUDA c
 Treat all #include paths starting with  as including a system header.
 
 Dependency file generation
-~~
+--
 
 Flags controlling generation of a dependency file for ``make``-like build
 systems.
@@ -986,7 +979,7 @@ Specify name of main file output in depf

Re: [libcxx] r292607 - Don't default older GCC's to C++17, but C++14 or C++11 instead

2017-01-26 Thread Marshall Clow via cfe-commits
On Thu, Jan 26, 2017 at 10:22 AM, Hans Wennborg  wrote:

> What's the status here? Waiting for Marshall?
>

I'm fine with merging this to the 4.0 branch

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


r293252 - Improve workaround for Sphinx's lack of support for command line options containing '+', '.' etc. to be more stable as the set of options changes.

2017-01-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 26 19:54:42 2017
New Revision: 293252

URL: http://llvm.org/viewvc/llvm-project?rev=293252&view=rev
Log:
Improve workaround for Sphinx's lack of support for command line options 
containing '+', '.' etc. to be more stable as the set of options changes.

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=293252&r1=293251&r2=293252&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Jan 26 19:54:42 2017
@@ -18,835 +18,656 @@ GCC-compatible ``clang`` and ``clang++``
 
 
 .. program:: clang
-.. program:: clang0
 .. option:: -A, --assert , --assert=
 
-.. program:: clang1
 .. option:: -B, --prefix , --prefix=
 
-.. program:: clang2
 .. option:: -C, --comments
 
-.. program:: clang3
 .. option:: -CC, --comments-in-macros
 
-.. program:: clang4
 .. option:: -F
 
 Add directory to framework include search path
 
-.. program:: clang5
 .. option:: -G
 
-.. program:: clang6
+.. program:: clang1
 .. option:: -G=
+.. program:: clang
 
-.. program:: clang7
 .. option:: -H, --trace-includes
 
 Show header includes and nesting depth
 
-.. program:: clang8
 .. option:: -Mach
 
-.. program:: clang9
 .. option:: -ObjC
 
 Treat source input files as Objective-C inputs
 
-.. program:: clang10
+.. program:: clang1
 .. option:: -ObjC++
+.. program:: clang
 
 Treat source input files as Objective-C++ inputs
 
-.. program:: clang11
 .. option:: -P, --no-line-commands
 
 Disable linemarker output in -E mode
 
-.. program:: clang12
 .. option:: -Q
 
-.. program:: clang13
 .. option:: -Qn
 
-.. program:: clang14
 .. option:: -Qunused-arguments
 
 Don't emit warning for unused driver arguments
 
-.. program:: clang15
 .. option:: -Wa,,...
 
 Pass the comma separated arguments in  to the assembler
 
-.. program:: clang16
 .. option:: -Wlarge-by-value-copy=
 
-.. program:: clang17
 .. option:: -Wp,,...
 
 Pass the comma separated arguments in  to the preprocessor
 
-.. program:: clang18
 .. option:: -X
 
-.. program:: clang19
+.. program:: clang1
 .. option:: -X
+.. program:: clang
 
-.. program:: clang20
 .. option:: -Xanalyzer 
 
 Pass  to the static analyzer
 
-.. program:: clang21
 .. option:: -Xarch\_ 
 
-.. program:: clang22
 .. option:: -Xassembler 
 
 Pass  to the assembler
 
-.. program:: clang23
 .. option:: -Xcuda-fatbinary 
 
 Pass  to fatbinary invocation
 
-.. program:: clang24
 .. option:: -Xcuda-ptxas 
 
 Pass  to the ptxas assembler
 
-.. program:: clang25
 .. option:: -Xpreprocessor 
 
 Pass  to the preprocessor
 
-.. program:: clang26
 .. option:: -Z
 
-.. program:: clang27
 .. option:: -a, --profile-blocks
 
-.. program:: clang28
 .. option:: -all\_load
 
-.. program:: clang29
 .. option:: -allowable\_client 
 
-.. program:: clang30
 .. option:: --analyze
 
 Run the static analyzer
 
-.. program:: clang31
 .. option:: --analyze-auto
 
-.. program:: clang32
 .. option:: --analyzer-no-default-checks
 
-.. program:: clang33
 .. option:: --analyzer-output
 
 Static analyzer report output format 
(html\|plist\|plist-multi-file\|plist-html\|text).
 
-.. program:: clang34
 .. option:: -ansi, --ansi
 
-.. program:: clang35
 .. option:: -arch 
 
-.. program:: clang36
+.. program:: clang1
 .. option:: -arch\_errors\_fatal
+.. program:: clang
 
-.. program:: clang37
+.. program:: clang2
 .. option:: -arch\_only 
+.. program:: clang
 
-.. program:: clang38
 .. option:: -arcmt-migrate-emit-errors
 
 Emit ARC errors even if the migrator can fix them
 
-.. program:: clang39
 .. option:: -arcmt-migrate-report-output 
 
 Output path for the plist report
 
-.. program:: clang40
 .. option:: -bind\_at\_load
 
-.. program:: clang41
 .. option:: -bundle
 
-.. program:: clang42
+.. program:: clang1
 .. option:: -bundle\_loader 
+.. program:: clang
 
-.. program:: clang43
 .. option:: -c, --compile
 
 Only run preprocess, compile, and assemble steps
 
-.. program:: clang44
 .. option:: -client\_name
 
-.. program:: clang45
 .. option:: -compatibility\_version
 
-.. program:: clang46
 .. option:: --constant-cfstrings
 
-.. program:: clang47
 .. option:: -coverage, --coverage
 
-.. program:: clang48
 .. option:: --cuda-compile-host-device
 
 Compile CUDA code for both host and device (default).  Has no effect on 
non-CUDA compilations.
 
-.. program:: clang49
 .. option:: --cuda-device-only
 
 Compile CUDA code for device only
 
-.. program:: clang50
 .. option:: --cuda-gpu-arch=, --no-cuda-gpu-arch=
 
 CUDA GPU architecture (e.g. sm\_35).  May be specified more than once.
 
-.. program:: clang51
 .. option:: --cuda-host-only
 
 Compile CUDA code for host only.  Has no effect on non-CUDA compilations.
 
-.. program:: clang52
 .. option:: --cuda-noopt-device-de

LLVM buildmaster will be updated and restarted tonight

2017-01-26 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


Re: r292561 - PR31701: Fix crash on invalid caused by parsing a dependent initializer when we

2017-01-26 Thread Richard Smith via cfe-commits
Sure, why not.

On 26 January 2017 at 15:56, Hans Wennborg  wrote:

> A candidate for clang 4?
>
> On Thu, Jan 19, 2017 at 5:19 PM, Richard Smith via cfe-commits
>  wrote:
> > Author: rsmith
> > Date: Thu Jan 19 19:19:46 2017
> > New Revision: 292561
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=292561&view=rev
> > Log:
> > PR31701: Fix crash on invalid caused by parsing a dependent initializer
> when we
> > don't know we're in a dependent context.
> >
> > Modified:
> > cfe/trunk/lib/AST/ASTContext.cpp
> > cfe/trunk/test/SemaCXX/constant-expression.cpp
> >
> > Modified: cfe/trunk/lib/AST/ASTContext.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ASTContext.cpp?rev=292561&r1=292560&r2=292561&view=diff
> > 
> ==
> > --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> > +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jan 19 19:19:46 2017
> > @@ -9021,7 +9021,8 @@ bool ASTContext::DeclMustBeEmitted(const
> >
> >// Variables that have initialization with side-effects are required.
> >if (VD->getInit() && VD->getInit()->HasSideEffects(*this) &&
> > -  !VD->evaluateValue())
> > +  // We can get a value-dependent initializer during error recovery.
> > +  (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
> >  return true;
> >
> >// Likewise, variables with tuple-like bindings are required if their
> >
> > Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/constant-expression.cpp?rev=292561&r1=292560&r2=292561&view=diff
> > 
> ==
> > --- cfe/trunk/test/SemaCXX/constant-expression.cpp (original)
> > +++ cfe/trunk/test/SemaCXX/constant-expression.cpp Thu Jan 19 19:19:46
> 2017
> > @@ -143,3 +143,14 @@ namespace rdar16064952 {
> >  }
> >
> >  char PR17381_ice = 100 * 100; // expected-warning {{overflow}}
> expected-warning {{changes value}}
> > +
> > +namespace PR31701 {
> > +  struct C {
> > +template static int n; // expected-warning {{extension}}
> > +  };
> > +  template  class D;
> > +  template 
> > +  template void D::set() { // expected-error {{from class
> 'D' without definition}}
> > +const C c = C::n;
> > +  }
> > +}
> >
> >
> > ___
> > 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] D29205: Change debug-info-for-profiling from a TargetOption to a function attribute.

2017-01-26 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.
Herald added a subscriber: mehdi_amini.

cfe change for https://reviews.llvm.org/D29203


https://reviews.llvm.org/D29205

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenFunction.cpp


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -793,6 +793,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add debug-info-for-profiling value.
+  Fn->addFnAttr("debug-info-for-profiling",
+llvm::toStringRef(CGM.getCodeGenOpts().DebugInfoForProfiling));
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -573,7 +573,6 @@
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
-  Options.DebugInfoForProfiling = CodeGenOpts.DebugInfoForProfiling;
 
   // Set EABI version.
   Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -793,6 +793,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add debug-info-for-profiling value.
+  Fn->addFnAttr("debug-info-for-profiling",
+llvm::toStringRef(CGM.getCodeGenOpts().DebugInfoForProfiling));
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -573,7 +573,6 @@
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
-  Options.DebugInfoForProfiling = CodeGenOpts.DebugInfoForProfiling;
 
   // Set EABI version.
   Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r293234 - [Clang-tidy documentation] Consistency (fix-it); 80 characters per line.

2017-01-26 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Jan 26 17:58:21 2017
New Revision: 293234

URL: http://llvm.org/viewvc/llvm-project?rev=293234&view=rev
Log:
[Clang-tidy documentation] Consistency (fix-it); 80 characters per line.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst?rev=293234&r1=293233&r2=293234&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst 
Thu Jan 26 17:58:21 2017
@@ -9,8 +9,8 @@ of an appropriate RAII object.
 See `C++ Core Guidelines
 
`.
 
-There is no attempt made to provide fixit hints, since manual resource 
management isn't
-easily transformed automatically into RAII.
+There is no attempt made to provide fix-it hints, since manual resource
+management isn't easily transformed automatically into RAII.
 
 .. code-block:: c++
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst?rev=293234&r1=293233&r2=293234&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
 Thu Jan 26 17:58:21 2017
@@ -4,7 +4,7 @@ cppcoreguidelines-pro-type-static-cast-d
 ===
 
 This check flags all usages of ``static_cast``, where a base class is casted to
-a derived class. In those cases, a fixit is provided to convert the cast to a
+a derived class. In those cases, a fix-it is provided to convert the cast to a
 ``dynamic_cast``.
 
 Use of these casts can violate type safety and cause the program to access a

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst?rev=293234&r1=293233&r2=293234&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst 
Thu Jan 26 17:58:21 2017
@@ -29,11 +29,10 @@ Options
 
 .. option:: ReplacementString
 
-Users can use :option:`ReplacementString` to specify a macro to use
-instead of ``noexcept``.  This is useful when maintaining source code
-that uses custom exception specification marking other than
-``noexcept``.  Fixit hints will only be generated for non-throwing
-specifications.
+Users can use :option:`ReplacementString` to specify a macro to use instead of
+``noexcept``.  This is useful when maintaining source code that uses custom
+exception specification marking other than ``noexcept``.  Fix-it hints will 
only
+be generated for non-throwing specifications.
 
 Example
 ^^^
@@ -47,18 +46,17 @@ transforms to:
 
 .. code-block:: c++
 
-  void bar() throw(int);  // No Fixit generated.
+  void bar() throw(int);  // No fix-it generated.
   void foo() NOEXCEPT;
 
 if the :option:`ReplacementString` option is set to `NOEXCEPT`.
 
 .. option:: UseNoexceptFalse
 
-Enabled by default, disabling will generate Fixit hints that remove
-throwing dynamic exception specs, e.g., ``throw()``,
-completely without providing a replacement text, except for
-destructors and delete operators that are ``noexcept(true)`` by
-default.
+Enabled by default, disabling will generate fix-it hints that remove throwing
+dynamic exception specs, e.g., ``throw()``, completely without
+providing a replacement text, except for destructors and delete operators that
+are ``noexcept(true)`` by default.
 
 Example
 ^^^

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=293234&r1=293233&r2=293234&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.

r293231 - Re-apply r292662, "IRGen: Start using the WriteThinLTOBitcode pass."

2017-01-26 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Jan 26 17:51:50 2017
New Revision: 293231

URL: http://llvm.org/viewvc/llvm-project?rev=293231&view=rev
Log:
Re-apply r292662, "IRGen: Start using the WriteThinLTOBitcode pass."

The internal build issue has been resolved.

Added:
cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=293231&r1=293230&r2=293231&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan 26 17:51:50 2017
@@ -684,9 +684,11 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=293231&r1=293230&r2=293231&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu Jan 26 17:51:50 2017
@@ -88,6 +88,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-bcanalyzer
 llvm-cat
 llvm-dis
+llvm-modextract
 llvm-nm
 llvm-objdump
 llvm-profdata

Added: cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp?rev=293231&view=auto
==
--- cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp Thu Jan 26 17:51:50 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}


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


Re: r292561 - PR31701: Fix crash on invalid caused by parsing a dependent initializer when we

2017-01-26 Thread Hans Wennborg via cfe-commits
A candidate for clang 4?

On Thu, Jan 19, 2017 at 5:19 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Jan 19 19:19:46 2017
> New Revision: 292561
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292561&view=rev
> Log:
> PR31701: Fix crash on invalid caused by parsing a dependent initializer when 
> we
> don't know we're in a dependent context.
>
> Modified:
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/test/SemaCXX/constant-expression.cpp
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=292561&r1=292560&r2=292561&view=diff
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jan 19 19:19:46 2017
> @@ -9021,7 +9021,8 @@ bool ASTContext::DeclMustBeEmitted(const
>
>// Variables that have initialization with side-effects are required.
>if (VD->getInit() && VD->getInit()->HasSideEffects(*this) &&
> -  !VD->evaluateValue())
> +  // We can get a value-dependent initializer during error recovery.
> +  (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
>  return true;
>
>// Likewise, variables with tuple-like bindings are required if their
>
> Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=292561&r1=292560&r2=292561&view=diff
> ==
> --- cfe/trunk/test/SemaCXX/constant-expression.cpp (original)
> +++ cfe/trunk/test/SemaCXX/constant-expression.cpp Thu Jan 19 19:19:46 2017
> @@ -143,3 +143,14 @@ namespace rdar16064952 {
>  }
>
>  char PR17381_ice = 100 * 100; // expected-warning {{overflow}} 
> expected-warning {{changes value}}
> +
> +namespace PR31701 {
> +  struct C {
> +template static int n; // expected-warning {{extension}}
> +  };
> +  template  class D;
> +  template 
> +  template void D::set() { // expected-error {{from class 'D' 
> without definition}}
> +const C c = C::n;
> +  }
> +}
>
>
> ___
> 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] D29198: clang-cl: Warn about /U flags that look like filenames (PR31662)

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

lgtm


https://reviews.llvm.org/D29198



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


Re: r292194 - [AST] AttributedType should derive type properties from the EquivalentType

2017-01-26 Thread Hans Wennborg via cfe-commits
Should we merge this to the release branch?

On Mon, Jan 16, 2017 at 8:14 PM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Mon Jan 16 22:14:25 2017
> New Revision: 292194
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292194&view=rev
> Log:
> [AST] AttributedType should derive type properties from the EquivalentType
>
> Using the canonical type instead of the equivalent type can result in
> insufficient template instantiations.
>
> This fixes PR31656.
>
> Differential Revision: https://reviews.llvm.org/D28788
>
> Modified:
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/test/CodeGenCXX/microsoft-abi-default-cc.cpp
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=292194&r1=292193&r2=292194&view=diff
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Mon Jan 16 22:14:25 2017
> @@ -3832,13 +3832,13 @@ private:
>
>friend class ASTContext; // creates these
>
> -  AttributedType(QualType canon, Kind attrKind,
> - QualType modified, QualType equivalent)
> -: Type(Attributed, canon, canon->isDependentType(),
> -   canon->isInstantiationDependentType(),
> -   canon->isVariablyModifiedType(),
> -   canon->containsUnexpandedParameterPack()),
> -  ModifiedType(modified), EquivalentType(equivalent) {
> +  AttributedType(QualType canon, Kind attrKind, QualType modified,
> + QualType equivalent)
> +  : Type(Attributed, canon, equivalent->isDependentType(),
> + equivalent->isInstantiationDependentType(),
> + equivalent->isVariablyModifiedType(),
> + equivalent->containsUnexpandedParameterPack()),
> +ModifiedType(modified), EquivalentType(equivalent) {
>  AttributedTypeBits.AttrKind = attrKind;
>}
>
>
> Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-default-cc.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-default-cc.cpp?rev=292194&r1=292193&r2=292194&view=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-default-cc.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-default-cc.cpp Mon Jan 16 
> 22:14:25 2017
> @@ -45,3 +45,12 @@ void __cdecl static_baz() {}
>  void static_qux() {}
>  // GCABI-LABEL: define void @_Z10static_quxv
>  // MSABI: define void @"\01?static_qux@@YAXXZ"
> +
> +namespace PR31656 {
> +template 
> +void __cdecl callee(int args[I]);
> +// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi(
> +// MSABI: declare void @"\01??$callee@$00@PR31656@@YAXQAH@Z"(
> +
> +void caller() { callee<1>(0); }
> +}
>
>
> ___
> 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: r293207 - PR0091R3: Implement parsing support for using templates as types.

2017-01-26 Thread Yung, Douglas via cfe-commits
Hi Richard,

I don't know if you have noticed, but the test you added in this commit is 
failing on both the Linux and Windows PS4 bots. The test is failing with an 
assertion failure:

Assertion failed: !A->getDeducedType().isNull() && "cannot request the size of 
an undeduced or dependent auto type", file 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\lib\AST\ASTContext.cpp,
 line 1884

Can you take a look?

Windows PS4 bot failure: 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/4531
Linux PS4 bot failure: 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/5093

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Richard Smith via cfe-commits
> Sent: Thursday, January 26, 2017 12:41
> To: cfe-commits@lists.llvm.org
> Subject: r293207 - PR0091R3: Implement parsing support for using
> templates as types.
> 
> Author: rsmith
> Date: Thu Jan 26 14:40:47 2017
> New Revision: 293207
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=293207&view=rev
> Log:
> PR0091R3: Implement parsing support for using templates as types.
> 
> This change adds a new type node, DeducedTemplateSpecializationType, to
> represent a type template name that has been used as a type. This is
> modeled
> around AutoType, and shares a common base class for representing a
> deduced
> placeholder type.
> 
> We allow deduced class template types in a few more places than the
> standard
> does: in conditions and for-range-declarators, and in new-type-ids.
> This is
> consistent with GCC and with discussion on the core reflector. This
> patch
> does not yet support deduced class template types being named in
> typename
> specifiers.
> 
> Added:
> cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/AST/TypeLoc.h
> cfe/trunk/include/clang/AST/TypeNodes.def
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/DeclSpec.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/AST/TypePrinter.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Parse/ParseExprCXX.cpp
> cfe/trunk/lib/Parse/Parser.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
> cfe/trunk/test/CXX/drs/dr5xx.cpp
> cfe/trunk/test/Parser/backtrack-off-by-one.cpp
> cfe/trunk/test/SemaTemplate/temp_arg.cpp
> cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/CXType.cpp
> 
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/AST/ASTContext.h?rev=293207&r1=293206&r
> 2=293207&view=diff
> ===
> ===
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jan 26 14:40:47 2017
> @@ -167,6 +167,8 @@ class ASTContext : public RefCountedBase
>mutable llvm::FoldingSet
>  DependentUnaryTransformTypes;
>mutable llvm::FoldingSet AutoTypes;
> +  mutable llvm::FoldingSet
> +DeducedTemplateSpecializationTypes;
>mutable llvm::FoldingSet AtomicTypes;
>llvm::FoldingSet AttributedTypes;
>mutable llvm::FoldingSet PipeTypes;
> @@ -1412,6 +1414,11 @@ public:
>/// \brief C++11 deduction pattern for 'auto &&' type.
>QualType getAutoRRefDeductType() const;
> 
> +  /// \brief C++1z deduced class template specialization type.
> +  QualType getDeducedTemplateSpecializationType(TemplateName Template,
> +QualType DeducedType,
> +bool IsDependent)
> const;

Re: r292590 - [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows

2017-01-26 Thread Hans Wennborg via cfe-commits
Should we merge this to the release branch?

On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits
 wrote:
> Author: abataev
> Date: Fri Jan 20 02:57:28 2017
> New Revision: 292590
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292590&view=rev
> Log:
> [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
> with SEH and openmp
>
> In some cituations (during codegen for Windows SEH constructs)
> CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
> code does not expect such situation during cleanup.
>
> Added:
> cfe/trunk/test/OpenMP/openmp_seh.c
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=292590&r1=292589&r2=292590&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017
> @@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
>if (FirstBlockInfo)
>  destroyBlockInfos(FirstBlockInfo);
>
> -  if (getLangOpts().OpenMP) {
> +  if (getLangOpts().OpenMP && CurFn)
>  CGM.getOpenMPRuntime().functionFinished(*this);
> -  }
>  }
>
>  CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
>
> Added: cfe/trunk/test/OpenMP/openmp_seh.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_seh.c?rev=292590&view=auto
> ==
> --- cfe/trunk/test/OpenMP/openmp_seh.c (added)
> +++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017
> @@ -0,0 +1,18 @@
> +// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp 
> -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
> +// expected-no-diagnostics
> +// REQUIRES: x86-registered-target
> +extern "C" {
> +void __cpuid(int[4], int);
> +}
> +
> +// CHECK-LABEL: @main
> +int main(void) {
> +  __try {
> +int info[4];
> +__cpuid(info, 1);
> +  } __except (1) {
> +  }
> +
> +  return 0;
> +}
> +
>
>
> ___
> 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


r293223 - [modules] Additional tests.

2017-01-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 26 17:07:59 2017
New Revision: 293223

URL: http://llvm.org/viewvc/llvm-project?rev=293223&view=rev
Log:
[modules] Additional tests.

Added:
cfe/trunk/test/Modules/Inputs/anon-redecl/
cfe/trunk/test/Modules/Inputs/anon-redecl/a.h
cfe/trunk/test/Modules/Inputs/anon-redecl/b.h
cfe/trunk/test/Modules/Inputs/anon-redecl/c1.h
cfe/trunk/test/Modules/Inputs/anon-redecl/c2.h
cfe/trunk/test/Modules/Inputs/anon-redecl/module.modulemap
cfe/trunk/test/Modules/Inputs/hidden-names/
cfe/trunk/test/Modules/Inputs/hidden-names/hidden.h
cfe/trunk/test/Modules/Inputs/hidden-names/module.modulemap
cfe/trunk/test/Modules/Inputs/hidden-names/visible.h
cfe/trunk/test/Modules/Inputs/merge-function-defs/
cfe/trunk/test/Modules/Inputs/merge-function-defs/a.h
cfe/trunk/test/Modules/Inputs/merge-function-defs/b.h
cfe/trunk/test/Modules/Inputs/merge-function-defs/map
cfe/trunk/test/Modules/anon-redecl.cpp
cfe/trunk/test/Modules/hidden-names.cpp
cfe/trunk/test/Modules/merge-function-defs.cpp

Added: cfe/trunk/test/Modules/Inputs/anon-redecl/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/anon-redecl/a.h?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/anon-redecl/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/anon-redecl/a.h Thu Jan 26 17:07:59 2017
@@ -0,0 +1,2 @@
+struct X { union { int n; }; };
+inline int a(X x) { return x.n; }

Added: cfe/trunk/test/Modules/Inputs/anon-redecl/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/anon-redecl/b.h?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/anon-redecl/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/anon-redecl/b.h Thu Jan 26 17:07:59 2017
@@ -0,0 +1,2 @@
+struct X { union { int n; }; };
+inline int b(X x) { return x.n; }

Added: cfe/trunk/test/Modules/Inputs/anon-redecl/c1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/anon-redecl/c1.h?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/anon-redecl/c1.h (added)
+++ cfe/trunk/test/Modules/Inputs/anon-redecl/c1.h Thu Jan 26 17:07:59 2017
@@ -0,0 +1,2 @@
+#include "a.h"
+#include "b.h"

Added: cfe/trunk/test/Modules/Inputs/anon-redecl/c2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/anon-redecl/c2.h?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/anon-redecl/c2.h (added)
+++ cfe/trunk/test/Modules/Inputs/anon-redecl/c2.h Thu Jan 26 17:07:59 2017
@@ -0,0 +1,2 @@
+struct X { union { int n; }; };
+inline int c(X x) { return x.n; }

Added: cfe/trunk/test/Modules/Inputs/anon-redecl/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/anon-redecl/module.modulemap?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/anon-redecl/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/anon-redecl/module.modulemap Thu Jan 26 
17:07:59 2017
@@ -0,0 +1,6 @@
+module a { header "a.h" }
+module b { header "b.h" }
+module c {
+  module c1 { header "c1.h" }
+  module c2 { header "c2.h" }
+}

Added: cfe/trunk/test/Modules/Inputs/hidden-names/hidden.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/hidden-names/hidden.h?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/hidden-names/hidden.h (added)
+++ cfe/trunk/test/Modules/Inputs/hidden-names/hidden.h Thu Jan 26 17:07:59 2017
@@ -0,0 +1,3 @@
+namespace NS {
+  struct X {};
+}

Added: cfe/trunk/test/Modules/Inputs/hidden-names/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/hidden-names/module.modulemap?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/hidden-names/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/hidden-names/module.modulemap Thu Jan 26 
17:07:59 2017
@@ -0,0 +1,4 @@
+module hidden {
+  header "visible.h"
+  explicit module sub { header "hidden.h" }
+}

Added: cfe/trunk/test/Modules/Inputs/hidden-names/visible.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/hidden-names/visible.h?rev=293223&view=auto
==
--- cfe/trunk/test/Modules/Inputs/hidden-names/visible.h (added)
+++ cfe/trunk/test/Modules/Inputs/hidden-names/visible.h Thu Jan 26 17:07:59 
2017
@@ -0,0 +1,2 @@
+// hidden-names/visible.h
+namespace NS {}

Added: cfe/trunk/test/Modules/Inputs/merge-function-defs/a.h
URL: 
http://llvm.org/viewvc/ll

r293222 - Add files forgotten in r293219.

2017-01-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 26 17:06:10 2017
New Revision: 293222

URL: http://llvm.org/viewvc/llvm-project?rev=293222&view=rev
Log:
Add files forgotten in r293219.

Added:
cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c1.h
cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c2.h

Added: cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c1.h?rev=293222&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c1.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c1.h Thu Jan 26 
17:06:10 2017
@@ -0,0 +1 @@
+// c1

Added: cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c2.h?rev=293222&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c2.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/c2.h Thu Jan 26 
17:06:10 2017
@@ -0,0 +1,2 @@
+// c2.h
+typedef struct {} merged_after_definition;


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


[PATCH] D29198: clang-cl: Warn about /U flags that look like filenames (PR31662)

2017-01-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:252
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as 
filenames">;
+

amccarth wrote:
> For Windows, wouldn't it make more sense to suggest using valid paths (with 
> backslashes instead of slashes)?
> 
> What about all the other characters paths can begin with?  Shouldn't we also 
> warn that /code/myproject will also be interpreted as /c rather than 
> \code\myproject?
I think it's better with a suggestion that works on both platforms.

I also think users run into this more often on non-Windows.

For `/code/myproject` we will not interpret it as the `/c` option since it has 
to be an exact match. `/I`, `/D` and others are problematic though.

I think it's hard to fix this in general, but `/U` is the one people keep 
running into, so I think targeting that with a warning makes sense.


https://reviews.llvm.org/D29198



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


[PATCH] D29077: [lsan] Enable LSan for x86 Linux.

2017-01-26 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D29077



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D20693#658087, @hintonda wrote:

> Great, thanks.  Could you commit for me?


Certainly! I've commit in r293217.


https://reviews.llvm.org/D20693



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


r293219 - [modules] When reading / writing a typedef that is a name for linkage for

2017-01-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 26 16:39:55 2017
New Revision: 293219

URL: http://llvm.org/viewvc/llvm-project?rev=293219&view=rev
Log:
[modules] When reading / writing a typedef that is a name for linkage for
another declaration, ensure we actually serialize / deserialize that
declaration.

Before this patch, if another copy of the typedef were merged with the parsed
version, we would emit type information referring to the merged version and
consequently emit nothing about the parsed anonymous struct. This resulted in
us losing information, particularly the visible merged module set for the
parsed definition. Force that information to be emitted and to be loaded when
the typedef is used.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/b.h
cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/module.modulemap
cfe/trunk/test/Modules/merge-name-for-linkage.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=293219&r1=293218&r2=293219&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Jan 26 16:39:55 2017
@@ -592,6 +592,11 @@ ASTDeclReader::VisitTypedefNameDecl(Type
 TD->setModedTypeSourceInfo(TInfo, modedT);
   } else
 TD->setTypeSourceInfo(TInfo);
+  // Read and discard the declaration for which this is a typedef name for
+  // linkage, if it exists. We cannot rely on our type to pull in this decl,
+  // because it might have been merged with a type from another module and
+  // thus might not refer to our version of the declaration.
+  ReadDecl();
   return Redecl;
 }
 

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=293219&r1=293218&r2=293219&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Jan 26 16:39:55 2017
@@ -368,6 +368,7 @@ void ASTDeclWriter::VisitTypedefNameDecl
   Record.push_back(D->isModed());
   if (D->isModed())
 Record.AddTypeRef(D->getUnderlyingType());
+  Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
 }
 
 void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {

Modified: cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/b.h?rev=293219&r1=293218&r2=293219&view=diff
==
--- cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/b.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/b.h Thu Jan 26 
16:39:55 2017
@@ -1 +1,5 @@
 typedef union {} pthread_mutex_t;
+
+// Define then merge with another definition.
+typedef struct {} merged_after_definition;
+#include "c1.h"

Modified: cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/module.modulemap?rev=293219&r1=293218&r2=293219&view=diff
==
--- cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/module.modulemap 
(original)
+++ cfe/trunk/test/Modules/Inputs/merge-name-for-linkage/module.modulemap Thu 
Jan 26 16:39:55 2017
@@ -1,2 +1,3 @@
 module a { header "a.h" export * }
 module b { header "b.h" export * }
+module c { module c1 { header "c1.h" export * } module c2 { header "c2.h" 
export * } }

Modified: cfe/trunk/test/Modules/merge-name-for-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-name-for-linkage.cpp?rev=293219&r1=293218&r2=293219&view=diff
==
--- cfe/trunk/test/Modules/merge-name-for-linkage.cpp (original)
+++ cfe/trunk/test/Modules/merge-name-for-linkage.cpp Thu Jan 26 16:39:55 2017
@@ -7,3 +7,4 @@ typedef pthread_mutex_t pthread_mutex_t;
 pthread_mutex_t x;
 #include "b.h"
 pthread_mutex_t y;
+merged_after_definition z;


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


[clang-tools-extra] r293218 - Correcting a typo in the test case to appease bots.

2017-01-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jan 26 16:39:01 2017
New Revision: 293218

URL: http://llvm.org/viewvc/llvm-project?rev=293218&view=rev
Log:
Correcting a typo in the test case to appease bots.

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp?rev=293218&r1=293217&r2=293218&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp Thu Jan 
26 16:39:01 2017
@@ -11,7 +11,7 @@ void foo() throw();
 template 
 void foo() throw();
 void footest() { foo(); foo(); }
-// CHECK-MESSAGES: :[[@LINE-2]:12: warning: dynamic exception specification 
'throw()' is deprecated; consider using 'noexcept' instead 
[modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 
'throw()' is deprecated; consider using 'noexcept' instead 
[modernize-use-noexcept]
 // CHECK-FIXES: void foo() noexcept;
 
 void bar() throw(...);


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


[clang-tools-extra] r293217 - Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications.

2017-01-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jan 26 16:34:24 2017
New Revision: 293217

URL: http://llvm.org/viewvc/llvm-project?rev=293217&view=rev
Log:
Implement a new clang-tidy check that suggests users replace dynamic exception 
specifications with noexcept exception specifications.

Patch by Don Hinton.

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=293217&r1=293216&r2=293217&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Jan 26 
16:34:24 2017
@@ -20,6 +20,7 @@ add_clang_library(clangTidyModernizeModu
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
+  UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseTransparentFunctorsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=293217&r1=293216&r2=293217&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
Jan 26 16:34:24 2017
@@ -26,6 +26,7 @@
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
+#include "UseNoexceptCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseTransparentFunctorsCheck.h"
@@ -63,6 +64,7 @@ public:
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
+CheckFactories.registerCheck("modernize-use-noexcept");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=293217&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp Thu Jan 
26 16:34:24 2017
@@ -0,0 +1,114 @@
+//===--- UseNoexceptCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseNoexceptCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+UseNoexceptCheck::UseNoexceptCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  NoexceptMacro(Options.get("ReplacementString", "")),
+  UseNoexceptFalse(Options.get("UseNoexceptFalse", true)) {}
+
+void UseNoexceptCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "ReplacementString", NoexceptMacro);
+  Options.store(Opts, "UseNoexceptFalse", UseNoexceptFalse);
+}
+
+void UseNoexceptCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  Finder->addMatcher(
+  functionDecl(
+  cxxMethodDecl(
+  hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec(,
+  anyOf(hasOverloadedOperatorName("delete[]"),
+hasOverloadedOperatorName("delete"), cxxDestructorDecl()))
+  .bind("del-dtor"))
+  .bind("funcDecl"),
+  this);
+
+  Finder->addMatcher(
+  functionDecl(
+  hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec(,
+  unless(anyOf(hasOverloadedOperatorName("delete[]"),
+   h

[PATCH] D29198: clang-cl: Warn about /U flags that look like filenames (PR31662)

2017-01-26 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:252
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as 
filenames">;
+

For Windows, wouldn't it make more sense to suggest using valid paths (with 
backslashes instead of slashes)?

What about all the other characters paths can begin with?  Shouldn't we also 
warn that /code/myproject will also be interpreted as /c rather than 
\code\myproject?


https://reviews.llvm.org/D29198



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


[PATCH] D29118: [clang-tidy] safety-no-vector-bool

2017-01-26 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp:50
+diag(MatchedDecl->getLocation(),
+ " function %0 returns an instance of std::vector")
+<< MatchedDecl;

djehuti wrote:
> JonasToth wrote:
> > i think all those diag() calls can be merged into one. inside the 
> > if/else-if you can just set a StringRef with the specific part of the 
> > warning, and have a parameterized diag() at the end of the function.
> > 
> > in NoMallocCheck there is a similar pattern:
> > 
> >   const CallExpr *Call = nullptr;   
> >
> >   StringRef Recommendation; 
> >
> > 
> >
> >   if ((Call = Result.Nodes.getNodeAs("aquisition")))  
> >
> > Recommendation = "consider a container or a smart pointer"; 
> >
> >   else if ((Call = Result.Nodes.getNodeAs("realloc")))
> >
> > Recommendation = "consider std::vector or std::string"; 
> >
> >   else if ((Call = Result.Nodes.getNodeAs("free")))   
> >
> > Recommendation = "use RAII";
> >
> > 
> >
> >   assert(Call && "Unhandled binding in the Matcher");   
> >
> > 
> >
> >   diag(Call->getLocStart(), "do not manage memory manually; %0")
> >
> >   << Recommendation << SourceRange(Call->getLocStart(), 
> > Call->getLocEnd());
> > 
> Except with braces, right? (That's another High-Integrity C++ rule btw.)  ;)
I agree that this _can_ be done but I'm not convinced it helps readability. 
Repetition is partial and very localized. I'll happily make the change if you 
feel strongly that it's an improvement.



Comment at: clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp:37
+std::vector> v4;  
+

JonasToth wrote:
> what happens for types where std::vector would be an template argument? 
> for example std::pair and tuple could contain a vector.
> is there a warning as well?
Nicely spotted. Those won't get picked up right now and need to be. 

I'm struggling to build a matcher for this. We really need to find any place 
where `std::vector` is used as a template argument.


https://reviews.llvm.org/D29118



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


Re: [libunwind] r292721 - DWARF: convert error logs to _LIBUNWIND_LOG

2017-01-26 Thread Evgenii Stepanov via cfe-commits
Actually, the bot has been red since Jan 21 with this exact error.

On Thu, Jan 26, 2017 at 2:27 PM, Evgenii Stepanov
 wrote:
> Hi,
>
> I'm not sure why we only see this now, but this change is breaking
> llvm bootstrap with -Werror:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/732/steps/bootstrap%20clang/logs/stdio
>
> llvm/projects/libunwind/src/config.h:90:41: error: token pasting of
> ',' and __VA_ARGS__ is a GNU extension
> [-Werror,-Wgnu-zero-variadic-macro-arguments]
>   fprintf(stderr, "libunwind: " msg "\n", ##__VA_ARGS__)
>
> On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
>  wrote:
>> Author: compnerd
>> Date: Sat Jan 21 10:22:55 2017
>> New Revision: 292721
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=292721&view=rev
>> Log:
>> DWARF: convert error logs to _LIBUNWIND_LOG
>>
>> Use the `_LIBUNWIND_LOG` macro instead of the explicit `fprintf` call.
>> NFC.
>>
>> Modified:
>> libunwind/trunk/src/DwarfParser.hpp
>> libunwind/trunk/src/config.h
>>
>> Modified: libunwind/trunk/src/DwarfParser.hpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=292721&r1=292720&r2=292721&view=diff
>> ==
>> --- libunwind/trunk/src/DwarfParser.hpp (original)
>> +++ libunwind/trunk/src/DwarfParser.hpp Sat Jan 21 10:22:55 2017
>> @@ -421,8 +421,7 @@ bool CFI_Parser::parseInstructions(A
>>offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
>>* cieInfo.dataAlignFactor;
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(stderr,
>> -"malformed DW_CFA_offset_extended DWARF unwind, reg too 
>> big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_offset_extended, reg too 
>> big");
>>  return false;
>>}
>>results->savedRegisters[reg].location = kRegisterInCFA;
>> @@ -436,9 +435,7 @@ bool CFI_Parser::parseInstructions(A
>>reg = addressSpace.getULEB128(p, instructionsEnd);
>>;
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(
>> -stderr,
>> -"malformed DW_CFA_restore_extended DWARF unwind, reg too 
>> big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_restore_extended, reg too 
>> big");
>>  return false;
>>}
>>results->savedRegisters[reg] = initialState.savedRegisters[reg];
>> @@ -448,8 +445,7 @@ bool CFI_Parser::parseInstructions(A
>>  case DW_CFA_undefined:
>>reg = addressSpace.getULEB128(p, instructionsEnd);
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(stderr,
>> -"malformed DW_CFA_undefined DWARF unwind, reg too big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_undefined, reg too big");
>>  return false;
>>}
>>results->savedRegisters[reg].location = kRegisterUnused;
>> @@ -459,8 +455,7 @@ bool CFI_Parser::parseInstructions(A
>>  case DW_CFA_same_value:
>>reg = addressSpace.getULEB128(p, instructionsEnd);
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(stderr,
>> -"malformed DW_CFA_same_value DWARF unwind, reg too big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_same_value, reg too big");
>>  return false;
>>}
>>//  DW_CFA_same_value unsupported
>> @@ -477,13 +472,11 @@ bool CFI_Parser::parseInstructions(A
>>reg = addressSpace.getULEB128(p, instructionsEnd);
>>reg2 = addressSpace.getULEB128(p, instructionsEnd);
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(stderr,
>> -"malformed DW_CFA_register DWARF unwind, reg too big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg too big");
>>  return false;
>>}
>>if (reg2 > kMaxRegisterNumber) {
>> -fprintf(stderr,
>> -"malformed DW_CFA_register DWARF unwind, reg2 too big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg2 too big");
>>  return false;
>>}
>>results->savedRegisters[reg].location = kRegisterInRegister;
>> @@ -525,7 +518,7 @@ bool CFI_Parser::parseInstructions(A
>>reg = addressSpace.getULEB128(p, instructionsEnd);
>>offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd);
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(stderr, "malformed DW_CFA_def_cfa DWARF unwind, reg too 
>> big\n");
>> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa, reg too big");
>>  return false;
>>}
>>results->cfaRegister = (uint32_t)reg;
>> @@ -537,9 +530,7 @@ bool CFI_Parser::parseInstructions(A
>>  case DW_CFA_def_cfa_register:
>>reg = addressSpace.getULEB128(p, instructionsEnd);
>>if (reg > kMaxRegisterNumber) {
>> -fprintf(
>> -stderr,
>> -"malformed DW_CFA_def_cfa_register DWARF unwind, r

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-01-26 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Great, thanks.  Could you commit for me?


https://reviews.llvm.org/D20693



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

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

Yes, this LGTM as well. Thank you for working on this!


https://reviews.llvm.org/D20693



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


Re: [libunwind] r292721 - DWARF: convert error logs to _LIBUNWIND_LOG

2017-01-26 Thread Evgenii Stepanov via cfe-commits
Hi,

I'm not sure why we only see this now, but this change is breaking
llvm bootstrap with -Werror:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/732/steps/bootstrap%20clang/logs/stdio

llvm/projects/libunwind/src/config.h:90:41: error: token pasting of
',' and __VA_ARGS__ is a GNU extension
[-Werror,-Wgnu-zero-variadic-macro-arguments]
  fprintf(stderr, "libunwind: " msg "\n", ##__VA_ARGS__)

On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
 wrote:
> Author: compnerd
> Date: Sat Jan 21 10:22:55 2017
> New Revision: 292721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292721&view=rev
> Log:
> DWARF: convert error logs to _LIBUNWIND_LOG
>
> Use the `_LIBUNWIND_LOG` macro instead of the explicit `fprintf` call.
> NFC.
>
> Modified:
> libunwind/trunk/src/DwarfParser.hpp
> libunwind/trunk/src/config.h
>
> Modified: libunwind/trunk/src/DwarfParser.hpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=292721&r1=292720&r2=292721&view=diff
> ==
> --- libunwind/trunk/src/DwarfParser.hpp (original)
> +++ libunwind/trunk/src/DwarfParser.hpp Sat Jan 21 10:22:55 2017
> @@ -421,8 +421,7 @@ bool CFI_Parser::parseInstructions(A
>offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
>* cieInfo.dataAlignFactor;
>if (reg > kMaxRegisterNumber) {
> -fprintf(stderr,
> -"malformed DW_CFA_offset_extended DWARF unwind, reg too 
> big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_offset_extended, reg too 
> big");
>  return false;
>}
>results->savedRegisters[reg].location = kRegisterInCFA;
> @@ -436,9 +435,7 @@ bool CFI_Parser::parseInstructions(A
>reg = addressSpace.getULEB128(p, instructionsEnd);
>;
>if (reg > kMaxRegisterNumber) {
> -fprintf(
> -stderr,
> -"malformed DW_CFA_restore_extended DWARF unwind, reg too big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_restore_extended, reg too 
> big");
>  return false;
>}
>results->savedRegisters[reg] = initialState.savedRegisters[reg];
> @@ -448,8 +445,7 @@ bool CFI_Parser::parseInstructions(A
>  case DW_CFA_undefined:
>reg = addressSpace.getULEB128(p, instructionsEnd);
>if (reg > kMaxRegisterNumber) {
> -fprintf(stderr,
> -"malformed DW_CFA_undefined DWARF unwind, reg too big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_undefined, reg too big");
>  return false;
>}
>results->savedRegisters[reg].location = kRegisterUnused;
> @@ -459,8 +455,7 @@ bool CFI_Parser::parseInstructions(A
>  case DW_CFA_same_value:
>reg = addressSpace.getULEB128(p, instructionsEnd);
>if (reg > kMaxRegisterNumber) {
> -fprintf(stderr,
> -"malformed DW_CFA_same_value DWARF unwind, reg too big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_same_value, reg too big");
>  return false;
>}
>//  DW_CFA_same_value unsupported
> @@ -477,13 +472,11 @@ bool CFI_Parser::parseInstructions(A
>reg = addressSpace.getULEB128(p, instructionsEnd);
>reg2 = addressSpace.getULEB128(p, instructionsEnd);
>if (reg > kMaxRegisterNumber) {
> -fprintf(stderr,
> -"malformed DW_CFA_register DWARF unwind, reg too big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg too big");
>  return false;
>}
>if (reg2 > kMaxRegisterNumber) {
> -fprintf(stderr,
> -"malformed DW_CFA_register DWARF unwind, reg2 too big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg2 too big");
>  return false;
>}
>results->savedRegisters[reg].location = kRegisterInRegister;
> @@ -525,7 +518,7 @@ bool CFI_Parser::parseInstructions(A
>reg = addressSpace.getULEB128(p, instructionsEnd);
>offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd);
>if (reg > kMaxRegisterNumber) {
> -fprintf(stderr, "malformed DW_CFA_def_cfa DWARF unwind, reg too 
> big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa, reg too big");
>  return false;
>}
>results->cfaRegister = (uint32_t)reg;
> @@ -537,9 +530,7 @@ bool CFI_Parser::parseInstructions(A
>  case DW_CFA_def_cfa_register:
>reg = addressSpace.getULEB128(p, instructionsEnd);
>if (reg > kMaxRegisterNumber) {
> -fprintf(
> -stderr,
> -"malformed DW_CFA_def_cfa_register DWARF unwind, reg too big\n");
> +_LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa_register, reg too 
> big");
>  return false;
>}
>results->cfaRegister = (uint32_t)reg;
> @@ -567,8 +558,7 @@ bool CFI_Parser::parseInstructions(A
>  

[PATCH] D29118: [clang-tidy] safety-no-vector-bool

2017-01-26 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 85967.
jbcoe marked 2 inline comments as done.
jbcoe added a comment.

Responses to some change requests. Input needed on template argument matcher.


https://reviews.llvm.org/D29118

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp
  clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.h
  clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/safety-no-vector-bool.rst
  clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp

Index: clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp
@@ -0,0 +1,37 @@
+// RUN: %check_clang_tidy %s safety-no-vector-bool %t
+
+namespace std
+{
+  template  
+  class allocator {};
+
+  template >
+  class vector {};
+}
+
+std::vector v0;
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: variable 'v0' is an instance of std::vector [safety-no-vector-bool]
+
+std::vector vb();
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'vb' returns an instance of std::vector [safety-no-vector-bool]
+
+class C {
+  std::vector v_;
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: member 'v_' is an instance of std::vector [safety-no-vector-bool]
+};
+
+typedef bool BoolTypedef;
+std::vector v1;
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: variable 'v1' is an instance of std::vector [safety-no-vector-bool]
+
+using vbool = std::vector;
+vbool v2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'v2' is an instance of std::vector [safety-no-vector-bool]
+
+std::vector v3;  
+
+template 
+class user_allocator {};
+
+std::vector> v4;  
+
Index: clang-tools-extra/docs/clang-tidy/checks/safety-no-vector-bool.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/safety-no-vector-bool.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - safety-no-vector-bool
+
+safety-no-vector-bool
+=
+
+``std::vector`` cannot be accessed safely concurrently in the same way as
+other ``std::vector`` specializations and is banned by some
+safefty-critical-c++ standards like High Integrity C++.
+
+This check finds instances of ``std::vector``. No fix is offered.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -152,3 +152,4 @@
readability-simplify-boolean-expr
readability-static-definition-in-anonymous-namespace
readability-uniqueptr-delete-release
+   safety-no-vector-bool
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -475,6 +475,11 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
+// This anchor is used to force the linker to link the SafetyModule.
+extern volatile int SafetyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED SafetyModuleAnchorDestination =
+SafetyModuleAnchorSource;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -23,6 +23,7 @@
   clangTidyMPIModule
   clangTidyPerformanceModule
   clangTidyReadabilityModule
+  clangTidySafetyModule
   clangTooling
   )
 
Index: clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
@@ -0,0 +1,38 @@
+//===--- SafetyTidyModule.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "NoVectorBoolCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace safety {
+
+class SafetyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"safety-no-vector-bool");
+  }
+};

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-26 Thread Aaron Ballman via cfe-commits
On Mon, Jan 23, 2017 at 5:55 PM, Nico Weber  wrote:
> On Mon, Jan 23, 2017 at 5:29 PM, Aaron Ballman 
> wrote:
>>
>> On Mon, Jan 23, 2017 at 5:00 PM, Nico Weber via cfe-commits
>>  wrote:
>> > On Sun, Jan 22, 2017 at 6:17 AM, Malcolm Parsons
>> > 
>> > wrote:
>> >>
>> >> On 20 January 2017 at 21:32, Nico Weber  wrote:
>> >> > This warns about code like
>> >> >
>> >> >   constexpr int foo = 4;
>> >> >   [&foo]() { use(foo); }
>> >> >
>> >> > That's correct, but removing &foo then makes MSVC complain about this
>> >> > code
>> >> > like "error C3493: 'foo' cannot be implicitly captured because no
>> >> > default
>> >> > capture mode has been specified". A workaround is to make foo static
>> >> > const
>> >> > instead of constexpr.
>> >> >
>> >> > This seems like an MSVC bug, but it's still a bit annoying that clang
>> >> > now
>> >> > suggests doing things that won't build in other compilers. Any ideas
>> >> > what to
>> >> > do about this?
>> >>
>> >> Should Clang care about the behaviour of other compilers that don't
>> >> follow the standard?
>> >
>> >
>> > clang should be a compiler that people like to use. Multi-platform
>> > development isn't super uncommon, so trying to give a good experience in
>> > that case seems like a good thing to me -- and we've tried to do that in
>> > the
>> > past pretty hard. It's possible that "do nothing" is the right thing,
>> > but
>> > "well that other compiler is buggy" seems like a somewhat oversimplified
>> > reply.
>>
>> We generally don't try to be bug-for-bug compatible with other
>> compilers unless the bug is sufficiently important (like it is relied
>> upon in system headers, for instance). In this case, I think the bug
>> in MSVC is annoying, but not the end of the world because it's trivial
>> to workaround in a compiler-agnostic way
>
>
> It's easy, but you need to know about it. Say you're working on some project
> that uses clang on macOS, gcc on Linux, MSVC on Windows, and you're
> developing on Linux. You write some patch, and things work fine on your
> machine. You submit your thing, it gets reverted because it triggers this
> new warning on mac. Hey, fair enough, looks like a good warning, so you
> remove the thing from the capture list and reland. Now you get reverted
> _again_ because MSVC does need that thing that clang just told you to
> revert. After three such interactions you'll be pretty unhappy, I gather :-)

I don't disagree that you'd be unhappy in that circumstance.

>> >> Cast foo to void inside the lambda.
>> >
>> >
>> > That's equivalent to disabling the clang warning in those cases (which
>> > would
>> > be a shame, since the warning is super useful, and it doesn't introduce
>> > problems in most cases -- only with local constexprs). Maybe the warning
>> > could be split in two, so that it can be toggled separately for
>> > constexpr?
>>
>> While functional, that seems like a lot of work for this case.
>
>
> It's like 4 lines, no?

Yes, but no. It's 4 lines that introduce a compiler flag that we have
to support forever, even if Microsoft eventually fixes their bug
(making the purpose to the compiler flag entirely moot), which is what
my concern boils down to. If this was a common problem, then I would
think the flag (or some other, heavier fix) might actually be worth
having to keep around forever. Since it doesn't really seem to be a
common issue, I'm not keen on adding a user-facing compiler flag
because of the maintenance burden.

~Aaron

> As I said, I'm not sure it's worth it either. As-is, I think larger cross
> platform teams must enable this warning for the reason mentioned above.
> Requiring this is a bit of a shame since I think it's a great warning, so I
> was hoping we could come up with a way so we could use the warning as well.
>
>>
>> However, the downside to the cast to void is that when MSVC does fix
>> the bug, the diagnostic remains silenced in the user's source base.
>>
>> >
>> >>
>> >> Only capture foo when building with MSVC.
>> >>
>> >> Stop building with MSVC.
>> >
>> >
>> > This reply like this make me believe you think it was silly to even
>> > report
>> > this problem. I don't think it's silly, and there's ample precedent in
>> > clang
>> > to make it work well in the actual world instead of in a world we wished
>> > we
>> > lived in.
>>
>> Definitely not silly to report the problem, but at the same time, that
>> precedent is usually reserved for things that affect a significant
>> portion of users when the issue boils down to a compiler bug in
>> another compiler. How common of a problem is this use case? Does it
>> crop up in important header files?
>
>
> It's not super common. Ivan, I think you ran into this twice in all of
> Chromium?
>
>>
>>
>> ~Aaron
>>
>> >
>> >>
>> >> Complain to Microsoft.
>> >
>> >
>> > Already done. The reality is that their shipping compiler produces this
>> > diagnostic, and the current 2017 build does too.
>> >
>> > ___
>> > cfe-commit

[PATCH] D29198: clang-cl: Warn about /U flags that look like filenames (PR31662)

2017-01-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.

Both on Mac and Windows, it's common to have a 'Users' directory in the root of 
the filesystem, so one might specify a filename as '/Users/me/myfile.c'. 
clang-cl (as well as MSVC's cl.exe) will interpret that as invoking '/U' 
option, which is probably not what the user wanted. Add a warning about this.


https://reviews.llvm.org/D29198

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/Driver.cpp
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -442,6 +442,12 @@
 // Xclang: "-cc1"
 // Xclang: "hellocc1"
 
+// Files under /Users are often confused with the /U flag. (This could happen
+// for other flags too, but this is the one people run into.)
+// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck 
-check-prefix=SlashU %s
+// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
+// SlashU: note: Use '--' to treat subsequent arguments as filenames
+
 // RTTI is on by default. /GR- controls -fno-rtti-data.
 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
 // NoRTTI: "-fno-rtti-data"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1583,6 +1583,14 @@
 Diag(clang::diag::err_drv_unknown_language) << A->getValue();
 InputType = types::TY_Object;
   }
+} else if (A->getOption().getID() == options::OPT__SLASH_U) {
+  assert(A->getNumValues() == 1 && "The /U option has one value.");
+  StringRef Val = A->getValue(0);
+  if (Val.find_first_of("/\\") != StringRef::npos) {
+// Warn about e.g. "/Users/me/myfile.c".
+Diag(diag::warn_slash_u_filename) << Val;
+Diag(diag::note_use_dashdash);
+  }
 }
   }
   if (CCCIsCPP() && Inputs.empty()) {
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -247,6 +247,10 @@
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as 
filenames">;
+
 def err_drv_ropi_rwpi_incompatible_with_pic : Error<
   "embedded and GOT-based position independence are incompatible">;
 def err_drv_ropi_incompatible_with_cxx : Error<


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -442,6 +442,12 @@
 // Xclang: "-cc1"
 // Xclang: "hellocc1"
 
+// Files under /Users are often confused with the /U flag. (This could happen
+// for other flags too, but this is the one people run into.)
+// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s
+// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
+// SlashU: note: Use '--' to treat subsequent arguments as filenames
+
 // RTTI is on by default. /GR- controls -fno-rtti-data.
 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
 // NoRTTI: "-fno-rtti-data"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1583,6 +1583,14 @@
 Diag(clang::diag::err_drv_unknown_language) << A->getValue();
 InputType = types::TY_Object;
   }
+} else if (A->getOption().getID() == options::OPT__SLASH_U) {
+  assert(A->getNumValues() == 1 && "The /U option has one value.");
+  StringRef Val = A->getValue(0);
+  if (Val.find_first_of("/\\") != StringRef::npos) {
+// Warn about e.g. "/Users/me/myfile.c".
+Diag(diag::warn_slash_u_filename) << Val;
+Diag(diag::note_use_dashdash);
+  }
 }
   }
   if (CCCIsCPP() && Inputs.empty()) {
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -247,6 +247,10 @@
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as filenames">;
+
 def err_drv_ropi_rwpi_incompatible_with_pic : Error<
   "embedded and GOT-based position independence are incompatible">;
 def err_drv_ropi_incompatible_with_cxx : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r293210 - Add missing x86 requirement.

2017-01-26 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Jan 26 15:38:48 2017
New Revision: 293210

URL: http://llvm.org/viewvc/llvm-project?rev=293210&view=rev
Log:
Add missing x86 requirement.

Modified:
cfe/trunk/test/CodeGen/thinlto-multi-module.ll

Modified: cfe/trunk/test/CodeGen/thinlto-multi-module.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-multi-module.ll?rev=293210&r1=293209&r2=293210&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto-multi-module.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-multi-module.ll Thu Jan 26 15:38:48 2017
@@ -1,3 +1,5 @@
+; REQUIRES: x86-registered-target
+
 ; RUN: opt -module-summary -o %t1.o %s
 ; RUN: llvm-lto -thinlto -o %t %t1.o
 


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


[PATCH] D29197: Avoid implementation defined behavior in a test.

2017-01-26 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.

num_put::put uses %p for pointer types, but the exact format of %p is
implementation defined behavior for the C library. Compare output to
snprintf for portability.


Repository:
  rL LLVM

https://reviews.llvm.org/D29197

Files:
  
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp


Index: 
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
===
--- 
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
+++ 
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
@@ -38,6 +38,12 @@
 char str[50];
 output_iterator iter = f.put(output_iterator(str), ios, 
'*', v);
 std::string ex(str, iter.base());
-assert(ex == "0x0" || ex == "(nil)");
+char expected_str[32] = {};
+// num_put::put uses %p for pointer types, but the exact format of %p 
is
+// implementation defined behavior for the C library. Compare output to
+// snprintf for portability.
+int rc = snprintf(expected_str, sizeof(expected_str), "%p", v);
+assert(rc > 0);
+assert(ex == expected_str);
 }
 }


Index: test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
===
--- test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
+++ test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
@@ -38,6 +38,12 @@
 char str[50];
 output_iterator iter = f.put(output_iterator(str), ios, '*', v);
 std::string ex(str, iter.base());
-assert(ex == "0x0" || ex == "(nil)");
+char expected_str[32] = {};
+// num_put::put uses %p for pointer types, but the exact format of %p is
+// implementation defined behavior for the C library. Compare output to
+// snprintf for portability.
+int rc = snprintf(expected_str, sizeof(expected_str), "%p", v);
+assert(rc > 0);
+assert(ex == expected_str);
 }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-26 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Pinging early because this is a release blocker. :)


https://reviews.llvm.org/D28889



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


[PATCH] D29067: IRGen: When loading the main module in the distributed ThinLTO backend, look for the module containing the summary.

2017-01-26 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293209: IRGen: When loading the main module in the 
distributed ThinLTO backend, look… (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D29067?vs=85618&id=85958#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29067

Files:
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/CodeGen/thinlto-multi-module.ll


Index: cfe/trunk/test/CodeGen/thinlto-multi-module.ll
===
--- cfe/trunk/test/CodeGen/thinlto-multi-module.ll
+++ cfe/trunk/test/CodeGen/thinlto-multi-module.ll
@@ -0,0 +1,20 @@
+; RUN: opt -module-summary -o %t1.o %s
+; RUN: llvm-lto -thinlto -o %t %t1.o
+
+; RUN: opt -o %t2.o %S/Inputs/thinlto_backend.ll
+; RUN: llvm-cat -b -o %t1cat.o %t1.o %t2.o
+; RUN: cp %t1cat.o %t1.o
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
+; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
+; CHECK-OBJ: T f1
+; CHECK-OBJ: U f2
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @f2()
+
+define void @f1() {
+  call void @f2()
+  ret void
+}
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -86,6 +86,7 @@
 FileCheck count not
 llc
 llvm-bcanalyzer
+llvm-cat
 llvm-dis
 llvm-nm
 llvm-objdump
Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -860,10 +860,31 @@
   SourceManager &SM = CI.getSourceManager();
 
   // For ThinLTO backend invocations, ensure that the context
-  // merges types based on ODR identifiers.
-  if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty())
+  // merges types based on ODR identifiers. We also need to read
+  // the correct module out of a multi-module bitcode file.
+  if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty()) {
 VMContext->enableDebugTypeODRUniquing();
 
+auto DiagErrors = [&](Error E) -> std::unique_ptr {
+  unsigned DiagID =
+  CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
+  handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
+CI.getDiagnostics().Report(DiagID) << EIB.message();
+  });
+  return {};
+};
+
+Expected BMOrErr = FindThinLTOModule(MBRef);
+if (!BMOrErr)
+  return DiagErrors(BMOrErr.takeError());
+
+Expected> MOrErr =
+BMOrErr->parseModule(*VMContext);
+if (!MOrErr)
+  return DiagErrors(MOrErr.takeError());
+return std::move(*MOrErr);
+  }
+
   llvm::SMDiagnostic Err;
   if (std::unique_ptr M = parseIR(MBRef, Err, *VMContext))
 return M;


Index: cfe/trunk/test/CodeGen/thinlto-multi-module.ll
===
--- cfe/trunk/test/CodeGen/thinlto-multi-module.ll
+++ cfe/trunk/test/CodeGen/thinlto-multi-module.ll
@@ -0,0 +1,20 @@
+; RUN: opt -module-summary -o %t1.o %s
+; RUN: llvm-lto -thinlto -o %t %t1.o
+
+; RUN: opt -o %t2.o %S/Inputs/thinlto_backend.ll
+; RUN: llvm-cat -b -o %t1cat.o %t1.o %t2.o
+; RUN: cp %t1cat.o %t1.o
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc
+; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
+; CHECK-OBJ: T f1
+; CHECK-OBJ: U f2
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @f2()
+
+define void @f1() {
+  call void @f2()
+  ret void
+}
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -86,6 +86,7 @@
 FileCheck count not
 llc
 llvm-bcanalyzer
+llvm-cat
 llvm-dis
 llvm-nm
 llvm-objdump
Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -860,10 +860,31 @@
   SourceManager &SM = CI.getSourceManager();
 
   // For ThinLTO backend invocations, ensure that the context
-  // merges types based on ODR identifiers.
-  if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty())
+  // merges types based on ODR identifiers. We also need to read
+  // the correct module out of a multi-module bitcode file.
+  if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty()) {
 VMContext->enableDebugTypeODRUniquing();
 
+auto DiagErrors = [&](Error E) -> std::unique_ptr {
+  unsigned DiagID =
+  CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
+  handleAllErrors(std::move(E), [&]

r293209 - IRGen: When loading the main module in the distributed ThinLTO backend, look for the module containing the summary.

2017-01-26 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Jan 26 15:09:48 2017
New Revision: 293209

URL: http://llvm.org/viewvc/llvm-project?rev=293209&view=rev
Log:
IRGen: When loading the main module in the distributed ThinLTO backend, look 
for the module containing the summary.

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

Added:
cfe/trunk/test/CodeGen/thinlto-multi-module.ll
Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=293209&r1=293208&r2=293209&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Jan 26 15:09:48 2017
@@ -860,10 +860,31 @@ std::unique_ptr CodeGenAct
   SourceManager &SM = CI.getSourceManager();
 
   // For ThinLTO backend invocations, ensure that the context
-  // merges types based on ODR identifiers.
-  if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty())
+  // merges types based on ODR identifiers. We also need to read
+  // the correct module out of a multi-module bitcode file.
+  if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty()) {
 VMContext->enableDebugTypeODRUniquing();
 
+auto DiagErrors = [&](Error E) -> std::unique_ptr {
+  unsigned DiagID =
+  CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0");
+  handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
+CI.getDiagnostics().Report(DiagID) << EIB.message();
+  });
+  return {};
+};
+
+Expected BMOrErr = FindThinLTOModule(MBRef);
+if (!BMOrErr)
+  return DiagErrors(BMOrErr.takeError());
+
+Expected> MOrErr =
+BMOrErr->parseModule(*VMContext);
+if (!MOrErr)
+  return DiagErrors(MOrErr.takeError());
+return std::move(*MOrErr);
+  }
+
   llvm::SMDiagnostic Err;
   if (std::unique_ptr M = parseIR(MBRef, Err, *VMContext))
 return M;

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=293209&r1=293208&r2=293209&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu Jan 26 15:09:48 2017
@@ -86,6 +86,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 FileCheck count not
 llc
 llvm-bcanalyzer
+llvm-cat
 llvm-dis
 llvm-nm
 llvm-objdump

Added: cfe/trunk/test/CodeGen/thinlto-multi-module.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-multi-module.ll?rev=293209&view=auto
==
--- cfe/trunk/test/CodeGen/thinlto-multi-module.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-multi-module.ll Thu Jan 26 15:09:48 2017
@@ -0,0 +1,20 @@
+; RUN: opt -module-summary -o %t1.o %s
+; RUN: llvm-lto -thinlto -o %t %t1.o
+
+; RUN: opt -o %t2.o %S/Inputs/thinlto_backend.ll
+; RUN: llvm-cat -b -o %t1cat.o %t1.o %t2.o
+; RUN: cp %t1cat.o %t1.o
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
+; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
+; CHECK-OBJ: T f1
+; CHECK-OBJ: U f2
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @f2()
+
+define void @f1() {
+  call void @f2()
+  ret void
+}


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


r293207 - PR0091R3: Implement parsing support for using templates as types.

2017-01-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 26 14:40:47 2017
New Revision: 293207

URL: http://llvm.org/viewvc/llvm-project?rev=293207&view=rev
Log:
PR0091R3: Implement parsing support for using templates as types.

This change adds a new type node, DeducedTemplateSpecializationType, to
represent a type template name that has been used as a type. This is modeled
around AutoType, and shares a common base class for representing a deduced
placeholder type.

We allow deduced class template types in a few more places than the standard
does: in conditions and for-range-declarators, and in new-type-ids. This is
consistent with GCC and with discussion on the core reflector. This patch
does not yet support deduced class template types being named in typename
specifiers.

Added:
cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/TypeNodes.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/Parser/backtrack-off-by-one.cpp
cfe/trunk/test/SemaTemplate/temp_arg.cpp
cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=293207&r1=293206&r2=293207&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jan 26 14:40:47 2017
@@ -167,6 +167,8 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet
 DependentUnaryTransformTypes;
   mutable llvm::FoldingSet AutoTypes;
+  mutable llvm::FoldingSet
+DeducedTemplateSpecializationTypes;
   mutable llvm::FoldingSet AtomicTypes;
   llvm::FoldingSet AttributedTypes;
   mutable llvm::FoldingSet PipeTypes;
@@ -1412,6 +1414,11 @@ public:
   /// \brief C++11 deduction pattern for 'auto &&' type.
   QualType getAutoRRefDeductType() const;
 
+  /// \brief C++1z deduced class template specialization type.
+  QualType getDeducedTemplateSpecializationType(TemplateName Template,
+QualType DeducedType,
+bool IsDependent) const;
+
   /// \brief Return the unique reference to the type for the specified TagDecl
   /// (struct/union/class/enum) decl.
   QualType getTagDeclType(const TagDecl *Decl) const;

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=293207&r1=293206&r2=293207&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jan 26 14:40:47 2017
@@ -1008,6 +1008,10 @@ DEF_TRAVERSE_TYPE(UnaryTransformType, {
 })
 
 DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDeducedType())); })
+DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, {
+  TRY_TO(TraverseTemplateName(T->getTemplateName()));
+  TRY_TO(TraverseType(T->getDeducedType()));
+})
 
 DEF_TRAVERSE_TYPE(RecordType, {})
 DEF_TRAVERSE_TYPE(EnumType, {})
@@ -1232,6 +1236,11 @@ DEF_TRAVERSE_TYPELOC(AutoType, {
   TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
 })
 
+DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, {
+  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getT

Re: [libcxx] r292607 - Don't default older GCC's to C++17, but C++14 or C++11 instead

2017-01-26 Thread Renato Golin via cfe-commits
On 26 January 2017 at 18:22, Hans Wennborg  wrote:
> What's the status here? Waiting for Marshall?

Possibly. I can confirm this made all the problem on ARM go away with
GCC 5.3 and 6.3.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r293190 - Use TargetMachine adjustPassManager hook

2017-01-26 Thread Stanislav Mekhanoshin via cfe-commits
Author: rampitec
Date: Thu Jan 26 10:49:21 2017
New Revision: 293190

URL: http://llvm.org/viewvc/llvm-project?rev=293190&view=rev
Log:
Use TargetMachine adjustPassManager hook

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=293190&r1=293189&r2=293190&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan 26 10:49:21 2017
@@ -334,13 +334,8 @@ void EmitAssemblyHelper::CreatePasses(le
 
   MPM.add(new TargetLibraryInfoWrapperPass(*TLII));
 
-  // Add target-specific passes that need to run as early as possible.
   if (TM)
-PMBuilder.addExtension(
-PassManagerBuilder::EP_EarlyAsPossible,
-[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
-  TM->addEarlyAsPossiblePasses(PM);
-});
+TM->adjustPassManager(PMBuilder);
 
   PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
  addAddDiscriminatorsPass);


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


[PATCH] D29186: clang-format: [JS] do not format MPEG transport streams.

2017-01-26 Thread Alex Eagle via Phabricator via cfe-commits
alexeagle added a comment.

confused, wasn't this committed last year? is this an extra check?


https://reviews.llvm.org/D29186



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


r293199 - Turn on -Wblock-capture-autoreleasing by default.

2017-01-26 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jan 26 12:51:10 2017
New Revision: 293199

URL: http://llvm.org/viewvc/llvm-project?rev=293199&view=rev
Log:
Turn on -Wblock-capture-autoreleasing by default.

Turning on the warning by default helps the users as it's a common
mistake to capture out-parameters in a block without ensuring the object
assigned doesn't get released.

rdar://problem/30200058

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=293199&r1=293198&r2=293199&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 26 12:51:10 
2017
@@ -5185,7 +5185,7 @@ def err_arc_inconsistent_property_owners
 def warn_block_capture_autoreleasing : Warning<
   "block captures an autoreleasing out-parameter, which may result in "
   "use-after-free bugs">,
-  InGroup, DefaultIgnore;
+  InGroup;
 def note_declare_parameter_autoreleasing : Note<
   "declare the parameter __autoreleasing explicitly to suppress this warning">;
 def note_declare_parameter_strong : Note<

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=293199&r1=293198&r2=293199&view=diff
==
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Thu Jan 26 12:51:10 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class 
-Wblock-capture-autoreleasing %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
 
 typedef unsigned long NSUInteger;
 typedef const void * CFTypeRef;


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


[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

2017-01-26 Thread Dimitry Andric via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293197: Disable thread safety analysis for some functions in 
__thread_support (authored by dim).

Changed prior to commit:
  https://reviews.llvm.org/D28520?vs=85794&id=85939#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28520

Files:
  libcxx/trunk/include/__threading_support


Index: libcxx/trunk/include/__threading_support
===
--- libcxx/trunk/include/__threading_support
+++ libcxx/trunk/include/__threading_support
@@ -40,6 +40,12 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__FreeBSD__) && defined(__clang__) && 
__has_attribute(no_thread_safety_analysis)
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 
__attribute__((no_thread_safety_analysis))
+#else
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
@@ -102,25 +108,25 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -133,10 +139,10 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts);
 


Index: libcxx/trunk/include/__threading_support
===
--- libcxx/trunk/include/__threading_support
+++ libcxx/trunk/include/__threading_support
@@ -40,6 +40,12 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis)
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis))
+#else
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
@@ -102,25 +108,25 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -133,10 +139,10 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_condvar_timedwait(__lib

[libcxx] r293197 - Disable thread safety analysis for some functions in __thread_support

2017-01-26 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Thu Jan 26 12:37:18 2017
New Revision: 293197

URL: http://llvm.org/viewvc/llvm-project?rev=293197&view=rev
Log:
Disable thread safety analysis for some functions in __thread_support

Many thread-related libc++ test cases fail on FreeBSD, due to the
following -Werror warnings:

In file included from 
test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
In file included from include/thread:97:
In file included from include/__mutex_base:17:
include/__threading_support:222:1: error: mutex '__m' is still held at the 
end of function [-Werror,-Wthread-safety-analysis]
}
^
include/__threading_support:221:10: note: mutex acquired here
  return pthread_mutex_lock(__m);
 ^
include/__threading_support:231:10: error: releasing mutex '__m' that was 
not held [-Werror,-Wthread-safety-analysis]
  return pthread_mutex_unlock(__m);
 ^
include/__threading_support:242:1: error: mutex '__m' is still held at the 
end of function [-Werror,-Wthread-safety-analysis]
}
^
include/__threading_support:241:10: note: mutex acquired here
  return pthread_mutex_lock(__m);
 ^
include/__threading_support:251:10: error: releasing mutex '__m' that was 
not held [-Werror,-Wthread-safety-analysis]
  return pthread_mutex_unlock(__m);
 ^
include/__threading_support:272:10: error: calling function 
'pthread_cond_wait' requires holding mutex '__m' exclusively 
[-Werror,-Wthread-safety-analysis]
  return pthread_cond_wait(__cv, __m);
 ^
include/__threading_support:278:10: error: calling function 
'pthread_cond_timedwait' requires holding mutex '__m' exclusively 
[-Werror,-Wthread-safety-analysis]
  return pthread_cond_timedwait(__cv, __m, __ts);
 ^
6 errors generated.

This is because on FreeBSD, the pthread functions have lock annotations.
Since the functions in __thread_support are internal to libc++ only, add
no_thread_safety_analysis attributes to suppress these warnings.

Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
Differential Revision: https://reviews.llvm.org/D28520

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293197&r1=293196&r2=293197&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Thu Jan 26 12:37:18 2017
@@ -40,6 +40,12 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__FreeBSD__) && defined(__clang__) && 
__has_attribute(no_thread_safety_analysis)
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 
__attribute__((no_thread_safety_analysis))
+#else
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
@@ -102,25 +108,25 @@ typedef DWORD __libcpp_tls_key;
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -133,10 +139,10 @@ int __libcpp_condvar_signal(__libcpp_con
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts);
 


___
cfe-commits mailing list

[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 85937.
JDevlieghere added a comment.

- Added missing instantiations in test


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,188 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
+// -std=c++14
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+// libc++'s implementation
+template 
+class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b),
+__size_(__s) {}
+
+public:
+  typedef _E value_type;
+  typedef const _E &reference;
+  typedef const _E &const_reference;
+  typedef size_t size_type;
+
+  typedef const _E *iterator;
+  typedef const _E *const_iterator;
+
+  initializer_list() : __begin_(nullptr), __size_(0) {}
+
+  size_t size() const { return __size_; }
+  const _E *begin() const { return __begin_; }
+  const _E *end() const { return __begin_ + __size_; }
+};
+
+template 
+class vector {
+public:
+  vector(T){};
+  vector(std::initializer_list) {}
+};
+}
+
+class Bar {};
+
+Bar b;
+
+class Foo {
+public:
+  Foo(Bar);
+  explicit Foo(Bar, unsigned int);
+  Foo(unsigned int);
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+class Quux : public Foo {
+public:
+  Quux(Bar bar) : Foo(bar){};
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
+
+auto f3() {
+  Bar b;
+  return Foo(b);
+}
+
+#define A(b) Foo(b)
+
+Foo f4() {
+  Bar b;
+  return A(b);
+}
+
+Foo f5() {
+  Bar b;
+  return Quux(b);
+}
+
+Foo f6() {
+  Bar b;
+  return Foo(b, 1);
+}
+
+std::vector f7() {
+  int i = 1;
+  return std::vector(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {i};
+}
+
+Bar f8() {
+  return {};
+}
+
+Bar f9() {
+  return Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {};
+}
+
+Bar f10() {
+  return Bar{};
+}
+
+Foo f11(Bar b) {
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f12() {
+  return f11(Bar());
+}
+
+Foo f13() {
+  return Foo(Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {Bar()};
+}
+
+Foo f14() {
+  // FIXME: Type narrowing should not occur!
+  return Foo(-1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {-1};
+}
+
+Foo f15() {
+  return Foo(f10());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {f10()};
+}
+
+template 
+T f16() {
+  return T();
+}
+
+Bar i1 = f16();
+Baz i2 = f16();
+
+template 
+Foo f17(T t) {
+  return Foo(t);
+}
+
+Foo i3 = f17(b);
+
+template 
+class BazT {
+public:
+  T m() {
+Bar b;
+return T(b);
+  }
+
+  Foo m2(T t) {
+return Foo(t);
+  }
+};
+
+BazT bazFoo;
+Foo i4 = bazFoo.m();
+Foo i5 = bazFoo.m2(b);
+
+BazT bazQuux;
+Foo i6 = bazQuux.m();
+Foo i7 = bazQuux.m2(b);
+
+auto v1 = []() { return std::vector({1, 2}); }();
+auto v2 = []() -> std::vector { return std::vector({1, 2}); }();
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-t

[PATCH] D29151: [clang-tidy] Add misc-invalidated-iterators check.

2017-01-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D29151#657435, @Prazek wrote:

> In https://reviews.llvm.org/D29151#656887, @Eugene.Zelenko wrote:
>
> > General question: isn't Static Analyzer is better place for such workflow 
> > checks?
>
>
> Probably yes, but it is much harder to implement this there. Other problem is 
> that it would be probably a part 
>  of one of the alpha checks, that are not developed and I don't know if they 
> will ever be fully supported.


But it'll be necessary to re-implement part of Static Analyzer functionality in 
Clang-tidy. Will it be generic enough to be used for similar purposes?

It'll be good idea to find out Static Analyzer release criteria.


Repository:
  rL LLVM

https://reviews.llvm.org/D29151



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


r293194 - [Sema][ObjC] Make sure -Wblock-capture-autoreleasing issues a warning

2017-01-26 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jan 26 12:13:06 2017
New Revision: 293194

URL: http://llvm.org/viewvc/llvm-project?rev=293194&view=rev
Log:
[Sema][ObjC] Make sure -Wblock-capture-autoreleasing issues a warning
even in the presence of nullability qualifiers.

This commit fixes bugs in r285031 where -Wblock-capture-autoreleasing
wouldn't issue warnings when the function parameters were annotated
with nullability qualifiers. Specifically, look through the sugar and
see if there is an AttributedType of kind attr_objc_ownership to
determine whether __autoreleasing was explicitly specified or implicitly
added by the compiler.

rdar://problem/30193488

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=293194&r1=293193&r2=293194&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jan 26 12:13:06 2017
@@ -13603,11 +13603,28 @@ static bool captureInBlock(BlockScopeInf
   }
 
   // Warn about implicitly autoreleasing indirect parameters captured by 
blocks.
-  if (auto *PT = dyn_cast(CaptureType)) {
+  if (const auto *PT = CaptureType->getAs()) {
+// This function finds out whether there is an AttributedType of kind
+// attr_objc_ownership in Ty. The existence of AttributedType of kind
+// attr_objc_ownership implies __autoreleasing was explicitly specified
+// rather than being added implicitly by the compiler.
+auto IsObjCOwnershipAttributedType = [](QualType Ty) {
+  while (const auto *AttrTy = Ty->getAs()) {
+if (AttrTy->getAttrKind() == AttributedType::attr_objc_ownership)
+  return true;
+
+// Peel off AttributedTypes that are not of kind objc_ownership.
+Ty = AttrTy->getModifiedType();
+  }
+
+  return false;
+};
+
 QualType PointeeTy = PT->getPointeeType();
-if (isa(PointeeTy.getCanonicalType()) &&
+
+if (PointeeTy->getAs() &&
 PointeeTy.getObjCLifetime() == Qualifiers::OCL_Autoreleasing &&
-!isa(PointeeTy)) {
+!IsObjCOwnershipAttributedType(PointeeTy)) {
   if (BuildAndDiagnose) {
 SourceLocation VarLoc = Var->getLocation();
 S.Diag(Loc, diag::warn_block_capture_autoreleasing);

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=293194&r1=293193&r2=293194&view=diff
==
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Thu Jan 26 12:13:06 2017
@@ -809,9 +809,30 @@ int garf() {
   TKAssertEqual(object, (id)nil);
 }
 
-void block_capture_autoreleasing(A * __autoreleasing *a, A **b) { // 
expected-note {{declare the parameter __autoreleasing explicitly to suppress 
this warning}} expected-note {{declare the parameter __strong or capture a 
__block __strong variable to keep values alive across autorelease pools}}
+void block_capture_autoreleasing(A * __autoreleasing *a,
+ A **b, // expected-note {{declare the 
parameter __autoreleasing explicitly to suppress this warning}} expected-note 
{{declare the parameter __strong or capture a __block __strong variable to keep 
values alive across autorelease pools}}
+ A * _Nullable *c, // expected-note {{declare 
the parameter __autoreleasing explicitly to suppress this warning}} 
expected-note {{declare the parameter __strong or capture a __block __strong 
variable to keep values alive across autorelease pools}}
+ A * _Nullable __autoreleasing *d,
+ A ** _Nullable e, // expected-note {{declare 
the parameter __autoreleasing explicitly to suppress this warning}} 
expected-note {{declare the parameter __strong or capture a __block __strong 
variable to keep values alive across autorelease pools}}
+ A * __autoreleasing * _Nullable f,
+ id __autoreleasing *g,
+ id *h, // expected-note {{declare the 
parameter __autoreleasing explicitly to suppress this warning}} expected-note 
{{declare the parameter __strong or capture a __block __strong variable to keep 
values alive across autorelease pools}}
+ id _Nullable *i, // expected-note {{declare 
the parameter __autoreleasing explicitly to suppress this warning}} 
expected-note {{declare the parameter __strong or capture a __block __strong 
variable to keep values alive across autorelease pools}}
+ id _Nullable __autoreleasing *j,
+ id * _Nullable k, // expected-note {{declare 
the parameter __autoreleasing explicitly to suppress this warning}} 
expected-note {{de

Re: [libcxxabi] r292638 - Fix catch_reference_nullptr.pass.cpp test for GCC.

2017-01-26 Thread Hans Wennborg via cfe-commits
On Fri, Jan 20, 2017 at 1:52 PM, Renato Golin  wrote:
> On 20 January 2017 at 19:46, Eric Fiselier  wrote:
>> This patch fixes a libc++abi test failure when compiled with GCC 5, 6, or 7.
>> We should merge this into 4.0 to help get `check-all` clean.
>
> Hi Eric,
>
> All good on my side, pass with GCC 5.4 and 6.3.
>
> Can you attach all commits that need to be backported into a bug
> against PR31622?
>
> We should probably squash them all before merge.

What's the status here?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r292607 - Don't default older GCC's to C++17, but C++14 or C++11 instead

2017-01-26 Thread Hans Wennborg via cfe-commits
What's the status here? Waiting for Marshall?

On Mon, Jan 23, 2017 at 10:20 AM, Hans Wennborg  wrote:
> Sounds good to me.
>
> On Fri, Jan 20, 2017 at 11:38 AM, Eric Fiselier  wrote:
>> We should merge this patch into the 4.0 release branch. It is needed to make
>> "check-all" pass when using GCC 4, 5 and 6.
>>
>> /Eric
>>
>> On Fri, Jan 20, 2017 at 5:54 AM, Eric Fiselier via cfe-commits
>>  wrote:
>>>
>>> Author: ericwf
>>> Date: Fri Jan 20 06:54:45 2017
>>> New Revision: 292607
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=292607&view=rev
>>> Log:
>>> Don't default older GCC's to C++17, but C++14 or C++11 instead
>>>
>>> Modified:
>>> libcxx/trunk/test/libcxx/test/config.py
>>>
>>> Modified: libcxx/trunk/test/libcxx/test/config.py
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292607&r1=292606&r2=292607&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/test/libcxx/test/config.py (original)
>>> +++ libcxx/trunk/test/libcxx/test/config.py Fri Jan 20 06:54:45 2017
>>> @@ -423,6 +423,15 @@ class Configuration(object):
>>>  if not std:
>>>  # Choose the newest possible language dialect if none is
>>> given.
>>>  possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
>>> +if self.cxx.type == 'gcc':
>>> +maj_v, _, _ = self.cxx.version
>>> +maj_v = int(maj_v)
>>> +if maj_v < 7:
>>> +possible_stds.remove('c++1z')
>>> +# FIXME: How many C++14 tests actually fail under GCC 5
>>> and 6?
>>> +# Should we XFAIL them individually instead?
>>> +if maj_v <= 6:
>>> +possible_stds.remove('c++14')
>>>  for s in possible_stds:
>>>  if self.cxx.hasCompileFlag('-std=%s' % s):
>>>  std = s
>>>
>>>
>>> ___
>>> 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: r291963 - [clang] Emit `diagnose_if` warnings from system headers

2017-01-26 Thread Hans Wennborg via cfe-commits
Ping?

On Mon, Jan 23, 2017 at 4:27 PM, Hans Wennborg  wrote:
> Ping?
>
> On Tue, Jan 17, 2017 at 4:16 PM, Hans Wennborg  wrote:
>> Richard, what do you think?
>>
>> On Fri, Jan 13, 2017 at 3:16 PM, Eric Fiselier  wrote:
>>> I would love to see this merged. It would make it easier to write libc++
>>> tests if the tests didn't have to worry about the old 4.0 behavior.
>>>
>>> CC'ing Richard: Would merging this be OK?
>>>
>>> On Fri, Jan 13, 2017 at 3:46 PM, George Burgess IV
>>>  wrote:

 Do we want to consider merging this into the release branch? Seems like
 more of a bugfix than a feature to me.

 On Fri, Jan 13, 2017 at 2:11 PM, Eric Fiselier via cfe-commits
  wrote:
>
> Author: ericwf
> Date: Fri Jan 13 16:11:40 2017
> New Revision: 291963
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291963&view=rev
> Log:
> [clang] Emit `diagnose_if` warnings from system headers
>
> Summary: In order for libc++ to meaningfully use `diagnose_if` warnings
> they need to be emitted from system headers by default. This patch changes
> the `diagnose_if` warning diagnostic to be shown in system headers.
>
> Reviewers: george.burgess.iv, rsmith, aaron.ballman
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D28703
>
> Added:
> cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/test/Sema/diagnose_if.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291963&r1=291962&r2=291963&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
> 16:11:40 2017
> @@ -3380,7 +3380,8 @@ def note_ovl_candidate_has_pass_object_s
>  "candidate address cannot be taken because parameter %0 has "
>  "pass_object_size attribute">;
>  def err_diagnose_if_succeeded : Error<"%0">;
> -def warn_diagnose_if_succeeded : Warning<"%0">,
> InGroup;
> +def warn_diagnose_if_succeeded : Warning<"%0">,
> InGroup,
> +ShowInSystemHeader;
>  def note_ovl_candidate_disabled_by_function_cond_attr : Note<
>  "candidate disabled: %0">;
>  def note_ovl_candidate_disabled_by_extension : Note<
>
> Added: cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h?rev=291963&view=auto
>
> ==
> --- cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h (added)
> +++ cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h Fri Jan
> 13 16:11:40 2017
> @@ -0,0 +1,11 @@
> +#pragma GCC system_header
> +
> +inline int system_header_func(int x)
> +  __attribute__((diagnose_if(x == x, "system header warning",
> "warning"))) // expected-note {{from 'diagnose_if' attribute}}
> +{
> +  return 0;
> +}
> +
> +void test_system_header() {
> +  system_header_func(0); // expected-warning {{system header warning}}
> +}
>
> Modified: cfe/trunk/test/Sema/diagnose_if.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diagnose_if.c?rev=291963&r1=291962&r2=291963&view=diff
>
> ==
> --- cfe/trunk/test/Sema/diagnose_if.c (original)
> +++ cfe/trunk/test/Sema/diagnose_if.c Fri Jan 13 16:11:40 2017
> @@ -150,3 +150,6 @@ void alwaysWarnWithArg(int a) _diagnose_
>  void runAlwaysWarnWithArg(int a) {
>alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}}
>  }
> +
> +// Test that diagnose_if warnings generated in system headers are not
> ignored.
> +#include "Inputs/diagnose-if-warn-system-header.h"
>
>
> ___
> 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] D29186: clang-format: [JS] do not format MPEG transport streams.

2017-01-26 Thread Martin Probst via Phabricator via cfe-commits
mprobst added a comment.

PTAL, moved the check down a bit.


https://reviews.llvm.org/D29186



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


[PATCH] D29186: clang-format: [JS] do not format MPEG transport streams.

2017-01-26 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 85934.
mprobst added a comment.

- Move MPEG check into Format.cpp.


https://reviews.llvm.org/D29186

Files:
  lib/Format/Format.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1036,6 +1036,15 @@
   verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);");
 }
 
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  std::string MpegTS(200, ' ');
+  MpegTS.replace(0, strlen("nearlyLooks  +   like +   ts + code;  "),
+ "nearlyLooks  +   like +   ts + code;  ");
+  MpegTS[0] = 0x47;
+  MpegTS[188] = 0x47;
+  verifyFormat(MpegTS, MpegTS);
+}
+
 TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: string;");
   verifyFormat("var x: {a: string; b: number;} = {};");
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -256,6 +256,7 @@
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
   }
+
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle->SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1462,12 +1462,22 @@
   return Replaces;
 }
 
+bool isMpegTS(StringRef Code) {
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
+}
+
 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
+  isMpegTS(Code))
+return Replaces;
   if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
 return sortJavaScriptImports(Style, Code, Ranges, FileName);
   sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
@@ -1813,7 +1823,8 @@
   FormatStyle Expanded = expandPresets(Style);
   if (Expanded.DisableFormat)
 return tooling::Replacements();
-
+  if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
+return tooling::Replacements();
   auto Env = Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
 
   if (Style.Language == FormatStyle::LK_JavaScript &&


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1036,6 +1036,15 @@
   verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);");
 }
 
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  std::string MpegTS(200, ' ');
+  MpegTS.replace(0, strlen("nearlyLooks  +   like +   ts + code;  "),
+ "nearlyLooks  +   like +   ts + code;  ");
+  MpegTS[0] = 0x47;
+  MpegTS[188] = 0x47;
+  verifyFormat(MpegTS, MpegTS);
+}
+
 TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: string;");
   verifyFormat("var x: {a: string; b: number;} = {};");
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -256,6 +256,7 @@
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
   }
+
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle->SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1462,12 +1462,22 @@
   return Replaces;
 }
 
+bool isMpegTS(StringRef Code) {
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
+}
+
 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
+  isMpegTS(Code))
+return Replaces;
   if (Style.Language == FormatStyle::LanguageKind::LK_JavaScri

Re: [libunwind] r292723 - X86: swap EBP, ESP on !APPLE

2017-01-26 Thread Hans Wennborg via cfe-commits
Michał suggested on the PR that this should be merged to the release branch.

Saleem, what do you think?

On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
 wrote:
> Author: compnerd
> Date: Sat Jan 21 10:22:59 2017
> New Revision: 292723
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292723&view=rev
> Log:
> X86: swap EBP, ESP on !APPLE
>
> Restore the `libunwind.h` enumeration values back to the inverted
> values.  This diverges from the DWARF definition of the register values.
> However, this allows our header to be compatible with other unwind
> implementations (e.g. HP, GNU Savannah, GCC).
>
> The register IDs are only swapped in the header and need to be unswapped
> when accessing the unwind register file.  The flipped EBP and ESP only
> applies on non-Apple x86 targets.
>
> When optimizations were enabled, EBP and ESP would no longer be
> equivalent.  As a result, the incorrect access on Linux would manifest
> as a failure to unwind the stack.  We can now unwind the stack with and
> without FPO on Linux x86.
>
> Resolves PR30879!
>
> Modified:
> libunwind/trunk/include/libunwind.h
> libunwind/trunk/src/Registers.hpp
>
> Modified: libunwind/trunk/include/libunwind.h
> URL: 
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=292723&r1=292722&r2=292723&view=diff
> ==
> --- libunwind/trunk/include/libunwind.h (original)
> +++ libunwind/trunk/include/libunwind.h Sat Jan 21 10:22:59 2017
> @@ -165,13 +165,8 @@ enum {
>UNW_X86_ECX = 1,
>UNW_X86_EDX = 2,
>UNW_X86_EBX = 3,
> -#if defined(__CloudABI__) || defined(__FreeBSD__)
> -  UNW_X86_ESP = 4,
> -  UNW_X86_EBP = 5,
> -#else
>UNW_X86_EBP = 4,
>UNW_X86_ESP = 5,
> -#endif
>UNW_X86_ESI = 6,
>UNW_X86_EDI = 7
>  };
>
> Modified: libunwind/trunk/src/Registers.hpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=292723&r1=292722&r2=292723&view=diff
> ==
> --- libunwind/trunk/src/Registers.hpp (original)
> +++ libunwind/trunk/src/Registers.hpp Sat Jan 21 10:22:59 2017
> @@ -122,9 +122,17 @@ inline uint32_t Registers_x86::getRegist
>  return _registers.__edx;
>case UNW_X86_EBX:
>  return _registers.__ebx;
> +#if !defined(__APPLE__)
> +  case UNW_X86_ESP:
> +#else
>case UNW_X86_EBP:
> +#endif
>  return _registers.__ebp;
> +#if !defined(__APPLE__)
> +  case UNW_X86_EBP:
> +#else
>case UNW_X86_ESP:
> +#endif
>  return _registers.__esp;
>case UNW_X86_ESI:
>  return _registers.__esi;
> @@ -154,10 +162,18 @@ inline void Registers_x86::setRegister(i
>case UNW_X86_EBX:
>  _registers.__ebx = value;
>  return;
> +#if !defined(__APPLE__)
> +  case UNW_X86_ESP:
> +#else
>case UNW_X86_EBP:
> +#endif
>  _registers.__ebp = value;
>  return;
> +#if !defined(__APPLE__)
> +  case UNW_X86_EBP:
> +#else
>case UNW_X86_ESP:
> +#endif
>  _registers.__esp = value;
>  return;
>case UNW_X86_ESI:
>
>
> ___
> 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: [libcxx] r293154 - Use the new __has_feature(cxx_constexpr_string_builtins) for detection of the C-string intrinsics for constexpr support in std::char_traits. Thanks to Richard for the intrisic s

2017-01-26 Thread Hans Wennborg via cfe-commits
On Thu, Jan 26, 2017 at 6:08 AM, Marshall Clow  wrote:
> On Wed, Jan 25, 2017 at 10:58 PM, Marshall Clow via cfe-commits
>  wrote:
>>
>> Author: marshall
>> Date: Thu Jan 26 00:58:29 2017
>> New Revision: 293154
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=293154&view=rev
>> Log:
>> Use the new __has_feature(cxx_constexpr_string_builtins) for detection of
>> the C-string intrinsics for constexpr support in std::char_traits. Thanks to
>> Richard for the intrisic support.
>>
>> Modified:
>> libcxx/trunk/include/__config
>> libcxx/trunk/include/__string
>>
>
> Hans --
>
> This should be merged to the 4.0 branch.
> Thanks!

r293193.

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


[libcxx] r293193 - Merging r293154:

2017-01-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 26 11:55:46 2017
New Revision: 293193

URL: http://llvm.org/viewvc/llvm-project?rev=293193&view=rev
Log:
Merging r293154:

r293154 | marshall | 2017-01-25 22:58:29 -0800 (Wed, 25 Jan 2017) | 1 line

Use the new __has_feature(cxx_constexpr_string_builtins) for detection of the 
C-string intrinsics for constexpr support in std::char_traits. Thanks to 
Richard for the intrisic support.


Modified:
libcxx/branches/release_40/   (props changed)
libcxx/branches/release_40/include/__config
libcxx/branches/release_40/include/__string

Propchange: libcxx/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 26 11:55:46 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:292013,292091,292990
+/libcxx/trunk:292013,292091,292990,293154

Modified: libcxx/branches/release_40/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/__config?rev=293193&r1=293192&r2=293193&view=diff
==
--- libcxx/branches/release_40/include/__config (original)
+++ libcxx/branches/release_40/include/__config Thu Jan 26 11:55:46 2017
@@ -403,15 +403,6 @@ namespace std {
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute__((__no_sanitize__("unsigned-integer-overflow")))
 #endif 
 
-// A constexpr version of __builtin_memcmp was added in clang 4.0
-#if __has_builtin(__builtin_memcmp)
-# ifdef __apple_build_version__
-// No shipping version of Apple's clang has constexpr __builtin_memcmp
-# elif __clang_major__ > 3
-#  define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR
-# endif
-#endif
-
 #elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))

Modified: libcxx/branches/release_40/include/__string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/__string?rev=293193&r1=293192&r2=293193&view=diff
==
--- libcxx/branches/release_40/include/__string (original)
+++ libcxx/branches/release_40/include/__string Thu Jan 26 11:55:46 2017
@@ -243,7 +243,7 @@ char_traits::compare(const char_ty
 {
 if (__n == 0)
 return 0;
-#ifdef _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR
+#if __has_feature(cxx_constexpr_string_builtins)
 return __builtin_memcmp(__s1, __s2, __n);
 #elif _LIBCPP_STD_VER <= 14
 return memcmp(__s1, __s2, __n);
@@ -265,7 +265,9 @@ char_traits::find(const char_type*
 {
 if (__n == 0)
 return NULL;
-#if _LIBCPP_STD_VER <= 14
+#if __has_feature(cxx_constexpr_string_builtins)
+return __builtin_char_memchr(__s, to_int_type(__a), __n);
+#elif _LIBCPP_STD_VER <= 14
 return (const char_type*) memchr(__s, to_int_type(__a), __n);
 #else
 for (; __n; --__n)
@@ -331,7 +333,7 @@ char_traits::compare(const char
 {
 if (__n == 0)
 return 0;
-#if __has_builtin(__builtin_wmemcmp)
+#if __has_feature(cxx_constexpr_string_builtins)
 return __builtin_wmemcmp(__s1, __s2, __n);
 #elif _LIBCPP_STD_VER <= 14
 return wmemcmp(__s1, __s2, __n);
@@ -351,7 +353,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX14
 size_t
 char_traits::length(const char_type* __s) _NOEXCEPT
 {
-#if __has_builtin(__builtin_wcslen)
+#if __has_feature(cxx_constexpr_string_builtins)
 return __builtin_wcslen(__s);
 #elif _LIBCPP_STD_VER <= 14
 return wcslen(__s);
@@ -369,7 +371,7 @@ char_traits::find(const char_ty
 {
 if (__n == 0)
 return NULL;
-#if __has_builtin(__builtin_wmemchr)
+#if __has_feature(cxx_constexpr_string_builtins)
 return __builtin_wmemchr(__s, __a, __n);
 #elif _LIBCPP_STD_VER <= 14
 return wmemchr(__s, __a, __n);


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


Re: [libcxx] r292990 - Change the return type of emplace_[front|back] back to void when building with C++14 or before. Resolves PR31680.

2017-01-26 Thread Hans Wennborg via cfe-commits
On Thu, Jan 26, 2017 at 6:05 AM, Marshall Clow  wrote:
> On Wed, Jan 25, 2017 at 9:11 AM, Hans Wennborg  wrote:
>>
>> Should we merge this to 4.0?
>
>
> Yes, please.

r293192.

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


[libcxx] r293192 - Merging r292990:

2017-01-26 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 26 11:51:25 2017
New Revision: 293192

URL: http://llvm.org/viewvc/llvm-project?rev=293192&view=rev
Log:
Merging r292990:

r292990 | marshall | 2017-01-24 15:09:12 -0800 (Tue, 24 Jan 2017) | 1 line

Change the return type of emplace_[front|back] back to void when building with 
C++14 or before. Resolves PR31680.


Modified:
libcxx/branches/release_40/   (props changed)
libcxx/branches/release_40/include/deque
libcxx/branches/release_40/include/forward_list
libcxx/branches/release_40/include/list
libcxx/branches/release_40/include/queue
libcxx/branches/release_40/include/stack
libcxx/branches/release_40/include/vector

libcxx/branches/release_40/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp

libcxx/branches/release_40/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp

libcxx/branches/release_40/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
libcxx/branches/release_40/www/cxx1z_status.html

Propchange: libcxx/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 26 11:51:25 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:292013,292091
+/libcxx/trunk:292013,292091,292990

Modified: libcxx/branches/release_40/include/deque
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/deque?rev=293192&r1=293191&r2=293192&view=diff
==
--- libcxx/branches/release_40/include/deque (original)
+++ libcxx/branches/release_40/include/deque Thu Jan 26 11:51:25 2017
@@ -110,8 +110,8 @@ public:
 void push_front(value_type&& v);
 void push_back(const value_type& v);
 void push_back(value_type&& v);
-template  reference emplace_front(Args&&... args);
-template  reference emplace_back(Args&&... args);
+template  reference emplace_front(Args&&... args);  // 
reference in C++17
+template  reference emplace_back(Args&&... args);   // 
reference in C++17
 template  iterator emplace(const_iterator p, Args&&... 
args);
 iterator insert(const_iterator p, const value_type& v);
 iterator insert(const_iterator p, value_type&& v);
@@ -1342,8 +1342,13 @@ public:
 void push_back(const value_type& __v);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_VARIADICS
+#if _LIBCPP_STD_VER > 14
 template  reference emplace_front(_Args&&... __args);
-template  reference emplace_back(_Args&&... __args);
+template  reference emplace_back (_Args&&... __args);
+#else
+template  void  emplace_front(_Args&&... __args);
+template  void  emplace_back (_Args&&... __args);
+#endif
 template  iterator emplace(const_iterator __p, _Args&&... 
__args);
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 void push_front(value_type&& __v);
@@ -1822,7 +1827,11 @@ deque<_Tp, _Allocator>::push_back(value_
 
 template 
 template 
+#if _LIBCPP_STD_VER > 14
 typename deque<_Tp, _Allocator>::reference
+#else
+void
+#endif
 deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 {
 allocator_type& __a = __base::__alloc();
@@ -1832,7 +1841,9 @@ deque<_Tp, _Allocator>::emplace_back(_Ar
 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()),
   _VSTD::forward<_Args>(__args)...);
 ++__base::size();
+#if _LIBCPP_STD_VER > 14
 return *--__base::end();
+#endif
 }
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
@@ -1870,7 +1881,11 @@ deque<_Tp, _Allocator>::push_front(value
 
 template 
 template 
+#if _LIBCPP_STD_VER > 14
 typename deque<_Tp, _Allocator>::reference
+#else
+void
+#endif
 deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
 {
 allocator_type& __a = __base::__alloc();
@@ -1880,7 +1895,9 @@ deque<_Tp, _Allocator>::emplace_front(_A
 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), 
_VSTD::forward<_Args>(__args)...);
 --__base::__start_;
 ++__base::size();
+#if _LIBCPP_STD_VER > 14
 return *__base::begin();
+#endif
 }
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS

Modified: l

[PATCH] D29186: clang-format: [JS] do not format MPEG transport streams.

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



Comment at: unittests/Format/FormatTestJS.cpp:1002
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  char mpegTS[200];
+  mpegTS[0] = 0x47;

nit: Should be MpegTS.


https://reviews.llvm.org/D29186



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


[PATCH] D28905: [analyzer] Consider function call arguments while building CallGraph

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

LGTM!


https://reviews.llvm.org/D28905



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


Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant

2017-01-26 Thread Nico Weber via cfe-commits
Yes, things are happy again, thanks!

Our bots currently use the macOS 10.10 SDK.

On Thu, Jan 26, 2017 at 6:56 AM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> Hi Nico,
>
> Hopefully I've sorted this out in r293166/r293167. Please let me know if
> things are not back to normal.
>
> (I'll keep an eye on your builder too)
>
> / Asiri
>
> On Wed, Jan 25, 2017 at 8:42 PM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> Hi Nico,
>>
>> Thanks for the links. I may have a clue to what is going on.
>>
>> I think in your Mac environment,  does not provide
>> either pthread_mach_thread_np() function or define the type mach_port_t
>> (is there a way for you to check this btw? just to make sure).
>>
>> This was not a problem before (for your builds) because this function was
>> only used in libcxxabi sources. In my eagerness to get rid of all pthread
>> dependencies in libcxx/libcxxabi, I have lifted this out into
>> __threading_support header in libcxx (which is our new threading API for
>> both libcxx and libcxxabi).
>>
>> @Eric: would it be OK to leave this Mac-specific pthread dependency in
>> libcxxabi sources as it was? In that way, libcxx builds like Nico's won't
>> be affected.
>>
>> Another option is to try and detect the conditions (on Mac environments)
>> where pthread_mach_thread_np/mach_port_t is available, and only define
>> the corresponding libcxx thread-api function (__libcpp_thread_get_port)
>> when this condition is true. Unfortunately I'm not familiar with Mac enough
>> to know this. Any thoughts?
>>
>> Side note:- Btw, if I'm correct with the above analysis, it won't be
>> possible to build libcxxabi in Nico's environment (even before my changes).
>> The dependency on pthread_mach_thread_np() was already there
>> in __cxa_guard_acquire().
>>
>> Thanks.
>>
>> / Asiri
>>
>>
>> On Wed, Jan 25, 2017 at 7:34 PM, Nico Weber  wrote:
>>
>>> Sure! https://build.chromium.org/p/chromium.fyi/builders/Cla
>>> ngToTMacASan/builds/8565/steps/gclient%20runhooks/logs/stdio has the
>>> invocations to build llvm/clang/compiler/rt, and
>>> https://build.chromium.org/p/chromium.fyi/builders/Clang
>>> ToTMacASan/builds/8565/steps/compile/logs/stdio is the actual build
>>> using that setup.
>>>
>>> On Wed, Jan 25, 2017 at 1:57 PM, Asiri Rathnayake <
>>> asiri.rathnay...@gmail.com> wrote:
>>>
 @Nico: could you let me know your build configuration? (cmake options)

 I'm surprised this went unnoticed for so long.

 Thanks.

 / Asiri

 On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" <
 asiri.rathnay...@gmail.com> wrote:

> (including cfe-commits)
>
> On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> Hi Nico,
>>
>> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Is it intentional that this change affects
>>> non-LIBCXX_HAS_EXTERNAL_THREAD_API builds at all?#
>>>
>>
>> Nope. But I'm not sure how this got broken on Mac.
>>
>> IIRC,  defines mach_port_t type on Mac, which gets
>> included when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is
>> what we expect to be the case on Mac, normally).
>>
>> I'll have to build this on a Mac tomorrow. Hopefully that's OK?
>>
>> Cheers,
>>
>> / Asiri
>>
>>
>>
>>>
>>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber 
>>> wrote:
>>>
 This breaks all our mac builds with:

 /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+
 Asserts/bin/../include/c++/v1/__threading_support:154:1: error:
 unknown type name 'mach_port_t'
 mach_port_t __libcpp_thread_get_port();

 On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: asiri
> Date: Tue Jan  3 06:59:50 2017
> New Revision: 290889
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290889&view=rev
> Log:
> [libcxx] Add build/test support for the externally threaded
> libc++abi variant
>
> Differential revision: https://reviews.llvm.org/D27576
>
> Reviewers: EricWF
>
> Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/include/__threading_support
> libcxx/trunk/test/CMakeLists.txt
> libcxx/trunk/test/libcxx/test/config.py
> libcxx/trunk/test/lit.site.cfg.in
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.
> txt?rev=290889&r1=290888&r2=290889&view=diff
> 
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Tue Jan 

[PATCH] D29186: clang-format: [JS] do not format MPEG transport streams.

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

The MPEG transport stream file format also uses ".ts" as its file extension.
This change detects its specific framing format (0x47 every 189 bytes) and
simply ignores MPEG TS files.


https://reviews.llvm.org/D29186

Files:
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -998,6 +998,13 @@
   verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);");
 }
 
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  char mpegTS[200];
+  mpegTS[0] = 0x47;
+  mpegTS[188] = 0x47;
+  verifyFormat(mpegTS);
+}
+
 TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: string;");
   verifyFormat("var x: {a: string; b: number;} = {};");
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -251,6 +251,14 @@
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
   FormatStyle FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  if (AssumedFileName.endswith(".ts") && Code->getBufferSize() > 188 &&
+  Code->getBuffer()[0] == 0x47 && Code->getBuffer()[188] == 0x47)
+return true;
+
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle.SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -998,6 +998,13 @@
   verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);");
 }
 
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  char mpegTS[200];
+  mpegTS[0] = 0x47;
+  mpegTS[188] = 0x47;
+  verifyFormat(mpegTS);
+}
+
 TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: string;");
   verifyFormat("var x: {a: string; b: number;} = {};");
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -251,6 +251,14 @@
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
   FormatStyle FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  if (AssumedFileName.endswith(".ts") && Code->getBufferSize() > 188 &&
+  Code->getBuffer()[0] == 0x47 && Code->getBuffer()[188] == 0x47)
+return true;
+
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle.SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D29183#657706, @NoQ wrote:

> Hmm, we should have done better work reviewing 
> https://reviews.llvm.org/D28905.


Oh, someone was quicker than me by one week...


https://reviews.llvm.org/D29183



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


[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I wonder if this could also be a problem for nested messages in Objective-C, 
since the call for VisitChildren() is also missing from 
VisitObjCMessageExpr()...


https://reviews.llvm.org/D29183



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


[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, we should have done better work reviewing https://reviews.llvm.org/D28905.


https://reviews.llvm.org/D29183



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


[PATCH] D28510: Reinstate CWG1607 restrictions on lambdas appearing inside certain constant-expressions

2017-01-26 Thread Faisal Vali via Phabricator via cfe-commits
faisalv updated this revision to Diff 85927.
faisalv added a comment.

I tried a different approach, not because I was convinced it was better, but 
because it seemed (at the time) a simpler tweak - I'm not sure it is robust 
enough - but would appreciate your thoughts on it.

The approach is predicated on the following:

- lambda expressions can only appear in types in a non-unevaluated context, 
within array brackets
- if we track within each parameter declarator, its parent function declarator, 
we can always get to the outer most declarator and if the outermost declarator 
has the form (ptr-op f)(...) it can not be a function declarator (but is a 
variable) - we can determine this without waiting for the recursion to complete 
(I set a special token on the declarator once we start parsing a parens 
declarator and the token is a ptr-operator)
- additionally we can check the context of the outermost declarator to ensure 
it is not within an alias-declaration or a template-argument

Based on the test cases, it seems to work well - but not sure if the test cases 
are exhaustive.
Also the patch needs some cleanup if we agree that this direction is worth 
pursuing (and not too fragile an approach).

Thanks!

Would appreciate feedback!


https://reviews.llvm.org/D28510

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -157,6 +157,56 @@
 
 } // end ns1_simple_lambda
 
+namespace test_forbidden_lambda_expressions {
+
+template struct X { }; //expected-error{{lambda expression may not appear}}
+X<[]{return 10; }()> x; //expected-error{{lambda expression may not appear}}
+void f(int arr[([] { return 5; }())]); //expected-error{{lambda expression may not appear}}
+// FIXME: Should this be ok?
+auto L = [](int arr[([] { return 5; }())]) { }; // OK
+
+// These should be allowed:
+struct A {
+  int : ([] { return 5; }());
+};
+
+int arr[([] { return 5; }())];
+enum { E = [] { return 5; }() };
+static_assert([]{return 5; }() == 5);
+int *ip = new int[([] { return 5; })()];
+
+int test_case(int x) {
+  switch(x) {
+case [] { return 5; }(): //OK
+  break;
+case [] (auto a) { return a; }(6): //expected-note{{previous}}
+  break;
+case 6:  //expected-error{{duplicate}}
+  break;
+  }
+  return x;
+}
+namespace ns2 {
+int (*f)(int a[([] { return 5; }())]);
+int fun(int a[([] { return 5; }())]);  //expected-error{{lambda expression}}
+int fun2(void (*)(int a[([] { return 5; }())])); //expected-error{{lambda expression}}
+int (*fun2p)(void f(int a[([] { return 5; }())]));
+
+int (*g(int))[([] { return 5; })()];  //expected-error{{lambda expression}}
+int *(fun3)(int a[([] { return 5; }())]); //expected-error{{lambda expression}}
+
+
+int *(&fun3r)(int a[([] { return 5; }())]) = ([] () -> auto& { int *fv(int *); return fv; })();
+
+int (*g2(int))[([] { return 5; })()]; //expected-error{{lambda expression}}
+
+int (*(*g3)(int))[([] { return 5; })()];
+template struct X { };
+X x; //expected-error{{lambda expression}}
+} //end ns2
+
+} // end ns forbidden_lambda_expressions
+
 namespace ns1_unimplemented {
 namespace ns1_captures {
 constexpr auto f(int i) {
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3787,7 +3787,8 @@
   case TemplateArgument::Expression: {
 // Template argument expressions are constant expressions.
 EnterExpressionEvaluationContext Unevaluated(
-getSema(), Uneval ? Sema::Unevaluated : Sema::ConstantEvaluated);
+getSema(),
+Uneval ? Sema::Unevaluated : Sema::ConstantEvaluatedInTemplateArgument);
 
 Expr *InputExpr = Input.getSourceExpression();
 if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2236,8 +2236,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
-EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
-   Sema::ConstantEvaluated);
+EnterExpressionEvaluationContext ConstantEvaluated(
+SemaRef, Sema::ConstantEvaluatedInTemplateArgument);
 ExprResult Value = SemaRef.SubstExpr(

[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Some comments how I found this bug. I got some strange false positives even 
after the fix for the iterator past end checker 
(https://reviews.llvm.org/D28771). I could reproduce it with the following code:

  #include 
  
  using std::list;
  using std::prev;
  
  namespace {
  
class Strange {
public:
  Strange(list &l) : Back(prev(l.end())), Item(*Back) {}
  void reset(list &l) { Back = prev(l.end()); Item = *Back; }
  int get1(list &l) { Back = prev(l.end()); return *Back; }
  int get2(list &l) { list::iterator i; i = prev(l.end()); return 
*i; }
  
private:
  list::iterator Back;
  int Item;
};
  
  }

This example was analyzed without errors, but if I removed get2(), I got 
iterator past end errors for every other function. Even more strange was that I 
could not reproduce this with std::vector, just with std::list. I started a 
long debugging session (days) and it turned out, that if I delete get2(), 
std::prev() is analyzed as top-level. Since std::prev() calls std::advance(), 
which calls an __advance() overload for bidirectional operators which 
increments or decrements the iterator in a loop. Since the number of iterations 
is undefined, after 4 iterations on both branch (++ and --) the analysis stops 
and marks the function as non-inlinable. This, of course does not happen for 
std::vector because it contains no loop but a simple += operation. If 
__advance() is marked as non-inlinable, it does not change its argument, so 
prev(l.end()) is the same as l.end(), so dereferencing the iterator is indeed 
an error.


https://reviews.llvm.org/D29183



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


[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D29183#657669, @xazax.hun wrote:

> Great find! Could you transform your examole into a testcasr that fails 
> before this patch? I think there should  be already some tests for call 
> graphs that you can take a look at.


Yes, but I am not sure where exactly to put it.


https://reviews.llvm.org/D29183



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


[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Great find! Could you transform your examole into a testcasr that fails before 
this patch? I think there should  be already some tests for call graphs that 
you can take a look at.


https://reviews.llvm.org/D29183



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


[PATCH] D29183: [Analysis] Fix for call graph to correctly handle nested call expressions

2017-01-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.

Take the following example:

  class Int {
  public:
Int(int n = 0): num(n) {}
Int(const Int& rhs): num(rhs.num) {}
Int& operator=(const Int& rhs) { num = rhs.num; }
operator int() { return num; }
  private:
int num;
  };
  
  
  template
  T h(T n) {
return n;
  }
  
  Int f(Int n) {
Int i;
i = h(n);
return i;
  }
  
  Int g(Int n) {
Int i = h(n);
return i;
  }

The call graph for this C++ compilation unit will omit the edge from f to h, 
but not from g to h. This is obviously an error. The reason is that when 
visiting the statements to build the call graph all call expressions are 
handled as leafs. In the example above f calls operator=, which is a call 
expression, but it also has a child call expression, a call to function h. 
However, this latter edge is not visited because operator= is handled as leaf 
and its child call expression is not visited.


https://reviews.llvm.org/D29183

Files:
  lib/Analysis/CallGraph.cpp


Index: lib/Analysis/CallGraph.cpp
===
--- lib/Analysis/CallGraph.cpp
+++ lib/Analysis/CallGraph.cpp
@@ -62,6 +62,7 @@
   void VisitCallExpr(CallExpr *CE) {
 if (Decl *D = getDeclFromCall(CE))
   addCalledDecl(D);
+VisitChildren(CE);
   }
 
   // Adds may-call edges for the ObjC message sends.


Index: lib/Analysis/CallGraph.cpp
===
--- lib/Analysis/CallGraph.cpp
+++ lib/Analysis/CallGraph.cpp
@@ -62,6 +62,7 @@
   void VisitCallExpr(CallExpr *CE) {
 if (Decl *D = getDeclFromCall(CE))
   addCalledDecl(D);
+VisitChildren(CE);
   }
 
   // Adds may-call edges for the ObjC message sends.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29032: [mips] Define macros related to -mabicalls in the preprocessor

2017-01-26 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

> My concern is that the stock gcc distributions for FreeBSD, NetBSD from your 
> sources doesn't define __mips_abicalls,

I think we should consider that a bug in GCC that we'll rectify. If 
`__mips_abicalls` is used in Linux GCC then we can expect 3rd party sources to 
check it, and we can migrate the in-tree (base system) uses to follow suit 
(even if we're stuck with the toolchain defining both indefinitely).


https://reviews.llvm.org/D29032



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


[PATCH] D29182: [change-namespace] correctly shorten namespace when references have leading '::'

2017-01-26 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293187: [change-namespace] correctly shorten namespace when 
references have leading '::' (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D29182?vs=85917&id=85919#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29182

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp


Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -703,9 +703,6 @@
   Result.SourceManager->getSpellingLoc(Start),
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, Result.Context->getLangOpts());
-  // If the symbol is already fully qualified, no change needs to be make.
-  if (NestedName.startswith("::"))
-return;
   std::string FromDeclName = FromDecl->getQualifiedNameAsString();
   std::string ReplaceName =
   getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
@@ -774,7 +771,8 @@
   }
   // If the new nested name in the new namespace is the same as it was in the
   // old namespace, we don't create replacement.
-  if (NestedName == ReplaceName)
+  if (NestedName == ReplaceName ||
+  (NestedName.startswith("::") && NestedName.drop_front(2) == ReplaceName))
 return;
   // If the reference need to be fully-qualified, add a leading "::" unless
   // NewNamespace is the global namespace.
Index: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -1667,6 +1667,45 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifierInAnonymousNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; ::ny::Y y; ::ny::na::A a; ::ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; Y y; A a; nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang


Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -703,9 +703,6 @@
   Result.SourceManager->getSpellingLoc(Start),
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, Result.Context->getLangOpts());
-  // If the symbol is already fully qualified, no change needs to be make.
-  if (NestedName.startswith("::"))
-return;
   std::string FromDeclName = FromDecl->getQualifiedNameAsString();
   std::string ReplaceName =
   getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
@@ -774,7 +771,8 @@
   }
   // If the new nested name in the new namespace is the same as it was in the
   // old namespace, we don't create replacement.
-  if (NestedName == ReplaceName)
+  if (NestedName == ReplaceName ||
+  (NestedName.startswith("::") && NestedName.drop_front(2) == ReplaceName))
 return;
   // If the reference need to be fully-qualified, add a leading "::" unless
   

[clang-tools-extra] r293187 - [change-namespace] correctly shorten namespace when references have leading '::'

2017-01-26 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Jan 26 10:31:32 2017
New Revision: 293187

URL: http://llvm.org/viewvc/llvm-project?rev=293187&view=rev
Log:
[change-namespace] correctly shorten namespace when references have leading '::'

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=293187&r1=293186&r2=293187&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Jan 26 
10:31:32 2017
@@ -703,9 +703,6 @@ void ChangeNamespaceTool::replaceQualifi
   Result.SourceManager->getSpellingLoc(Start),
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, Result.Context->getLangOpts());
-  // If the symbol is already fully qualified, no change needs to be make.
-  if (NestedName.startswith("::"))
-return;
   std::string FromDeclName = FromDecl->getQualifiedNameAsString();
   std::string ReplaceName =
   getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
@@ -774,7 +771,8 @@ void ChangeNamespaceTool::replaceQualifi
   }
   // If the new nested name in the new namespace is the same as it was in the
   // old namespace, we don't create replacement.
-  if (NestedName == ReplaceName)
+  if (NestedName == ReplaceName ||
+  (NestedName.startswith("::") && NestedName.drop_front(2) == ReplaceName))
 return;
   // If the reference need to be fully-qualified, add a leading "::" unless
   // NewNamespace is the global namespace.

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=293187&r1=293186&r2=293187&view=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Thu Jan 26 10:31:32 2017
@@ -1667,6 +1667,45 @@ TEST_F(ChangeNamespaceTest, ShortenNames
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifierInAnonymousNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; ::ny::Y y; ::ny::na::A a; ::ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; Y y; A a; nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang


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


[PATCH] D29182: [change-namespace] correctly shorten namespace when references have leading '::'

2017-01-26 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D29182



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


[PATCH] D29182: [change-namespace] correctly shorten namespace when references have leading '::'

2017-01-26 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.

https://reviews.llvm.org/D29182

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -1667,6 +1667,45 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifierInAnonymousNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; ::ny::Y y; ::ny::na::A a; ::ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; Y y; A a; nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -703,9 +703,6 @@
   Result.SourceManager->getSpellingLoc(Start),
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, Result.Context->getLangOpts());
-  // If the symbol is already fully qualified, no change needs to be make.
-  if (NestedName.startswith("::"))
-return;
   std::string FromDeclName = FromDecl->getQualifiedNameAsString();
   std::string ReplaceName =
   getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
@@ -774,7 +771,8 @@
   }
   // If the new nested name in the new namespace is the same as it was in the
   // old namespace, we don't create replacement.
-  if (NestedName == ReplaceName)
+  if (NestedName == ReplaceName ||
+  (NestedName.startswith("::") && NestedName.drop_front(2) == ReplaceName))
 return;
   // If the reference need to be fully-qualified, add a leading "::" unless
   // NewNamespace is the global namespace.


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -1667,6 +1667,45 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifierInAnonymousNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "namespace {\n"
+ "class X {\n"
+ " G g; ::ny::Y y; ::ny::na::A a; ::ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+  

r293183 - [OpenMP] Codegen support for 'target teams' on the NVPTX device.

2017-01-26 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Jan 26 09:43:27 2017
New Revision: 293183

URL: http://llvm.org/viewvc/llvm-project?rev=293183&view=rev
Log:
[OpenMP] Codegen support for 'target teams' on the NVPTX device.

This is a simple patch to teach OpenMP codegen to emit the construct
in Generic mode.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29143

Added:
cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=293183&r1=293182&r2=293183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Jan 26 09:43:27 2017
@@ -198,6 +198,7 @@ getExecutionModeForDirective(CodeGenModu
   OpenMPDirectiveKind DirectiveKind = D.getDirectiveKind();
   switch (DirectiveKind) {
   case OMPD_target:
+  case OMPD_target_teams:
 return CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
   case OMPD_target_parallel:
 return CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;

Added: cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp?rev=293183&view=auto
==
--- cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp Thu Jan 26 09:43:27 
2017
@@ -0,0 +1,222 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix 
CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ 
-triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck 
%s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// Check that the execution mode of all 2 target regions is set to Generic 
Mode.
+// CHECK-DAG: {{@__omp_offloading_.+l26}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l31}}_exec_mode = weak constant i8 1
+
+template
+tx ftemplate(int n) {
+  tx a = 0;
+  short aa = 0;
+  tx b[10];
+
+  #pragma omp target teams if(0)
+  {
+b[2] += 1;
+  }
+
+  #pragma omp target teams if(1)
+  {
+a = '1';
+  }
+
+  #pragma omp target teams if(n>40)
+  {
+aa = 1;
+  }
+
+  return a;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-NOT: define {{.*}}void 
{{@__omp_offloading_.+template.+l21}}_worker()
+
+
+
+
+
+
+  // CHECK-LABEL: define {{.*}}void 
{{@__omp_offloading_.+template.+l26}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
+  // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
+  // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label 
{{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]]
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
+  // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label 
{{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK: call void @__kmpc_kernel_end_parallel()
+  // CHECK: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // 

[PATCH] D29143: [OpenMP] Codegen support for 'target teams' on the NVPTX device.

2017-01-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293183: [OpenMP] Codegen support for 'target teams' on the 
NVPTX device. (authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D29143?vs=85791&id=85913#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29143

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp

Index: cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
+++ cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -0,0 +1,222 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// Check that the execution mode of all 2 target regions is set to Generic Mode.
+// CHECK-DAG: {{@__omp_offloading_.+l26}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l31}}_exec_mode = weak constant i8 1
+
+template
+tx ftemplate(int n) {
+  tx a = 0;
+  short aa = 0;
+  tx b[10];
+
+  #pragma omp target teams if(0)
+  {
+b[2] += 1;
+  }
+
+  #pragma omp target teams if(1)
+  {
+a = '1';
+  }
+
+  #pragma omp target teams if(n>40)
+  {
+aa = 1;
+  }
+
+  return a;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l21}}_worker()
+
+
+
+
+
+
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
+  // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
+  // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]]
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
+  // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK: call void @__kmpc_kernel_end_parallel()
+  // CHECK: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK: ret void
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+template.+l26]](i[[SZ:32|64]] [[A:%[^)]+]])
+  // CHECK: store i[[SZ]] [[A]], i[[SZ]]* [[A_ADDR:%.+]], align
+  // CHECK: [[CONV:%.+]] = bitcast i[[SZ]]* [[A_ADDR]] to i8*
+
+  // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-DAG: [[TH_LIMIT:%.+]] = sub i32 [[NTH]], [[WS]]
+  // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[TH_LIMIT]]
+  // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[CHECK_MASTER:.+]]
+  //
+  // CHECK: [[WORKER]]
+  // CHECK: {{call|invoke}} void [[T1]]_worker()
+  // CHECK: br label {{%?}}[[EXIT:.+]]
+  //
+  // CHECK: [[CHECK_MASTER]]
+  // CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.n

[PATCH] D27917: [OpenCL] Improve diagnostics for double type

2017-01-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

with the new pragma for associating types with extensions. This feature can be 
implemented by solely modify opencl-c.h by adding #pragma OPENCL EXTENSION 
cl_khr_fp64 : begin/end around vector double type definitions, e.g.

  #pragma OPENCL EXTENSION cl_khr_fp64 : begin
  typedef double double2 __attribute__((ext_vector_type(2)));
  typedef double double3 __attribute__((ext_vector_type(3)));
  typedef double double4 __attribute__((ext_vector_type(4)));
  typedef double double8 __attribute__((ext_vector_type(8)));
  typedef double double16 __attribute__((ext_vector_type(16)));
  #pragma OPENCL EXTENSION cl_khr_fp64 : end
  #ifdef cl_khr_fp64
  #if __OPENCL_C_VERSION__ < CL_VERSION_1_2
  #pragma OPENCL EXTENSION cl_khr_fp64 : enable
  #endif
  #endif

The

  #pragma OPENCL EXTENSION cl_khr_fp64 : enable

is for suppressing diagnostics due to using double type in builtin functions. 
Ideally they should also be surrounded by #pragma OPENCL EXTENSION cl_khr_fp64 
: begin/end.


https://reviews.llvm.org/D27917



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


[PATCH] D29176: [change-namespace] add leading '::' to references in new namespace when name conflict is possible.

2017-01-26 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293182: [change-namespace] add leading '::' to references in 
new namespace when name… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D29176?vs=85903&id=85904#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29176

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -1599,6 +1599,74 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ExistingNamespaceConflictWithNewNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " na::A a; nb::B b;\n"
+ "};\n"
+ "} // namespace nx\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "namespace nc {\n"
+ "class X {\n"
+ " ::na::A a; nb::B b;\n"
+ "};\n"
+ "} // namespace nc\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifier) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " G g; ny::Y y; ny::na::A a; ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "class X {\n"
+ " G g; Y y; A a; nc::C c;\n"
+ "};\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -196,6 +196,8 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// Note that if `DeclName` is `::b::X` and `NsName` is `::a::b`, this returns
+// "::b::X" instead of "b::X" since there will be a name conflict otherwise.
 // \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
 // \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
 //will have empty name.
@@ -206,14 +208,42 @@
   if (DeclName.find(':') == llvm::StringRef::npos)
 return DeclName;
 
-  while (!DeclName.consume_front((NsName + "::").str())) {
-const auto Pos = NsName.find_last_of(':');
-if (Pos == llvm::StringRef::npos)
-  return DeclName;
-assert(Pos > 0);
-NsName = NsName.substr(0, Pos - 1);
+  llvm::SmallVector NsNam

[clang-tools-extra] r293182 - [change-namespace] add leading '::' to references in new namespace when name conflict is possible.

2017-01-26 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Jan 26 09:08:44 2017
New Revision: 293182

URL: http://llvm.org/viewvc/llvm-project?rev=293182&view=rev
Log:
[change-namespace] add leading '::' to references in new namespace when name 
conflict is possible.

Summary:
For example, when we change 'na' to "nb::nc", we need to add leading '::' to
references "::nc::X" in the changed namespace.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=293182&r1=293181&r2=293182&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Jan 26 
09:08:44 2017
@@ -196,6 +196,8 @@ tooling::Replacement createInsertion(Sou
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// Note that if `DeclName` is `::b::X` and `NsName` is `::a::b`, this returns
+// "::b::X" instead of "b::X" since there will be a name conflict otherwise.
 // \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
 // \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
 //will have empty name.
@@ -206,14 +208,42 @@ std::string getShortestQualifiedNameInNa
   if (DeclName.find(':') == llvm::StringRef::npos)
 return DeclName;
 
-  while (!DeclName.consume_front((NsName + "::").str())) {
-const auto Pos = NsName.find_last_of(':');
-if (Pos == llvm::StringRef::npos)
-  return DeclName;
-assert(Pos > 0);
-NsName = NsName.substr(0, Pos - 1);
+  llvm::SmallVector NsNameSplitted;
+  NsName.split(NsNameSplitted, "::", /*MaxSplit=*/-1,
+   /*KeepEmpty=*/false);
+  llvm::SmallVector DeclNsSplitted;
+  DeclName.split(DeclNsSplitted, "::", /*MaxSplit=*/-1,
+   /*KeepEmpty=*/false);
+  llvm::StringRef UnqualifiedDeclName = DeclNsSplitted.pop_back_val();
+  // If the Decl is in global namespace, there is no need to shorten it.
+  if (DeclNsSplitted.empty())
+return UnqualifiedDeclName;
+  // If NsName is the global namespace, we can simply use the DeclName sans
+  // leading "::".
+  if (NsNameSplitted.empty())
+return DeclName;
+
+  if (NsNameSplitted.front() != DeclNsSplitted.front()) {
+// The DeclName must be fully-qualified, but we still need to decide if a
+// leading "::" is necessary. For example, if `NsName` is "a::b::c" and the
+// `DeclName` is "b::X", then the reference must be qualified as "::b::X"
+// to avoid conflict.
+if (llvm::is_contained(NsNameSplitted, DeclNsSplitted.front()))
+  return ("::" + DeclName).str();
+return DeclName;
+  }
+  // Since there is already an overlap namespace, we know that `DeclName` can 
be
+  // shortened, so we reduce the longest common prefix.
+  auto DeclI = DeclNsSplitted.begin();
+  auto DeclE = DeclNsSplitted.end();
+  auto NsI = NsNameSplitted.begin();
+  auto NsE = NsNameSplitted.end();
+  for (; DeclI != DeclE && NsI != NsE && *DeclI == *NsI; ++DeclI, ++NsI) {
   }
-  return DeclName;
+  return (DeclI == DeclE)
+ ? UnqualifiedDeclName.str()
+ : (llvm::join(DeclI, DeclE, "::") + "::" + UnqualifiedDeclName)
+   .str();
 }
 
 std::string wrapCodeInNamespace(StringRef NestedNs, std::string Code) {

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=293182&r1=293181&r2=293182&view=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Thu Jan 26 09:08:44 2017
@@ -1599,6 +1599,74 @@ TEST_F(ChangeNamespaceTest, TemplateUsin
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ExistingNamespaceConflictWithNewNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " na::A a; nb::B b;\n"
+ "};\n"
+  

[PATCH] D29176: [change-namespace] add leading '::' to references in new namespace when name conflict is possible.

2017-01-26 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 85903.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D29176

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -1599,6 +1599,74 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ExistingNamespaceConflictWithNewNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " na::A a; nb::B b;\n"
+ "};\n"
+ "} // namespace nx\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "namespace nc {\n"
+ "class X {\n"
+ " ::na::A a; nb::B b;\n"
+ "};\n"
+ "} // namespace nc\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifier) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " G g; ny::Y y; ny::na::A a; ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "class X {\n"
+ " G g; Y y; A a; nc::C c;\n"
+ "};\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -196,6 +196,8 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// Note that if `DeclName` is `::b::X` and `NsName` is `::a::b`, this returns
+// "::b::X" instead of "b::X" since there will be a name conflict otherwise.
 // \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
 // \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
 //will have empty name.
@@ -206,14 +208,42 @@
   if (DeclName.find(':') == llvm::StringRef::npos)
 return DeclName;
 
-  while (!DeclName.consume_front((NsName + "::").str())) {
-const auto Pos = NsName.find_last_of(':');
-if (Pos == llvm::StringRef::npos)
-  return DeclName;
-assert(Pos > 0);
-NsName = NsName.substr(0, Pos - 1);
+  llvm::SmallVector NsNameSplitted;
+  NsName.split(NsNameSplitted, "::", /*MaxSplit=*/-1,
+   /*KeepEmpty=*/false);
+  llvm::SmallVector DeclNsSplitted;
+  DeclName.split(DeclNsSplitted, "::", /*MaxSplit=*/-1,
+   /*KeepEmpty=*/false);
+  llvm::StringRef UnqualifiedDeclName = DeclNsSplitted.pop_back_val();
+  // If the Decl is in global namespace, there is no need

[PATCH] D29176: [change-namespace] add leading '::' to references in new namespace when name conflict is possible.

2017-01-26 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Only nits below.




Comment at: change-namespace/ChangeNamespace.cpp:232
+auto &DeclNsTop = DeclNsSplitted.front();
+for (auto &Ns : NsNameSplitted)
+  if (Ns == DeclNsTop)

This could use llvm::is_contained



Comment at: change-namespace/ChangeNamespace.cpp:237
+  }
+  // Since there is already an overlap namespace, we know that `DeclName` can 
be
+  // shortened.

I guess you could add here that you're now searching the longest common prefix.



Comment at: change-namespace/ChangeNamespace.cpp:243
+  auto NsE = NsNameSplitted.end();
+  for (; DeclI != DeclE && NsI != NsE && *DeclI == *NsI; ++DeclI, ++NsI) {
   }

Not sure if this should be a while loop. It's so ugly right now :(


https://reviews.llvm.org/D29176



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


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

2017-01-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D28814



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


[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

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

LGTM! Thank you for being patient while we figured this out. :-)


https://reviews.llvm.org/D28520



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


[PATCH] D27985: Add demangling support for C++11 thread_local variables

2017-01-26 Thread Dave Bozier via Phabricator via cfe-commits
davidb added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D27985



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


[libcxx] r293179 - Fixed a couple of invalid statuses for 2665 and 2758

2017-01-26 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jan 26 08:36:14 2017
New Revision: 293179

URL: http://llvm.org/viewvc/llvm-project?rev=293179&view=rev
Log:
Fixed a couple of invalid statuses for 2665 and 2758

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=293179&r1=293178&r2=293179&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Jan 26 08:36:14 2017
@@ -369,7 +369,7 @@
http://wg21.link/LWG2591";>2591std::function's member 
template target() should not lead to undefined 
behaviourIssaquah
http://wg21.link/LWG2598";>2598addressof 
works on temporariesIssaquahComplete
http://wg21.link/LWG2664";>2664operator/ 
(and other append) semantics not useful if argument has 
rootIssaquahComplete
-   http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectIssaquahSee Below
+   http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectIssaquahComplete
http://wg21.link/LWG2672";>2672Should 
is_empty use error_code in its 
specification?IssaquahComplete
http://wg21.link/LWG2678";>2678std::filesystem enum classes 
overspecifiedIssaquahComplete
http://wg21.link/LWG2679";>2679Inconsistent Use of Effects 
and Equivalent ToIssaquahComplete
@@ -400,7 +400,7 @@
http://wg21.link/LWG2752";>2752"Throws:" 
clauses of async and packaged_task are 
unimplementableIssaquah
http://wg21.link/LWG2755";>2755[string.view.io] uses 
non-existent basic_string_view::to_string 
functionIssaquahComplete
http://wg21.link/LWG2756";>2756C++ WP 
optional should 'forward' T's implicit 
conversionsIssaquahComplete
-   http://wg21.link/LWG2758";>2758std::string{}.assign("ABCDE", 
0, 1) is ambiguousComplete
+   http://wg21.link/LWG2758";>2758std::string{}.assign("ABCDE", 
0, 1) is ambiguousIssaquahComplete
http://wg21.link/LWG2759";>2759gcd / lcm 
and bool for the WPIssaquahComplete
http://wg21.link/LWG2760";>2760non-const 
basic_string::data should not invalidate 
iteratorsIssaquahComplete
http://wg21.link/LWG2765";>2765Did LWG 
1123 go too far?Issaquah
@@ -417,7 +417,7 @@
 
   
 
-  Last Updated: 23-Jan-2017
+  Last Updated: 26-Jan-2017
 
 
 


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


[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

2017-01-26 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added a comment.

This looks good to me.


https://reviews.llvm.org/D28520



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


[PATCH] D29176: [change-namespace] add leading '::' to references in new namespace when name conflict is possible.

2017-01-26 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.

For example, when we change 'na' to "nb::nc", we need to add leading '::' to
references "::nc::X" in the changed namespace.


https://reviews.llvm.org/D29176

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -1599,6 +1599,74 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, ExistingNamespaceConflictWithNewNamespace) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " na::A a; nb::B b;\n"
+ "};\n"
+ "} // namespace nx\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "} // namespace na\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "} // namespace nb\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "namespace nc {\n"
+ "class X {\n"
+ " ::na::A a; nb::B b;\n"
+ "};\n"
+ "} // namespace nc\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, ShortenNamespaceSpecifier) {
+  OldNamespace = "nx";
+  NewNamespace = "ny::na";
+  std::string Code = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "namespace nx {\n"
+ "class X {\n"
+ " G g; ny::Y y; ny::na::A a; ny::na::nc::C c;\n"
+ "};\n"
+ "} // namespace nx\n";
+  std::string Expected = "class G {};\n"
+ "namespace ny {\n"
+ "class Y {};\n"
+ "namespace na {\n"
+ "class A {};\n"
+ "namespace nc { class C {}; } // namespace nc\n"
+ "}\n // namespace na\n"
+ "}\n // namespace ny\n"
+ "\n"
+ "namespace ny {\n"
+ "namespace na {\n"
+ "class X {\n"
+ " G g; Y y; A a; nc::C c;\n"
+ "};\n"
+ "} // namespace na\n"
+ "} // namespace ny\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -196,6 +196,8 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// Note that if `DeclName` is `::b::X` and `NsName` is `::a::b`, this returns
+// "::b::X" instead of "b::X" since there will be a name conflict otherwise.
 // \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
 // \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
 //will have empty name.
@@ -206,14 +208,44 @@
   if (DeclName.find(':') == llvm::StringRef::npos)
 return DeclName;
 
-  while (!DeclName.consume_front((NsName + "::").str())) {
-const auto Pos = NsName.find_last_of(':');
-if (Pos == llvm::StringRef::npos)
-  return DeclName;
-assert(Pos > 0);
-NsName = NsName.substr(0, Pos - 1);
+  llvm::SmallVector NsNameSplitted;
+  NsName.split(NsNameSplitted, "::", /*MaxSplit=*/-1,
+   /*KeepEmpty=*/false);
+  llvm::SmallVector DeclNsSplitted;
+  DeclName.split(DeclNsSplitted, "::", /*MaxSplit=*/-1,
+   /*KeepEmpty=*/false);
+  llvm::StringRef UnqualifiedDeclName = DeclNsSplitted.pop_back_val();
+  // If the Decl is in global name

Re: [libcxx] r293154 - Use the new __has_feature(cxx_constexpr_string_builtins) for detection of the C-string intrinsics for constexpr support in std::char_traits. Thanks to Richard for the intrisic s

2017-01-26 Thread Marshall Clow via cfe-commits
On Wed, Jan 25, 2017 at 10:58 PM, Marshall Clow via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: marshall
> Date: Thu Jan 26 00:58:29 2017
> New Revision: 293154
>
> URL: http://llvm.org/viewvc/llvm-project?rev=293154&view=rev
> Log:
> Use the new __has_feature(cxx_constexpr_string_builtins) for detection of
> the C-string intrinsics for constexpr support in std::char_traits. Thanks
> to Richard for the intrisic support.
>
> Modified:
> libcxx/trunk/include/__config
> libcxx/trunk/include/__string
>
>
Hans --

This should be merged to the 4.0 branch.
Thanks!

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


Re: [libcxx] r292990 - Change the return type of emplace_[front|back] back to void when building with C++14 or before. Resolves PR31680.

2017-01-26 Thread Marshall Clow via cfe-commits
On Wed, Jan 25, 2017 at 9:11 AM, Hans Wennborg  wrote:

> Should we merge this to 4.0?
>

Yes, please.

-- Marshall


>
> On Tue, Jan 24, 2017 at 3:09 PM, Marshall Clow via cfe-commits
>  wrote:
> > Author: marshall
> > Date: Tue Jan 24 17:09:12 2017
> > New Revision: 292990
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=292990&view=rev
> > Log:
> > Change the return type of emplace_[front|back] back to void when
> building with C++14 or before. Resolves PR31680.
> >
> > Modified:
> > libcxx/trunk/include/deque
> > libcxx/trunk/include/forward_list
> > libcxx/trunk/include/list
> > libcxx/trunk/include/queue
> > libcxx/trunk/include/stack
> > libcxx/trunk/include/vector
> > libcxx/trunk/test/std/containers/container.adaptors/
> queue/queue.defn/emplace.pass.cpp
> > libcxx/trunk/test/std/containers/container.adaptors/
> stack/stack.defn/emplace.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/deque/
> deque.modifiers/emplace_back.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/deque/
> deque.modifiers/emplace_front.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.
> modifiers/emplace_front.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/list/
> list.modifiers/emplace_back.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/list/
> list.modifiers/emplace_front.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/vector.
> bool/emplace_back.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/vector/
> vector.modifiers/emplace_back.pass.cpp
> > libcxx/trunk/www/cxx1z_status.html
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



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

Anastasia wrote:
> arsenm wrote:
> > arsenm wrote:
> > > Should this have a 2.0 run line for good measure?
> > 1.0 too I suppose
> Sure!
Apparently CL1.0 is not supported! I missed that


https://reviews.llvm.org/D29038



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


  1   2   >