Re: [PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-12 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: cmake/config-ix.cmake:45
@@ -44,3 +44,3 @@
 check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
 check_library_exists(c __cxa_thread_atexit_impl ""

compnerd wrote:
> EricWF wrote:
> > compnerd wrote:
> > > Might be nice to extend this further to allow building against 
> > > clang_rt.builtins.  We could of course do that as a follow up if you 
> > > prefer.
> > I don't think the clang_rt.builtin libraries are *ever* along the library 
> > search path. Maybe we could detect if clang accepts `--rtlib `? (I 
> > don't know the flag off hand).
> Pretty close with the flag: it is `--rtlib=` if you like the 2 dash version.  
> Hmm, though the problem with the symbol we are using for gcc_s here is the 
> crus of the issue I think.  The problem is that if clang_rt.builtins is used, 
> `__gcc_personality_v0` will be defined since the symbol is the C personality 
> routine.  Perhaps a compromise may be to change the symbol we use to detect 
> gcc_s.  However, given that this was the original behavior, Im not as 
> concerned, since it has worked for most people so far (and its easy to 
> modify).
Another problem is that `--rtlib=compiler-rt` doesn't work when 
`-nodefaultlibs` is given.  We can try and manually find 
libclang_rt.builtins-.a but that requires us to 1) find clangs library 
directory 2) Explicitly deduce the name of the actual library file based on the 
target triple.

I've done this in libc++ for some more extreme cases but it is not fun.

I would like to support using clang_rt.builtins but we might need to add some 
compiler support to help us find it.


Comment at: src/CMakeLists.txt:37
@@ +36,3 @@
+
+remove_flags(-Wl,-z,defs)
+

compnerd wrote:
> EricWF wrote:
> > compnerd wrote:
> > > Do we need to worry about an alternative spelling of `-z defs`?
> > Not sure. I only considered the spellings used within the LLVM source tree 
> > `llvm/cmake/modules/HandleLLVMOptions.cmake`.
> This is a change in the original behavior.  I think it may be safer to add 
> the `-z defs` and `-zdefs` spellings as well if you want the no undefined 
> symbols behavior.  At least on solaris, I believe that `-no-undefined` is 
> also going to cause this to be emitted.
> This is a change in the original behavior.

Yes it is. libc++abi.so used to resolve the missing _Unwind symbols in 
libgcc_eh. However I'm hesitant to use `remove_flags` more than we need to 
because it's really dumb. For example calling `remove_flags(-pedantic)` on 
"-Wno-pedantic -pedantic-errors -pedantic" will result in the string "-Wno- 
-errors".  For this reason I think its safest to only handle the spelling LLVM 
uses.

Users shouldn't be passing any spelling of "-Wl,-zdefs" to the libc++abi build. 
I feel like this is one of those instances of "Doctor it hurts when I do this!".

Has this swayed your opinion at all? 


Comment at: src/CMakeLists.txt:62
@@ -44,1 +61,3 @@
+# first and last library on the link line. This behavior mimics clang's
+# behavior.
 set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})

compnerd wrote:
> Why does gcc_s need to be first?  Is there some symbol that needs to be 
> resolved from it and not another provider?
Woops. It doesn't need to be first, but it needs to come before the builtin C 
libraries. In particular libpthread and libc.  This is because libc (and maybe 
pthread) can have their own definitions for some  of the _Unwind functions 
found in libgcc_s.  Because we want `ld` to always choose the version in 
libgcc_s we need to put it first.

Here is a quote from a bug report I found:

>If by some circumstance (use of -Bdirect, -z lazyload, maybe others)
> libc.so.1 happens to be searched by ld.so.1 before libgcc_s.so.1 and
> some library (e.g. libstdc++.so.6) uses functions both from GCC_3.0
> (then resolved from libc.so.1) and others (resolved from libgcc_s.so.1),
> crashes result due to mixing those different implementations with
> different internal data structures.

http://patchwork.ozlabs.org/patch/312087/

I'm not sure if we will run into any of these cases when building libc++abi  
but it seems best to mimic what the linux linker does with libgcc_s.


http://reviews.llvm.org/D15440



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


[clang-tools-extra] r255431 - [clang-tidy] Fix PR25812.

2015-12-12 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Sat Dec 12 05:31:25 2015
New Revision: 255431

URL: http://llvm.org/viewvc/llvm-project?rev=255431&view=rev
Log:
[clang-tidy] Fix PR25812.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp?rev=255431&r1=255430&r2=255431&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
Sat Dec 12 05:31:25 2015
@@ -15,24 +15,22 @@
 using namespace clang::ast_matchers;
 
 static bool isContainer(llvm::StringRef ClassName) {
-  static const char *const ContainerNames[] = {
-"std::array",
-"std::deque",
-"std::forward_list",
-"std::list",
-"std::map",
-"std::multimap",
-"std::multiset",
-"std::priority_queue",
-"std::queue",
-"std::set",
-"std::stack",
-"std::unordered_map",
-"std::unordered_multimap",
-"std::unordered_multiset",
-"std::unordered_set",
-"std::vector"
-  };
+  static const char *const ContainerNames[] = {"std::array",
+   "std::deque",
+   "std::forward_list",
+   "std::list",
+   "std::map",
+   "std::multimap",
+   "std::multiset",
+   "std::priority_queue",
+   "std::queue",
+   "std::set",
+   "std::stack",
+   "std::unordered_map",
+   "std::unordered_multimap",
+   "std::unordered_multiset",
+   "std::unordered_set",
+   "std::vector"};
   return std::binary_search(std::begin(ContainerNames),
 std::end(ContainerNames), ClassName);
 }
@@ -65,7 +63,8 @@ void ContainerSizeEmptyCheck::registerMa
   anyOf(has(integerLiteral(equals(0))),
 allOf(anyOf(hasOperatorName("<"), hasOperatorName(">="),
 hasOperatorName(">"), hasOperatorName("<=")),
-  hasEitherOperand(integerLiteral(equals(1))
+  hasEitherOperand(
+  ignoringImpCasts(integerLiteral(equals(1)))
   .bind("SizeBinaryOp")),
   hasParent(implicitCastExpr(
   hasImplicitDestinationType(isBoolType()),
@@ -101,19 +100,21 @@ void ContainerSizeEmptyCheck::check(cons
 
   if (BinaryOp) { // Determine the correct transformation.
 bool Negation = false;
-const bool ContainerIsLHS = !llvm::isa(BinaryOp->getLHS());
+const bool ContainerIsLHS =
+!llvm::isa(BinaryOp->getLHS()->IgnoreImpCasts());
 const auto OpCode = BinaryOp->getOpcode();
 uint64_t Value = 0;
 if (ContainerIsLHS) {
-  if (const auto *Literal =
-  llvm::dyn_cast(BinaryOp->getRHS()))
+  if (const auto *Literal = llvm::dyn_cast(
+  BinaryOp->getRHS()->IgnoreImpCasts()))
 Value = Literal->getValue().getLimitedValue();
   else
 return;
 } else {
-  Value = llvm::dyn_cast(BinaryOp->getLHS())
-  ->getValue()
-  .getLimitedValue();
+  Value =
+  llvm::dyn_cast(BinaryOp->getLHS()->IgnoreImpCasts())
+  ->getValue()
+  .getLimitedValue();
 }
 
 // Constant that is not handled.

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp?rev=255431&r1=255430&r2=255431&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp 
Sat Dec 12 05:31:25 2015
@@ -3,7 +3,7 @@
 namespace std {
 template  struct vector {
   vector() {}
-  int size() const {}
+  unsigned long size() const {}
   bool empty() const {}
 };
 }


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

Re: [PATCH] D15223: [ARM] [AARCH64] Add CodeGen IR tests for {VS}QRDML{AS}H v8.1a intrinsics.

2015-12-12 Thread James Molloy via cfe-commits
jmolloy resigned from this revision.
jmolloy removed a reviewer: jmolloy.
jmolloy added a comment.

Eric is reviewing this; resigning myself.


http://reviews.llvm.org/D15223



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


[patch] Let -Wdelete-non-virtual-dtor mention that making the class final is a good fix too

2015-12-12 Thread Nico Weber via cfe-commits
Hi,

the attached patch changes

  delete called on 'dnvd::B' that has virtual functions but non-virtual
destructor

to

  delete called on non-final 'dnvd::B' that has virtual functions but
non-virtual destructor

I'm not sure if it should only do this for c++11 and newer – the new
message is true in c++98 as well and I think we support final as an
extension in c++98. So this patch unconditionally changes the warning text.

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


Re: [PATCH] D15470: Preserve source location in namespaced base ctor initializers

2015-12-12 Thread Shahms King via cfe-commits
shahms updated this revision to Diff 42608.
shahms added a comment.

Address comments and add CHECK for TypeRef as well


http://reviews.llvm.org/D15470

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/Index/namespaced-base-ctor-init.cpp

Index: test/Index/namespaced-base-ctor-init.cpp
===
--- /dev/null
+++ test/Index/namespaced-base-ctor-init.cpp
@@ -0,0 +1,10 @@
+namespace ns1 {
+struct Base {};
+struct Derived : Base {
+  Derived() : ns1::Base() {}
+};
+}
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: namespaced-base-ctor-init.cpp:4:15: NamespaceRef=ns1:1:11 
Extent=[4:15 - 4:18]
+// CHECK: namespaced-base-ctor-init.cpp:4:20: TypeRef=struct ns1::Base:2:8 
Extent=[4:20 - 4:24]
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2980,10 +2980,15 @@
 if (BaseType.isNull()) {
   BaseType = Context.getTypeDeclType(TyD);
   MarkAnyDeclReferenced(TyD->getLocation(), TyD, /*OdrUse=*/false);
-  if (SS.isSet())
-// FIXME: preserve source range information
+  if (SS.isSet()) {
 BaseType = Context.getElaboratedType(ETK_None, SS.getScopeRep(),
  BaseType);
+TInfo = Context.CreateTypeSourceInfo(BaseType);
+ElaboratedTypeLoc TL = TInfo->getTypeLoc().castAs();
+TL.getNamedTypeLoc().castAs().setNameLoc(IdLoc);
+TL.setElaboratedKeywordLoc(SourceLocation());
+TL.setQualifierLoc(SS.getWithLocInContext(Context));
+  }
 }
   }
 


Index: test/Index/namespaced-base-ctor-init.cpp
===
--- /dev/null
+++ test/Index/namespaced-base-ctor-init.cpp
@@ -0,0 +1,10 @@
+namespace ns1 {
+struct Base {};
+struct Derived : Base {
+  Derived() : ns1::Base() {}
+};
+}
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: namespaced-base-ctor-init.cpp:4:15: NamespaceRef=ns1:1:11 Extent=[4:15 - 4:18]
+// CHECK: namespaced-base-ctor-init.cpp:4:20: TypeRef=struct ns1::Base:2:8 Extent=[4:20 - 4:24]
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2980,10 +2980,15 @@
 if (BaseType.isNull()) {
   BaseType = Context.getTypeDeclType(TyD);
   MarkAnyDeclReferenced(TyD->getLocation(), TyD, /*OdrUse=*/false);
-  if (SS.isSet())
-// FIXME: preserve source range information
+  if (SS.isSet()) {
 BaseType = Context.getElaboratedType(ETK_None, SS.getScopeRep(),
  BaseType);
+TInfo = Context.CreateTypeSourceInfo(BaseType);
+ElaboratedTypeLoc TL = TInfo->getTypeLoc().castAs();
+TL.getNamedTypeLoc().castAs().setNameLoc(IdLoc);
+TL.setElaboratedKeywordLoc(SourceLocation());
+TL.setQualifierLoc(SS.getWithLocInContext(Context));
+  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15470: Preserve source location in namespaced base ctor initializers

2015-12-12 Thread Shahms King via cfe-commits
shahms marked 2 inline comments as done.
shahms added a comment.

Thanks for taking a look at this so quickly.  I've updated the test to make 
sure the TypeRef is correct as well, in light of the changes here.


http://reviews.llvm.org/D15470



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


Re: [PATCH] D15370: [scan-view] replace deprecated optparse with argparse

2015-12-12 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 42636.
omtcyf0 added a comment.

Added tool description.


http://reviews.llvm.org/D15370

Files:
  tools/scan-view/bin/scan-view

Index: tools/scan-view/bin/scan-view
===
--- tools/scan-view/bin/scan-view
+++ tools/scan-view/bin/scan-view
@@ -24,19 +24,22 @@
 
 ###
 
+
 def url_is_up(url):
 try:
 o = urllib.urlopen(url)
 except IOError:
 return False
 o.close()
 return True
 
+
 def start_browser(port, options):
-import urllib, webbrowser
+import urllib
+import webbrowser
+
+url = 'http://%s:%d' % (options.host, port)
 
-url = 'http://%s:%d'%(options.host, port)
-
 # Wait for server to start...
 if options.debug:
 sys.stderr.write('%s: Waiting for server.' % sys.argv[0])
@@ -49,92 +52,92 @@
 sys.stderr.flush()
 time.sleep(kSleepTimeout)
 else:
-print >>sys.stderr,'WARNING: Unable to detect that server started.'
+print >> sys.stderr, 'WARNING: Unable to detect that server started.'
 
 if options.debug:
-print >>sys.stderr,'%s: Starting webbrowser...' % sys.argv[0]
+print >> sys.stderr, '%s: Starting webbrowser...' % sys.argv[0]
 webbrowser.open(url)
 
+
 def run(port, options, root):
 # Prefer to look relative to the installed binary
 share = os.path.dirname(__file__) + "/../share/scan-view"
 if not os.path.isdir(share):
-  # Otherwise look relative to the source
-  share = os.path.dirname(__file__) + "/../../scan-view/share"
+# Otherwise look relative to the source
+share = os.path.dirname(__file__) + "/../../scan-view/share"
 sys.path.append(share)
 
 import ScanView
 try:
-print 'Starting scan-view at: http://%s:%d'%(options.host,
- port)
+print 'Starting scan-view at: http://%s:%d' % (options.host,
+   port)
 print '  Use Ctrl-C to exit.'
 httpd = ScanView.create_server((options.host, port),
options, root)
 httpd.serve_forever()
 except KeyboardInterrupt:
 pass
 
+
 def port_is_open(port):
 import SocketServer
 try:
-t = SocketServer.TCPServer((kDefaultHost,port),None)
+t = SocketServer.TCPServer((kDefaultHost, port), None)
 except:
 return False
 t.server_close()
 return True
 
-def main():
-from optparse import OptionParser
-parser = OptionParser('usage: %prog [options] ')
-parser.set_description(__doc__)
-parser.add_option(
-'--host', dest="host", default=kDefaultHost, type="string",
+
+def main():
+import argparse
+parser = argparse.ArgumentParser(description="The clang static analyzer "
+ "results viewer.")
+parser.add_argument("root", metavar="", type=str)
+parser.add_argument(
+'--host', dest="host", default=kDefaultHost, type=str,
 help="Host interface to listen on. (default=%s)" % kDefaultHost)
-parser.add_option(
-'--port', dest="port", default=None, type="int",
-help="Port to listen on. (default=%s)" % kDefaultPort)
-parser.add_option("--debug", dest="debug", default=0, 
-  action="count",
-  help="Print additional debugging information.")
-parser.add_option("--auto-reload", dest="autoReload", default=False, 
-  action="store_true",
-  help="Automatically update module for each request.")
-parser.add_option("--no-browser", dest="startBrowser", default=True, 
-  action="store_false",
-  help="Don't open a webbrowser on startup.")
-parser.add_option("--allow-all-hosts", dest="onlyServeLocal", default=True, 
-  action="store_false",
-  help='Allow connections from any host (access restricted to "127.0.0.1" by default)')
-(options, args) = parser.parse_args()
-
-if len(args) != 1:
-parser.error('No results directory specified.')
-root, = args
+parser.add_argument('--port', dest="port", default=None, type=int,
+help="Port to listen on. (default=%s)" % kDefaultPort)
+parser.add_argument("--debug", dest="debug", default=0,
+action="count",
+help="Print additional debugging information.")
+parser.add_argument("--auto-reload", dest="autoReload", default=False,
+action="store_true",
+help="Automatically update module for each request.")
+parser.add_argument("--no-browser", dest="startBrowser", default=True,
+action="store_false",
+help="Don't open a webbrowser on startup.")
+parser.a

Re: [PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-12 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: cmake/config-ix.cmake:45
@@ -44,3 +44,3 @@
 check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
 check_library_exists(c __cxa_thread_atexit_impl ""

EricWF wrote:
> compnerd wrote:
> > EricWF wrote:
> > > compnerd wrote:
> > > > Might be nice to extend this further to allow building against 
> > > > clang_rt.builtins.  We could of course do that as a follow up if you 
> > > > prefer.
> > > I don't think the clang_rt.builtin libraries are *ever* along the library 
> > > search path. Maybe we could detect if clang accepts `--rtlib `? (I 
> > > don't know the flag off hand).
> > Pretty close with the flag: it is `--rtlib=` if you like the 2 dash 
> > version.  Hmm, though the problem with the symbol we are using for gcc_s 
> > here is the crus of the issue I think.  The problem is that if 
> > clang_rt.builtins is used, `__gcc_personality_v0` will be defined since the 
> > symbol is the C personality routine.  Perhaps a compromise may be to change 
> > the symbol we use to detect gcc_s.  However, given that this was the 
> > original behavior, Im not as concerned, since it has worked for most people 
> > so far (and its easy to modify).
> Another problem is that `--rtlib=compiler-rt` doesn't work when 
> `-nodefaultlibs` is given.  We can try and manually find 
> libclang_rt.builtins-.a but that requires us to 1) find clangs 
> library directory 2) Explicitly deduce the name of the actual library file 
> based on the target triple.
> 
> I've done this in libc++ for some more extreme cases but it is not fun.
> 
> I would like to support using clang_rt.builtins but we might need to add some 
> compiler support to help us find it.
We should definitely fix that: `gcc -print-file-name=libgcc.a` should be 
rewritten to `clang -print-file-name=libclang_rt.buitlins-${ARCH}.a` and we can 
use that :-).  Ill see if I can fix that.


Comment at: src/CMakeLists.txt:37
@@ +36,3 @@
+
+remove_flags(-Wl,-z,defs)
+

EricWF wrote:
> compnerd wrote:
> > EricWF wrote:
> > > compnerd wrote:
> > > > Do we need to worry about an alternative spelling of `-z defs`?
> > > Not sure. I only considered the spellings used within the LLVM source 
> > > tree `llvm/cmake/modules/HandleLLVMOptions.cmake`.
> > This is a change in the original behavior.  I think it may be safer to add 
> > the `-z defs` and `-zdefs` spellings as well if you want the no undefined 
> > symbols behavior.  At least on solaris, I believe that `-no-undefined` is 
> > also going to cause this to be emitted.
> > This is a change in the original behavior.
> 
> Yes it is. libc++abi.so used to resolve the missing _Unwind symbols in 
> libgcc_eh. However I'm hesitant to use `remove_flags` more than we need to 
> because it's really dumb. For example calling `remove_flags(-pedantic)` on 
> "-Wno-pedantic -pedantic-errors -pedantic" will result in the string "-Wno- 
> -errors".  For this reason I think its safest to only handle the spelling 
> LLVM uses.
> 
> Users shouldn't be passing any spelling of "-Wl,-zdefs" to the libc++abi 
> build. I feel like this is one of those instances of "Doctor it hurts when I 
> do this!".
> 
> Has this swayed your opinion at all? 
It has, only in a slightly different direction.  Why not use 
`--allow-shlib-undefined` instead?  That way we can insert the flag, which 
would actually mean that we wouldn't need to filter, and by adding it to the 
end, we don't need to worry about the flags from LLVM/users.


Comment at: src/CMakeLists.txt:62
@@ -44,1 +61,3 @@
+# first and last library on the link line. This behavior mimics clang's
+# behavior.
 set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})

EricWF wrote:
> compnerd wrote:
> > Why does gcc_s need to be first?  Is there some symbol that needs to be 
> > resolved from it and not another provider?
> Woops. It doesn't need to be first, but it needs to come before the builtin C 
> libraries. In particular libpthread and libc.  This is because libc (and 
> maybe pthread) can have their own definitions for some  of the _Unwind 
> functions found in libgcc_s.  Because we want `ld` to always choose the 
> version in libgcc_s we need to put it first.
> 
> Here is a quote from a bug report I found:
> 
> >If by some circumstance (use of -Bdirect, -z lazyload, maybe others)
> > libc.so.1 happens to be searched by ld.so.1 before libgcc_s.so.1 and
> > some library (e.g. libstdc++.so.6) uses functions both from GCC_3.0
> > (then resolved from libc.so.1) and others (resolved from libgcc_s.so.1),
> > crashes result due to mixing those different implementations with
> > different internal data structures.
> 
> http://patchwork.ozlabs.org/patch/312087/
> 
> I'm not sure if we will run into any of thes

r255435 - [PGO] Stop using invalid char in instr variable names.

2015-12-12 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Sat Dec 12 11:28:37 2015
New Revision: 255435

URL: http://llvm.org/viewvc/llvm-project?rev=255435&view=rev
Log:
[PGO] Stop using invalid char in instr variable names.

(This is part-2 of the patch of r255434 -- 
fixing test cases, second try)


Modified:
cfe/trunk/test/CoverageMapping/unused_names.c
cfe/trunk/test/Profile/c-captured.c
cfe/trunk/test/Profile/c-general.c
cfe/trunk/test/Profile/c-linkage.c
cfe/trunk/test/Profile/cxx-lambda.cpp
cfe/trunk/test/Profile/objc-general.m

Modified: cfe/trunk/test/CoverageMapping/unused_names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/unused_names.c?rev=255435&r1=255434&r2=255435&view=diff
==
--- cfe/trunk/test/CoverageMapping/unused_names.c (original)
+++ cfe/trunk/test/CoverageMapping/unused_names.c Sat Dec 12 11:28:37 2015
@@ -6,7 +6,7 @@
 
 // CHECK-DAG: @__llvm_profile_name_bar = {{.*}} [3 x i8] c"bar", section 
"{{.*}}__llvm_prf_names"
 // CHECK-DAG: @__llvm_profile_name_baz = {{.*}} [3 x i8] c"baz", section 
"{{.*}}__llvm_prf_names"
-// CHECK-DAG: @"__llvm_profile_name_unused_names.c:qux" = {{.*}} [18 x i8] 
c"unused_names.c:qux", section "{{.*}}__llvm_prf_names"
+// CHECK-DAG: @__llvm_profile_name_unused_names.c_qux = {{.*}} [18 x i8] 
c"unused_names.c:qux", section "{{.*}}__llvm_prf_names"
 
 // SYSHEADER-NOT: @__llvm_profile_name_foo =
 

Modified: cfe/trunk/test/Profile/c-captured.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-captured.c?rev=255435&r1=255434&r2=255435&view=diff
==
--- cfe/trunk/test/Profile/c-captured.c (original)
+++ cfe/trunk/test/Profile/c-captured.c Sat Dec 12 11:28:37 2015
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-captured.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck 
-check-prefix=PGOUSE -check-prefix=PGOALL %s
 
 // PGOGEN: @[[DCC:__llvm_profile_counters_debug_captured]] = private global [3 
x i64] zeroinitializer
-// PGOGEN: @[[CSC:"__llvm_profile_counters_c-captured.c:__captured_stmt"]] = 
private global [2 x i64] zeroinitializer
-// PGOGEN: @[[C1C:"__llvm_profile_counters_c-captured.c:__captured_stmt.1"]] = 
private global [3 x i64] zeroinitializer
+// PGOGEN: @[[CSC:__llvm_profile_counters_c_captured.c___captured_stmt]] = 
private global [2 x i64] zeroinitializer
+// PGOGEN: @[[C1C:__llvm_profile_counters_c_captured.c___captured_stmt.1]] = 
private global [3 x i64] zeroinitializer
 
 // PGOALL-LABEL: define void @debug_captured()
 // PGOGEN: store {{.*}} @[[DCC]], i64 0, i64 0

Modified: cfe/trunk/test/Profile/c-general.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-general.c?rev=255435&r1=255434&r2=255435&view=diff
==
--- cfe/trunk/test/Profile/c-general.c (original)
+++ cfe/trunk/test/Profile/c-general.c Sat Dec 12 11:28:37 2015
@@ -19,7 +19,7 @@
 // PGOGEN: @[[COC:__llvm_profile_counters_conditional_operator]] = private 
global [3 x i64] zeroinitializer
 // PGOGEN: @[[DFC:__llvm_profile_counters_do_fallthrough]] = private global [4 
x i64] zeroinitializer
 // PGOGEN: @[[MAC:__llvm_profile_counters_main]] = private global [1 x i64] 
zeroinitializer
-// PGOGEN: @[[STC:"__llvm_profile_counters_c-general.c:static_func"]] = 
private global [2 x i64] zeroinitializer
+// PGOGEN: @[[STC:__llvm_profile_counters_c_general.c_static_func]] = private 
global [2 x i64] zeroinitializer
 
 // PGOGEN-LABEL: @simple_loops()
 // PGOUSE-LABEL: @simple_loops()

Modified: cfe/trunk/test/Profile/c-linkage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-linkage.c?rev=255435&r1=255434&r2=255435&view=diff
==
--- cfe/trunk/test/Profile/c-linkage.c (original)
+++ cfe/trunk/test/Profile/c-linkage.c Sat Dec 12 11:28:37 2015
@@ -4,7 +4,7 @@
 // CHECK: @__llvm_profile_name_foo = private constant [3 x i8] c"foo"
 // CHECK: @__llvm_profile_name_foo_weak = weak hidden constant [8 x i8] 
c"foo_weak"
 // CHECK: @__llvm_profile_name_main = private constant [4 x i8] c"main"
-// CHECK: @"__llvm_profile_name_c-linkage.c:foo_internal" = private constant 
[24 x i8] c"c-linkage.c:foo_internal"
+// CHECK: @__llvm_profile_name_c_linkage.c_foo_internal = private constant [24 
x i8] c"c-linkage.c:foo_internal"
 
 void foo(void) { }
 

Modified: cfe/trunk/test/Profile/cxx-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-lambda.cpp?rev=255435&r1=255434&r2=255435&view=diff
==
--- cfe/trunk/test/Profile/cxx-lambda.cpp (original)
+++ cfe/trunk/test/Profile/cxx-lambda.cpp Sat Dec 12 11:28:37 2015
@@ -11,7 +11,7 @@
 
 // PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]

r255436 - [PGO] add a test case with -no-integrated-as

2015-12-12 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Sat Dec 12 11:39:38 2015
New Revision: 255436

URL: http://llvm.org/viewvc/llvm-project?rev=255436&view=rev
Log:
[PGO] add a test case with -no-integrated-as

Added:
cfe/trunk/test/Profile/cxx-static.cpp

Added: cfe/trunk/test/Profile/cxx-static.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-static.cpp?rev=255436&view=auto
==
--- cfe/trunk/test/Profile/cxx-static.cpp (added)
+++ cfe/trunk/test/Profile/cxx-static.cpp Sat Dec 12 11:39:38 2015
@@ -0,0 +1,13 @@
+// RUN: %clang -std=c++11 -o %t.o -c -no-integrated-as 
-fprofile-instr-generate %s
+
+__attribute__((noinline)) static int bar() {
+return 1;
+}
+
+int foo(int a, int b)
+{
+auto Func = [](int a, int b) { return a > b; };
+
+return Func(a,b) + bar();
+}
+


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


r255437 - Revert 255436 : remove test that needs to be refined

2015-12-12 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Sat Dec 12 12:49:37 2015
New Revision: 255437

URL: http://llvm.org/viewvc/llvm-project?rev=255437&view=rev
Log:
Revert 255436 : remove test that needs to be refined

Removed:
cfe/trunk/test/Profile/cxx-static.cpp

Removed: cfe/trunk/test/Profile/cxx-static.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-static.cpp?rev=255436&view=auto
==
--- cfe/trunk/test/Profile/cxx-static.cpp (original)
+++ cfe/trunk/test/Profile/cxx-static.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %clang -std=c++11 -o %t.o -c -no-integrated-as 
-fprofile-instr-generate %s
-
-__attribute__((noinline)) static int bar() {
-return 1;
-}
-
-int foo(int a, int b)
-{
-auto Func = [](int a, int b) { return a > b; };
-
-return Func(a,b) + bar();
-}
-


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


Re: [PATCH] D6712: Introduce _LIBCPP_ABI_UNSTABLE to libc++

2015-12-12 Thread Eric Fiselier via cfe-commits
EricWF resigned from this revision.
EricWF removed a reviewer: EricWF.
EricWF added a comment.

This is really old and should be closed.


http://reviews.llvm.org/D6712



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


[PATCH] D15478: [MS ABI] Don't rely on terminatepad

2015-12-12 Thread David Majnemer via cfe-commits
majnemer created this revision.
majnemer added a reviewer: rnk.
majnemer added a subscriber: cfe-commits.

We'd like to remove support for terminatepad from LLVM.  To do this, we
need to move Clang off of it first.  The intent behind terminatepad was
to carefully model exception specifications for the MSVC personality.

However, we don't support exception specifications for the MSVC
personality and neither does MSVC.  Instead, MSVC supports
all-or-nothing exception specifications.  We can model this limited
usage using cleanuppads which call std::terminate.

http://reviews.llvm.org/D15478

Files:
  lib/CodeGen/CGException.cpp
  test/CodeGenCXX/exceptions-cxx-new.cpp
  test/CodeGenCXX/microsoft-abi-eh-terminate.cpp

Index: test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
@@ -9,6 +9,7 @@
 // CHECK-LABEL: define void @"\01?never_throws@@YAXXZ"()
 // CHECK-SAME:  personality i8* bitcast (i32 (...)* 
@__CxxFrameHandler3 to i8*)
 // CHECK:  invoke void @"\01?may_throw@@YAXXZ"()
-// MSVC2013:  terminatepad within none [void ()* @"\01?terminate@@YAXXZ"]
-// MSVC2015:  terminatepad within none [void ()* @__std_terminate]
+// CHECK:  cleanuppad within none []
+// MSVC2013:  call void @"\01?terminate@@YAXXZ"()
+// MSVC2015:  call void @__std_terminate()
 // CHECK-NEXT: unreachable
Index: test/CodeGenCXX/exceptions-cxx-new.cpp
===
--- test/CodeGenCXX/exceptions-cxx-new.cpp
+++ test/CodeGenCXX/exceptions-cxx-new.cpp
@@ -72,5 +72,6 @@
 // CHECK:   ret void
 
 // CHECK: [[TERMINATE]]
-// CHECK:   terminatepad within none [void ()* @"\01?terminate@@YAXXZ"] unwind 
to caller
+// CHECK:   cleanuppad within none []
+// CHECK-NEXT:   call void @"\01?terminate@@YAXXZ"()
 
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -1325,21 +1325,20 @@
   // end of the function by FinishFunction.
   TerminateHandler = createBasicBlock("terminate.handler");
   Builder.SetInsertPoint(TerminateHandler);
+  llvm::Value *Exn = nullptr;
   if (EHPersonality::get(*this).usesFuncletPads()) {
 llvm::Value *ParentPad = CurrentFuncletPad;
 if (!ParentPad)
   ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
-Builder.CreateTerminatePad(ParentPad, /*UnwindBB=*/nullptr,
-   {CGM.getTerminateFn()});
+Builder.CreateCleanupPad(ParentPad);
   } else {
-llvm::Value *Exn = nullptr;
 if (getLangOpts().CPlusPlus)
   Exn = getExceptionFromSlot();
-llvm::CallInst *terminateCall =
-CGM.getCXXABI().emitTerminateForUnexpectedException(*this, Exn);
-terminateCall->setDoesNotReturn();
-Builder.CreateUnreachable();
   }
+  llvm::CallInst *terminateCall =
+  CGM.getCXXABI().emitTerminateForUnexpectedException(*this, Exn);
+  terminateCall->setDoesNotReturn();
+  Builder.CreateUnreachable();
 
   // Restore the saved insertion state.
   Builder.restoreIP(SavedIP);


Index: test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
@@ -9,6 +9,7 @@
 // CHECK-LABEL: define void @"\01?never_throws@@YAXXZ"()
 // CHECK-SAME:  personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
 // CHECK:  invoke void @"\01?may_throw@@YAXXZ"()
-// MSVC2013:  terminatepad within none [void ()* @"\01?terminate@@YAXXZ"]
-// MSVC2015:  terminatepad within none [void ()* @__std_terminate]
+// CHECK:  cleanuppad within none []
+// MSVC2013:  call void @"\01?terminate@@YAXXZ"()
+// MSVC2015:  call void @__std_terminate()
 // CHECK-NEXT: unreachable
Index: test/CodeGenCXX/exceptions-cxx-new.cpp
===
--- test/CodeGenCXX/exceptions-cxx-new.cpp
+++ test/CodeGenCXX/exceptions-cxx-new.cpp
@@ -72,5 +72,6 @@
 // CHECK:   ret void
 
 // CHECK: [[TERMINATE]]
-// CHECK:   terminatepad within none [void ()* @"\01?terminate@@YAXXZ"] unwind to caller
+// CHECK:   cleanuppad within none []
+// CHECK-NEXT:   call void @"\01?terminate@@YAXXZ"()
 
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -1325,21 +1325,20 @@
   // end of the function by FinishFunction.
   TerminateHandler = createBasicBlock("terminate.handler");
   Builder.SetInsertPoint(TerminateHandler);
+  llvm::Value *Exn = nullptr;
   if (EHPersonality::get(*this).usesFuncletPads()) {
 llvm::Value *ParentPad = CurrentFuncletPad;
 if (!ParentPad)
   ParentPad = llvm::ConstantTokenNone::get(CG

Re: [PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-12 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: src/CMakeLists.txt:37
@@ +36,3 @@
+
+remove_flags(-Wl,-z,defs)
+

compnerd wrote:
> EricWF wrote:
> > compnerd wrote:
> > > EricWF wrote:
> > > > compnerd wrote:
> > > > > Do we need to worry about an alternative spelling of `-z defs`?
> > > > Not sure. I only considered the spellings used within the LLVM source 
> > > > tree `llvm/cmake/modules/HandleLLVMOptions.cmake`.
> > > This is a change in the original behavior.  I think it may be safer to 
> > > add the `-z defs` and `-zdefs` spellings as well if you want the no 
> > > undefined symbols behavior.  At least on solaris, I believe that 
> > > `-no-undefined` is also going to cause this to be emitted.
> > > This is a change in the original behavior.
> > 
> > Yes it is. libc++abi.so used to resolve the missing _Unwind symbols in 
> > libgcc_eh. However I'm hesitant to use `remove_flags` more than we need to 
> > because it's really dumb. For example calling `remove_flags(-pedantic)` on 
> > "-Wno-pedantic -pedantic-errors -pedantic" will result in the string "-Wno- 
> > -errors".  For this reason I think its safest to only handle the spelling 
> > LLVM uses.
> > 
> > Users shouldn't be passing any spelling of "-Wl,-zdefs" to the libc++abi 
> > build. I feel like this is one of those instances of "Doctor it hurts when 
> > I do this!".
> > 
> > Has this swayed your opinion at all? 
> It has, only in a slightly different direction.  Why not use 
> `--allow-shlib-undefined` instead?  That way we can insert the flag, which 
> would actually mean that we wouldn't need to filter, and by adding it to the 
> end, we don't need to worry about the flags from LLVM/users.
That seems fairly reasonable. I didn't think of using `--allow-shlib-undefined` 
since that was already the default behavior. However so long as it actually 
works it seems like a good solution.


Comment at: src/CMakeLists.txt:62
@@ -44,1 +61,3 @@
+# first and last library on the link line. This behavior mimics clang's
+# behavior.
 set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})

compnerd wrote:
> EricWF wrote:
> > compnerd wrote:
> > > Why does gcc_s need to be first?  Is there some symbol that needs to be 
> > > resolved from it and not another provider?
> > Woops. It doesn't need to be first, but it needs to come before the builtin 
> > C libraries. In particular libpthread and libc.  This is because libc (and 
> > maybe pthread) can have their own definitions for some  of the _Unwind 
> > functions found in libgcc_s.  Because we want `ld` to always choose the 
> > version in libgcc_s we need to put it first.
> > 
> > Here is a quote from a bug report I found:
> > 
> > >If by some circumstance (use of -Bdirect, -z lazyload, maybe others)
> > > libc.so.1 happens to be searched by ld.so.1 before libgcc_s.so.1 and
> > > some library (e.g. libstdc++.so.6) uses functions both from GCC_3.0
> > > (then resolved from libc.so.1) and others (resolved from libgcc_s.so.1),
> > > crashes result due to mixing those different implementations with
> > > different internal data structures.
> > 
> > http://patchwork.ozlabs.org/patch/312087/
> > 
> > I'm not sure if we will run into any of these cases when building libc++abi 
> >  but it seems best to mimic what the linux linker does with libgcc_s.
> Because they may statically link against gcc_eh, I assume, which when not 
> done with a rebuild of the system, you get this "beautiful" behavior.  Ill 
> just throw in an "ugh" and look the other way.  However, I don't think that 
> you will be able to inject the link request in the right location since the 
> -lc is inserted by the driver, and the request that you put in will not be 
> hoisted before that -lc.  So, you may still end up with cross-library 
> references.  Im not sure what the best option here is.
libgcc_eh is only provided as a static library for static linking, That's the 
intent of the library [1][2].

When we are building libc++abi we link with `-nodefaultlib` so we don't need to 
worry about the driver messing with the link line.

More importantly, the link line I create here is meant to mimic what clang 
already does. On linux both GCC and clang will make sure "-lgcc_s" appears 
after "-lc++" but before "-lc" and "-lpthread" (as well at at the end of the 
link line). 

I think this is needed because libc and libpthread contain their own 
definitions of the _Unwinding symbols in order to support  C++ destructors in 
`pthread_exit` and `pthread_cancel`.  
It appears that libc's definition of _Unwind_resume attempts to dispatch to 
libgcc_s via dlopen. [3]

I suspect this is the reason for the deliberate placement and double linking 
"-lgcc_s". 

I think putting "-lgcc_s" before "-lc" is needed to ensure that libraries like 
libc++abi resolve their _Unwind symbols in libgcc and not libc.


[1] https://gcc.gnu.org/ml/gcc-patches/2005-02/msg00541.html
[2] https://gcc.gnu.org/ml/gcc/2012-03/msg0

Re: [PATCH] D9600: Add scan-build python implementation

2015-12-12 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: tools/scan-build-py/libear/ear.c:142
@@ +141,3 @@
+#endif
+if (!initialized)
+initialized = bear_capture_env_t(&initial_env);

rizsotto.mailinglist wrote:
> rizsotto.mailinglist wrote:
> > to run the full test set
> > 
> > > PATH=$(pwd)/bin:$PATH python -m unittest discover
> > 
> > to run that specific test
> > 
> > > PATH=$(pwd)/bin:$PATH python -m unittest -v 
> > > tests.functional.cases.test_create_cdb.CompilationDatabaseTest.test_successful_build_on_empty_env
> > 
> > to more about run tests
> > 
> > https://docs.python.org/2/library/unittest.html
> my understanding on the `_NSGetEnviron` is, that it shall be used when the 
> library is during the load process. later when the build process calls 
> `execv` the load process is over, and `environ` variable is available. an 
> earlier version of this code had a `get_environ` method, which were either 
> return the `environ` variable or called the `_NSGetEnviron`. then i made this 
> change and the tests were still passing, so i don't see where your issue is 
> coming from. please tell me what kind of test you run against it to find it 
> as problem. would like to add it to the test suite.
Aaah, I had an ancient libscanbuild in my global site-packages, which seemed to 
cause `unittest discover` to not work.

When running the above on your latest patch on a machine without SIP I get.

```
test_successful_build_on_empty_env 
(tests.functional.cases.test_create_cdb.CompilationDatabaseTest) ... ERROR

==
ERROR: test_successful_build_on_empty_env 
(tests.functional.cases.test_create_cdb.CompilationDatabaseTest)
--
Traceback (most recent call last):
  File "tests/functional/cases/test_create_cdb.py", line 58, in 
test_successful_build_on_empty_env
'env', '-'] + make)
  File "tests/functional/cases/__init__.py", line 38, in silent_check_call
return subprocess.check_call(cmd, *args, **kwargs)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
 line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['intercept-build', '--cdb', 
'/var/folders/mq/46lsd1kx65v5702dzrkgzdlrgn/T/scan-build-test-cKXza1/cdb.json',
 'env', '-', 'make', 'SRCDIR=tests/functional/src', 
'OBJDIR=/var/folders/mq/46lsd1kx65v5702dzrkgzdlrgn/T/scan-build-test-cKXza1',
 '-f', 'tests/functional/src/build/Makefile', 'CC=clang', 'build_regular']' 
returned non-zero exit status 2

--
Ran 1 test in 0.554s

FAILED (errors=1)
```
This goes away if you use my suggested *_NSGetEnviron() fix above.
After applying that fix, all but 6 test past on OS X without SIP. The remaining 
6 failures are due to your use of mknod() in tests, which requires superuser 
privileges on OS X:


```
==
ERROR: test_interposition_cxx_works 
(tests.functional.cases.test_from_cmd.RunAnalyzerTest)
--
Traceback (most recent call last):
  File 
"/Volumes/Data/Clangs/OpenSourceGit/clang/tools/scan-build-py/tests/functional/cases/test_from_cmd.py",
 line 102, in test_interposition_cxx_works
self.compile_empty_source_file(tmpdir, True))
  File 
"/Volumes/Data/Clangs/OpenSourceGit/clang/tools/scan-build-py/tests/functional/cases/test_from_cmd.py",
 line 87, in compile_empty_source_file
os.mknod(src_file)
OSError: [Errno 1] Operation not permitted
```

Is there a more portable way to create an empty file? Perhaps open a file for 
writing and then closing it?


With SIP I see different failures:

```
workzilla:scan-build-py dcoughlin$ PATH=$(pwd)/bin:$PATH python -m unittest -v 
tests.functional.cases.test_create_cdb.CompilationDatabaseTest.test_successful_build_on_empty_env
test_successful_build_on_empty_env 
(tests.functional.cases.test_create_cdb.CompilationDatabaseTest) ... FAIL

==
FAIL: test_successful_build_on_empty_env 
(tests.functional.cases.test_create_cdb.CompilationDatabaseTest)
--
Traceback (most recent call last):
  File "tests/functional/cases/test_create_cdb.py", line 60, in 
test_successful_build_on_empty_env
self.assertEqual(5, self.count_entries(result))
AssertionError: 5 != 0

--
Ran 1 test in 1.069s

FAILED (failures=1)
```

Running the entire test suite with SIP yields:

```
F...EEFFE..FEEF.EE...
...
Ran 85 tests in 15.688s

FAILED (failures=9, errors=7)
```
I tried changing intercept.py to always use compiler wrappers 

Re: [PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a

2015-12-12 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: src/CMakeLists.txt:37
@@ +36,3 @@
+
+remove_flags(-Wl,-z,defs)
+

EricWF wrote:
> compnerd wrote:
> > EricWF wrote:
> > > compnerd wrote:
> > > > EricWF wrote:
> > > > > compnerd wrote:
> > > > > > Do we need to worry about an alternative spelling of `-z defs`?
> > > > > Not sure. I only considered the spellings used within the LLVM source 
> > > > > tree `llvm/cmake/modules/HandleLLVMOptions.cmake`.
> > > > This is a change in the original behavior.  I think it may be safer to 
> > > > add the `-z defs` and `-zdefs` spellings as well if you want the no 
> > > > undefined symbols behavior.  At least on solaris, I believe that 
> > > > `-no-undefined` is also going to cause this to be emitted.
> > > > This is a change in the original behavior.
> > > 
> > > Yes it is. libc++abi.so used to resolve the missing _Unwind symbols in 
> > > libgcc_eh. However I'm hesitant to use `remove_flags` more than we need 
> > > to because it's really dumb. For example calling 
> > > `remove_flags(-pedantic)` on "-Wno-pedantic -pedantic-errors -pedantic" 
> > > will result in the string "-Wno- -errors".  For this reason I think its 
> > > safest to only handle the spelling LLVM uses.
> > > 
> > > Users shouldn't be passing any spelling of "-Wl,-zdefs" to the libc++abi 
> > > build. I feel like this is one of those instances of "Doctor it hurts 
> > > when I do this!".
> > > 
> > > Has this swayed your opinion at all? 
> > It has, only in a slightly different direction.  Why not use 
> > `--allow-shlib-undefined` instead?  That way we can insert the flag, which 
> > would actually mean that we wouldn't need to filter, and by adding it to 
> > the end, we don't need to worry about the flags from LLVM/users.
> That seems fairly reasonable. I didn't think of using 
> `--allow-shlib-undefined` since that was already the default behavior. 
> However so long as it actually works it seems like a good solution.
After looking at documentation it would appear that `--allow-shlib-undefined` 
doesn't do what we though.

http://stackoverflow.com/questions/2356168/force-gcc-to-notify-about-undefined-references-in-shared-libraries


http://reviews.llvm.org/D15440



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


Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2015-12-12 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 42649.
bruno added a comment.

Thanks Duncan and Argyrios, updated a patch with the suggestions!


http://reviews.llvm.org/D15173

Files:
  lib/Lex/PPCaching.cpp
  test/Parser/objcxx11-protocol-in-template.mm

Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -97,8 +97,26 @@
 void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   assert(Tok.isAnnotation() && "Expected annotation token");
   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
-  assert(CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc()
- && "The annotation should be until the most recent cached token");
+
+#ifndef NDEBUG
+  Token CachedLastTok = CachedTokens[CachedLexPos - 1];
+  SourceLocation CachedLastTokLoc = CachedLastTok.getLastLoc();
+  SourceLocation TokAnnEndLoc = Tok.getAnnotationEndLoc();
+
+  // The annotation should be until the most recent cached token. Since
+  // `Tok` length could be bigger than one (e.g. greatergreater '>>'), account
+  // for that cases before checking the assertion.
+  if (!CachedLastTok.isAnnotation()) {
+CachedLastTokLoc =
+CachedLastTokLoc.getLocWithOffset(CachedLastTok.getLength());
+unsigned TokAnnEndLocSize = Lexer::MeasureTokenLength(
+SourceMgr.getSpellingLoc(TokAnnEndLoc), SourceMgr, LangOpts);
+TokAnnEndLoc = TokAnnEndLoc.getLocWithOffset(TokAnnEndLocSize);
+  }
+
+  assert(CachedLastTokLoc == TokAnnEndLoc &&
+ "The annotation should be until the most recent cached token");
+#endif
 
   // Start from the end of the cached tokens list and look for the token
   // that is the beginning of the annotation token.


Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -97,8 +97,26 @@
 void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   assert(Tok.isAnnotation() && "Expected annotation token");
   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
-  assert(CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc()
- && "The annotation should be until the most recent cached token");
+
+#ifndef NDEBUG
+  Token CachedLastTok = CachedTokens[CachedLexPos - 1];
+  SourceLocation CachedLastTokLoc = CachedLastTok.getLastLoc();
+  SourceLocation TokAnnEndLoc = Tok.getAnnotationEndLoc();
+
+  // The annotation should be until the most recent cached token. Since
+  // `Tok` length could be bigger than one (e.g. greatergreater '>>'), account
+  // for that cases before checking the assertion.
+  if (!CachedLastTok.isAnnotation()) {
+CachedLastTokLoc =
+CachedLastTokLoc.getLocWithOffset(CachedLastTok.getLength());
+unsigned TokAnnEndLocSize = Lexer::MeasureTokenLength(
+SourceMgr.getSpellingLoc(TokAnnEndLoc), SourceMgr, LangOpts);
+TokAnnEndLoc = TokAnnEndLoc.getLocWithOffset(TokAnnEndLocSize);
+  }
+
+  assert(CachedLastTokLoc == TokAnnEndLoc &&
+ "The annotation should be until the most recent cached token");
+#endif
 
   // Start from the end of the cached tokens list and look for the token
   // that is the beginning of the annotation token.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r255445 - Resubmit new test case after adding more constraint

2015-12-12 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Sat Dec 12 21:03:35 2015
New Revision: 255445

URL: http://llvm.org/viewvc/llvm-project?rev=255445&view=rev
Log:
Resubmit new test case after adding more constraint

Added:
cfe/trunk/test/Profile/cxx-static.cpp

Added: cfe/trunk/test/Profile/cxx-static.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-static.cpp?rev=255445&view=auto
==
--- cfe/trunk/test/Profile/cxx-static.cpp (added)
+++ cfe/trunk/test/Profile/cxx-static.cpp Sat Dec 12 21:03:35 2015
@@ -0,0 +1,11 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang -target i386-unknown-linux -std=c++11 -o %t.o -c 
-no-integrated-as -fprofile-instr-generate %s
+
+__attribute__((noinline)) static int bar() { return 1; }
+
+int foo(int a, int b) {
+  auto Func = [](int a, int b) { return a > b; };
+
+  return Func(a, b) + bar();
+}
+


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


r255447 - Revert r255445: adding a new test case

2015-12-12 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Sat Dec 12 22:45:49 2015
New Revision: 255447

URL: http://llvm.org/viewvc/llvm-project?rev=255447&view=rev
Log:
Revert r255445: adding a new test case

Removed:
cfe/trunk/test/Profile/cxx-static.cpp

Removed: cfe/trunk/test/Profile/cxx-static.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-static.cpp?rev=255446&view=auto
==
--- cfe/trunk/test/Profile/cxx-static.cpp (original)
+++ cfe/trunk/test/Profile/cxx-static.cpp (removed)
@@ -1,11 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang -target i386-unknown-linux -std=c++11 -o %t.o -c 
-no-integrated-as -fprofile-instr-generate %s
-
-__attribute__((noinline)) static int bar() { return 1; }
-
-int foo(int a, int b) {
-  auto Func = [](int a, int b) { return a > b; };
-
-  return Func(a, b) + bar();
-}
-


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


r255450 - [Sema] Add -Wparentheses warnings for '^' in '|' expressions and '&' in '^' expressions to compliment '&' in '|' that is already present. Matches gcc behavior.

2015-12-12 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Dec 12 23:41:41 2015
New Revision: 255450

URL: http://llvm.org/viewvc/llvm-project?rev=255450&view=rev
Log:
[Sema] Add -Wparentheses warnings for '^' in '|' expressions and '&' in '^' 
expressions to compliment '&' in '|' that is already present. Matches gcc 
behavior.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/parentheses.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255450&r1=255449&r2=255450&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Dec 12 23:41:41 
2015
@@ -4977,8 +4977,8 @@ def note_logical_instead_of_bitwise_chan
 def note_logical_instead_of_bitwise_remove_constant : Note<
   "remove constant to silence this warning">;
 
-def warn_bitwise_and_in_bitwise_or : Warning<
-  "'&' within '|'">, InGroup;
+def warn_bitwise_op_in_bitwise_op : Warning<
+  "'%0' within '%1'">, InGroup;
 
 def warn_logical_and_in_logical_or : Warning<
   "'&&' within '||'">, InGroup;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=255450&r1=255449&r2=255450&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Dec 12 23:41:41 2015
@@ -10504,21 +10504,6 @@ static void DiagnoseBitwisePrecedence(Se
 ParensRange);
 }
 
-/// \brief It accepts a '&' expr that is inside a '|' one.
-/// Emit a diagnostic together with a fixit hint that wraps the '&' expression
-/// in parentheses.
-static void
-EmitDiagnosticForBitwiseAndInBitwiseOr(Sema &Self, SourceLocation OpLoc,
-   BinaryOperator *Bop) {
-  assert(Bop->getOpcode() == BO_And);
-  Self.Diag(Bop->getOperatorLoc(), diag::warn_bitwise_and_in_bitwise_or)
-  << Bop->getSourceRange() << OpLoc;
-  SuggestParentheses(Self, Bop->getOperatorLoc(),
-Self.PDiag(diag::note_precedence_silence)
-  << Bop->getOpcodeStr(),
-Bop->getSourceRange());
-}
-
 /// \brief It accepts a '&&' expr that is inside a '||' one.
 /// Emit a diagnostic together with a fixit hint that wraps the '&&' expression
 /// in parentheses.
@@ -10587,12 +10572,21 @@ static void DiagnoseLogicalAndInLogicalO
   }
 }
 
-/// \brief Look for '&' in the left or right hand of a '|' expr.
-static void DiagnoseBitwiseAndInBitwiseOr(Sema &S, SourceLocation OpLoc,
-  Expr *OrArg) {
-  if (BinaryOperator *Bop = dyn_cast(OrArg)) {
-if (Bop->getOpcode() == BO_And)
-  return EmitDiagnosticForBitwiseAndInBitwiseOr(S, OpLoc, Bop);
+/// \brief Look for bitwise op in the left or right hand of a bitwise op with
+/// lower precedence and emit a diagnostic together with a fixit hint that 
wraps
+/// the '&' expression in parentheses.
+static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc,
+ SourceLocation OpLoc, Expr *SubExpr) {
+  if (BinaryOperator *Bop = dyn_cast(SubExpr)) {
+if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
+  S.Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
+<< Bop->getOpcodeStr() << BinaryOperator::getOpcodeStr(Opc)
+<< Bop->getSourceRange() << OpLoc;
+  SuggestParentheses(S, Bop->getOperatorLoc(),
+S.PDiag(diag::note_precedence_silence)
+  << Bop->getOpcodeStr(),
+Bop->getSourceRange());
+}
   }
 }
 
@@ -10647,9 +10641,10 @@ static void DiagnoseBinOpPrecedence(Sema
 DiagnoseBitwisePrecedence(Self, Opc, OpLoc, LHSExpr, RHSExpr);
 
   // Diagnose "arg1 & arg2 | arg3"
-  if (Opc == BO_Or && !OpLoc.isMacroID()/* Don't warn in macros. */) {
-DiagnoseBitwiseAndInBitwiseOr(Self, OpLoc, LHSExpr);
-DiagnoseBitwiseAndInBitwiseOr(Self, OpLoc, RHSExpr);
+  if ((Opc == BO_Or || Opc == BO_Xor) &&
+  !OpLoc.isMacroID()/* Don't warn in macros. */) {
+DiagnoseBitwiseOpInBitwiseOp(Self, Opc, OpLoc, LHSExpr);
+DiagnoseBitwiseOpInBitwiseOp(Self, Opc, OpLoc, RHSExpr);
   }
 
   // Warn about arg1 || arg2 && arg3, as GCC 4.3+ does.

Modified: cfe/trunk/test/Sema/parentheses.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/parentheses.c?rev=255450&r1=255449&r2=255450&view=diff
==
--- cfe/trunk/test/Sema/parentheses.c (original)
+++ cfe/trunk/test/Sema/parentheses.c Sat Dec 12 23:41:41 2015
@@ -55,6 +55,26 @@ void bitwise_rel(unsigned i) {
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:19-[[@LINE-3]]:19}:")"
 
+  (void)(i ^ i | i); // expected-warning {

r255449 - [Sema] Write some checks for groups of BinaryOperatorKinds in terms of the predicates already available in BinaryOperator. NFC

2015-12-12 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Dec 12 23:41:37 2015
New Revision: 255449

URL: http://llvm.org/viewvc/llvm-project?rev=255449&view=rev
Log:
[Sema] Write some checks for groups of BinaryOperatorKinds in terms of the 
predicates already available in BinaryOperator. NFC

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=255449&r1=255448&r2=255449&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Dec 12 23:41:37 2015
@@ -3034,7 +3034,10 @@ public:
 
   /// predicates to categorize the respective opcodes.
   bool isPtrMemOp() const { return Opc == BO_PtrMemD || Opc == BO_PtrMemI; }
-  bool isMultiplicativeOp() const { return Opc >= BO_Mul && Opc <= BO_Rem; }
+  static bool isMultiplicativeOp(Opcode Opc) {
+return Opc >= BO_Mul && Opc <= BO_Rem;
+  }
+  bool isMultiplicativeOp() const { return isMultiplicativeOp(getOpcode()); }
   static bool isAdditiveOp(Opcode Opc) { return Opc == BO_Add || Opc==BO_Sub; }
   bool isAdditiveOp() const { return isAdditiveOp(getOpcode()); }
   static bool isShiftOp(Opcode Opc) { return Opc == BO_Shl || Opc == BO_Shr; }

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=255449&r1=255448&r2=255449&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Dec 12 23:41:37 2015
@@ -6523,7 +6523,9 @@ static void SuggestParentheses(Sema &Sel
 }
 
 static bool IsArithmeticOp(BinaryOperatorKind Opc) {
-  return Opc >= BO_Mul && Opc <= BO_Shr;
+  return BinaryOperator::isAdditiveOp(Opc) ||
+ BinaryOperator::isMultiplicativeOp(Opc) ||
+ BinaryOperator::isShiftOp(Opc);
 }
 
 /// IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary
@@ -6569,10 +6571,6 @@ static bool IsArithmeticBinaryExpr(Expr
   return false;
 }
 
-static bool IsLogicOp(BinaryOperatorKind Opc) {
-  return (Opc >= BO_LT && Opc <= BO_NE) || (Opc >= BO_LAnd && Opc <= BO_LOr);
-}
-
 /// ExprLooksBoolean - Returns true if E looks boolean, i.e. it has boolean 
type
 /// or is a logical expression such as (x==y) which has int type, but is
 /// commonly interpreted as boolean.
@@ -6582,7 +6580,7 @@ static bool ExprLooksBoolean(Expr *E) {
   if (E->getType()->isBooleanType())
 return true;
   if (BinaryOperator *OP = dyn_cast(E))
-return IsLogicOp(OP->getOpcode());
+return OP->isComparisonOp() || OP->isLogicalOp();
   if (UnaryOperator *OP = dyn_cast(E))
 return OP->getOpcode() == UO_LNot;
   if (E->getType()->isPointerType())


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