[PATCH] D39360: [C++11] Don't put empty quotes in static_assert diagnostic.

2017-10-26 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete created this revision.
Rakete added a project: clang.

This patch removes the empty `""` when using `static_assert(1 + 1 == 3, "");` 
in the diagnostic:

  main.cpp:1:1: error: static_assert failed
  static_assert(1 + 1 == 3, "");
  ^ ~~


https://reviews.llvm.org/D39360

Files:
  lib/Sema/SemaDeclCXX.cpp


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13319,8 +13319,9 @@
  Expr *AssertExpr,
  Expr *AssertMessageExpr,
  SourceLocation RParenLoc) {
-  StringLiteral *AssertMessage =
-  AssertMessageExpr ? cast(AssertMessageExpr) : nullptr;
+  auto *AssertMessage = cast_or_null(AssertMessageExpr);
+  if (AssertMessage && !AssertMessage->getLength())
+AssertMessage = nullptr;
 
   if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
 return nullptr;


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13319,8 +13319,9 @@
  Expr *AssertExpr,
  Expr *AssertMessageExpr,
  SourceLocation RParenLoc) {
-  StringLiteral *AssertMessage =
-  AssertMessageExpr ? cast(AssertMessageExpr) : nullptr;
+  auto *AssertMessage = cast_or_null(AssertMessageExpr);
+  if (AssertMessage && !AssertMessage->getLength())
+AssertMessage = nullptr;
 
   if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
 return nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Zachary Turner via cfe-commits
looks good!  Feel free to commit whenever, I'd definitely recommend posting
a PSA on cfe-dev@ (after you commit) so that people know about it.  You
might also get some useful ideas for improvements that way too.

On Thu, Oct 26, 2017 at 9:52 PM Don Hinton  wrote:

> On Thu, Oct 26, 2017 at 5:44 PM, Zachary Turner 
> wrote:
>
>>
>>
>> On Thu, Oct 26, 2017 at 3:18 PM Don Hinton  wrote:
>>
>>> On Thu, Oct 26, 2017 at 2:48 PM, Zachary Turner 
>>> wrote:
>>>
 Seems fine, it would be nice if the workflow could be improved a little
 bit so that all you have to do is say `clangdiag break
 —error=“-Wcovered-switch”` or something . I think that gives the most
 intuitive usage for people, even it’s a bit harder to implement.

>>>
>>> The idea was to break on actual diagnostics emitted, but if you want to
>>> break on diagnostic usage, i.e., when it was checked but not emitted, I
>>> suppose that's possible as well.  diagtool doesn't produce a mapping for
>>> this, but it could be added -- assuming tablegen produced enough info in
>>> the .inc files to support it.  I added the feature I'm using here a few
>>> months ago, which was an extension to what Alex added earlier.
>>>
>>
>> That was my idea too.  But still, wouldn't it be possible to say
>> `clangdiag break --error="-Wcovered-switch"` and then have it break only
>> when the -Wcovered-switch diagnostic is *emitted*?
>>
>
> Please give it a try, e.g., here are a few I tried:
>
> clangdiag enable covered-switch-default
> clangdiag enable c++11-compat
>
> You can't pass the "-W" part since argparse thinks it's an option (can
> probably fix that if it's a problem), and you must provide the entire
> name.  You can get the available names from diagtool, e.g.:
>
> diagtool list-warnings
>
> Please let me know what you think, and thanks for suggesting it.
>
>
>
>>
>> The reason I keep using this syntax though is because clang developers
>> always think in terms of the warning names.  If you want to find out why a
>> warning is being emitted amidst a spew of other warnings and errors, you
>> really want to be able to specify the name of the warning.
>>
>> Don't get me wrong though, I do think this is a nice feature, I'm just
>> thinking of ways to make it more compelling by looking at it from the clang
>> developer's perspective and how they will most likely want to use it.
>>
>> Also, I still think it should go in lldb, not in clang.  That's kind of
>> exactly what the lldb/examples folder is for.
>>
>> That said, lgtm, but I'm still interested to see if the workflow can be
>> streamlined down the line.  Perhaps after it gets checked in you can make a
>> PSA on cfe-dev@ and mention that you want people to try it out and offer
>> feedback ;-)
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39321: ARM: centralise SizeType, PtrDiffType, and IntPtrType

2017-10-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: lib/Basic/Targets/ARM.cpp:231
+  else if (Triple.isWatchABI())
+PtrDiffType = SignedLong;
+

I changed this to:

if (Triple.isOSDarwin() && !Triple.isWatchABI())
  PtrDiffType = SignedInt;


Repository:
  rL LLVM

https://reviews.llvm.org/D39321



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


Re: [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via cfe-commits
On Thu, Oct 26, 2017 at 5:44 PM, Zachary Turner  wrote:

>
>
> On Thu, Oct 26, 2017 at 3:18 PM Don Hinton  wrote:
>
>> On Thu, Oct 26, 2017 at 2:48 PM, Zachary Turner 
>> wrote:
>>
>>> Seems fine, it would be nice if the workflow could be improved a little
>>> bit so that all you have to do is say `clangdiag break
>>> —error=“-Wcovered-switch”` or something . I think that gives the most
>>> intuitive usage for people, even it’s a bit harder to implement.
>>>
>>
>> The idea was to break on actual diagnostics emitted, but if you want to
>> break on diagnostic usage, i.e., when it was checked but not emitted, I
>> suppose that's possible as well.  diagtool doesn't produce a mapping for
>> this, but it could be added -- assuming tablegen produced enough info in
>> the .inc files to support it.  I added the feature I'm using here a few
>> months ago, which was an extension to what Alex added earlier.
>>
>
> That was my idea too.  But still, wouldn't it be possible to say
> `clangdiag break --error="-Wcovered-switch"` and then have it break only
> when the -Wcovered-switch diagnostic is *emitted*?
>

Please give it a try, e.g., here are a few I tried:

clangdiag enable covered-switch-default
clangdiag enable c++11-compat

You can't pass the "-W" part since argparse thinks it's an option (can
probably fix that if it's a problem), and you must provide the entire
name.  You can get the available names from diagtool, e.g.:

diagtool list-warnings

Please let me know what you think, and thanks for suggesting it.



>
> The reason I keep using this syntax though is because clang developers
> always think in terms of the warning names.  If you want to find out why a
> warning is being emitted amidst a spew of other warnings and errors, you
> really want to be able to specify the name of the warning.
>
> Don't get me wrong though, I do think this is a nice feature, I'm just
> thinking of ways to make it more compelling by looking at it from the clang
> developer's perspective and how they will most likely want to use it.
>
> Also, I still think it should go in lldb, not in clang.  That's kind of
> exactly what the lldb/examples folder is for.
>
> That said, lgtm, but I'm still interested to see if the workflow can be
> streamlined down the line.  Perhaps after it gets checked in you can make a
> PSA on cfe-dev@ and mention that you want people to try it out and offer
> feedback ;-)
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 120538.
hintonda added a comment.

- Add ability to add breakpoints matching -W warnings.


https://reviews.llvm.org/D36347

Files:
  utils/clangdiag.py

Index: utils/clangdiag.py
===
--- /dev/null
+++ utils/clangdiag.py
@@ -0,0 +1,175 @@
+#!/usr/bin/python
+
+#--
+# Be sure to add the python path that points to the LLDB shared library.
+#
+# # To use this in the embedded python interpreter using "lldb" just
+# import it with the full path using the "command script import"
+# command
+#   (lldb) command script import /path/to/clandiag.py
+#--
+
+import lldb
+import argparse
+import commands
+import shlex
+import os
+import re
+import subprocess
+
+class MyParser(argparse.ArgumentParser):
+def format_help(self):
+return ''' Commands for managing clang diagnostic breakpoints
+
+Syntax: clangdiag enable []
+clangdiag disable
+clangdiag diagtool [|reset]
+
+The following subcommands are supported:
+
+  enable   -- Enable clang diagnostic breakpoints.
+  disable  -- Disable all clang diagnostic breakpoints.
+  diagtool -- Return, set, or reset diagtool path.
+
+This command sets breakpoints in clang, and clang based tools, that
+emit diagnostics.  When a diagnostic is emitted, and clangdiag is
+enabled, it will use the appropriate diagtool application to determine
+the name of the DiagID, and set breakpoints in all locations that
+'diag::name' appears in the source.  Since the new breakpoints are set
+after they are encountered, users will need to launch the executable a
+second time in order to hit the new breakpoints.
+
+For in-tree builds, the diagtool application, used to map DiagID's to
+names, is found automatically in the same directory as the target
+executable.  However, out-or-tree builds must use the 'diagtool'
+subcommand to set the appropriate path for diagtool in the clang debug
+bin directory.  Since this mapping is created at build-time, it's
+important for users to use the same version that was generated when
+clang was compiled, or else the id's won't match.
+
+Notes:
+
+- If  is passed, just enable the DiagID for that warning.
+- Rerunning enable clears existing breakpoints.
+- diagtool is used in breakpoint callbacks, so it can be changed
+  without the need to rerun enable.
+- Make it always available by adding this to your ~.lldbinit file:
+  "command script import /path/to/clangdiag.py"
+
+'''
+
+def create_diag_options():
+parser = MyParser(prog='clangdiag')
+subparsers = parser.add_subparsers(
+title='subcommands',
+dest='subcommands',
+metavar='')
+disable_parser = subparsers.add_parser('disable')
+enable_parser = subparsers.add_parser('enable')
+enable_parser.add_argument('id', nargs='?')
+diagtool_parser = subparsers.add_parser('diagtool')
+diagtool_parser.add_argument('path', nargs='?')
+return parser
+
+def getDiagtool(target, diagtool = None):
+id = target.GetProcess().GetProcessID()
+if 'diagtool' not in getDiagtool.__dict__:
+getDiagtool.diagtool = {}
+if diagtool:
+if diagtool == 'reset':
+getDiagtool.diagtool[id] = None
+elif os.path.exists(diagtool):
+getDiagtool.diagtool[id] = diagtool
+else:
+print('clangdiag: %s not found.' % diagtool)
+if not id in getDiagtool.diagtool or not getDiagtool.diagtool[id]:
+getDiagtool.diagtool[id] = None
+exe = target.GetExecutable()
+if not exe.Exists():
+print('clangdiag: Target (%s) not set.' % exe.GetFilename())
+else:
+diagtool = os.path.join(exe.GetDirectory(), 'diagtool')
+if os.path.exists(diagtool):
+getDiagtool.diagtool[id] = diagtool
+else:
+print('clangdiag: diagtool not found along side %s' % exe)
+
+return getDiagtool.diagtool[id]
+
+def setDiagBreakpoint(frame, bp_loc, dict):
+id = frame.FindVariable("DiagID").GetValue()
+if id is None:
+print('clangdiag: id is None')
+return False
+
+# Don't need to test this time, since we did that in enable.
+target = frame.GetThread().GetProcess().GetTarget()
+diagtool = getDiagtool(target)
+name = subprocess.check_output([diagtool, "find-diagnostic-id", id]).rstrip();
+bp = target.BreakpointCreateBySourceRegex(name, lldb.SBFileSpec())
+bp.AddName("clang::Diagnostic")
+
+return False
+
+def enable(exe_ctx, args):
+# Always disable existing breakpoints
+disable(exe_ctx)
+
+target = exe_ctx.GetTarget()
+
+if args.id:
+diagtool = getDiagtool(target)
+list = subprocess.check_output([diagtool, "list-warnings"]).rstrip();
+for line in list.splitlines(True):
+m = 

[PATCH] D39280: [libunwind] Use uint64_t for unw_word_t in ARM EHABI

2017-10-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D39280#908825, @compnerd wrote:

> I dont think that this is correct.  IIRC, the unwind specification expects 
> `unw_word_t` to match `uintptr_t` (that is, it should be 32-bits on 
> https://reviews.llvm.org/P32 environments).


Ok, well currently it doesn't, on 32 bit x86 and ppc at least.


https://reviews.llvm.org/D39280



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


[PATCH] D39321: ARM: centralise SizeType, PtrDiffType, and IntPtrType

2017-10-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 120534.
compnerd added a comment.

Catch a couple of missed instances, add more context


Repository:
  rL LLVM

https://reviews.llvm.org/D39321

Files:
  lib/Basic/Targets/ARM.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1791,6 +1791,11 @@
 // ARM:#define __arm 1
 // ARM:#define __arm__ 1
 
+// RUN: %clang_cc1 -dM -ffreestanding -triple arm-none-none -target-abi apcs-gnu -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-APCS-GNU %s
+// ARM-APCS-GNU: #define __INTPTR_TYPE__ int
+// ARM-APCS-GNU: #define __PTRDIFF_TYPE__ int
+// ARM-APCS-GNU: #define __SIZE_TYPE__ unsigned int
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=armeb-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM-BE %s
 //
 // ARM-BE-NOT:#define _LP64
Index: lib/Basic/Targets/ARM.cpp
===
--- lib/Basic/Targets/ARM.cpp
+++ lib/Basic/Targets/ARM.cpp
@@ -28,14 +28,6 @@
   DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
   const llvm::Triple  = getTriple();
 
-  // size_t is unsigned long on MachO-derived environments, NetBSD, and
-  // OpenBSD.
-  if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD ||
-  T.getOS() == llvm::Triple::OpenBSD)
-SizeType = UnsignedLong;
-  else
-SizeType = UnsignedInt;
-
   bool IsNetBSD = T.getOS() == llvm::Triple::NetBSD;
   bool IsOpenBSD = T.getOS() == llvm::Triple::OpenBSD;
   if (!T.isOSWindows() && !IsNetBSD && !IsOpenBSD)
@@ -83,12 +75,6 @@
   else
 DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
 
-  // size_t is unsigned int on FreeBSD.
-  if (T.getOS() == llvm::Triple::FreeBSD)
-SizeType = UnsignedInt;
-  else
-SizeType = UnsignedLong;
-
   WCharType = SignedInt;
 
   // Do not respect the alignment of bit-field types when laying out
@@ -225,22 +211,25 @@
  const TargetOptions )
 : TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(true), LDREX(0),
   HW_FP(0) {
-
-  switch (getTriple().getOS()) {
-  case llvm::Triple::NetBSD:
-  case llvm::Triple::OpenBSD:
-PtrDiffType = SignedLong;
-break;
-  default:
-PtrDiffType = SignedInt;
-break;
-  }
-
   bool IsOpenBSD = Triple.getOS() == llvm::Triple::OpenBSD;
   bool IsNetBSD = Triple.getOS() == llvm::Triple::NetBSD;
-  IntPtrType =
+
+  PtrDiffType = IntPtrType =
   (Triple.isOSDarwin() || IsOpenBSD || IsNetBSD) ? SignedLong : SignedInt;
 
+  // FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like
+  // environment where size_t is `unsigned long` rather than `unsigned int`
+  SizeType = (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
+  IsNetBSD)
+ ? UnsignedLong
+ : UnsignedInt;
+
+  // ptrdiff_t is inconsistent on Darwin
+  if (Triple.isOSDarwin())
+PtrDiffType = SignedInt;
+  else if (Triple.isWatchABI())
+PtrDiffType = SignedLong;
+
   // Cache arch related info.
   setArchInfo();
 
@@ -927,7 +916,6 @@
 WindowsARMTargetInfo::WindowsARMTargetInfo(const llvm::Triple ,
const TargetOptions )
 : WindowsTargetInfo(Triple, Opts), Triple(Triple) {
-  SizeType = UnsignedInt;
 }
 
 void WindowsARMTargetInfo::getVisualStudioDefines(const LangOptions ,
@@ -1047,10 +1035,6 @@
 // Darwin on iOS uses a variant of the ARM C++ ABI.
 TheCXXABI.set(TargetCXXABI::WatchOS);
 
-// The 32-bit ABI is silent on what ptrdiff_t should be, but given that
-// size_t is long, it's a bit weird for it to be int.
-PtrDiffType = SignedLong;
-
 // BOOL should be a real boolean on the new ABI
 UseSignedCharForObjCBool = false;
   } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39280: [libunwind] Use uint64_t for unw_word_t in ARM EHABI

2017-10-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I dont think that this is correct.  IIRC, the unwind specification expects 
`unw_word_t` to match `uintptr_t` (that is, it should be 32-bits on 
https://reviews.llvm.org/P32 environments).


https://reviews.llvm.org/D39280



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


[PATCH] D39281: [libunwind] Express Registers_*::lastDwarfReg using _LIBUNWIND_HIGHEST_DWARF_REGISTER

2017-10-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added inline comments.
This revision is now accepted and ready to land.



Comment at: src/DwarfInstructions.hpp:170
   const int lastReg = R::lastDwarfRegNum();
-  assert((int)CFI_Parser::kMaxRegisterNumber > lastReg &&
+  assert((int)CFI_Parser::kMaxRegisterNumber >= lastReg &&
  "register range too large");

Please use `static_cast` rather than the C style cast.


https://reviews.llvm.org/D39281



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


[PATCH] D24933: Enable configuration files in clang

2017-10-26 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/Driver/Driver.cpp:706
+
+  // Determine architecture part of the file name, if it presents.
+  size_t ArchPrefixLen = 0;

if it presents. -> if it is present.



Comment at: lib/Driver/Driver.cpp:739
+  // like: i386-clang.cfg -> x86_64-clang.cfg.
+  if (ArchPrefixLen < CfgFileName.size())
+FixedConfigFile += CfgFileName.substr(ArchPrefixLen);

I don't see how this length check makes sense in all cases. If CfgFileName came 
from a --config command-line options, whether or not it is longer or shoter 
than ArchPrefixLen seems irrelevant. Do you need to do some prefix check here?


https://reviews.llvm.org/D24933



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


[PATCH] D39354: [WebAssembly] Add crt1.o when calling lld

2017-10-26 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 120529.
sbc100 added a comment.

- rebase


https://reviews.llvm.org/D39354

Files:
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/WebAssembly.cpp
  test/Driver/wasm-toolchain.c


Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -49,6 +49,9 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -309,14 +309,12 @@
 
 std::string ToolChain::getCompilerRTPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName;
-  if (Triple.isOSFreeBSD())
-OSLibName = "freebsd";
-  else if (Triple.isOSBinFormatWasm())
-OSLibName = "wasm";
-  else
-OSLibName = getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  if (Triple.isOSUnknown()) {
+llvm::sys::path::append(Path, "lib");
+  } else {
+StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+llvm::sys::path::append(Path, "lib", OSLibName);
+  }
   return Path.str();
 }
 


Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -49,6 +49,9 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -309,14 +309,12 @@
 
 std::string 

[PATCH] D39357: Filter out invalid 'target' items from being passed to LLVM

2017-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:1173
   .Case("x86", true)
+  .Case("x87", true)
   .Case("x86_32", true)

A test also revealed that we forgot this as well.  Craig just added sse4, which 
was also missing.


https://reviews.llvm.org/D39357



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


[PATCH] D39357: Filter out invalid 'target' items from being passed to LLVM

2017-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

Craig noticed that CodeGen wasn't properly ignoring the
values sent to the target attribute.  This patch ignores
them.

This patch also sets the 'default' for this checking to 
'supported', since only X86 has implemented the support
for checking valid CPU names and Feature Names.

One test was changed to i686, since it uses a lakemont,
which would otherwise be prohibited in x86_64.


https://reviews.llvm.org/D39357

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/X86.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/attr-target-x86.c

Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-cpu x86-64 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
@@ -19,7 +19,7 @@
 
 int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
 
-int __attribute__((target("arch=lakemont"))) lake(int a) { return 4; }
+int __attribute__((target("arch=lakemont,mmx"))) lake(int a) { return 4; }
 
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
@@ -36,11 +36,11 @@
 // CHECK: qax{{.*}} #5
 // CHECK: qq{{.*}} #6
 // CHECK: lake{{.*}} #7
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+x87"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-avx512vpopcntdq,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
-// CHECK: #4 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-avx512vpopcntdq,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-xop,-xsave,-xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="i686" "target-features"="+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-avx512vpopcntdq,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+// CHECK: #3 = {{.*}}"target-cpu"="i686" "target-features"="+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
+// CHECK: #4 = {{.*}}"target-cpu"="i686" "target-features"="+x87,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-avx512vpopcntdq,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-xop,-xsave,-xsaveopt"
 // CHECK: #5 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
-// CHECK: #6 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
-// CHECK: #7 = {{.*}}"target-cpu"="lakemont" "target-features"="+mmx,+sse,+sse2"
+// CHECK: #6 = {{.*}}"target-cpu"="i686" "target-features"="+x87,-3dnow,-3dnowa,-mmx"
+// CHECK: #7 = {{.*}}"target-cpu"="lakemont" "target-features"="+mmx"
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4582,14 +4582,21 @@
 // If we have a TargetAttr build up the feature map based on that.
 TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
 
+ParsedAttr.Features.erase(
+remove_if(ParsedAttr.Features.begin(), ParsedAttr.Features.end(),
+[&](const std::string ) {
+  return !Target.isValidFeatureName(StringRef{Feat}.substr(1));
+}), ParsedAttr.Features.end());
+
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
 ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if (ParsedAttr.Architecture != "")
-  TargetCPU = ParsedAttr.Architecture ;
+if (ParsedAttr.Architecture != "" &&
+Target.isValidCPUName(ParsedAttr.Architecture))
+  TargetCPU = ParsedAttr.Architecture;
 
 // Now populate the feature map, first with the TargetCPU which is either
   

r316725 - Fix test/Driver/wasm-toolchain.c on windows

2017-10-26 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Oct 26 18:20:16 2017
New Revision: 316725

URL: http://llvm.org/viewvc/llvm-project?rev=316725=rev
Log:
Fix test/Driver/wasm-toolchain.c on windows

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=316725=316724=316725=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Oct 26 18:20:16 2017
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


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


r316723 - [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

2017-10-26 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Oct 26 17:56:23 2017
New Revision: 316723

URL: http://llvm.org/viewvc/llvm-project?rev=316723=rev
Log:
[CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

Fixes an assertion failure when ivar is a struct containing incomplete
array. Also completes support for direct flexible array members.

rdar://problem/21054495

Reviewers: rjmccall, theraven

Reviewed By: rjmccall

Subscribers: cfe-commits

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


Added:
cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=316723=316722=316723=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Oct 26 17:56:23 2017
@@ -5084,6 +5084,11 @@ void IvarLayoutBuilder::visitField(const
 
   // Drill down into arrays.
   uint64_t numElts = 1;
+  if (auto arrayType = CGM.getContext().getAsIncompleteArrayType(fieldType)) {
+numElts = 0;
+fieldType = arrayType->getElementType();
+  }
+  // Unlike incomplete arrays, constant arrays can be nested.
   while (auto arrayType = CGM.getContext().getAsConstantArrayType(fieldType)) {
 numElts *= arrayType->getSize().getZExtValue();
 fieldType = arrayType->getElementType();

Added: cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m?rev=316723=auto
==
--- cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m (added)
+++ cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m Thu Oct 26 17:56:23 
2017
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wno-objc-root-class -fobjc-arc 
-emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/21054495
+@interface FlexibleArrayMember {
+  char flexible_array[][4][2];
+}
+@end
+@implementation FlexibleArrayMember
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} 
c"flexible_array\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant 
{{.*}} c"^[4[2c]]\00"
+
+
+typedef char FlexibleArray[];
+
+struct Packet {
+  int size;
+  FlexibleArray data;
+};
+
+@interface VariableSizeIvar {
+  struct Packet flexible_struct;
+}
+@end
+@implementation VariableSizeIvar
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} 
c"flexible_struct\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant 
{{.*}} c"{Packet=\22size\22i\22data\22[0c]}\00"


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


[PATCH] D38774: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

2017-10-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316723: [CodeGen] Add support for IncompleteArrayType in 
Obj-C ivars. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D38774?vs=120337=120524#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38774

Files:
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m


Index: cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
===
--- cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
+++ cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wno-objc-root-class -fobjc-arc 
-emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/21054495
+@interface FlexibleArrayMember {
+  char flexible_array[][4][2];
+}
+@end
+@implementation FlexibleArrayMember
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} 
c"flexible_array\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant 
{{.*}} c"^[4[2c]]\00"
+
+
+typedef char FlexibleArray[];
+
+struct Packet {
+  int size;
+  FlexibleArray data;
+};
+
+@interface VariableSizeIvar {
+  struct Packet flexible_struct;
+}
+@end
+@implementation VariableSizeIvar
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} 
c"flexible_struct\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant 
{{.*}} c"{Packet=\22size\22i\22data\22[0c]}\00"
Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp
@@ -5084,6 +5084,11 @@
 
   // Drill down into arrays.
   uint64_t numElts = 1;
+  if (auto arrayType = CGM.getContext().getAsIncompleteArrayType(fieldType)) {
+numElts = 0;
+fieldType = arrayType->getElementType();
+  }
+  // Unlike incomplete arrays, constant arrays can be nested.
   while (auto arrayType = CGM.getContext().getAsConstantArrayType(fieldType)) {
 numElts *= arrayType->getSize().getZExtValue();
 fieldType = arrayType->getElementType();


Index: cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
===
--- cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
+++ cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wno-objc-root-class -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/21054495
+@interface FlexibleArrayMember {
+  char flexible_array[][4][2];
+}
+@end
+@implementation FlexibleArrayMember
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} c"flexible_array\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}} c"^[4[2c]]\00"
+
+
+typedef char FlexibleArray[];
+
+struct Packet {
+  int size;
+  FlexibleArray data;
+};
+
+@interface VariableSizeIvar {
+  struct Packet flexible_struct;
+}
+@end
+@implementation VariableSizeIvar
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} c"flexible_struct\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}} c"{Packet=\22size\22i\22data\22[0c]}\00"
Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp
@@ -5084,6 +5084,11 @@
 
   // Drill down into arrays.
   uint64_t numElts = 1;
+  if (auto arrayType = CGM.getContext().getAsIncompleteArrayType(fieldType)) {
+numElts = 0;
+fieldType = arrayType->getElementType();
+  }
+  // Unlike incomplete arrays, constant arrays can be nested.
   while (auto arrayType = CGM.getContext().getAsConstantArrayType(fieldType)) {
 numElts *= arrayType->getSize().getZExtValue();
 fieldType = arrayType->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Zachary Turner via cfe-commits
On Thu, Oct 26, 2017 at 3:18 PM Don Hinton  wrote:

> On Thu, Oct 26, 2017 at 2:48 PM, Zachary Turner 
> wrote:
>
>> Seems fine, it would be nice if the workflow could be improved a little
>> bit so that all you have to do is say `clangdiag break
>> —error=“-Wcovered-switch”` or something . I think that gives the most
>> intuitive usage for people, even it’s a bit harder to implement.
>>
>
> The idea was to break on actual diagnostics emitted, but if you want to
> break on diagnostic usage, i.e., when it was checked but not emitted, I
> suppose that's possible as well.  diagtool doesn't produce a mapping for
> this, but it could be added -- assuming tablegen produced enough info in
> the .inc files to support it.  I added the feature I'm using here a few
> months ago, which was an extension to what Alex added earlier.
>

That was my idea too.  But still, wouldn't it be possible to say `clangdiag
break --error="-Wcovered-switch"` and then have it break only when the
-Wcovered-switch diagnostic is *emitted*?

The reason I keep using this syntax though is because clang developers
always think in terms of the warning names.  If you want to find out why a
warning is being emitted amidst a spew of other warnings and errors, you
really want to be able to specify the name of the warning.

Don't get me wrong though, I do think this is a nice feature, I'm just
thinking of ways to make it more compelling by looking at it from the clang
developer's perspective and how they will most likely want to use it.

Also, I still think it should go in lldb, not in clang.  That's kind of
exactly what the lldb/examples folder is for.

That said, lgtm, but I'm still interested to see if the workflow can be
streamlined down the line.  Perhaps after it gets checked in you can make a
PSA on cfe-dev@ and mention that you want people to try it out and offer
feedback ;-)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 120518.
hintonda added a comment.

- Maintain process id map for diagtool.


https://reviews.llvm.org/D36347

Files:
  utils/clangdiag.py

Index: utils/clangdiag.py
===
--- /dev/null
+++ utils/clangdiag.py
@@ -0,0 +1,163 @@
+#!/usr/bin/python
+
+#--
+# Be sure to add the python path that points to the LLDB shared library.
+#
+# # To use this in the embedded python interpreter using "lldb" just
+# import it with the full path using the "command script import"
+# command
+#   (lldb) command script import /path/to/clandiag.py
+#--
+
+import lldb
+import argparse
+import commands
+import shlex
+import os
+import subprocess
+
+class MyParser(argparse.ArgumentParser):
+def format_help(self):
+return ''' Commands for managing clang diagnostic breakpoints
+
+Syntax: clangdiag enable
+clangdiag disable
+clangdiag diagtool [|reset]
+
+The following subcommands are supported:
+
+  enable   -- Enable clang diagnostic breakpoints.
+  disable  -- Disable all clang diagnostic breakpoints.
+  diagtool -- Return, set, or reset diagtool path.
+
+This command sets breakpoints in clang, and clang based tools, that
+emit diagnostics.  When a diagnostic is emitted, and clangdiag is
+enabled, it will use the appropriate diagtool application to determine
+the name of the DiagID, and set breakpoints in all locations that
+'diag::name' appears in the source.  Since the new breakpoints are set
+after they are encountered, users will need to launch the executable a
+second time in order to hit the new breakpoints.
+
+For in-tree builds, the diagtool application, used to map DiagID's to
+names, is found automatically in the same directory as the target
+executable.  However, out-or-tree builds must use the 'diagtool'
+subcommand to set the appropriate path for diagtool in the clang debug
+bin directory.  Since this mapping is created at build-time, it's
+important for users to use the same version that was generated when
+clang was compiled, or else the id's won't match.
+
+Notes:
+
+- Rerunning enable clears existing breakpoints.
+- diagtool is used in breakpoint callbacks, so it can be changed
+  without the need to rerun enable.
+- Make it always available by adding this to your ~.lldbinit file:
+  "command script import /path/to/clangdiag.py"
+
+'''
+
+def create_diag_options():
+parser = MyParser(prog='clangdiag')
+subparsers = parser.add_subparsers(
+title='subcommands',
+dest='subcommands',
+metavar='')
+disable_parser = subparsers.add_parser('disable')
+enable_parser = subparsers.add_parser('enable')
+diagtool_parser = subparsers.add_parser('diagtool')
+diagtool_parser.add_argument('path', nargs='?')
+return parser
+
+def getDiagtool(target, diagtool = None):
+id = target.GetProcess().GetProcessID()
+if 'diagtool' not in getDiagtool.__dict__:
+getDiagtool.diagtool = {}
+if diagtool:
+if diagtool == 'reset':
+getDiagtool.diagtool[id] = None
+elif os.path.exists(diagtool):
+getDiagtool.diagtool[id] = diagtool
+else:
+print('clangdiag: %s not found.' % diagtool)
+if not id in getDiagtool.diagtool or not getDiagtool.diagtool[id]:
+getDiagtool.diagtool[id] = None
+exe = target.GetExecutable()
+if not exe.Exists():
+print('clangdiag: Target (%s) not set.' % exe.GetFilename())
+else:
+diagtool = os.path.join(exe.GetDirectory(), 'diagtool')
+if os.path.exists(diagtool):
+getDiagtool.diagtool[id] = diagtool
+else:
+print('clangdiag: diagtool not found along side %s' % exe)
+
+return getDiagtool.diagtool[id]
+
+def setDiagBreakpoint(frame, bp_loc, dict):
+id = frame.FindVariable("DiagID").GetValue()
+if id is None:
+ print('clangdiag: id is None')
+ return False
+
+# Don't need to test this time, since we did that in enable.
+target = frame.GetThread().GetProcess().GetTarget()
+diagtool = getDiagtool(target)
+name = subprocess.check_output([diagtool, "find-diagnostic-id", id]).rstrip();
+bp = target.BreakpointCreateBySourceRegex(name, lldb.SBFileSpec())
+bp.AddName("clang::Diagnostic")
+
+return False
+
+def enable(exe_ctx, args):
+# Always disable existing breakpoints
+disable(exe_ctx)
+
+target = exe_ctx.GetTarget()
+# Just make sure we can find diagtool since it gets used in callbacks.
+diagtool = getDiagtool(target)
+bp = target.BreakpointCreateByName('DiagnosticsEngine::Report')
+bp.SetScriptCallbackFunction('clangdiag.setDiagBreakpoint')
+bp.AddName("clang::Diagnostic")
+
+return
+
+def disable(exe_ctx):
+target = 

[PATCH] D39218: [WebAssembly] Include libclang_rt.builtins in the standard way

2017-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316719: [WebAssembly] Include libclang_rt.builtins in the 
standard way (authored by sbc).

Changed prior to commit:
  https://reviews.llvm.org/D39218?vs=120111=120516#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39218

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
  cfe/trunk/test/Driver/wasm-toolchain.c


Index: cfe/trunk/test/Driver/wasm-toolchain.c
===
--- cfe/trunk/test/Driver/wasm-toolchain.c
+++ cfe/trunk/test/Driver/wasm-toolchain.c
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" 
"-allow-undefined-file" "wasm.syms" "-lc" 
"{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1027,15 +1027,7 @@
 
   switch (RLT) {
   case ToolChain::RLT_CompilerRT:
-switch (TC.getTriple().getOS()) {
-default:
-  llvm_unreachable("unsupported OS");
-case llvm::Triple::Win32:
-case llvm::Triple::Linux:
-case llvm::Triple::Fuchsia:
-  CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
-  break;
-}
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 break;
   case ToolChain::RLT_Libgcc:
 // Make sure libgcc is not used under MSVC environment by default
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -61,7 +61,7 @@
 CmdArgs.push_back("-allow-undefined-file");
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("wasm.syms")));
 CmdArgs.push_back("-lc");
-CmdArgs.push_back("-lcompiler_rt");
+AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
   CmdArgs.push_back("-o");
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -309,7 +309,13 @@
 
 std::string ToolChain::getCompilerRTPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  StringRef OSLibName;
+  if (Triple.isOSFreeBSD())
+OSLibName = "freebsd";
+  else if (Triple.isOSBinFormatWasm())
+OSLibName = "wasm";
+  else
+OSLibName = getOS();
   llvm::sys::path::append(Path, "lib", OSLibName);
   return Path.str();
 }


Index: cfe/trunk/test/Driver/wasm-toolchain.c
===
--- cfe/trunk/test/Driver/wasm-toolchain.c
+++ cfe/trunk/test/Driver/wasm-toolchain.c
@@ -27,10 +27,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "-lcompiler_rt" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: 

[PATCH] D39317: Use -fuse-init-array if no gcc installation is found.

2017-10-26 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r316713, thanks!


https://reviews.llvm.org/D39317



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


r316713 - Use -fuse-init-array if no gcc installation is found.

2017-10-26 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Oct 26 16:26:29 2017
New Revision: 316713

URL: http://llvm.org/viewvc/llvm-project?rev=316713=rev
Log:
Use -fuse-init-array if no gcc installation is found.

clang currently uses .init_array instead of .ctors on Linux if it detects gcc
4.7+. Make it so that it also uses .init_array if no gcc installation is found
at all – if there's no old gcc, there's nothing we need to be compatible with.

icecc for example runs clang in a very small chroot, so before this change
clang would use .ctors if run under icecc. And lld currently silently mislinks
inputs with .ctors sections, so before this clang + icecc + lld would produce
broken binaries. (But this seems like a good change independent of that lld
bug.)

https://reviews.llvm.org/D39317

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/constructors.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=316713=316712=316713=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 26 16:26:29 2017
@@ -105,6 +105,10 @@ Non-comprehensive list of changes in thi
   Users should generally expect this to be regularly raised to match the most
   recently released version of the Visual C++ compiler.
 
+- clang now defaults to ``.init_array`` if no gcc installation can be found.
+  If a gcc installation is found, it still prefers ``.ctors`` if the found
+  gcc is older than 4.7.0.
+
 New Compiler Flags
 --
 

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=316713=316712=316713=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Oct 26 16:26:29 2017
@@ -2366,7 +2366,8 @@ void Generic_ELF::addClangTargetOptions(
   getTriple().getArch() == llvm::Triple::aarch64 ||
   getTriple().getArch() == llvm::Triple::aarch64_be ||
   (getTriple().getOS() == llvm::Triple::Linux &&
-   (!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) ||
+   ((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) ||
+getTriple().isAndroid())) ||
   getTriple().getOS() == llvm::Triple::NaCl ||
   (getTriple().getVendor() == llvm::Triple::MipsTechnologies &&
!getTriple().hasEnvironment()) ||

Modified: cfe/trunk/test/Driver/constructors.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/constructors.c?rev=316713=316712=316713=diff
==
--- cfe/trunk/test/Driver/constructors.c (original)
+++ cfe/trunk/test/Driver/constructors.c Thu Oct 26 16:26:29 2017
@@ -6,6 +6,12 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1   \
 // RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/resource_dir \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1   \
+// RUN: -target i386-unknown-linux \
 // RUN: --sysroot=%S/Inputs/fake_install_tree \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s


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


[PATCH] D39349: [X86] Make -march=i686 an alias of -march=pentiumpro

2017-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316712: [X86] Make -march=i686 an alias of -march=pentiumpro 
(authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D39349?vs=120503=120508#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39349

Files:
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/test/Preprocessor/predefined-arch-macros.c


Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -119,7 +119,6 @@
   case CK_i486:
   case CK_i586:
   case CK_Pentium:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Lakemont:
 break;
@@ -806,15 +805,8 @@
 Builder.defineMacro("__tune_pentium2__");
 LLVM_FALLTHROUGH;
   case CK_PentiumPro:
-Builder.defineMacro("__tune_i686__");
-Builder.defineMacro("__tune_pentiumpro__");
-LLVM_FALLTHROUGH;
-  case CK_i686:
-Builder.defineMacro("__i686");
-Builder.defineMacro("__i686__");
-// Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
-Builder.defineMacro("__pentiumpro");
-Builder.defineMacro("__pentiumpro__");
+defineCPUMacros(Builder, "i686");
+defineCPUMacros(Builder, "pentiumpro");
 break;
   case CK_Pentium4:
 defineCPUMacros(Builder, "pentium4");
@@ -1542,7 +1534,6 @@
   case CK_i586:
   case CK_Pentium:
   case CK_PentiumMMX:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Pentium2:
   case CK_Pentium3:
@@ -1606,8 +1597,7 @@
   .Case("i586", CK_i586)
   .Case("pentium", CK_Pentium)
   .Case("pentium-mmx", CK_PentiumMMX)
-  .Case("i686", CK_i686)
-  .Case("pentiumpro", CK_PentiumPro)
+  .Cases("i686", "pentiumpro", CK_PentiumPro)
   .Case("pentium2", CK_Pentium2)
   .Cases("pentium3", "pentium3m", CK_Pentium3)
   .Case("pentium-m", CK_PentiumM)
Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -122,7 +122,6 @@
 /// \name i686
 /// i686-generation processors, P6 / Pentium M microarchitecture based.
 //@{
-CK_i686,
 CK_PentiumPro,
 CK_Pentium2,
 CK_Pentium3,
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c
@@ -156,6 +156,8 @@
 // CHECK_I686_M32: #define __i686__ 1
 // CHECK_I686_M32: #define __pentiumpro 1
 // CHECK_I686_M32: #define __pentiumpro__ 1
+// CHECK_I686_M32: #define __tune_i686__ 1
+// CHECK_I686_M32: #define __tune_pentiumpro__ 1
 // CHECK_I686_M32: #define i386 1
 // RUN: not %clang -march=i686 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \


Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -119,7 +119,6 @@
   case CK_i486:
   case CK_i586:
   case CK_Pentium:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Lakemont:
 break;
@@ -806,15 +805,8 @@
 Builder.defineMacro("__tune_pentium2__");
 LLVM_FALLTHROUGH;
   case CK_PentiumPro:
-Builder.defineMacro("__tune_i686__");
-Builder.defineMacro("__tune_pentiumpro__");
-LLVM_FALLTHROUGH;
-  case CK_i686:
-Builder.defineMacro("__i686");
-Builder.defineMacro("__i686__");
-// Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
-Builder.defineMacro("__pentiumpro");
-Builder.defineMacro("__pentiumpro__");
+defineCPUMacros(Builder, "i686");
+defineCPUMacros(Builder, "pentiumpro");
 break;
   case CK_Pentium4:
 defineCPUMacros(Builder, "pentium4");
@@ -1542,7 +1534,6 @@
   case CK_i586:
   case CK_Pentium:
   case CK_PentiumMMX:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Pentium2:
   case CK_Pentium3:
@@ -1606,8 +1597,7 @@
   .Case("i586", CK_i586)
   .Case("pentium", CK_Pentium)
   .Case("pentium-mmx", CK_PentiumMMX)
-  .Case("i686", CK_i686)
-  .Case("pentiumpro", CK_PentiumPro)
+  .Cases("i686", "pentiumpro", CK_PentiumPro)
   .Case("pentium2", CK_Pentium2)
   .Cases("pentium3", "pentium3m", CK_Pentium3)
   .Case("pentium-m", CK_PentiumM)
Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -122,7 +122,6 @@
 /// \name i686
 /// i686-generation processors, P6 / Pentium M microarchitecture based.
 //@{
-CK_i686,
 CK_PentiumPro,
 CK_Pentium2,
 CK_Pentium3,
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c

[PATCH] D38824: [X86] Synchronize the existing CPU predefined macros with the cases that gcc defines them

2017-10-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

In https://reviews.llvm.org/D38824#908540, @RKSimon wrote:

> Where is the best place to document this policy so people have a chance of 
> understanding it going forward?


Given the (apparent) amount of confusion here, I'd suggest a dedicated document 
in Clang's documentation that gives suggested best practices and warns about 
anti-patterns for detecting these kinds of things. We can write it reasonably 
generically and make it not too Clang-specific and citable for guidance even 
when folks are using GCC (or other compilers).


https://reviews.llvm.org/D38824



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


r316712 - [X86] Make -march=i686 an alias of -march=pentiumpro

2017-10-26 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Oct 26 16:06:19 2017
New Revision: 316712

URL: http://llvm.org/viewvc/llvm-project?rev=316712=rev
Log:
[X86] Make -march=i686 an alias of -march=pentiumpro

I think the only reason they are different is because we don't set tune_i686 
for -march=i686 to match GCC. But GCC 4.9.0 seems to have changed this behavior 
and they do set it now. So I think they can aliases now.

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

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=316712=316711=316712=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Thu Oct 26 16:06:19 2017
@@ -119,7 +119,6 @@ bool X86TargetInfo::initFeatureMap(
   case CK_i486:
   case CK_i586:
   case CK_Pentium:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Lakemont:
 break;
@@ -806,15 +805,8 @@ void X86TargetInfo::getTargetDefines(con
 Builder.defineMacro("__tune_pentium2__");
 LLVM_FALLTHROUGH;
   case CK_PentiumPro:
-Builder.defineMacro("__tune_i686__");
-Builder.defineMacro("__tune_pentiumpro__");
-LLVM_FALLTHROUGH;
-  case CK_i686:
-Builder.defineMacro("__i686");
-Builder.defineMacro("__i686__");
-// Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
-Builder.defineMacro("__pentiumpro");
-Builder.defineMacro("__pentiumpro__");
+defineCPUMacros(Builder, "i686");
+defineCPUMacros(Builder, "pentiumpro");
 break;
   case CK_Pentium4:
 defineCPUMacros(Builder, "pentium4");
@@ -1542,7 +1534,6 @@ bool X86TargetInfo::checkCPUKind(CPUKind
   case CK_i586:
   case CK_Pentium:
   case CK_PentiumMMX:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Pentium2:
   case CK_Pentium3:
@@ -1606,8 +1597,7 @@ X86TargetInfo::CPUKind X86TargetInfo::ge
   .Case("i586", CK_i586)
   .Case("pentium", CK_Pentium)
   .Case("pentium-mmx", CK_PentiumMMX)
-  .Case("i686", CK_i686)
-  .Case("pentiumpro", CK_PentiumPro)
+  .Cases("i686", "pentiumpro", CK_PentiumPro)
   .Case("pentium2", CK_Pentium2)
   .Cases("pentium3", "pentium3m", CK_Pentium3)
   .Case("pentium-m", CK_PentiumM)

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=316712=316711=316712=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Thu Oct 26 16:06:19 2017
@@ -122,7 +122,6 @@ class LLVM_LIBRARY_VISIBILITY X86TargetI
 /// \name i686
 /// i686-generation processors, P6 / Pentium M microarchitecture based.
 //@{
-CK_i686,
 CK_PentiumPro,
 CK_Pentium2,
 CK_Pentium3,

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=316712=316711=316712=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Thu Oct 26 16:06:19 
2017
@@ -156,6 +156,8 @@
 // CHECK_I686_M32: #define __i686__ 1
 // CHECK_I686_M32: #define __pentiumpro 1
 // CHECK_I686_M32: #define __pentiumpro__ 1
+// CHECK_I686_M32: #define __tune_i686__ 1
+// CHECK_I686_M32: #define __tune_pentiumpro__ 1
 // CHECK_I686_M32: #define i386 1
 // RUN: not %clang -march=i686 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \


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


[PATCH] D39349: [X86] Make -march=i686 an alias of -march=pentiumpro

2017-10-26 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I suspect the gcc behavior changed when this bug was fixed 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59588


https://reviews.llvm.org/D39349



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


[PATCH] D39204: [CodeGen] __builtin_sqrt should map to the compiler's intrinsic sqrt function

2017-10-26 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39204#905860, @efriedma wrote:

> I think you're understanding the semantics correctly.
>
> For r265521, look again at the implementation of 
> llvm::checkUnaryFloatSignature; if "I.onlyReadsMemory()" is true, we somehow 
> proved the call doesn't set errno (mostly likely because we know something 
> about the target's libm).


Right. Either by target default, or because the user passed -fno-math-errno (or 
something that implies it, such as -ffast-math), we mark the functions as 
readonly/readnone because they won't write to errno.

In https://reviews.llvm.org/D39204#905361, @spatel wrote:

> Working my way through the stack: does the sqrt LangRef change mean we can 
> revert https://reviews.llvm.org/rL265521?


Yes, maybe. We can now form the intrinsics from the library calls so long as we 
only care about the result (and not the value of errno), even if the input is 
negative or would otherwise generate a NaN (as the intrinsic no longer as UB in 
those situations). However, we still need to know that the potential value of 
errno is of no interest. I'm not sure how we know that without some particular 
modeling.

> What allows us to transform any of those libm calls that set errno to vectors 
> in the first place?
> 
> I'm even more confused than usual, but if I can find a way to untangle this 
> mess, I'll try to start making patches.




https://reviews.llvm.org/D39204



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


[PATCH] D39349: [X86] Make -march=i686 an alias of -march=pentiumpro

2017-10-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM, nice.


https://reviews.llvm.org/D39349



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


[PATCH] D39349: [X86] Make -march=i686 an alias of -march=pentiumpro

2017-10-26 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.

I think the only reason they are different is because we don't set 
__tune_i686__ for -march=i686 to match GCC. But GCC 4.9.0 seems to have changed 
this behavior and they do set it now. So I think they can aliases now.


https://reviews.llvm.org/D39349

Files:
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  test/Preprocessor/predefined-arch-macros.c


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -156,6 +156,8 @@
 // CHECK_I686_M32: #define __i686__ 1
 // CHECK_I686_M32: #define __pentiumpro 1
 // CHECK_I686_M32: #define __pentiumpro__ 1
+// CHECK_I686_M32: #define __tune_i686__ 1
+// CHECK_I686_M32: #define __tune_pentiumpro__ 1
 // CHECK_I686_M32: #define i386 1
 // RUN: not %clang -march=i686 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -122,7 +122,6 @@
 /// \name i686
 /// i686-generation processors, P6 / Pentium M microarchitecture based.
 //@{
-CK_i686,
 CK_PentiumPro,
 CK_Pentium2,
 CK_Pentium3,
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -119,7 +119,6 @@
   case CK_i486:
   case CK_i586:
   case CK_Pentium:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Lakemont:
 break;
@@ -806,15 +805,8 @@
 Builder.defineMacro("__tune_pentium2__");
 LLVM_FALLTHROUGH;
   case CK_PentiumPro:
-Builder.defineMacro("__tune_i686__");
-Builder.defineMacro("__tune_pentiumpro__");
-LLVM_FALLTHROUGH;
-  case CK_i686:
-Builder.defineMacro("__i686");
-Builder.defineMacro("__i686__");
-// Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
-Builder.defineMacro("__pentiumpro");
-Builder.defineMacro("__pentiumpro__");
+defineCPUMacros(Builder, "i686");
+defineCPUMacros(Builder, "pentiumpro");
 break;
   case CK_Pentium4:
 defineCPUMacros(Builder, "pentium4");
@@ -1542,7 +1534,6 @@
   case CK_i586:
   case CK_Pentium:
   case CK_PentiumMMX:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Pentium2:
   case CK_Pentium3:
@@ -1606,8 +1597,7 @@
   .Case("i586", CK_i586)
   .Case("pentium", CK_Pentium)
   .Case("pentium-mmx", CK_PentiumMMX)
-  .Case("i686", CK_i686)
-  .Case("pentiumpro", CK_PentiumPro)
+  .Cases("i686", "pentiumpro", CK_PentiumPro)
   .Case("pentium2", CK_Pentium2)
   .Cases("pentium3", "pentium3m", CK_Pentium3)
   .Case("pentium-m", CK_PentiumM)


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -156,6 +156,8 @@
 // CHECK_I686_M32: #define __i686__ 1
 // CHECK_I686_M32: #define __pentiumpro 1
 // CHECK_I686_M32: #define __pentiumpro__ 1
+// CHECK_I686_M32: #define __tune_i686__ 1
+// CHECK_I686_M32: #define __tune_pentiumpro__ 1
 // CHECK_I686_M32: #define i386 1
 // RUN: not %clang -march=i686 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -122,7 +122,6 @@
 /// \name i686
 /// i686-generation processors, P6 / Pentium M microarchitecture based.
 //@{
-CK_i686,
 CK_PentiumPro,
 CK_Pentium2,
 CK_Pentium3,
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -119,7 +119,6 @@
   case CK_i486:
   case CK_i586:
   case CK_Pentium:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Lakemont:
 break;
@@ -806,15 +805,8 @@
 Builder.defineMacro("__tune_pentium2__");
 LLVM_FALLTHROUGH;
   case CK_PentiumPro:
-Builder.defineMacro("__tune_i686__");
-Builder.defineMacro("__tune_pentiumpro__");
-LLVM_FALLTHROUGH;
-  case CK_i686:
-Builder.defineMacro("__i686");
-Builder.defineMacro("__i686__");
-// Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
-Builder.defineMacro("__pentiumpro");
-Builder.defineMacro("__pentiumpro__");
+defineCPUMacros(Builder, "i686");
+defineCPUMacros(Builder, "pentiumpro");
 break;
   case CK_Pentium4:
 defineCPUMacros(Builder, "pentium4");
@@ -1542,7 +1534,6 @@
   case CK_i586:
   case CK_Pentium:
   case CK_PentiumMMX:
-  case CK_i686:
   case CK_PentiumPro:
   case CK_Pentium2:
   case CK_Pentium3:
@@ -1606,8 +1597,7 @@
   .Case("i586", CK_i586)
   .Case("pentium", CK_Pentium)
   

[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Added all of @rsmith's comments here, I believe I have them all and have 
properly responded to them.




Comment at: include/clang/AST/ASTContext.h:2115
+  bool hasUniqueObjectRepresentations(QualType Ty) const;
+
   
//======//

Moved because @rsmith said: 

I think this would make more sense as a member of ASTContext. The Type object 
generally doesn't know or care about its representation.



Comment at: lib/AST/Type.cpp:2212
-for (const auto Base : ClassDecl->bases()) {
-  if (Base.isVirtual())
-return false;

@rsmith said: Hmm, are there any cases in which we might want to guarantee the 
vptr is identical across all instances?

I believe the answer to that is 'no', but if you have a case in mind, I can 
change this.



Comment at: lib/AST/Type.cpp:2218
-  // Empty base takes up 0 size.
-  if (!isStructEmpty(Base.getType())) {
-if (!Base.getType().structHasUniqueObjectRepresentations(Context))

@rsmith said: This seems really fragile to me. Empty bases may or may not 
occupy storage. But that's beside the point -- empty bases are just a special 
case of bases with tail padding, which are not properly handled here.

I really think you should be walking the record layout rather than trying to 
determine this from sizes alone.

Response:
I think I did that properly in this patch here.  I re-did a bunch of the code 
around this, so hopefully it is to your liking.




Comment at: lib/AST/Type.cpp:2233
-return StructSize == BaseSize;
-  ;
-

@rsmith said: Stray semicolon?

Yep, don't know how that got in there...




Comment at: lib/AST/Type.cpp:2281
-  if ((*this)->isArrayType())
-return Context.getBaseElementType(*this).hasUniqueObjectRepresentations(
-Context);

@rsmith said: I don't think this is correct. As a weird GNU behaviour, we can 
have, say, a type with size 3 and alignment 4 (via an alignment attribute on a 
typedef). An array of 1 such element has size 4, and has padding even if its 
element type does not.

I think I added a test that covers that here.  Is there a way to mark 
non-record types with an alignment?  If not, this cause problems, because the 
Layout.getSize() checks in the struct handling will take care of this, since 
'getSize' includes alignment.



Comment at: lib/AST/Type.cpp:2296
-
-  // All pointers are unique, since they're just integrals.
-  if ((*this)->isPointerType() || (*this)->isMemberPointerType())

@rsmith said: The second half of this comment doesn't seem right to me. They 
may be represented as sequences of bits, but that doesn't make them integral.

I think you're right, I removed this part.



Comment at: lib/AST/Type.cpp:2303
-
-// Lambda types are not unique, so exclude them immediately.
-if (Record->isLambda())

@rsmith said: Why?

Thats a good question that I lack the answer to... I decided to remove this and 
let the 'struct' handling take care of it, which seems to make sense, and even 
better, seems to work.




Comment at: lib/AST/Type.cpp:2308
-if (Record->isUnion())
-  return unionHasUniqueObjectRepresentations(Context);
-return structHasUniqueObjectRepresentations(Context);

@rsmith said: Making these members of QualType seems counterproductive. You 
already have the Record here; it'd be better to make these file-static and pass 
that in.

Done.



https://reviews.llvm.org/D39347



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


Re: [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via cfe-commits
On Thu, Oct 26, 2017 at 2:48 PM, Zachary Turner  wrote:

> Seems fine, it would be nice if the workflow could be improved a little
> bit so that all you have to do is say `clangdiag break
> —error=“-Wcovered-switch”` or something . I think that gives the most
> intuitive usage for people, even it’s a bit harder to implement.
>

The idea was to break on actual diagnostics emitted, but if you want to
break on diagnostic usage, i.e., when it was checked but not emitted, I
suppose that's possible as well.  diagtool doesn't produce a mapping for
this, but it could be added -- assuming tablegen produced enough info in
the .inc files to support it.  I added the feature I'm using here a few
months ago, which was an extension to what Alex added earlier.


>
> I also think user shouldn’t really have to concern themselves with
> diagtool, it should all just be magic. I get why it’s easier to do this
> way, but from the users perspective, having the commands map as closely as
> possible to the thing the person wants to do and hiding implementation
> details is a big win from a usability standpoint.
>

For the normal use case, i.e., clang/llvm developers that build both
together, it will just work by magic, i.e., you just run enable/disable.
The only problem is when you build out-of-tree.  If you can suggest a way
to find the correct location by examining the executable, I'd be happy to
add it.


>
> We can iterate on it later though
>

I'm happy to keep hacking on it -- got plenty of time on my hands right
now...  And I get to learn more about lldb...


> On Thu, Oct 26, 2017 at 2:38 PM Don Hinton via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> hintonda updated this revision to Diff 120492.
>> hintonda added a comment.
>>
>> - Remove debugging print statement, and enhance help message.
>>
>>
>> https://reviews.llvm.org/D36347
>>
>> Files:
>>   utils/clangdiag.py
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

Corrections done for @rsmith 's comments after-commit
on cfe-commits.


https://reviews.llvm.org/D39347

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2166,151 +2166,6 @@
   return false;
 }
 
-bool QualType::unionHasUniqueObjectRepresentations(
-const ASTContext ) const {
-  assert((*this)->isUnionType() && "must be union type");
-  CharUnits UnionSize = Context.getTypeSizeInChars(*this);
-  const RecordDecl *Union = getTypePtr()->getAs()->getDecl();
-
-  for (const auto *Field : Union->fields()) {
-if (!Field->getType().hasUniqueObjectRepresentations(Context))
-  return false;
-CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
-if (FieldSize != UnionSize)
-  return false;
-  }
-  return true;
-}
-
-bool isStructEmpty(QualType Ty) {
-  assert(Ty.getTypePtr()->isStructureOrClassType() &&
- "Must be struct or class");
-  const RecordDecl *RD = Ty.getTypePtr()->getAs()->getDecl();
-
-  if (!RD->field_empty())
-return false;
-
-  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
-return ClassDecl->isEmpty();
-  }
-
-  return true;
-}
-
-bool QualType::structHasUniqueObjectRepresentations(
-const ASTContext ) const {
-  assert((*this)->isStructureOrClassType() && "Must be struct or class");
-  const RecordDecl *RD = getTypePtr()->getAs()->getDecl();
-
-  if (isStructEmpty(*this))
-return false;
-
-  // Check base types.
-  CharUnits BaseSize{};
-  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
-for (const auto Base : ClassDecl->bases()) {
-  if (Base.isVirtual())
-return false;
-
-  // Empty bases are permitted, otherwise ensure base has unique
-  // representation. Also, Empty Base Optimization means that an
-  // Empty base takes up 0 size.
-  if (!isStructEmpty(Base.getType())) {
-if (!Base.getType().structHasUniqueObjectRepresentations(Context))
-  return false;
-BaseSize += Context.getTypeSizeInChars(Base.getType());
-  }
-}
-  }
-
-  CharUnits StructSize = Context.getTypeSizeInChars(*this);
-
-  // This struct obviously has bases that keep it from being 'empty', so
-  // checking fields is no longer required.  Ensure that the struct size
-  // is the sum of the bases.
-  if (RD->field_empty())
-return StructSize == BaseSize;
-  ;
-
-  CharUnits CurOffset =
-  Context.toCharUnitsFromBits(Context.getFieldOffset(*RD->field_begin()));
-
-  // If the first field isn't at the sum of the size of the bases, there
-  // is padding somewhere.
-  if (BaseSize != CurOffset)
-return false;
-
-  for (const auto *Field : RD->fields()) {
-if (!Field->getType().hasUniqueObjectRepresentations(Context))
-  return false;
-CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
-CharUnits FieldOffset =
-Context.toCharUnitsFromBits(Context.getFieldOffset(Field));
-// Has padding between fields.
-if (FieldOffset != CurOffset)
-  return false;
-CurOffset += FieldSize;
-  }
-  // Check for tail padding.
-  return CurOffset == StructSize;
-}
-
-bool QualType::hasUniqueObjectRepresentations(const ASTContext ) const {
-  // C++17 [meta.unary.prop]:
-  //   The predicate condition for a template specialization
-  //   has_unique_object_representations shall be
-  //   satisfied if and only if:
-  // (9.1) - T is trivially copyable, and
-  // (9.2) - any two objects of type T with the same value have the same
-  // object representation, where two objects
-  //   of array or non-union class type are considered to have the same value
-  //   if their respective sequences of
-  //   direct subobjects have the same values, and two objects of union type
-  //   are considered to have the same
-  //   value if they have the same active member and the corresponding members
-  //   have the same value.
-  //   The set of scalar types for which this condition holds is
-  //   implementation-defined. [ Note: If a type has padding
-  //   bits, the condition does not hold; otherwise, the condition holds true
-  //   for unsigned integral types. -- end note ]
-  if (isNull())
-return false;
-
-  // Arrays are unique only if their element type is unique.
-  if ((*this)->isArrayType())
-return Context.getBaseElementType(*this).hasUniqueObjectRepresentations(
-Context);
-
-  // (9.1) - T is trivially copyable, and
-  if (!isTriviallyCopyableType(Context))
-return false;
-
-  // Functions are not unique.
-  if ((*this)->isFunctionType())
-return false;
-
-  // All integrals and enums are unique!
-  if ((*this)->isIntegralOrEnumerationType())
-return true;
-
-  // All pointers are unique, since they're just integrals.

[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-10-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I didn't really search for it before, but it looks like LLVM already has a 
routine for computing column widths?  See llvm::sys::unicode::columnWidthUTF8.

There are some tools which parse clang diagnostic output; we might need a flag 
to control this.  Not sure who would know about that?




Comment at: lib/Basic/SourceManager.cpp:1501
+  unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second, ,
+   /*BytePosition=*/false);
   if (Invalid)

Instead of adding a parameter to getColumnNumber, it would probably make sense 
to just make this caller correct the column number afterwards.


https://reviews.llvm.org/D33765



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


Re: [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via cfe-commits
On Thu, Oct 26, 2017 at 3:00 PM, Greg Clayton via Phabricator <
revi...@reviews.llvm.org> wrote:

> clayborg added a comment.
>
> Each lldb.SBValue has accessors for the stuff in an execution context:
>
> ``
>
>   lldb::SBTarget GetTarget();
>   lldb::SBProcess GetProcess();
>   lldb::SBThread GetThread();
>   lldb::SBFrame GetFrame();
>
>   You could keep a global map of process ID to diagtool if you want?
>
>   What are you thinking of using this for?
>

Part of the rational for using exe_ctx was to allow debugging multiple
targets as the same time, but if these use different versions of clang, the
diagtool map won't match.

I'll try moving it from the function __dict__ to the exe_ctx and see if
that works.

thanks...


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


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Greg Clayton via Phabricator via cfe-commits
clayborg added a comment.

Each lldb.SBValue has accessors for the stuff in an execution context:

``

  lldb::SBTarget GetTarget();
  lldb::SBProcess GetProcess();
  lldb::SBThread GetThread();
  lldb::SBFrame GetFrame();

  You could keep a global map of process ID to diagtool if you want?
  
  What are you thinking of using this for?


https://reviews.llvm.org/D36347



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


Re: [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Zachary Turner via cfe-commits
Seems fine, it would be nice if the workflow could be improved a little bit
so that all you have to do is say `clangdiag break
—error=“-Wcovered-switch”` or something . I think that gives the most
intuitive usage for people, even it’s a bit harder to implement.

I also think user shouldn’t really have to concern themselves with
diagtool, it should all just be magic. I get why it’s easier to do this
way, but from the users perspective, having the commands map as closely as
possible to the thing the person wants to do and hiding implementation
details is a big win from a usability standpoint.

We can iterate on it later though
On Thu, Oct 26, 2017 at 2:38 PM Don Hinton via Phabricator <
revi...@reviews.llvm.org> wrote:

> hintonda updated this revision to Diff 120492.
> hintonda added a comment.
>
> - Remove debugging print statement, and enhance help message.
>
>
> https://reviews.llvm.org/D36347
>
> Files:
>   utils/clangdiag.py
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location

2017-10-26 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39053#906513, @spetrovic wrote:

> Well, basically I'm just expanding the existing algorithm, why should we 
> split fields just in case when current field is integer,
>  I'm not resolving specific problem with unaligned loads/stores on MIPS.
>
> In this example:
>
> typedef struct {
>
>   unsigned int f1 : 28;
>   unsigned int f2 : 4;
>   unsigned int f3 : 12;
>
> } S5;
>
> S5 *cmd;
>
> void foo() {
>
>   cmd->f3 = 5;
>
> }
>
> With this patch there is improvement in code size not just on MIPS 
> architecture, on X86 and ARM is also improved code size. If structure S5 is 
> treated as i48 type there are extra instructions for reading it not just on 
> MIPS. We can take results for MIPS just for example:
>
> Output without the patch:
>
>  :
>
>0: 3c01lui at,0x0
>4: 0039082ddaddu   at,at,t9
>8: 6421daddiu  at,at,0
>c: dc21ld  at,0(at)
>   10: dc21ld  at,0(at)
>   14: 6822ldl v0,0(at)
>   18: 6c220007ldr v0,7(at)
>   1c: 64030005daddiu  v1,zero,5
>   20: 7c62fd07dinsv0,v1,0x14,0xc
>   24: b022sdl v0,0(at)
>   28: 03e8jr  ra
>   2c: b4220007sdr v0,7(at)
>   
>   
>
> Output with the patch:
>
>  :
>
>0: 3c01lui at,0x0
>4: 0039082ddaddu   at,at,t9
>8: 6421daddiu  at,at,0
>c: dc21ld  at,0(at)
>   10: dc21ld  at,0(at)
>   14: 94220004lhu v0,4(at)
>   18: 24030005li  v1,5
>   1c: 7c62f904ins v0,v1,0x4,0x1c
>   20: 03e8jr  ra
>   24: a4220004sh  v0,4(at)
>   
>
> This is simple example, in more complicated examples there is more 
> improvement.


I think this is part of the slippery slope we didn't want to go down. We 
introduced this mode in the first place only to resolve a store-to-load 
forwarding problem that is theoretically unsolvable by any local lowering 
decisions. This, on the other hand, looks like a local code-generation problem 
that we can/should fix in the backend. If I'm wrong, we should consider this as 
well.


https://reviews.llvm.org/D39053



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


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

Is there a way to associate a particular diagtool variable to an exe_ctx?


https://reviews.llvm.org/D36347



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


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 120492.
hintonda added a comment.

- Remove debugging print statement, and enhance help message.


https://reviews.llvm.org/D36347

Files:
  utils/clangdiag.py

Index: utils/clangdiag.py
===
--- /dev/null
+++ utils/clangdiag.py
@@ -0,0 +1,161 @@
+#!/usr/bin/python
+
+#--
+# Be sure to add the python path that points to the LLDB shared library.
+#
+# # To use this in the embedded python interpreter using "lldb" just
+# import it with the full path using the "command script import"
+# command
+#   (lldb) command script import /path/to/clandiag.py
+#--
+
+import lldb
+import argparse
+import commands
+import shlex
+import os
+import subprocess
+
+class MyParser(argparse.ArgumentParser):
+def format_help(self):
+return ''' Commands for managing clang diagnostic breakpoints
+
+Syntax: clangdiag enable
+clangdiag disable
+clangdiag diagtool [|reset]
+
+The following subcommands are supported:
+
+  enable   -- Enable clang diagnostic breakpoints.
+  disable  -- Disable all clang diagnostic breakpoints.
+  diagtool -- Return, set, or reset diagtool path.
+
+This command sets breakpoints in clang, and clang based tools, that
+emit diagnostics.  When a diagnostic is emitted, and clangdiag is
+enabled, it will use the appropriate diagtool application to determine
+the name of the DiagID, and set breakpoints in all locations that
+'diag::name' appears in the source.  Since the new breakpoints are set
+after they are encountered, users will need to launch the executable a
+second time in order to hit the new breakpoints.
+
+For in-tree builds, the diagtool application, used to map DiagID's to
+names, is found automatically in the same directory as the target
+executable.  However, out-or-tree builds must use the 'diagtool'
+subcommand to set the appropriate path for diagtool in the clang debug
+bin directory.  Since this mapping is created at build-time, it's
+important for users to use the same version that was generated when
+clang was compiled, or else the id's won't match.
+
+Notes:
+
+- Rerunning enable clears existing breakpoints.
+- diagtool is used in breakpoint callbacks, so it can be changed
+  without the need to rerun enable.
+- Make it always available by adding this to your ~.lldbinit file:
+  "command script import /path/to/clangdiag.py"
+
+'''
+
+def create_diag_options():
+parser = MyParser(prog='clangdiag')
+subparsers = parser.add_subparsers(
+title='subcommands',
+dest='subcommands',
+metavar='')
+disable_parser = subparsers.add_parser('disable')
+enable_parser = subparsers.add_parser('enable')
+diagtool_parser = subparsers.add_parser('diagtool')
+diagtool_parser.add_argument('path', nargs='?')
+return parser
+
+def getDiagtool(target, diagtool = None):
+if 'diagtool' not in getDiagtool.__dict__:
+getDiagtool.diagtool = None
+if diagtool:
+if diagtool == 'reset':
+getDiagtool.diagtool = None
+elif os.path.exists(diagtool):
+getDiagtool.diagtool = diagtool
+else:
+print('clangdiag: %s not found.' % diagtool)
+if getDiagtool.diagtool is None:
+exe = target.GetExecutable()
+if not exe.Exists():
+print('clangdiag: Target (%s) not set.' % exe.GetFilename())
+else:
+diagtool = os.path.join(exe.GetDirectory(), 'diagtool')
+if os.path.exists(diagtool):
+getDiagtool.diagtool = diagtool
+else:
+print('clangdiag: diagtool not found along side %s' % exe)
+
+return getDiagtool.diagtool
+
+def setDiagBreakpoint(frame, bp_loc, dict):
+id = frame.FindVariable("DiagID").GetValue()
+if id is None:
+ print('clangdiag: id is None')
+ return False
+
+# Don't need to test this time, since we did that in enable.
+target = frame.GetThread().GetProcess().GetTarget()
+diagtool = getDiagtool(target)
+name = subprocess.check_output([diagtool, "find-diagnostic-id", id]).rstrip();
+bp = target.BreakpointCreateBySourceRegex(name, lldb.SBFileSpec())
+bp.AddName("clang::Diagnostic")
+
+return False
+
+def enable(exe_ctx, args):
+# Always disable existing breakpoints
+disable(exe_ctx)
+
+target = exe_ctx.GetTarget()
+# Just make sure we can find diagtool since it gets used in callbacks.
+diagtool = getDiagtool(target)
+bp = target.BreakpointCreateByName('DiagnosticsEngine::Report')
+bp.SetScriptCallbackFunction('clangdiag.setDiagBreakpoint')
+bp.AddName("clang::Diagnostic")
+
+return
+
+def disable(exe_ctx):
+target = exe_ctx.GetTarget()
+# Remove all diag breakpoints.
+bkpts = lldb.SBBreakpointList(target)
+

[PATCH] D39341: [X86][Driver] Move all of the X86 feature flags to one spot in the Options.td file and pair them up with their negations.

2017-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316705: [X86][Driver] Move all of the X86 feature flags to 
one spot in the Options.td… (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D39341?vs=120468=120490#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39341

Files:
  cfe/trunk/include/clang/Driver/Options.td

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1693,8 +1693,6 @@
 def m32 : Flag<["-"], "m32">, Group, Flags<[DriverOption, CoreOption]>;
 def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, Group, Flags<[DriverOption,CC1Option]>,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">;
-def m3dnowa : Flag<["-"], "m3dnowa">, Group;
-def m3dnow : Flag<["-"], "m3dnow">, Group;
 def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, CoreOption]>;
 def mx32 : Flag<["-"], "mx32">, Group, Flags<[DriverOption, CoreOption]>;
 def mabi_EQ : Joined<["-"], "mabi=">, Group;
@@ -1781,79 +1779,16 @@
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
   HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">;
 
-def mmmx : Flag<["-"], "mmmx">, Group;
-def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group;
-def mno_3dnow : Flag<["-"], "mno-3dnow">, Group;
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>,
   HelpText<"Disable merging of globals">;
-def mno_mmx : Flag<["-"], "mno-mmx">, Group;
 def mno_pascal_strings : Flag<["-"], "mno-pascal-strings">,
   Alias;
 def mno_red_zone : Flag<["-"], "mno-red-zone">, Group;
 def mno_relax_all : Flag<["-"], "mno-relax-all">, Group;
 def mno_rtd: Flag<["-"], "mno-rtd">, Group;
 def mno_soft_float : Flag<["-"], "mno-soft-float">, Group;
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
-def mno_x87 : Flag<["-"], "mno-x87">, Group;
-def mno_80387 : Flag<["-"], "mno-80387">, Alias;
-def mno_sse2 : Flag<["-"], "mno-sse2">, Group;
-def mno_sse3 : Flag<["-"], "mno-sse3">, Group;
-def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
-def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group;
-def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group;
-// -mno-sse4 turns off sse4.1 which has the effect of turning off everything
-// later than 4.1. -msse4 turns on 4.2 which has the effect of turning on
-// everything earlier than 4.2.
-def mno_sse4 : Flag<["-"], "mno-sse4">, Alias;
-def mno_sse : Flag<["-"], "mno-sse">, Group;
-def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group;
-def mno_aes : Flag<["-"], "mno-aes">, Group;
-def mno_avx : Flag<["-"], "mno-avx">, Group;
-def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
-def mno_avx512f : Flag<["-"], "mno-avx512f">, Group;
-def mno_avx512cd : Flag<["-"], "mno-avx512cd">, Group;
-def mno_avx512vpopcntdq : Flag<["-"], "mno-avx512vpopcntdq">, Group;
-def mno_avx512er : Flag<["-"], "mno-avx512er">, Group;
-def mno_avx512pf : Flag<["-"], "mno-avx512pf">, Group;
-def mno_avx512dq : Flag<["-"], "mno-avx512dq">, Group;
-def mno_avx512bw : Flag<["-"], "mno-avx512bw">, Group;
-def mno_avx512vl : Flag<["-"], "mno-avx512vl">, Group;
-def mno_avx512vbmi : Flag<["-"], "mno-avx512vbmi">, Group;
-def mno_avx512ifma : Flag<["-"], "mno-avx512ifma">, Group;
-def mno_pclmul : Flag<["-"], "mno-pclmul">, Group;
-def mno_lzcnt : Flag<["-"], "mno-lzcnt">, Group;
-def mno_rdrnd : Flag<["-"], "mno-rdrnd">, Group;
-def mno_fsgsbase : Flag<["-"], "mno-fsgsbase">, Group;
-def mno_bmi : Flag<["-"], "mno-bmi">, Group;
-def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group;
-def mno_popcnt : Flag<["-"], "mno-popcnt">, Group;
-def mno_tbm : Flag<["-"], "mno-tbm">, Group;
-def mno_lwp : Flag<["-"], "mno-lwp">, Group;
-def mno_fma4 : Flag<["-"], "mno-fma4">, Group;
-def mno_fma : Flag<["-"], "mno-fma">, Group;
-def mno_xop : Flag<["-"], "mno-xop">, Group;
-def mno_f16c : Flag<["-"], "mno-f16c">, Group;
-def mno_rtm : Flag<["-"], "mno-rtm">, Group;
-def mno_prfchw : Flag<["-"], "mno-prfchw">, Group;
-def mno_rdseed : Flag<["-"], "mno-rdseed">, Group;
-def mno_adx : Flag<["-"], "mno-adx">, Group;
-def mno_sha : Flag<["-"], "mno-sha">, Group;
-def mno_cx16 : Flag<["-"], "mno-cx16">, Group;
-def mno_fxsr : Flag<["-"], "mno-fxsr">, Group;
-def mno_xsave : Flag<["-"], "mno-xsave">, Group;
-def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">, Group;
-def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
-def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
-def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
-def mno_clzero : Flag<["-"], "mno-clzero">, Group;
-def mno_pku : Flag<["-"], "mno-pku">, Group;
-def mno_clflushopt : Flag<["-"], "mno-clflushopt">, Group;
-def mno_clwb : Flag<["-"], "mno-clwb">, Group;
-def mno_movbe : Flag<["-"], "mno-movbe">, Group;
-def mno_mpx : Flag<["-"], "mno-mpx">, 

r316705 - [X86][Driver] Move all of the X86 feature flags to one spot in the Options.td file and pair them up with their negations.

2017-10-26 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Oct 26 14:28:33 2017
New Revision: 316705

URL: http://llvm.org/viewvc/llvm-project?rev=316705=rev
Log:
[X86][Driver] Move all of the X86 feature flags to one spot in the Options.td 
file and pair them up with their negations.

It looks like at one time Options.td was in alphabetical order, but that looks 
to have long been broken. The result is that it all the no- x86 options got 
separated from their other friends for no good reason.

This patch puts them all together in one place with the no- paired with its 
none negated version.

I've kept all the SSE and AVX/AVX512 bits together since they represent a 
somewhat linear progression of features. The rest I just put in alphabetical 
order after.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=316705=316704=316705=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 26 14:28:33 2017
@@ -1693,8 +1693,6 @@ def m16 : Flag<["-"], "m16">, Group, Group, Flags<[DriverOption, 
CoreOption]>;
 def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, Group, 
Flags<[DriverOption,CC1Option]>,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">;
-def m3dnowa : Flag<["-"], "m3dnowa">, Group;
-def m3dnow : Flag<["-"], "m3dnow">, Group;
 def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, 
CoreOption]>;
 def mx32 : Flag<["-"], "mx32">, Group, Flags<[DriverOption, 
CoreOption]>;
 def mabi_EQ : Joined<["-"], "mabi=">, Group;
@@ -1781,13 +1779,9 @@ def mthread_model : Separate<["-"], "mth
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
   HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, 
Values<"default,4,5,gnu">;
 
-def mmmx : Flag<["-"], "mmmx">, Group;
-def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group;
-def mno_3dnow : Flag<["-"], "mno-3dnow">, Group;
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, 
Group;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, 
Flags<[CC1Option]>,
   HelpText<"Disable merging of globals">;
-def mno_mmx : Flag<["-"], "mno-mmx">, Group;
 def mno_pascal_strings : Flag<["-"], "mno-pascal-strings">,
   Alias;
 def mno_red_zone : Flag<["-"], "mno-red-zone">, Group;
@@ -1795,65 +1789,6 @@ def mno_relax_all : Flag<["-"], "mno-rel
 def mno_rtd: Flag<["-"], "mno-rtd">, Group;
 def mno_soft_float : Flag<["-"], "mno-soft-float">, Group;
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
-def mno_x87 : Flag<["-"], "mno-x87">, Group;
-def mno_80387 : Flag<["-"], "mno-80387">, Alias;
-def mno_sse2 : Flag<["-"], "mno-sse2">, Group;
-def mno_sse3 : Flag<["-"], "mno-sse3">, Group;
-def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
-def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group;
-def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group;
-// -mno-sse4 turns off sse4.1 which has the effect of turning off everything
-// later than 4.1. -msse4 turns on 4.2 which has the effect of turning on
-// everything earlier than 4.2.
-def mno_sse4 : Flag<["-"], "mno-sse4">, Alias;
-def mno_sse : Flag<["-"], "mno-sse">, Group;
-def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group;
-def mno_aes : Flag<["-"], "mno-aes">, Group;
-def mno_avx : Flag<["-"], "mno-avx">, Group;
-def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
-def mno_avx512f : Flag<["-"], "mno-avx512f">, Group;
-def mno_avx512cd : Flag<["-"], "mno-avx512cd">, Group;
-def mno_avx512vpopcntdq : Flag<["-"], "mno-avx512vpopcntdq">, 
Group;
-def mno_avx512er : Flag<["-"], "mno-avx512er">, Group;
-def mno_avx512pf : Flag<["-"], "mno-avx512pf">, Group;
-def mno_avx512dq : Flag<["-"], "mno-avx512dq">, Group;
-def mno_avx512bw : Flag<["-"], "mno-avx512bw">, Group;
-def mno_avx512vl : Flag<["-"], "mno-avx512vl">, Group;
-def mno_avx512vbmi : Flag<["-"], "mno-avx512vbmi">, 
Group;
-def mno_avx512ifma : Flag<["-"], "mno-avx512ifma">, 
Group;
-def mno_pclmul : Flag<["-"], "mno-pclmul">, Group;
-def mno_lzcnt : Flag<["-"], "mno-lzcnt">, Group;
-def mno_rdrnd : Flag<["-"], "mno-rdrnd">, Group;
-def mno_fsgsbase : Flag<["-"], "mno-fsgsbase">, Group;
-def mno_bmi : Flag<["-"], "mno-bmi">, Group;
-def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group;
-def mno_popcnt : Flag<["-"], "mno-popcnt">, Group;
-def mno_tbm : Flag<["-"], "mno-tbm">, Group;
-def mno_lwp : Flag<["-"], "mno-lwp">, Group;
-def mno_fma4 : Flag<["-"], "mno-fma4">, Group;
-def mno_fma : Flag<["-"], "mno-fma">, Group;
-def mno_xop : Flag<["-"], "mno-xop">, Group;
-def mno_f16c : Flag<["-"], "mno-f16c">, Group;
-def mno_rtm : Flag<["-"], "mno-rtm">, Group;
-def mno_prfchw : Flag<["-"], "mno-prfchw">, Group;
-def mno_rdseed : Flag<["-"], "mno-rdseed">, Group;
-def mno_adx : Flag<["-"], "mno-adx">, Group;
-def mno_sha : 

[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316704: [CGBlocks] Improve line info in backtraces 
containing *_helper_block (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D39310?vs=120461=120489#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39310

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/test/CodeGenObjC/debug-info-blocks.m


Index: cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
===
--- cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
+++ cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
@@ -10,23 +10,20 @@
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], 
metadata !{{.*}})
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata 
![[D:[0-9]+]], metadata !{{.*}})
 
-// rdar://problem/14386148
-// Test that we don't emit bogus line numbers for the helper functions.
-// Test that we do emit scope info for the helper functions.
+// Test that we do emit scope info for the helper functions, and that the
+// parameters to these functions are marked as artificial (so the debugger
+// doesn't accidentally step into the function).
 // CHECK: define {{.*}} @__copy_helper_block_{{.*}}(i8*, i8*)
 // CHECK-NOT: ret
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
+// CHECK: ret void, !dbg ![[COPY_LINE]]
 // CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*)
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
+// CHECK: ret void, !dbg ![[DESTROY_LINE]]
 
-// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
-// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: 
![[DESTROY_SP:[0-9]+]])
-// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_"
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -60,6 +57,14 @@
 - (id)init
 {
 if ((self = [super init])) {
+  // CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: 
![[COPY_SP:[0-9]+]])
+  // CHECK-DAG: [[COPY_LINE]] = !DILocation(line: [[@LINE+7]], scope: 
![[COPY_SP:[0-9]+]])
+  // CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: 
"__copy_helper_block_"
+  // CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: [[@LINE+5]], scope: 
![[DESTROY_SP:[0-9]+]])
+  // CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_"
+  // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
+  // CHECK-DAG: !DILocalVariable(arg: 2, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
+  // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[DESTROY_SP]], {{.*}}, 
flags: DIFlagArtificial)
   run(^{
   // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", 
scope:{{.*}}, line: [[@LINE+4]],
   // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, 
line: [[@LINE+1]],
Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp
===
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp
@@ -1644,10 +1644,8 @@
 
   CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
 
-  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  // Create a scope with an artificial location for the body of this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 
   Address src = GetAddrOfLocalVar();
@@ -1816,10 +1814,8 @@
 
   CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
 
-  // Create a scope with an artificial location for the body of this function.
-  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 


Index: cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
===
--- cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
+++ cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
@@ -10,23 +10,20 @@
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}})
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
 
-// rdar://problem/14386148
-// Test that we don't 

r316704 - [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Oct 26 14:27:24 2017
New Revision: 316704

URL: http://llvm.org/viewvc/llvm-project?rev=316704=rev
Log:
[CGBlocks] Improve line info in backtraces containing *_helper_block

Instead of only setting a non-zero debug location on the return
instruction in *_helper_block functions, set a proper location on all
instructions within these functions. Pick the start location of the
block literal expr for maximum clarity.

The debugger does not step into *_helper_block functions during normal
single-stepping because we mark their parameters as artificial. This is
what we want (the functions are implicitly generated and uninteresting
to most users). The stepping behavior is unchanged by this patch.

rdar://32907581

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjC/debug-info-blocks.m

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=316704=316703=316704=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct 26 14:27:24 2017
@@ -1644,10 +1644,8 @@ CodeGenFunction::GenerateCopyHelperFunct
 
   CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
 
-  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  // Create a scope with an artificial location for the body of this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 
   Address src = GetAddrOfLocalVar();
@@ -1816,10 +1814,8 @@ CodeGenFunction::GenerateDestroyHelperFu
 
   CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
 
-  // Create a scope with an artificial location for the body of this function.
-  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 

Modified: cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-blocks.m?rev=316704=316703=316704=diff
==
--- cfe/trunk/test/CodeGenObjC/debug-info-blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/debug-info-blocks.m Thu Oct 26 14:27:24 2017
@@ -10,23 +10,20 @@
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], 
metadata !{{.*}})
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata 
![[D:[0-9]+]], metadata !{{.*}})
 
-// rdar://problem/14386148
-// Test that we don't emit bogus line numbers for the helper functions.
-// Test that we do emit scope info for the helper functions.
+// Test that we do emit scope info for the helper functions, and that the
+// parameters to these functions are marked as artificial (so the debugger
+// doesn't accidentally step into the function).
 // CHECK: define {{.*}} @__copy_helper_block_{{.*}}(i8*, i8*)
 // CHECK-NOT: ret
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
+// CHECK: ret void, !dbg ![[COPY_LINE]]
 // CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*)
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
+// CHECK: ret void, !dbg ![[DESTROY_LINE]]
 
-// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
-// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: 
![[DESTROY_SP:[0-9]+]])
-// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_"
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -60,6 +57,14 @@ static void run(void (^block)(void))
 - (id)init
 {
 if ((self = [super init])) {
+  // CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: 
![[COPY_SP:[0-9]+]])
+  // CHECK-DAG: [[COPY_LINE]] = !DILocation(line: [[@LINE+7]], scope: 
![[COPY_SP:[0-9]+]])
+  // CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: 
"__copy_helper_block_"
+  // CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: [[@LINE+5]], scope: 
![[DESTROY_SP:[0-9]+]])
+  // CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_"
+  // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
+  // CHECK-DAG: !DILocalVariable(arg: 2, scope: ![[COPY_SP]], {{.*}}, 

[PATCH] D38639: [clangd] #include statements support for Open definition

2017-10-26 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 120485.
Nebiroth added a comment.

- Fixed adding incorrect test file.


https://reviews.llvm.org/D38639

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/Protocol.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Logger.h"
 #include "clang/Basic/VirtualFileSystem.h"
@@ -1056,7 +1055,7 @@
 AddDocument(FileIndex);
 
   Position Pos{LineDist(RandGen), ColumnDist(RandGen)};
-  ASSERT_TRUE(!!Server.findDefinitions(FilePaths[FileIndex], Pos));
+  Server.findDefinitions(FilePaths[FileIndex], Pos);
 };
 
 std::vector> AsyncRequests = {
@@ -1185,6 +1184,57 @@
   EXPECT_FALSE(PathResult.hasValue());
 }
 
+TEST_F(ClangdVFSTest, CheckDefinitionIncludes) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+
+  ClangdServer Server(CDB, DiagConsumer, FS, 0, clangd::CodeCompleteOptions(),
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents = R"cpp(
+  #include "foo.h"
+  #include "invalid.h"
+  int b = a;
+  )cpp";
+  FS.Files[FooCpp] = SourceContents;
+  auto FooH = getVirtualTestFilePath("foo.h");
+  const auto HeaderContents = "int a;";
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = HeaderContents;
+
+  Server.addDocument(FooH, HeaderContents);
+  Server.addDocument(FooCpp, SourceContents);
+
+  Position P = Position{1, 11};
+
+  std::vector Locations = Server.findDefinitions(FooCpp, P).get().Value;
+  EXPECT_TRUE(!Locations.empty());
+  std::string s("file:///");
+  std::string check = URI::unparse(Locations[0].uri);
+  check = check.erase(0, s.size());
+  check = check.substr(0, check.size() - 1);
+  ASSERT_EQ(check, FooH);
+  ASSERT_EQ(Locations[0].range.start.line, 0);
+  ASSERT_EQ(Locations[0].range.start.character, 0);
+  ASSERT_EQ(Locations[0].range.end.line, 0);
+  ASSERT_EQ(Locations[0].range.end.character, 0);
+
+  // Test ctrl-clicking on the #include part on the statement
+  Position P3 = Position{1, 3};
+
+  Locations = Server.findDefinitions(FooCpp, P3).get().Value;
+  EXPECT_TRUE(!Locations.empty());
+
+  // Test invalid include
+  Position P2 = Position{2, 11};
+
+  Locations = Server.findDefinitions(FooCpp, P2).get().Value;
+  EXPECT_TRUE(Locations.empty());
+}
+
 TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
   class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
   public:
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -96,12 +96,21 @@
   friend bool operator<(const Range , const Range ) {
 return std::tie(LHS.start, LHS.end) < std::tie(RHS.start, RHS.end);
   }
-
   static llvm::Optional parse(llvm::yaml::MappingNode *Params,
  clangd::Logger );
   static std::string unparse(const Range );
+
+};
+
+class RangeHash {
+public:
+  std::size_t operator()(const Range ) const
+  {
+return ((R.start.line & 0x18) << 3) | ((R.start.character & 0x18) << 1) | ((R.end.line & 0x18) >> 1) | ((R.end.character & 0x18) >> 3);
+  }
 };
 
+
 struct Location {
   /// The text document's URI.
   URI uri;
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -9,6 +9,7 @@
 
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
+#include "ProtocolHandlers.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -30,6 +31,8 @@
   Command.CommandLine.insert(It, ExtraFlags.begin(), ExtraFlags.end());
 }
 
+
+
 tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
   std::vector CommandLine{"clang", "-fsyntax-only", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
Index: clangd/ClangdUnit.h
===
--- clangd/ClangdUnit.h
+++ clangd/ClangdUnit.h
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace llvm {
 class raw_ostream;
@@ -128,11 +129,17 @@
 struct PreambleData {
   PreambleData(PrecompiledPreamble Preamble,
std::vector TopLevelDeclIDs,
-   std::vector Diags);
+   std::vector Diags,
+   std::unordered_map IncludeMap,
+   std::vector> 

[PATCH] D38639: [clangd] #include statements support for Open definition

2017-10-26 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 120482.
Nebiroth added a comment.

- Now overriding InclusionDirective as a callback to get proper includes 
information.
- Fixed tests.


https://reviews.llvm.org/D38639

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/Protocol.h
  test/clangd/documenthighlight.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Logger.h"
 #include "clang/Basic/VirtualFileSystem.h"
@@ -1056,7 +1055,7 @@
 AddDocument(FileIndex);
 
   Position Pos{LineDist(RandGen), ColumnDist(RandGen)};
-  ASSERT_TRUE(!!Server.findDefinitions(FilePaths[FileIndex], Pos));
+  Server.findDefinitions(FilePaths[FileIndex], Pos);
 };
 
 std::vector> AsyncRequests = {
@@ -1185,6 +1184,57 @@
   EXPECT_FALSE(PathResult.hasValue());
 }
 
+TEST_F(ClangdVFSTest, CheckDefinitionIncludes) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+
+  ClangdServer Server(CDB, DiagConsumer, FS, 0, clangd::CodeCompleteOptions(),
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents = R"cpp(
+  #include "foo.h"
+  #include "invalid.h"
+  int b = a;
+  )cpp";
+  FS.Files[FooCpp] = SourceContents;
+  auto FooH = getVirtualTestFilePath("foo.h");
+  const auto HeaderContents = "int a;";
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = HeaderContents;
+
+  Server.addDocument(FooH, HeaderContents);
+  Server.addDocument(FooCpp, SourceContents);
+
+  Position P = Position{1, 11};
+
+  std::vector Locations = Server.findDefinitions(FooCpp, P).get().Value;
+  EXPECT_TRUE(!Locations.empty());
+  std::string s("file:///");
+  std::string check = URI::unparse(Locations[0].uri);
+  check = check.erase(0, s.size());
+  check = check.substr(0, check.size() - 1);
+  ASSERT_EQ(check, FooH);
+  ASSERT_EQ(Locations[0].range.start.line, 0);
+  ASSERT_EQ(Locations[0].range.start.character, 0);
+  ASSERT_EQ(Locations[0].range.end.line, 0);
+  ASSERT_EQ(Locations[0].range.end.character, 0);
+
+  // Test ctrl-clicking on the #include part on the statement
+  Position P3 = Position{1, 3};
+
+  Locations = Server.findDefinitions(FooCpp, P3).get().Value;
+  EXPECT_TRUE(!Locations.empty());
+
+  // Test invalid include
+  Position P2 = Position{2, 11};
+
+  Locations = Server.findDefinitions(FooCpp, P2).get().Value;
+  EXPECT_TRUE(Locations.empty());
+}
+
 TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
   class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
   public:
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+# CHECK: Content-Length: 580
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:   "textDocumentSync": 1,
+# CHECK:   "documentFormattingProvider": true,
+# CHECK:   "documentRangeFormattingProvider": true,
+# CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
+# CHECK:   "codeActionProvider": true,
+# CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
+# CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
+# CHECK: }}}
+#
+
+Content-Length: 455
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 16, "character": 4}, "end": {"line": 16, "character": 12}}, "kind": 1},{"range": {"start": {"line": 17, 

[PATCH] D38824: [X86] Synchronize the existing CPU predefined macros with the cases that gcc defines them

2017-10-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

So, doing research to understand the impact of this has convinced me we 
*really* need to stop doing this. Multiple libraries are actually trying to 
enumerate every CPU that has feature X for some feature X. =[[[ This, combined 
with the fundamental pattern of defining a precise macro for the CPU, leaves a 
time bomb where anyone that passes a new CPU to `-march` using some older 
headers will incorrectly believe features aren't available on *newer* CPUs. =[

Specific examples:
https://github.com/hwoarang/glibc/blob/master/sysdeps/x86/cpu-features.h#L263
https://github.com/boostorg/atomic/blob/boost-1.65.1/include/boost/atomic/detail/caps_gcc_x86.hpp#L30

I think my conclusion is that the best way forward is to officially stop 
defining CPU-specific macros, but to also continue defining __corei7__ macros 
on all CPUs newer than that for all time so that old headers using these macros 
for "feature detection" actually work.

Thoughts?




Comment at: lib/Basic/Targets/X86.cpp:835
 defineCPUMacros(Builder, "slm");
+// gcc also defineds 'silvermont', but we never have. See comment below.
 break;

RKSimon wrote:
> defines
Nit picking detail: I would also capitalize GCC here and elsewhere.


https://reviews.llvm.org/D38824



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


[PATCH] D39308: [libcxx] Keep track of heap allocated regex states

2017-10-26 Thread Tim Shen via Phabricator via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D39308#907424, @mclow.lists wrote:

> A couple of notes.


Sorry for the oversights, when a C++11(-only :) contributor doesn't care about 
ABI stability, nor exceptions, he contributes naive code. :P I'll fix them.

> - This change means that  now requires C++11 (the new `__push` 
> function w/ the varargs).  I don't know how important that is; but I'm pretty 
> sure libc++ currently provides `` in C++03 mode.
> - This is an ABI change; existing code that was compiled with the "old" 
> `` implementation will not interoperate with this.

Can you give an example on what would go wrong, while it's not expected to go 
wrong?

> - I think that there may be some exception-safety issues in `__push`; if the 
> `push_back` throws, I think we leak.


https://reviews.llvm.org/D39308



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


[PATCH] D39342: [Bash-autocompletion] Pass all flags in shell command-line to Clang

2017-10-26 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi created this revision.

Previously, we passed "#" to --autocomplete to indicate to enable cc1
flags. For example, when -cc1 or -Xclang was passed to bash, bash
executed `clang --autocomplete=#-`.

However, this was not a good implementation because it depends -Xclang
and -cc1 parsing to shell. So I changed this to pass all flags shell
has, so that Clang can handle them internally.

I'll leave exsisting testcase as it is inorder to test backward
compatibility.


https://reviews.llvm.org/D39342

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/autocomplete.c
  clang/utils/bash-autocomplete.sh

Index: clang/utils/bash-autocomplete.sh
===
--- clang/utils/bash-autocomplete.sh
+++ clang/utils/bash-autocomplete.sh
@@ -25,11 +25,11 @@
 w2="${COMP_WORDS[$cword - 2]}"
   fi
 
-  # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show
-  # cc1 options otherwise.
-  if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
-arg="#"
-  fi
+  # Pass all the current command-line flags to clang, so that clang can handle
+  # these internally.
+  for i in `seq 1 $(($cword-1))`; do
+arg="$arg${COMP_WORDS[$i]}:"
+  done
 
   # bash always separates '=' as a token even if there's no space before/after '='.
   # On the other hand, '=' is just a regular character for clang options that
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -4,7 +4,6 @@
 
 // Some corner cases.
 // RUN: %clang --autocomplete= | FileCheck %s -check-prefix=ALL_FLAGS
-// RUN: %clang --autocomplete=# | FileCheck %s -check-prefix=ALL_FLAGS
 // Let's pick some example flags that are hopefully unlikely to change.
 // ALL_FLAGS: -fast
 // ALL_FLAGS: -fastcp
@@ -93,10 +92,6 @@
 // MRELOCMODELALL-NEXT: ropi-rwpi
 // MRELOCMODELALL-NEXT: rwpi
 // MRELOCMODELALL-NEXT: static
-// RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG
-// MRELOCMODEL_CLANG-NOT: -mrelocation-model
-// RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
-// MRELOCMODEL_CC1: -mrelocation-model
 // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
 // WARNING: -Wmacro-redefined
 // WARNING-NEXT: -Wmain
@@ -110,3 +105,16 @@
 // ANALYZER: unix.Malloc
 // RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL
 // STDVAL: c99
+//
+// Clang shouldn't autocomplete CC1 options unless -cc1 or -Xclang were provided
+// RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG
+// MRELOCMODEL_CLANG-NOT: -mrelocation-model
+// RUN: %clang --autocomplete=-Xclang:-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
+// RUN: %clang --autocomplete=-cc1:-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
+// MRELOCMODEL_CC1: -mrelocation-model
+// Make sure it ignores passed flags unlesss they are -Xclang or -cc1
+// RUN: %clang --autocomplete=foo:bar::-fsyn | FileCheck %s -check-prefix=FSYN-CORON
+// FSYN-CORON: -fsyntax-only
+// Check if they can autocomplete values with coron
+// RUN: %clang --autocomplete=foo::bar-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER-CORON
+// FNOSANICOVER-CORON: func
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1164,34 +1164,38 @@
 
   unsigned short DisableFlags =
   options::NoDriverOption | options::Unsupported | options::Ignored;
-  // We want to show cc1-only options only when clang is invoked as "clang
-  // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning
-  // of an --autocomplete  option so that the clang driver can distinguish
-  // whether it is requested to show cc1-only options or not.
-  if (PassedFlags.size() > 0 && PassedFlags[0] == '#') {
-DisableFlags &= ~options::NoDriverOption;
-PassedFlags = PassedFlags.substr(1);
+
+  // Parse PassedFlags by ":" as all the command-line flags are passed to this
+  // function separated by ":"
+  StringRef TargetFlag = PassedFlags;
+  for (; TargetFlag.find(':') != StringRef::npos;) {
+StringRef CurFlag;
+std::tie(CurFlag, TargetFlag) = TargetFlag.split(":");
+// We want to show cc1-only options only when clang is invoked with -cc1 or
+// -Xclang.
+if (CurFlag == "-Xclang" || CurFlag == "-cc1")
+  DisableFlags &= ~options::NoDriverOption;
   }
 
-  if (PassedFlags.find(',') == StringRef::npos) {
+  if (TargetFlag.find(',') == StringRef::npos) {
 // If the flag is in the form of "--autocomplete=-foo",
 // we were requested to print out all option names that start with "-foo".
 // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
-

r316695 - Fix C++ testcase I forgot to add to r316689.

2017-10-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Oct 26 13:16:03 2017
New Revision: 316695

URL: http://llvm.org/viewvc/llvm-project?rev=316695=rev
Log:
Fix C++ testcase I forgot to add to r316689.

Modified:
cfe/trunk/test/CodeGenCXX/blocks.cpp

Modified: cfe/trunk/test/CodeGenCXX/blocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/blocks.cpp?rev=316695=316694=316695=diff
==
--- cfe/trunk/test/CodeGenCXX/blocks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/blocks.cpp Thu Oct 26 13:16:03 2017
@@ -122,7 +122,6 @@ namespace test4 {
   // CHECK-LABEL: define internal void @___ZN5test44testEv_block_invoke
   // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1
   // CHECK-NEXT: store i8* [[BLOCKDESC:%.*]], i8** {{.*}}, align 8
-  // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* [[BLOCKDESC]] to <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor* }>*
   // CHECK:  call void @_ZN5test41AC1Ev([[A]]* [[TMP]])
   // CHECK-NEXT: call void @_ZN5test43fooENS_1AE([[A]]* [[TMP]])


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


[PATCH] D39049: [analyzer] Fix wrong calculation of offset in ArrayBoundsV2

2017-10-26 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

> Do you mind writing some tests with multidimensional arrays to check what do 
> we lose if we remove that code?

I have spent a few hours trying to write a test case that shows there is false 
negatives caused by this change. And fail.

I see lots of false negatives for multidimensional arrays with or without this 
code.

For instance:

  void f(int x) {
int buf[2][3];
if (x < 4 || x>10)
  return;
buf[1][x] = 0;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D39049



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


[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: test/CodeGenObjC/debug-info-blocks.m:20
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]

vsk wrote:
> aprantl wrote:
> > aprantl wrote:
> > > vsk wrote:
> > > > aprantl wrote:
> > > > > What's the location used for the ret? I think it should also be` 
> > > > > ![[DBG_LINE]]` since we are not actually executing the block.
> > > > We're using COPY_LINE, which is the same location used for the load 
> > > > instruction below.
> > > > 
> > > > What's the semantic difference between DBG_LINE (line 0) and COPY_LINE 
> > > > (line 68) anyway? Why do we have two different locations for the 
> > > > arguments to this function?
> > > The debugger will skip over line 0 locations when single-stepping or when 
> > > setting breakpoints. I can't tell without reading the code why we decide 
> > > to put a line 0 on the call.
> > The important thing is that the testcase should check that the ret has 
> > either COPY_LINE or line 0 on it and not line 71.
> I'll fix up the test case.
> 
> It looks like the zero location is an artifact of 
> CodeGenFunction::StartFunction:
> ```
> 1128   // Emit a location at the end of the prologue. 
>   
>  
> 1129   if (CGDebugInfo *DI = getDebugInfo())  
>   
>  
> 1130 DI->EmitLocation(Builder, StartLoc);
> ```
> 
> I think it's unnecessary, but maybe we can look into that separately?
... and StartLoc is empty for this function? (which would make sense)
I think I'm fine with leaving this as is unless you feel strongly about it.


https://reviews.llvm.org/D39310



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


[PATCH] D39008: [CodeGen] Propagate may-alias'ness of lvalues with TBAA info

2017-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sure, that makes sense to me.

John.


Repository:
  rL LLVM

https://reviews.llvm.org/D39008



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


[PATCH] D39177: [CodeGen] Generate TBAA info for reference loads

2017-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D39177



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


r316689 - Simplify codegen and debug info generation for block context parameters.

2017-10-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Oct 26 13:08:52 2017
New Revision: 316689

URL: http://llvm.org/viewvc/llvm-project?rev=316689=rev
Log:
Simplify codegen and debug info generation for block context parameters.

The exisiting code goes out of its way to put block parameters into an
alloca only at -O0, and then describes the funciton argument with a
dbg.declare, which is undocumented in the LLVM-CFE contract and does
not actually behave as intended after LLVM r642022.

This patch just generates the alloca unconditionally, the mem2reg pass
will eliminate it at -O1 and up anyway and points the dbg.declare to
the alloca as intended (which mem2reg will then correctly rewrite into
a dbg.value).

This reapplies r316684 with some dead code removed.

rdar://problem/35043980

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

Added:
cfe/trunk/test/CodeGen/debug-info-block-vars.c
Removed:
cfe/trunk/test/CodeGenObjC/debug-info-block-captured-self.m
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=316689=316688=316689=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct 26 13:08:52 2017
@@ -1293,20 +1293,17 @@ void CodeGenFunction::setBlockContextPar
llvm::Value *arg) {
   assert(BlockInfo && "not emitting prologue of block invocation function?!");
 
-  llvm::Value *localAddr = nullptr;
-  if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
-// Allocate a stack slot to let the debug info survive the RA.
-Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
-Builder.CreateStore(arg, alloc);
-localAddr = Builder.CreateLoad(alloc);
-  }
-
+  // Allocate a stack slot like for any local variable to guarantee optimal
+  // debug info at -O0. The mem2reg pass will eliminate it when optimizing.
+  Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
+  Builder.CreateStore(arg, alloc);
   if (CGDebugInfo *DI = getDebugInfo()) {
 if (CGM.getCodeGenOpts().getDebugInfo() >=
 codegenoptions::LimitedDebugInfo) {
   DI->setLocation(D->getLocation());
-  DI->EmitDeclareOfBlockLiteralArgVariable(*BlockInfo, arg, argNum,
-   localAddr, Builder);
+  DI->EmitDeclareOfBlockLiteralArgVariable(
+  *BlockInfo, D->getName(), argNum,
+  cast(alloc.getPointer()), Builder);
 }
   }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=316689=316688=316689=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 26 13:08:52 2017
@@ -3694,9 +3694,9 @@ bool operator<(const BlockLayoutChunk 
 }
 
 void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo 
,
-   llvm::Value *Arg,
+   StringRef Name,
unsigned ArgNo,
-   llvm::Value *LocalAddr,
+   llvm::AllocaInst 
*Alloca,
CGBuilderTy ) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   ASTContext  = CGM.getContext();
@@ -3828,19 +3828,11 @@ void CGDebugInfo::EmitDeclareOfBlockLite
 
   // Create the descriptor for the parameter.
   auto *debugVar = DBuilder.createParameterVariable(
-  scope, Arg->getName(), ArgNo, tunit, line, type,
+  scope, Name, ArgNo, tunit, line, type,
   CGM.getLangOpts().Optimize, flags);
 
-  if (LocalAddr) {
-// Insert an llvm.dbg.value into the current block.
-DBuilder.insertDbgValueIntrinsic(
-LocalAddr, debugVar, DBuilder.createExpression(),
-llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
-Builder.GetInsertBlock());
-  }
-
   // Insert an llvm.dbg.declare into the current block.
-  DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(),
+  DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
  llvm::DebugLoc::get(line, column, scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=316689=316688=316689=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ 

[PATCH] D39341: [X86][Driver] Move all of the X86 feature flags to one spot in the Options.td file and pair them up with their negations.

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

LGTM. Thanks.


https://reviews.llvm.org/D39341



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


[PATCH] D38774: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

2017-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D38774



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


[PATCH] D38824: [X86] Synchronize the existing CPU predefined macros with the cases that gcc defines them

2017-10-26 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 120469.
craig.topper added a comment.

Fix Simon's comment


https://reviews.llvm.org/D38824

Files:
  lib/Basic/Targets/X86.cpp
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -427,11 +427,8 @@
 // CHECK_COREI7_AVX_M32: #define __SSSE3__ 1
 // CHECK_COREI7_AVX_M32: #define __XSAVEOPT__ 1
 // CHECK_COREI7_AVX_M32: #define __XSAVE__ 1
-// CHECK_COREI7_AVX_M32: #define __corei7 1
-// CHECK_COREI7_AVX_M32: #define __corei7__ 1
 // CHECK_COREI7_AVX_M32: #define __i386 1
 // CHECK_COREI7_AVX_M32: #define __i386__ 1
-// CHECK_COREI7_AVX_M32: #define __tune_corei7__ 1
 // CHECK_COREI7_AVX_M32: #define i386 1
 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -454,9 +451,6 @@
 // CHECK_COREI7_AVX_M64: #define __XSAVE__ 1
 // CHECK_COREI7_AVX_M64: #define __amd64 1
 // CHECK_COREI7_AVX_M64: #define __amd64__ 1
-// CHECK_COREI7_AVX_M64: #define __corei7 1
-// CHECK_COREI7_AVX_M64: #define __corei7__ 1
-// CHECK_COREI7_AVX_M64: #define __tune_corei7__ 1
 // CHECK_COREI7_AVX_M64: #define __x86_64 1
 // CHECK_COREI7_AVX_M64: #define __x86_64__ 1
 //
@@ -477,11 +471,8 @@
 // CHECK_CORE_AVX_I_M32: #define __SSSE3__ 1
 // CHECK_CORE_AVX_I_M32: #define __XSAVEOPT__ 1
 // CHECK_CORE_AVX_I_M32: #define __XSAVE__ 1
-// CHECK_CORE_AVX_I_M32: #define __corei7 1
-// CHECK_CORE_AVX_I_M32: #define __corei7__ 1
 // CHECK_CORE_AVX_I_M32: #define __i386 1
 // CHECK_CORE_AVX_I_M32: #define __i386__ 1
-// CHECK_CORE_AVX_I_M32: #define __tune_corei7__ 1
 // CHECK_CORE_AVX_I_M32: #define i386 1
 // RUN: %clang -march=core-avx-i -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -504,9 +495,6 @@
 // CHECK_CORE_AVX_I_M64: #define __XSAVE__ 1
 // CHECK_CORE_AVX_I_M64: #define __amd64 1
 // CHECK_CORE_AVX_I_M64: #define __amd64__ 1
-// CHECK_CORE_AVX_I_M64: #define __corei7 1
-// CHECK_CORE_AVX_I_M64: #define __corei7__ 1
-// CHECK_CORE_AVX_I_M64: #define __tune_corei7__ 1
 // CHECK_CORE_AVX_I_M64: #define __x86_64 1
 // CHECK_CORE_AVX_I_M64: #define __x86_64__ 1
 //
@@ -533,11 +521,8 @@
 // CHECK_CORE_AVX2_M32: #define __SSSE3__ 1
 // CHECK_CORE_AVX2_M32: #define __XSAVEOPT__ 1
 // CHECK_CORE_AVX2_M32: #define __XSAVE__ 1
-// CHECK_CORE_AVX2_M32: #define __corei7 1
-// CHECK_CORE_AVX2_M32: #define __corei7__ 1
 // CHECK_CORE_AVX2_M32: #define __i386 1
 // CHECK_CORE_AVX2_M32: #define __i386__ 1
-// CHECK_CORE_AVX2_M32: #define __tune_corei7__ 1
 // CHECK_CORE_AVX2_M32: #define i386 1
 // RUN: %clang -march=core-avx2 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -566,9 +551,6 @@
 // CHECK_CORE_AVX2_M64: #define __XSAVE__ 1
 // CHECK_CORE_AVX2_M64: #define __amd64 1
 // CHECK_CORE_AVX2_M64: #define __amd64__ 1
-// CHECK_CORE_AVX2_M64: #define __corei7 1
-// CHECK_CORE_AVX2_M64: #define __corei7__ 1
-// CHECK_CORE_AVX2_M64: #define __tune_corei7__ 1
 // CHECK_CORE_AVX2_M64: #define __x86_64 1
 // CHECK_CORE_AVX2_M64: #define __x86_64__ 1
 //
@@ -597,11 +579,8 @@
 // CHECK_BROADWELL_M32: #define __SSSE3__ 1
 // CHECK_BROADWELL_M32: #define __XSAVEOPT__ 1
 // CHECK_BROADWELL_M32: #define __XSAVE__ 1
-// CHECK_BROADWELL_M32: #define __corei7 1
-// CHECK_BROADWELL_M32: #define __corei7__ 1
 // CHECK_BROADWELL_M32: #define __i386 1
 // CHECK_BROADWELL_M32: #define __i386__ 1
-// CHECK_BROADWELL_M32: #define __tune_corei7__ 1
 // CHECK_BROADWELL_M32: #define i386 1
 // RUN: %clang -march=broadwell -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -632,9 +611,6 @@
 // CHECK_BROADWELL_M64: #define __XSAVE__ 1
 // CHECK_BROADWELL_M64: #define __amd64 1
 // CHECK_BROADWELL_M64: #define __amd64__ 1
-// CHECK_BROADWELL_M64: #define __corei7 1
-// CHECK_BROADWELL_M64: #define __corei7__ 1
-// CHECK_BROADWELL_M64: #define __tune_corei7__ 1
 // CHECK_BROADWELL_M64: #define __x86_64 1
 // CHECK_BROADWELL_M64: #define __x86_64__ 1
 //
@@ -892,9 +868,6 @@
 // CHECK_SKX_M32: #define __XSAVE__ 1
 // CHECK_SKX_M32: #define __i386 1
 // CHECK_SKX_M32: #define __i386__ 1
-// CHECK_SKX_M32: #define __skx 1
-// CHECK_SKX_M32: #define __skx__ 1
-// CHECK_SKX_M32: #define __tune_skx__ 1
 // CHECK_SKX_M32: #define i386 1
 
 // RUN: %clang -march=skylake-avx512 -m64 -E -dM %s -o - 2>&1 \
@@ -936,9 +909,6 @@
 // CHECK_SKX_M64: #define __XSAVE__ 1
 // CHECK_SKX_M64: #define __amd64 1
 // CHECK_SKX_M64: #define __amd64__ 1
-// CHECK_SKX_M64: #define __skx 1
-// CHECK_SKX_M64: #define __skx__ 1
-// CHECK_SKX_M64: #define __tune_skx__ 1
 // CHECK_SKX_M64: #define __x86_64 1
 // CHECK_SKX_M64: #define __x86_64__ 1
 //
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -830,35 +830,35 @@
 

[PATCH] D39341: [X86][Driver] Move all of the X86 feature flags to one spot in the Options.td file and pair them up with their negations.

2017-10-26 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.

It looks like at one time Options.td was in alphabetical order, but that looks 
to have long been broken. The result is that it all the no- x86 options got 
separated from their other friends for no good reason.

This patch puts them all together in one place with the no- paired with its 
none negated version.

I've kept all the SSE and AVX/AVX512 bits together since they represent a 
somewhat linear progression of features. The rest I just put in alphabetical 
order after.


https://reviews.llvm.org/D39341

Files:
  include/clang/Driver/Options.td

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1693,8 +1693,6 @@
 def m32 : Flag<["-"], "m32">, Group, Flags<[DriverOption, CoreOption]>;
 def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, Group, Flags<[DriverOption,CC1Option]>,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">;
-def m3dnowa : Flag<["-"], "m3dnowa">, Group;
-def m3dnow : Flag<["-"], "m3dnow">, Group;
 def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, CoreOption]>;
 def mx32 : Flag<["-"], "mx32">, Group, Flags<[DriverOption, CoreOption]>;
 def mabi_EQ : Joined<["-"], "mabi=">, Group;
@@ -1781,79 +1779,16 @@
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
   HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">;
 
-def mmmx : Flag<["-"], "mmmx">, Group;
-def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group;
-def mno_3dnow : Flag<["-"], "mno-3dnow">, Group;
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>,
   HelpText<"Disable merging of globals">;
-def mno_mmx : Flag<["-"], "mno-mmx">, Group;
 def mno_pascal_strings : Flag<["-"], "mno-pascal-strings">,
   Alias;
 def mno_red_zone : Flag<["-"], "mno-red-zone">, Group;
 def mno_relax_all : Flag<["-"], "mno-relax-all">, Group;
 def mno_rtd: Flag<["-"], "mno-rtd">, Group;
 def mno_soft_float : Flag<["-"], "mno-soft-float">, Group;
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
-def mno_x87 : Flag<["-"], "mno-x87">, Group;
-def mno_80387 : Flag<["-"], "mno-80387">, Alias;
-def mno_sse2 : Flag<["-"], "mno-sse2">, Group;
-def mno_sse3 : Flag<["-"], "mno-sse3">, Group;
-def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
-def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group;
-def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group;
-// -mno-sse4 turns off sse4.1 which has the effect of turning off everything
-// later than 4.1. -msse4 turns on 4.2 which has the effect of turning on
-// everything earlier than 4.2.
-def mno_sse4 : Flag<["-"], "mno-sse4">, Alias;
-def mno_sse : Flag<["-"], "mno-sse">, Group;
-def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group;
-def mno_aes : Flag<["-"], "mno-aes">, Group;
-def mno_avx : Flag<["-"], "mno-avx">, Group;
-def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
-def mno_avx512f : Flag<["-"], "mno-avx512f">, Group;
-def mno_avx512cd : Flag<["-"], "mno-avx512cd">, Group;
-def mno_avx512vpopcntdq : Flag<["-"], "mno-avx512vpopcntdq">, Group;
-def mno_avx512er : Flag<["-"], "mno-avx512er">, Group;
-def mno_avx512pf : Flag<["-"], "mno-avx512pf">, Group;
-def mno_avx512dq : Flag<["-"], "mno-avx512dq">, Group;
-def mno_avx512bw : Flag<["-"], "mno-avx512bw">, Group;
-def mno_avx512vl : Flag<["-"], "mno-avx512vl">, Group;
-def mno_avx512vbmi : Flag<["-"], "mno-avx512vbmi">, Group;
-def mno_avx512ifma : Flag<["-"], "mno-avx512ifma">, Group;
-def mno_pclmul : Flag<["-"], "mno-pclmul">, Group;
-def mno_lzcnt : Flag<["-"], "mno-lzcnt">, Group;
-def mno_rdrnd : Flag<["-"], "mno-rdrnd">, Group;
-def mno_fsgsbase : Flag<["-"], "mno-fsgsbase">, Group;
-def mno_bmi : Flag<["-"], "mno-bmi">, Group;
-def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group;
-def mno_popcnt : Flag<["-"], "mno-popcnt">, Group;
-def mno_tbm : Flag<["-"], "mno-tbm">, Group;
-def mno_lwp : Flag<["-"], "mno-lwp">, Group;
-def mno_fma4 : Flag<["-"], "mno-fma4">, Group;
-def mno_fma : Flag<["-"], "mno-fma">, Group;
-def mno_xop : Flag<["-"], "mno-xop">, Group;
-def mno_f16c : Flag<["-"], "mno-f16c">, Group;
-def mno_rtm : Flag<["-"], "mno-rtm">, Group;
-def mno_prfchw : Flag<["-"], "mno-prfchw">, Group;
-def mno_rdseed : Flag<["-"], "mno-rdseed">, Group;
-def mno_adx : Flag<["-"], "mno-adx">, Group;
-def mno_sha : Flag<["-"], "mno-sha">, Group;
-def mno_cx16 : Flag<["-"], "mno-cx16">, Group;
-def mno_fxsr : Flag<["-"], "mno-fxsr">, Group;
-def mno_xsave : Flag<["-"], "mno-xsave">, Group;
-def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">, Group;
-def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
-def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
-def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
-def mno_clzero : Flag<["-"], "mno-clzero">, Group;
-def mno_pku : Flag<["-"], "mno-pku">, Group;
-def mno_clflushopt : 

[PATCH] D39281: [libunwind] Express Registers_*::lastDwarfReg using _LIBUNWIND_HIGHEST_DWARF_REGISTER

2017-10-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 120467.
mstorsjo edited the summary of this revision.
mstorsjo added a comment.
Herald added subscribers: JDevlieghere, aprantl.

Adjusted _LIBUNWIND_HIGHEST_DWARF_REGISTER to actually have the value of the 
highest register, not highest+1.


https://reviews.llvm.org/D39281

Files:
  include/__libunwind_config.h
  src/DwarfInstructions.hpp
  src/DwarfParser.hpp
  src/Registers.hpp

Index: src/Registers.hpp
===
--- src/Registers.hpp
+++ src/Registers.hpp
@@ -44,7 +44,7 @@
   voidsetVectorRegister(int num, v128 value);
   const char *getRegisterName(int num);
   voidjumpto();
-  static int  lastDwarfRegNum() { return 8; }
+  static int  lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER; }
 
   uint32_t  getSP() const  { return _registers.__esp; }
   void  setSP(uint32_t value)  { _registers.__esp = value; }
@@ -250,7 +250,7 @@
   voidsetVectorRegister(int num, v128 value);
   const char *getRegisterName(int num);
   voidjumpto();
-  static int  lastDwarfRegNum() { return 16; }
+  static int  lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER; }
 
   uint64_t  getSP() const  { return _registers.__rsp; }
   void  setSP(uint64_t value)  { _registers.__rsp = value; }
@@ -500,7 +500,7 @@
   voidsetVectorRegister(int num, v128 value);
   const char *getRegisterName(int num);
   voidjumpto();
-  static int  lastDwarfRegNum() { return 112; }
+  static int  lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER; }
 
   uint64_t  getSP() const { return _registers.__r1; }
   void  setSP(uint32_t value) { _registers.__r1 = value; }
@@ -1066,7 +1066,7 @@
   voidsetVectorRegister(int num, v128 value);
   const char *getRegisterName(int num);
   voidjumpto();
-  static int  lastDwarfRegNum() { return 95; }
+  static int  lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER; }
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
@@ -1815,7 +1815,7 @@
   voidsetVectorRegister(int num, v128 value);
   const char *getRegisterName(int num);
   voidjumpto();
-  static int  lastDwarfRegNum() { return 31; }
+  static int  lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER; }
 
   uint64_t  getSP() const { return _registers.__r[1]; }
   void  setSP(uint32_t value) { _registers.__r[1] = value; }
Index: src/DwarfParser.hpp
===
--- src/DwarfParser.hpp
+++ src/DwarfParser.hpp
@@ -87,7 +87,7 @@
 uint32_t  codeOffsetAtStackDecrement;
 bool  registersInOtherRegisters;
 bool  sameValueUsed;
-RegisterLocation  savedRegisters[kMaxRegisterNumber];
+RegisterLocation  savedRegisters[kMaxRegisterNumber + 1];
   };
 
   struct PrologInfoStackEntry {
Index: src/DwarfInstructions.hpp
===
--- src/DwarfInstructions.hpp
+++ src/DwarfInstructions.hpp
@@ -167,7 +167,7 @@
   R newRegisters = registers;
   pint_t returnAddress = 0;
   const int lastReg = R::lastDwarfRegNum();
-  assert((int)CFI_Parser::kMaxRegisterNumber > lastReg &&
+  assert((int)CFI_Parser::kMaxRegisterNumber >= lastReg &&
  "register range too large");
   assert(lastReg >= (int)cieInfo.returnAddressRegister &&
  "register range does not contain return address register");
Index: include/__libunwind_config.h
===
--- include/__libunwind_config.h
+++ include/__libunwind_config.h
@@ -20,22 +20,22 @@
 #  define _LIBUNWIND_TARGET_I386
 #  define _LIBUNWIND_CONTEXT_SIZE 8
 #  define _LIBUNWIND_CURSOR_SIZE 19
-#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 9
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 8
 # elif defined(__x86_64__)
 #  define _LIBUNWIND_TARGET_X86_64 1
 #  define _LIBUNWIND_CONTEXT_SIZE 21
 #  define _LIBUNWIND_CURSOR_SIZE 33
-#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 17
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 16
 # elif defined(__ppc__)
 #  define _LIBUNWIND_TARGET_PPC 1
 #  define _LIBUNWIND_CONTEXT_SIZE 117
 #  define _LIBUNWIND_CURSOR_SIZE 128
-#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 113
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 112
 # elif defined(__aarch64__)
 #  define _LIBUNWIND_TARGET_AARCH64 1
 #  define _LIBUNWIND_CONTEXT_SIZE 66
 #  define _LIBUNWIND_CURSOR_SIZE 78
-#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 95
 # elif defined(__arm__)
 #  define _LIBUNWIND_TARGET_ARM 1
 #  if defined(__ARM_WMMX)
@@ -45,12 +45,12 @@
 #define _LIBUNWIND_CONTEXT_SIZE 42
 #define _LIBUNWIND_CURSOR_SIZE 49
 #  endif
-#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
+#  define 

[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

In https://reviews.llvm.org/D36347#908186, @zturner wrote:

> Do I understand correctly that this will insert breakpoints on *all* clang 
> diagnostics?  That's not necessarily bad, but I was under the impression 
> originally that it would let you pick the diagnostics you wanted to insert 
> breakpoints on.


`clangdiag enable` sets a breakpoint in `DiagnosticsEngine::Report` and adds a 
callback.  The callback passed the value of DiagID to diagtool to get the enum 
spelling of the DiagID, e.g., `err_undeclared_var_use`, then calls 
`BreakpointCreateBySourceRegex` with that string and and empty `FileSpec` to 
set breakpoints in every location that string is seen -- specifically, we use 
"diag::err_undeclared_var_use` for this case.  Now, that might add a few more 
breakpoints than actually needed, but not many, and only rarely in places that 
were actually covered by this particular run.

Also, since we add the breakpoint after it was seen -- 
`DiagnosticsEngine::Report` is called later, and sometimes much later, you'll 
need to run the debugger again to actually hit all the breakpoints.

> Also, What is the workflow for using the "clangdiag diagtool" subcommand?  
> Would you have to do two steps, `clangdiag enable` and then `clangdiag 
> diagtool`?  If so, maybe it could just be `clangdiag enable --diagtool=`

I put `command script import 
/Users/dhinton/projects/llvm_project/llvm/tools/clang/utils/clangdiag.py` in my 
`~/.lldbinit` file, so here's an example of how I use it:

  $ lldb bin/clang-6.0
  The "clangdiag" command has been installed, type "help clangdiag" or 
"clangdiag --help" for detailed help.
  (lldb) target create "bin/clang-6.0"
  Current executable set to 'bin/clang-6.0' (x86_64).
  
  (lldb) clangdiag diagtool
  diagtool = /Users/dhinton/projects/llvm_project/build/Debug/bin/diagtool
  
  (lldb) clangdiag diagtool /bad/path/xx
  clangdiag: /bad/path/xx not found.
  diagtool = /Users/dhinton/projects/llvm_project/build/Debug/bin/diagtool
  
  (lldb) clangdiag diagtool 
/Users/dhinton/projects/monorepo/build/Debug/bin/diagtool
  diagtool = /Users/dhinton/projects/monorepo/build/Debug/bin/diagtool
  
  (lldb) clangdiag diagtool reset
  diagtool = /Users/dhinton/projects/llvm_project/build/Debug/bin/diagtool
  
  (lldb) clangdiag enable
  (lldb) br l
  Current breakpoints:
  1: name = 'DiagnosticsEngine::Report', locations = 33
  Breakpoint commands (Python):
return clangdiag.setDiagBreakpoint(frame, bp_loc, internal_dict)
  
Names:
  clang::Diagnostic
  
1.1: where = clang-6.0`clang::DiagnosticsEngine::Report(unsigned int) + 38 
at Diagnostic.h:1215, address = clang-6.0[0x000100022cd6], unresolved, hit 
count = 0
1.2: where = 
clang-6.0`clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) 
+ 46 at Diagnostic.h:1207, address = clang-6.0[0x00010002c6ce], unresolved, 
hit count = 0
  <...snip...>
  
  (lldb) clangdiag disable
  (lldb) br l
  No breakpoints currently set.
  
  (lldb) clangdiag enable
  (lldb) br l
  Current breakpoints:
  2: name = 'DiagnosticsEngine::Report', locations = 33
  Breakpoint commands (Python):
return clangdiag.setDiagBreakpoint(frame, bp_loc, internal_dict)
  
Names:
  clang::Diagnostic
  
2.1: where = clang-6.0`clang::DiagnosticsEngine::Report(unsigned int) + 38 
at Diagnostic.h:1215, address = clang-6.0[0x000100022cd6], unresolved, hit 
count = 0
2.2: where = 
clang-6.0`clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) 
+ 46 at Diagnostic.h:1207, address = clang-6.0[0x00010002c6ce], unresolved, 
hit count = 0
  <...snip...>
  
  (lldb) run <...>
   might hit one of the new breakpoints if they are seen more than once
  (lldb) run 
   should hit all the breakpoints for which diagnostics were produced
  
  (lldb) br l
  Current breakpoints:
  2: name = 'DiagnosticsEngine::Report', locations = 33, resolved = 33, hit 
count = 5
  Breakpoint commands (Python):
return clangdiag.setDiagBreakpoint(frame, bp_loc, internal_dict)
  
Names:
  clang::Diagnostic
2.1: where = clang-6.0`clang::DiagnosticsEngine::Report(unsigned int) + 38 
at Diagnostic.h:1215, address = 0x000100022cd6, resolved, hit count = 0 

   
2.2: where = 
clang-6.0`clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) 
+ 46 at Diagnostic.h:1207, address = 0x00010002c6ce, resolved, hit count = 0
  <...snip...>
  
  3: source regex = "err_unknown_typename", exact_match = 0, locations = 6, 
resolved = 6, hit count = 2 

  Names:

   

r316687 - [Analyzer] [Tests] Write analyzers crashes to stdout, and not to a separate file

2017-10-26 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Oct 26 12:00:22 2017
New Revision: 316687

URL: http://llvm.org/viewvc/llvm-project?rev=316687=rev
Log:
[Analyzer] [Tests] Write analyzers crashes to stdout, and not to a separate file

With this change it would be sufficient to look at CI console to see the
failure.

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=316687=316686=316687=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Thu Oct 26 12:00:22 2017
@@ -450,29 +450,21 @@ def checkBuild(SBOutputDir):
 len(Plists)
 return
 
-# Create summary file to display when the build fails.
-SummaryPath = os.path.join(
-SBOutputDir, LogFolderName, FailuresSummaryFileName)
-if (Verbose > 0):
-print "  Creating the failures summary file %s" % (SummaryPath,)
-
-with open(SummaryPath, "w+") as SummaryLog:
-SummaryLog.write("Total of %d failures discovered.\n" % (TotalFailed,))
-if TotalFailed > NumOfFailuresInSummary:
-SummaryLog.write("See the first %d below.\n" % (
-NumOfFailuresInSummary,))
+print "Error: analysis failed."
+print "Total of %d failures discovered." % TotalFailed
+if TotalFailed > NumOfFailuresInSummary:
+print "See the first %d below.\n" % NumOfFailuresInSummary
 # TODO: Add a line "See the results folder for more."
 
-Idx = 0
-for FailLogPathI in Failures:
-if Idx >= NumOfFailuresInSummary:
-break
-Idx += 1
-SummaryLog.write("\n-- Error #%d ---\n" % (Idx,))
-with open(FailLogPathI, "r") as FailLogI:
-shutil.copyfileobj(FailLogI, SummaryLog)
+Idx = 0
+for FailLogPathI in Failures:
+if Idx >= NumOfFailuresInSummary:
+break
+Idx += 1
+print "\n-- Error #%d ---\n" % Idx
+with open(FailLogPathI, "r") as FailLogI:
+shutil.copyfileobj(FailLogI, sys.stdout)
 
-print "Error: analysis failed. See ", SummaryPath
 sys.exit(1)
 
 


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


[PATCH] D38985: [refactor] Add support for editor commands that connect IDEs/editors to the refactoring actions

2017-10-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 120466.
arphaman added a comment.

- Use a `RefactoringDescriptor` struct that's accessible from a static function 
in an operation class.
- Make `createSourceReplacements` private.


Repository:
  rL LLVM

https://reviews.llvm.org/D38985

Files:
  include/clang/Tooling/Refactoring/Extract/Extract.h
  include/clang/Tooling/Refactoring/RefactoringActionRegistry.def
  include/clang/Tooling/Refactoring/RefactoringActionRule.h
  include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
  include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/Extract.cpp
  lib/Tooling/Refactoring/RefactoringActions.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  unittests/Tooling/RefactoringActionRulesTest.cpp

Index: unittests/Tooling/RefactoringActionRulesTest.cpp
===
--- unittests/Tooling/RefactoringActionRulesTest.cpp
+++ unittests/Tooling/RefactoringActionRulesTest.cpp
@@ -10,7 +10,8 @@
 #include "ReplacementTest.h"
 #include "RewriterTestContext.h"
 #include "clang/Tooling/Refactoring.h"
-#include "clang/Tooling/Refactoring/RefactoringActionRules.h"
+#include "clang/Tooling/Refactoring/Extract/Extract.h"
+#include "clang/Tooling/Refactoring/RefactoringAction.h"
 #include "clang/Tooling/Refactoring/RefactoringDiagnostic.h"
 #include "clang/Tooling/Refactoring/Rename/SymbolName.h"
 #include "clang/Tooling/Tooling.h"
@@ -63,6 +64,12 @@
 ReplaceAWithB(std::pair Selection)
 : Selection(Selection) {}
 
+static Expected
+initiate(RefactoringRuleContext ,
+ std::pair Selection) {
+  return ReplaceAWithB(Selection);
+}
+
 Expected
 createSourceReplacements(RefactoringRuleContext ) {
   const SourceManager  = Context.getSources();
@@ -141,6 +148,11 @@
 TEST_F(RefactoringActionRulesTest, ReturnError) {
   class ErrorRule : public SourceChangeRefactoringRule {
   public:
+static Expected initiate(RefactoringRuleContext &,
+SourceRange R) {
+  return ErrorRule(R);
+}
+
 ErrorRule(SourceRange R) {}
 Expected createSourceReplacements(RefactoringRuleContext &) {
   return llvm::make_error(
@@ -191,6 +203,11 @@
   public:
 FindOccurrences(SourceRange Selection) : Selection(Selection) {}
 
+static Expected initiate(RefactoringRuleContext &,
+  SourceRange Selection) {
+  return FindOccurrences(Selection);
+}
+
 Expected
 findSymbolOccurrences(RefactoringRuleContext &) override {
   SymbolOccurrences Occurrences;
@@ -219,4 +236,13 @@
 SourceRange(Cursor, Cursor.getLocWithOffset(strlen("test";
 }
 
+TEST_F(RefactoringActionRulesTest, EditorCommandBinding) {
+  const RefactoringDescriptor  = ExtractFunction::describe();
+  EXPECT_EQ(Descriptor.Name, "extract-function");
+  EXPECT_EQ(
+  Descriptor.Description,
+  "(WIP action; use with caution!) Extracts code into a new function");
+  EXPECT_EQ(Descriptor.Title, "Extract Function");
+}
+
 } // end anonymous namespace
Index: lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -41,22 +41,6 @@
 
 namespace {
 
-class SymbolSelectionRequirement : public SourceRangeSelectionRequirement {
-public:
-  Expected evaluate(RefactoringRuleContext ) const {
-Expected Selection =
-SourceRangeSelectionRequirement::evaluate(Context);
-if (!Selection)
-  return Selection.takeError();
-const NamedDecl *ND =
-getNamedDeclAt(Context.getASTContext(), Selection->getBegin());
-if (!ND)
-  return Context.createDiagnosticError(
-  Selection->getBegin(), diag::err_refactor_selection_no_symbol);
-return getCanonicalSymbolDeclaration(ND);
-  }
-};
-
 class OccurrenceFinder final : public FindSymbolOccurrencesRefactoringRule {
 public:
   OccurrenceFinder(const NamedDecl *ND) : ND(ND) {}
@@ -74,50 +58,36 @@
   const NamedDecl *ND;
 };
 
-class RenameOccurrences final : public SourceChangeRefactoringRule {
-public:
-  RenameOccurrences(const NamedDecl *ND, std::string NewName)
-  : Finder(ND), NewName(std::move(NewName)) {}
-
-  Expected
-  createSourceReplacements(RefactoringRuleContext ) override {
-Expected Occurrences =
-Finder.findSymbolOccurrences(Context);
-if (!Occurrences)
-  return Occurrences.takeError();
-// FIXME: Verify that the new name is valid.
-SymbolName Name(NewName);
-return createRenameReplacements(
-*Occurrences, Context.getASTContext().getSourceManager(), Name);
-  }
-
-private:
-  OccurrenceFinder Finder;
-  std::string NewName;
-};
-
-class LocalRename final : public RefactoringAction {
-public:
-  

[PATCH] D38824: [X86] Synchronize the existing CPU predefined macros with the cases that gcc defines them

2017-10-26 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:835
 defineCPUMacros(Builder, "slm");
+// gcc also defineds 'silvermont', but we never have. See comment below.
 break;

defines


https://reviews.llvm.org/D38824



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


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Greg Clayton via Phabricator via cfe-commits
clayborg added a comment.

Looks good.


https://reviews.llvm.org/D36347



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


[PATCH] D38985: [refactor] Add support for editor commands that connect IDEs/editors to the refactoring actions

2017-10-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked 5 inline comments as done.
arphaman added inline comments.



Comment at: include/clang/Tooling/Refactoring/Extract/ExtractFunction.h:21
+/// then called from the place where the original code was.
+class ExtractFunction final : public SourceChangeRefactoringRule {
+public:

sammccall wrote:
> The interface given here looks great, much simpler to use directly!
> 
> The inheritance gives me some pause. A couple of related things are going on 
> here:
>  - we're inheriting the `RefactoringActionRuleBase` interface, which allows 
> this refactoring to be used generically
>  - we're inheriting `SourceChangeRefactoringRule`, which adapts the generic 
> interface to the one we actually implement
> 
> As consequences:
>   - we're bound to use a fairly generic name as our entry point here (but I 
> actually think it's a good name, so no worries)
>   - we advertise *two* public entry point, that do the same thing (but it's 
> not obvious from the signature)
> 
> The thing is, I don't think people who want the "generic" interface will be 
> using this class directly - they'll be going through the Engine, right?
> So `ExtractFunction` -> `RefactoringActionRuleBase` adapter doesn't need to 
> be here, I think it can be private in the Engine.
> That seems like a clearer separation of concerns: `ExtractFunction` only 
> cares about getting its work done, and `RefactoringEngine` owns exposing a 
> generic interface to all the rules.
You're right about the dual adaption, but this kind of class **should not** be 
invoked directly for the following reason:
While it's easy to call `createSourceReplacements` or `invoke` for local 
refactorings, the cross-TU actions will need a different invocation harness 
around them. Clangd should avoid using this kind of class directly and use 
another harness that can run refactorings across multiple-TUs if needed.

I think it's best if it stays right now, as it will help to drive cross-TU 
refactorings. We can reconsider this in the future though.
I made the `createSourceReplacements` here private though.



Comment at: include/clang/Tooling/Refactoring/RefactoringActionRule.h:79
+  /// Returns the descriptor for this refactoring rule.
+  virtual const RefactoringDescriptorInterface () = 0;
 };

sammccall wrote:
> Did you intend to put this in RefactoringActionRuleBase? It'd be nice to have 
> it for all types of rules.
> 
> Also, it's an instance method, but don't you want to be able to get at the 
> information even if you can't apply the refactoring in the given context (so 
> initiate fails).
> 
> Maybe this should be static (and `RefactoringEngine` should expose it as part 
> of its generic interface)
Classes like ExtractFunction could be reused by multiple rules, so I put it 
there before to keep the "is this refactoring available in editor" associated 
with a rule. But now with a more generic descriptor that doesn't really 
associate title with "is this refactoring available in an editor" I can put the 
descriptor into the ExtractFunction class itself.


Repository:
  rL LLVM

https://reviews.llvm.org/D38985



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


[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: test/CodeGenObjC/debug-info-blocks.m:20
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]

aprantl wrote:
> aprantl wrote:
> > vsk wrote:
> > > aprantl wrote:
> > > > What's the location used for the ret? I think it should also be` 
> > > > ![[DBG_LINE]]` since we are not actually executing the block.
> > > We're using COPY_LINE, which is the same location used for the load 
> > > instruction below.
> > > 
> > > What's the semantic difference between DBG_LINE (line 0) and COPY_LINE 
> > > (line 68) anyway? Why do we have two different locations for the 
> > > arguments to this function?
> > The debugger will skip over line 0 locations when single-stepping or when 
> > setting breakpoints. I can't tell without reading the code why we decide to 
> > put a line 0 on the call.
> The important thing is that the testcase should check that the ret has either 
> COPY_LINE or line 0 on it and not line 71.
I'll fix up the test case.

It looks like the zero location is an artifact of 
CodeGenFunction::StartFunction:
```
1128   // Emit a location at the end of the prologue.   

 
1129   if (CGDebugInfo *DI = getDebugInfo())

 
1130 DI->EmitLocation(Builder, StartLoc);
```

I think it's unnecessary, but maybe we can look into that separately?


https://reviews.llvm.org/D39310



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


[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 120461.
vsk marked 8 inline comments as done.
vsk added a comment.

- Tighten test case to show the dbg loc on return instructions.


https://reviews.llvm.org/D39310

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenObjC/debug-info-blocks.m


Index: test/CodeGenObjC/debug-info-blocks.m
===
--- test/CodeGenObjC/debug-info-blocks.m
+++ test/CodeGenObjC/debug-info-blocks.m
@@ -10,23 +10,20 @@
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], 
metadata !{{.*}})
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata 
![[D:[0-9]+]], metadata !{{.*}})
 
-// rdar://problem/14386148
-// Test that we don't emit bogus line numbers for the helper functions.
-// Test that we do emit scope info for the helper functions.
+// Test that we do emit scope info for the helper functions, and that the
+// parameters to these functions are marked as artificial (so the debugger
+// doesn't accidentally step into the function).
 // CHECK: define {{.*}} @__copy_helper_block_{{.*}}(i8*, i8*)
 // CHECK-NOT: ret
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
+// CHECK: ret void, !dbg ![[COPY_LINE]]
 // CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*)
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
+// CHECK: ret void, !dbg ![[DESTROY_LINE]]
 
-// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
-// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: 
![[DESTROY_SP:[0-9]+]])
-// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_"
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -60,6 +57,14 @@
 - (id)init
 {
 if ((self = [super init])) {
+  // CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: 
![[COPY_SP:[0-9]+]])
+  // CHECK-DAG: [[COPY_LINE]] = !DILocation(line: [[@LINE+7]], scope: 
![[COPY_SP:[0-9]+]])
+  // CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: 
"__copy_helper_block_"
+  // CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: [[@LINE+5]], scope: 
![[DESTROY_SP:[0-9]+]])
+  // CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_"
+  // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
+  // CHECK-DAG: !DILocalVariable(arg: 2, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
+  // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[DESTROY_SP]], {{.*}}, 
flags: DIFlagArtificial)
   run(^{
   // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", 
scope:{{.*}}, line: [[@LINE+4]],
   // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, 
line: [[@LINE+1]],
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1647,10 +1647,8 @@
 
   CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
 
-  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  // Create a scope with an artificial location for the body of this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 
   Address src = GetAddrOfLocalVar();
@@ -1819,10 +1817,8 @@
 
   CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
 
-  // Create a scope with an artificial location for the body of this function.
-  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 


Index: test/CodeGenObjC/debug-info-blocks.m
===
--- test/CodeGenObjC/debug-info-blocks.m
+++ test/CodeGenObjC/debug-info-blocks.m
@@ -10,23 +10,20 @@
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}})
 // CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
 
-// rdar://problem/14386148
-// Test that we don't emit bogus line numbers for the helper functions.
-// Test that we do emit scope info for the helper functions.
+// Test that we do emit scope info for the helper functions, and that the
+// parameters to these functions are marked as 

[PATCH] D38596: Implement attribute target multiversioning

2017-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 120460.

https://reviews.llvm.org/D38596

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/attr-target-multiversion.c
  test/CodeGenCXX/attr-target-multiversion.cpp
  test/Sema/attr-target-multiversion.c
  test/SemaCXX/attr-target-multiversion.cpp

Index: test/SemaCXX/attr-target-multiversion.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-target-multiversion.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+struct S {
+  __attribute__((target("arch=sandybridge")))
+  void mv(){}
+  __attribute__((target("arch=ivybridge")))
+  void mv(){}
+  __attribute__((target("default")))
+  void mv(){}
+
+  // NOTE: Virtual functions aren't implement for multiversioning in GCC either,
+  // so this is a 'TBD' feature.
+  // expected-error@+2 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  __attribute__((target("arch=sandybridge")))
+  virtual void mv_2(){}
+  // expected-error@+4 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-3 {{previous definition is here}}
+  __attribute__((target("arch=ivybridge")))
+  virtual void mv_2(){}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-7 {{previous definition is here}}
+  __attribute__((target("default")))
+  virtual void mv_2(){}
+};
+
+// Note: Template attribute 'target' isn't implemented in GCC either, and would
+// end up causing some nasty issues attempting it, so ensure that it still gives
+// the same errors as without the attribute.
+
+template
+__attribute__((target("arch=sandybridge")))
+void mv_temp(){}
+
+template
+__attribute__((target("arch=ivybridge")))
+//expected-error@+2 {{redefinition of}}
+//expected-note@-5{{previous definition is here}}
+void mv_temp(){}
+
+template
+__attribute__((target("default")))
+void mv_temp(){}
+
+void foo() {
+  //expected-error@+2{{no matching function for call to}}
+  //expected-note@-8{{candidate template ignored}}
+  mv_temp();
+}
Index: test/Sema/attr-target-multiversion.c
===
--- /dev/null
+++ test/Sema/attr-target-multiversion.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_DEFAULT %s
+
+#if defined(CHECK_DEFAULT)
+__attribute__((target("arch=sandybridge")))
+//expected-error@+1 {{function multiversioning with 'target' requires a 'default' implementation}}
+void no_default(){}
+__attribute__((target("arch=ivybridge")))
+void no_default(){}
+#else
+// Only multiversioning causes issues with redeclaration changing 'target'.
+__attribute__((target("arch=sandybridge")))
+void fine_since_no_mv();
+void fine_since_no_mv();
+
+void also_fine_since_no_mv();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv();
+
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+void also_fine_since_no_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void mv(){}
+__attribute__((target("arch=ivybridge")))
+void mv(){}
+__attribute__((target("default")))
+void mv(){}
+
+void redecl_causes_mv();
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-4 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv2();
+void redecl_causes_mv2();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-2 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_without_attr();
+__attribute__((target("arch=ivybridge")))
+void redecl_without_attr();
+// expected-error@+2 {{function redeclaration is missing 'target' attribute in a multiversioned function}}
+// expected-note@-4 {{previous declaration is here}}
+void redecl_without_attr();
+
+__attribute__((target("arch=sandybridge")))
+void multiversion_with_predecl();

[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 120459.
hintonda added a comment.

- Enhance diagtool option to check, reset, print out current value.


https://reviews.llvm.org/D36347

Files:
  utils/clangdiag.py

Index: utils/clangdiag.py
===
--- /dev/null
+++ utils/clangdiag.py
@@ -0,0 +1,137 @@
+#!/usr/bin/python
+
+#--
+# Be sure to add the python path that points to the LLDB shared library.
+#
+# # To use this in the embedded python interpreter using "lldb" just
+# import it with the full path using the "command script import"
+# command
+#   (lldb) command script import /path/to/clandiag.py
+#--
+
+import lldb
+import argparse
+import commands
+import shlex
+import os
+import subprocess
+
+class MyParser(argparse.ArgumentParser):
+def format_help(self):
+return ''' Commands for operating on clang diagnostic breakpoints
+
+Syntax: clangdiag enable
+clangdiag disable
+clangdiag diagtool [|reset]
+
+The following subcommands are supported:
+
+  enable   -- Enable clang diagnostic breakpoints.
+  disable  -- Disable all clang diagnostic breakpoints.
+  diagtool -- Return, set, or reset diagtool path.
+'''
+
+def create_diag_options():
+parser = MyParser(prog='clangdiag')
+subparsers = parser.add_subparsers(
+title='subcommands',
+dest='subcommands',
+metavar='')
+disable_parser = subparsers.add_parser('disable')
+enable_parser = subparsers.add_parser('enable')
+diagtool_parser = subparsers.add_parser('diagtool')
+diagtool_parser.add_argument('path', nargs='?')
+return parser
+
+def getDiagtool(target, diagtool = None):
+if 'diagtool' not in getDiagtool.__dict__:
+getDiagtool.diagtool = None
+if diagtool:
+if diagtool == 'reset':
+getDiagtool.diagtool = None
+elif os.path.exists(diagtool):
+getDiagtool.diagtool = diagtool
+else:
+print('clangdiag: %s not found.' % diagtool)
+if getDiagtool.diagtool is None:
+exe = target.GetExecutable()
+if not exe.Exists():
+print('clangdiag: Target (%s) not set.' % exe.GetFilename())
+else:
+diagtool = os.path.join(exe.GetDirectory(), 'diagtool')
+if os.path.exists(diagtool):
+getDiagtool.diagtool = diagtool
+else:
+print('clangdiag: diagtool not found along side %s' % exe)
+
+return getDiagtool.diagtool
+
+def setDiagBreakpoint(frame, bp_loc, dict):
+id = frame.FindVariable("DiagID").GetValue()
+if id is None:
+ print('clangdiag: id is None')
+ return False
+
+# Don't need to test this time, since we did that in enable.
+target = frame.GetThread().GetProcess().GetTarget()
+diagtool = getDiagtool(target)
+name = subprocess.check_output([diagtool, "find-diagnostic-id", id]).rstrip();
+bp = target.BreakpointCreateBySourceRegex(name, lldb.SBFileSpec())
+bp.AddName("clang::Diagnostic")
+
+return False
+
+def enable(exe_ctx, args):
+# Always disable existing breakpoints
+disable(exe_ctx)
+
+target = exe_ctx.GetTarget()
+# Just make sure we can find diagtool since it gets used in callbacks.
+diagtool = getDiagtool(target)
+bp = target.BreakpointCreateByName('DiagnosticsEngine::Report')
+bp.SetScriptCallbackFunction('clangdiag.setDiagBreakpoint')
+bp.AddName("clang::Diagnostic")
+
+return
+
+def disable(exe_ctx):
+target = exe_ctx.GetTarget()
+# Remove all diag breakpoints.
+bkpts = lldb.SBBreakpointList(target)
+target.FindBreakpointsByName("clang::Diagnostic", bkpts)
+for i in range(bkpts.GetSize()):
+target.BreakpointDelete(bkpts.GetBreakpointAtIndex(i).GetID())
+
+return
+
+def the_diag_command(debugger, command, exe_ctx, result, dict):
+# Use the Shell Lexer to properly parse up command options just like a
+# shell would
+command_args = shlex.split(command)
+parser = create_diag_options()
+try:
+args = parser.parse_args(command_args)
+except:
+return
+
+if args.subcommands == 'enable':
+enable(exe_ctx, args)
+elif args.subcommands == 'disable':
+disable(exe_ctx)
+else:
+print(args)
+diagtool = getDiagtool(exe_ctx.GetTarget(), args.path)
+print('diagtool = %s' % diagtool)
+
+return
+
+def __lldb_init_module(debugger, dict):
+# This initializer is being run from LLDB in the embedded command interpreter
+# Make the options so we can generate the help text for the new LLDB
+# command line command prior to registering it with LLDB below
+parser = create_diag_options()
+the_diag_command.__doc__ = parser.format_help()
+# Add any commands contained in this module to 

r316686 - Revert "Simplify codegen and debug info generation for block context parameters."

2017-10-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Oct 26 11:32:16 2017
New Revision: 316686

URL: http://llvm.org/viewvc/llvm-project?rev=316686=rev
Log:
Revert "Simplify codegen and debug info generation for block context 
parameters."

This reverts commit r316684 while investigating buildbot breakage.

Added:
cfe/trunk/test/CodeGenObjC/debug-info-block-captured-self.m
Removed:
cfe/trunk/test/CodeGen/debug-info-block-vars.c
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=316686=316685=316686=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct 26 11:32:16 2017
@@ -1294,19 +1294,19 @@ void CodeGenFunction::setBlockContextPar
   assert(BlockInfo && "not emitting prologue of block invocation function?!");
 
   llvm::Value *localAddr = nullptr;
-  // Allocate a stack slot like for any local variable to guarantee optimal
-  // debug info at -O0. The mem2reg pass will eliminate it when optimizing.
-  Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
-  Builder.CreateStore(arg, alloc);
-  localAddr = Builder.CreateLoad(alloc);
+  if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
+// Allocate a stack slot to let the debug info survive the RA.
+Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
+Builder.CreateStore(arg, alloc);
+localAddr = Builder.CreateLoad(alloc);
+  }
 
   if (CGDebugInfo *DI = getDebugInfo()) {
 if (CGM.getCodeGenOpts().getDebugInfo() >=
 codegenoptions::LimitedDebugInfo) {
   DI->setLocation(D->getLocation());
-  DI->EmitDeclareOfBlockLiteralArgVariable(
-  *BlockInfo, D->getName(), argNum,
-  cast(alloc.getPointer()), Builder);
+  DI->EmitDeclareOfBlockLiteralArgVariable(*BlockInfo, arg, argNum,
+   localAddr, Builder);
 }
   }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=316686=316685=316686=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 26 11:32:16 2017
@@ -3694,9 +3694,9 @@ bool operator<(const BlockLayoutChunk 
 }
 
 void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo 
,
-   StringRef Name,
+   llvm::Value *Arg,
unsigned ArgNo,
-   llvm::AllocaInst 
*Alloca,
+   llvm::Value *LocalAddr,
CGBuilderTy ) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   ASTContext  = CGM.getContext();
@@ -3828,11 +3828,19 @@ void CGDebugInfo::EmitDeclareOfBlockLite
 
   // Create the descriptor for the parameter.
   auto *debugVar = DBuilder.createParameterVariable(
-  scope, Name, ArgNo, tunit, line, type,
+  scope, Arg->getName(), ArgNo, tunit, line, type,
   CGM.getLangOpts().Optimize, flags);
 
+  if (LocalAddr) {
+// Insert an llvm.dbg.value into the current block.
+DBuilder.insertDbgValueIntrinsic(
+LocalAddr, debugVar, DBuilder.createExpression(),
+llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
+Builder.GetInsertBlock());
+  }
+
   // Insert an llvm.dbg.declare into the current block.
-  DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
+  DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(),
  llvm::DebugLoc::get(line, column, scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=316686=316685=316686=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Oct 26 11:32:16 2017
@@ -398,8 +398,8 @@ public:
   /// Emit call to \c llvm.dbg.declare for the block-literal argument
   /// to a block invocation function.
   void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo ,
-StringRef Name, unsigned ArgNo,
-llvm::AllocaInst *LocalAddr,
+llvm::Value *Arg, unsigned ArgNo,
+llvm::Value *LocalAddr,
  

[PATCH] D39321: ARM: centralise SizeType, PtrDiffType, and IntPtrType

2017-10-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think you missed a couple other places which still set SizeType and 
PtrDiffType?


Repository:
  rL LLVM

https://reviews.llvm.org/D39321



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


[PATCH] D39305: Simplify codegen and debug info generation for block context parameters.

2017-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316684: Simplify codegen and debug info generation for block 
context parameters. (authored by adrian).

Changed prior to commit:
  https://reviews.llvm.org/D39305?vs=120312=120455#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39305

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/test/CodeGen/debug-info-block-vars.c
  cfe/trunk/test/CodeGenObjC/debug-info-block-captured-self.m

Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -398,8 +398,8 @@
   /// Emit call to \c llvm.dbg.declare for the block-literal argument
   /// to a block invocation function.
   void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo ,
-llvm::Value *Arg, unsigned ArgNo,
-llvm::Value *LocalAddr,
+StringRef Name, unsigned ArgNo,
+llvm::AllocaInst *LocalAddr,
 CGBuilderTy );
 
   /// Emit information about a global variable.
Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp
===
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp
@@ -1294,19 +1294,19 @@
   assert(BlockInfo && "not emitting prologue of block invocation function?!");
 
   llvm::Value *localAddr = nullptr;
-  if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
-// Allocate a stack slot to let the debug info survive the RA.
-Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
-Builder.CreateStore(arg, alloc);
-localAddr = Builder.CreateLoad(alloc);
-  }
+  // Allocate a stack slot like for any local variable to guarantee optimal
+  // debug info at -O0. The mem2reg pass will eliminate it when optimizing.
+  Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
+  Builder.CreateStore(arg, alloc);
+  localAddr = Builder.CreateLoad(alloc);
 
   if (CGDebugInfo *DI = getDebugInfo()) {
 if (CGM.getCodeGenOpts().getDebugInfo() >=
 codegenoptions::LimitedDebugInfo) {
   DI->setLocation(D->getLocation());
-  DI->EmitDeclareOfBlockLiteralArgVariable(*BlockInfo, arg, argNum,
-   localAddr, Builder);
+  DI->EmitDeclareOfBlockLiteralArgVariable(
+  *BlockInfo, D->getName(), argNum,
+  cast(alloc.getPointer()), Builder);
 }
   }
 
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3694,9 +3694,9 @@
 }
 
 void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo ,
-   llvm::Value *Arg,
+   StringRef Name,
unsigned ArgNo,
-   llvm::Value *LocalAddr,
+   llvm::AllocaInst *Alloca,
CGBuilderTy ) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   ASTContext  = CGM.getContext();
@@ -3828,19 +3828,11 @@
 
   // Create the descriptor for the parameter.
   auto *debugVar = DBuilder.createParameterVariable(
-  scope, Arg->getName(), ArgNo, tunit, line, type,
+  scope, Name, ArgNo, tunit, line, type,
   CGM.getLangOpts().Optimize, flags);
 
-  if (LocalAddr) {
-// Insert an llvm.dbg.value into the current block.
-DBuilder.insertDbgValueIntrinsic(
-LocalAddr, debugVar, DBuilder.createExpression(),
-llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
-Builder.GetInsertBlock());
-  }
-
   // Insert an llvm.dbg.declare into the current block.
-  DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(),
+  DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
  llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
  Builder.GetInsertBlock());
 }
Index: cfe/trunk/test/CodeGen/debug-info-block-vars.c
===
--- cfe/trunk/test/CodeGen/debug-info-block-vars.c
+++ cfe/trunk/test/CodeGen/debug-info-block-vars.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -x c -fblocks -debug-info-kind=standalone -emit-llvm -O0 \
+// RUN:   -triple x86_64-apple-darwin -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c -fblocks -debug-info-kind=standalone -emit-llvm -O1 \
+// RUN:   -triple 

r316684 - Simplify codegen and debug info generation for block context parameters.

2017-10-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Oct 26 11:16:05 2017
New Revision: 316684

URL: http://llvm.org/viewvc/llvm-project?rev=316684=rev
Log:
Simplify codegen and debug info generation for block context parameters.

The exisiting code goes out of its way to put block parameters into an
alloca only at -O0, and then describes the funciton argument with a
dbg.declare, which is undocumented in the LLVM-CFE contract and does
not actually behave as intended after LLVM r642022.

This patch just generates the alloca unconditionally, the mem2reg pass
will eliminate it at -O1 and up anyway and points the dbg.declare to
the alloca as intended (which mem2reg will then correctly rewrite into
a dbg.value).

rdar://problem/35043980

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

Added:
cfe/trunk/test/CodeGen/debug-info-block-vars.c
Removed:
cfe/trunk/test/CodeGenObjC/debug-info-block-captured-self.m
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=316684=316683=316684=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct 26 11:16:05 2017
@@ -1294,19 +1294,19 @@ void CodeGenFunction::setBlockContextPar
   assert(BlockInfo && "not emitting prologue of block invocation function?!");
 
   llvm::Value *localAddr = nullptr;
-  if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
-// Allocate a stack slot to let the debug info survive the RA.
-Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
-Builder.CreateStore(arg, alloc);
-localAddr = Builder.CreateLoad(alloc);
-  }
+  // Allocate a stack slot like for any local variable to guarantee optimal
+  // debug info at -O0. The mem2reg pass will eliminate it when optimizing.
+  Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
+  Builder.CreateStore(arg, alloc);
+  localAddr = Builder.CreateLoad(alloc);
 
   if (CGDebugInfo *DI = getDebugInfo()) {
 if (CGM.getCodeGenOpts().getDebugInfo() >=
 codegenoptions::LimitedDebugInfo) {
   DI->setLocation(D->getLocation());
-  DI->EmitDeclareOfBlockLiteralArgVariable(*BlockInfo, arg, argNum,
-   localAddr, Builder);
+  DI->EmitDeclareOfBlockLiteralArgVariable(
+  *BlockInfo, D->getName(), argNum,
+  cast(alloc.getPointer()), Builder);
 }
   }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=316684=316683=316684=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 26 11:16:05 2017
@@ -3694,9 +3694,9 @@ bool operator<(const BlockLayoutChunk 
 }
 
 void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo 
,
-   llvm::Value *Arg,
+   StringRef Name,
unsigned ArgNo,
-   llvm::Value *LocalAddr,
+   llvm::AllocaInst 
*Alloca,
CGBuilderTy ) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   ASTContext  = CGM.getContext();
@@ -3828,19 +3828,11 @@ void CGDebugInfo::EmitDeclareOfBlockLite
 
   // Create the descriptor for the parameter.
   auto *debugVar = DBuilder.createParameterVariable(
-  scope, Arg->getName(), ArgNo, tunit, line, type,
+  scope, Name, ArgNo, tunit, line, type,
   CGM.getLangOpts().Optimize, flags);
 
-  if (LocalAddr) {
-// Insert an llvm.dbg.value into the current block.
-DBuilder.insertDbgValueIntrinsic(
-LocalAddr, debugVar, DBuilder.createExpression(),
-llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
-Builder.GetInsertBlock());
-  }
-
   // Insert an llvm.dbg.declare into the current block.
-  DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(),
+  DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
  llvm::DebugLoc::get(line, column, scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=316684=316683=316684=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Oct 26 11:16:05 2017
@@ -398,8 +398,8 @@ public:
   /// 

[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: test/CodeGenObjC/debug-info-blocks.m:20
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]

aprantl wrote:
> vsk wrote:
> > aprantl wrote:
> > > What's the location used for the ret? I think it should also be` 
> > > ![[DBG_LINE]]` since we are not actually executing the block.
> > We're using COPY_LINE, which is the same location used for the load 
> > instruction below.
> > 
> > What's the semantic difference between DBG_LINE (line 0) and COPY_LINE 
> > (line 68) anyway? Why do we have two different locations for the arguments 
> > to this function?
> The debugger will skip over line 0 locations when single-stepping or when 
> setting breakpoints. I can't tell without reading the code why we decide to 
> put a line 0 on the call.
The important thing is that the testcase should check that the ret has either 
COPY_LINE or line 0 on it and not line 71.


https://reviews.llvm.org/D39310



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


[PATCH] D38596: Implement attribute target multiversioning

2017-10-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I note my rebase lost the tests... I'll fix that up soon, sorry guys!


https://reviews.llvm.org/D38596



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


[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: test/CodeGenObjC/debug-info-blocks.m:20
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]

vsk wrote:
> aprantl wrote:
> > What's the location used for the ret? I think it should also be` 
> > ![[DBG_LINE]]` since we are not actually executing the block.
> We're using COPY_LINE, which is the same location used for the load 
> instruction below.
> 
> What's the semantic difference between DBG_LINE (line 0) and COPY_LINE (line 
> 68) anyway? Why do we have two different locations for the arguments to this 
> function?
The debugger will skip over line 0 locations when single-stepping or when 
setting breakpoints. I can't tell without reading the code why we decide to put 
a line 0 on the call.


https://reviews.llvm.org/D39310



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


[PATCH] D39331: Add flags to control the -finstrument-functions instrumentation calls to __cyg_profile functions

2017-10-26 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Quick question: We're talking about a few different variants on this feature 
now: Post-inlining instrumentation, only marking function entries, and not 
passing the function address. Do you intend to use all of these things 
separately? I ask because, taken together, that's what we already get with 
mcount().


https://reviews.llvm.org/D39331



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


[PATCH] D39305: Simplify codegen and debug info generation for block context parameters.

2017-10-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In https://reviews.llvm.org/D39305#908208, @rjmccall wrote:

> The original code doesn't make any sense; it looks like the indirection is 
> backwards.  We just built a debug variable corresponding to the block 
> descriptor pointer parameter, so LocalAddr should be dbg.declare'd to be that 
> variable and Arg should be dbg.value'd.  It looks like the real fix in your 
> patch is just getting that right rather than anything to do with the alloca.


Correct. The alloca is just a simplification.

> I don't particularly care about eliminating the alloca, since there are 
> plenty of other places where we emit allocas that we assume we can destroy, 
> and a few easily-eliminated instructions in a scattered function isn't going 
> to greatly contribute to -O build times.  So I think this patch is fine.

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D39305



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


[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: test/CodeGenObjC/debug-info-blocks.m:13
 
-// rdar://problem/14386148
-// Test that we don't emit bogus line numbers for the helper functions.
-// Test that we do emit scope info for the helper functions.
+// rdar://problem/32907581
+// Test that we do emit scope info for the helper functions, and that the

aprantl wrote:
> We nowadays usually try to avoid rdar links in anything but commit messages 
> because it is not helpful information for the LLVM community. It's better to 
> just describe the issue at hand (which you are doing!) or create a PR with 
> that contents and link to it.
Got it.



Comment at: test/CodeGenObjC/debug-info-blocks.m:20
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]

aprantl wrote:
> What's the location used for the ret? I think it should also be` 
> ![[DBG_LINE]]` since we are not actually executing the block.
We're using COPY_LINE, which is the same location used for the load instruction 
below.

What's the semantic difference between DBG_LINE (line 0) and COPY_LINE (line 
68) anyway? Why do we have two different locations for the arguments to this 
function?


https://reviews.llvm.org/D39310



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


r316681 - [X86] Add a target attribute test for no-sse4.

2017-10-26 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Oct 26 10:54:22 2017
New Revision: 316681

URL: http://llvm.org/viewvc/llvm-project?rev=316681=rev
Log:
[X86] Add a target attribute test for no-sse4.

Modified:
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=316681=316680=316681=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Thu Oct 26 10:54:22 2017
@@ -10,6 +10,7 @@ int __attribute__((target("fpmath=387"))
 int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
 
 int __attribute__((target("sse4"))) panda(int a) { return 4; }
+int __attribute__((target("no-sse4"))) narwhal(int a) { return 4; }
 
 int bar(int a) { return baz(a) + foo(a); }
 
@@ -29,15 +30,17 @@ int __attribute__((target("arch=lakemont
 // CHECK: koala{{.*}} #0
 // CHECK: echidna{{.*}} #2
 // CHECK: panda{{.*}} #3
+// CHECK: narwhal{{.*}} #4
 // CHECK: bar{{.*}} #0
 // CHECK: qux{{.*}} #1
-// CHECK: qax{{.*}} #4
-// CHECK: qq{{.*}} #5
-// CHECK: lake{{.*}} #6
+// CHECK: qax{{.*}} #5
+// CHECK: qq{{.*}} #6
+// CHECK: lake{{.*}} #7
 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
 // CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-avx512vpopcntdq,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
 // CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
-// CHECK: #6 = {{.*}}"target-cpu"="lakemont" 
"target-features"="+mmx,+sse,+sse2"
+// CHECK: #4 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-avx512vpopcntdq,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-xop,-xsave,-xsaveopt"
+// CHECK: #5 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
+// CHECK: #6 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
+// CHECK: #7 = {{.*}}"target-cpu"="lakemont" 
"target-features"="+mmx,+sse,+sse2"


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


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Greg Clayton via Phabricator via cfe-commits
clayborg accepted this revision.
clayborg added inline comments.



Comment at: utils/clangdiag.py:117
+disable(exe_ctx)
+else:
+getDiagtool(exe_ctx.GetTarget(), args.path[0])

hintonda wrote:
> clayborg wrote:
> > should probably verify that this 'diagtool' with:
> > 
> > ```
> > elif args.subcommands == 'diagtool':
> > ```
> > and add an else that creates an error:
> > ```
> > else:
> > result.SetError("invalid subcommand '%s'" % (args.subcommands))
> > ```
> This is already handled by `argparser`, which will raise an exception if the 
> first parameter isn't one of (enable, disable, daigtool).  That's the benefit 
> of using `subparsers`.  So, by the time you get to this point, it must be 
> "diagtool".
> 
> However, I think I should probably verify the path past actually exists.  
> Plus, I think I could add a better exception to alert the user how to fix the 
> problem if diagtool couldn't be found in the callback.  Suggestions welcome.
nice, I didn't realized that argparser would protect against that. Checking the 
file exists would be a good idea.


https://reviews.llvm.org/D36347



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


[PATCH] D39305: Simplify codegen and debug info generation for block context parameters.

2017-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The original code doesn't make any sense; it looks like the indirection is 
backwards.  We just built a debug variable corresponding to the block 
descriptor pointer parameter, so LocalAddr should be dbg.declare'd to be that 
variable and Arg should be dbg.value'd.  It looks like the real fix in your 
patch is just getting that right rather than anything to do with the alloca.

I don't particularly care about eliminating the alloca, since there are plenty 
of other places where we emit allocas that we assume we can destroy, and a few 
easily-eliminated instructions in a scattered function isn't going to greatly 
contribute to -O build times.  So I think this patch is fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D39305



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


[PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-26 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

Do I understand correctly that this will insert breakpoints on *all* clang 
diagnostics?  That's not necessarily bad, but I was under the impression 
originally that it would let you pick the diagnostics you wanted to insert 
breakpoints on.

Also, What is the workflow for using the "clangdiag diagtool" subcommand?  
Would you have to do two steps, `clangdiag enable` and then `clangdiag 
diagtool`?  If so, maybe it could just be `clangdiag enable --diagtool=`


https://reviews.llvm.org/D36347



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


r316674 - Move MS inline asm parser methods out of line to reduce indentation, NFC

2017-10-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct 26 10:07:48 2017
New Revision: 316674

URL: http://llvm.org/viewvc/llvm-project?rev=316674=rev
Log:
Move MS inline asm parser methods out of line to reduce indentation, NFC

Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=316674=316673=316674=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Thu Oct 26 10:07:48 2017
@@ -56,53 +56,11 @@ public:
 
   void LookupInlineAsmIdentifier(StringRef ,
  llvm::InlineAsmIdentifierInfo ,
- bool IsUnevaluatedContext) override {
-// Collect the desired tokens.
-SmallVector LineToks;
-const Token *FirstOrigToken = nullptr;
-findTokensForString(LineBuf, LineToks, FirstOrigToken);
-
-unsigned NumConsumedToks;
-ExprResult Result = TheParser.ParseMSAsmIdentifier(
-LineToks, NumConsumedToks, IsUnevaluatedContext);
-
-// If we consumed the entire line, tell MC that.
-// Also do this if we consumed nothing as a way of reporting failure.
-if (NumConsumedToks == 0 || NumConsumedToks == LineToks.size()) {
-  // By not modifying LineBuf, we're implicitly consuming it all.
-
-  // Otherwise, consume up to the original tokens.
-} else {
-  assert(FirstOrigToken && "not using original tokens?");
-
-  // Since we're using original tokens, apply that offset.
-  assert(FirstOrigToken[NumConsumedToks].getLocation() ==
- LineToks[NumConsumedToks].getLocation());
-  unsigned FirstIndex = FirstOrigToken - AsmToks.begin();
-  unsigned LastIndex = FirstIndex + NumConsumedToks - 1;
-
-  // The total length we've consumed is the relative offset
-  // of the last token we consumed plus its length.
-  unsigned TotalOffset =
-  (AsmTokOffsets[LastIndex] + AsmToks[LastIndex].getLength() -
-   AsmTokOffsets[FirstIndex]);
-  LineBuf = LineBuf.substr(0, TotalOffset);
-}
-
-// Initialize Info with the lookup result.
-if (!Result.isUsable())
-  return;
-TheParser.getActions().FillInlineAsmIdentifierInfo(Result.get(), Info);
-  }
+ bool IsUnevaluatedContext) override;
 
   StringRef LookupInlineAsmLabel(StringRef Identifier, llvm::SourceMgr ,
  llvm::SMLoc Location,
- bool Create) override {
-SourceLocation Loc = translateLocation(LSM, Location);
-LabelDecl *Label =
-  TheParser.getActions().GetOrCreateMSAsmLabel(Identifier, Loc, Create);
-return Label->getMSAsmLabel();
-  }
+ bool Create) override;
 
   bool LookupInlineAsmField(StringRef Base, StringRef Member,
 unsigned ) override {
@@ -117,65 +75,127 @@ public:
 private:
   /// Collect the appropriate tokens for the given string.
   void findTokensForString(StringRef Str, SmallVectorImpl ,
-   const Token *) const {
-// For now, assert that the string we're working with is a substring
-// of what we gave to MC.  This lets us use the original tokens.
-assert(!std::less()(Str.begin(), AsmString.begin()) &&
-   !std::less()(AsmString.end(), Str.end()));
-
-// Try to find a token whose offset matches the first token.
-unsigned FirstCharOffset = Str.begin() - AsmString.begin();
-const unsigned *FirstTokOffset = std::lower_bound(
-AsmTokOffsets.begin(), AsmTokOffsets.end(), FirstCharOffset);
-
-// For now, assert that the start of the string exactly
-// corresponds to the start of a token.
-assert(*FirstTokOffset == FirstCharOffset);
-
-// Use all the original tokens for this line.  (We assume the
-// end of the line corresponds cleanly to a token break.)
-unsigned FirstTokIndex = FirstTokOffset - AsmTokOffsets.begin();
-FirstOrigToken = [FirstTokIndex];
-unsigned LastCharOffset = Str.end() - AsmString.begin();
-for (unsigned i = FirstTokIndex, e = AsmTokOffsets.size(); i != e; ++i) {
-  if (AsmTokOffsets[i] >= LastCharOffset)
-break;
-  TempToks.push_back(AsmToks[i]);
-}
-  }
+   const Token *) const;
+
+  SourceLocation translateLocation(const llvm::SourceMgr ,
+   llvm::SMLoc SMLoc);
 
-  SourceLocation translateLocation(const llvm::SourceMgr , llvm::SMLoc 
SMLoc) {
-// Compute an offset into the inline asm buffer.
-// FIXME: This isn't right if .macro is involved (but hopefully, no
-// real-world code does that).
-const llvm::MemoryBuffer *LBuf =
-LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(SMLoc));
-unsigned Offset = SMLoc.getPointer() - LBuf->getBufferStart();
-
-// Figure out which 

[PATCH] D39317: Use -fuse-init-array if no gcc installation is found.

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

I don't think working around an lld bug is a particularly good justification 
for this, but I do think it makes sense to switch this from being a 
"compatibility with GCC 4.7+" thing to being a "compatibility with GCC <= 4.6" 
thing. Please update the release notes to mention this change.


https://reviews.llvm.org/D39317



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


[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-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/D38819



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


RE: r316518 - mplement __has_unique_object_representations

2017-10-26 Thread Keane, Erich via cfe-commits
Thanks for the review Richard.  Would you like me to revert, or can I just make 
these changes in a new patch?


From: Richard Smith [mailto:rich...@metafoo.co.uk]
Sent: Thursday, October 26, 2017 9:50 AM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r316518 - mplement __has_unique_object_representations

On 24 Oct 2017 14:32, "Erich Keane via cfe-commits" 
> wrote:
Author: erichkeane
Date: Tue Oct 24 14:31:50 2017
New Revision: 316518

URL: http://llvm.org/viewvc/llvm-project?rev=316518=rev
Log:
mplement __has_unique_object_representations

A helper builtin to facilitate implementing the
std::has_unique_object_representations type trait.

Requested here: https://bugs.llvm.org/show_bug.cgi?id=34942
Also already exists in GCC and MSVC.

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

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Basic/TypeTraits.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=316518=316517=316518=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Oct 24 14:31:50 2017
@@ -770,6 +770,10 @@ public:
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;

+  /// Return true if this has unique object representations according to (C++17
+  /// [meta.unary.prop]p9)
+  bool hasUniqueObjectRepresentations(const ASTContext ) const;

I think this would make more sense as a member of ASTContext. The Type object 
generally doesn't know or care about its representation.

+
   // Don't promise in the API that anything besides 'const' can be
   // easily added.

@@ -1114,6 +1118,8 @@ public:
   QualType getAtomicUnqualifiedType() const;

 private:
+  bool unionHasUniqueObjectRepresentations(const ASTContext& Context) const;
+  bool structHasUniqueObjectRepresentations(const ASTContext& Context) const;
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
   // caller.

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=316518=316517=316518=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Oct 24 14:31:50 2017
@@ -455,6 +455,8 @@ TYPE_TRAIT_1(__is_pod, IsPOD, KEYCXX)
 TYPE_TRAIT_1(__is_polymorphic, IsPolymorphic, KEYCXX)
 TYPE_TRAIT_1(__is_trivial, IsTrivial, KEYCXX)
 TYPE_TRAIT_1(__is_union, IsUnion, KEYCXX)
+TYPE_TRAIT_1(__has_unique_object_representations,
+ HasUniqueObjectRepresentations, KEYCXX)

 // Clang-only C++ Type Traits
 TYPE_TRAIT_N(__is_trivially_constructible, IsTriviallyConstructible, KEYCXX)

Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TypeTraits.h?rev=316518=316517=316518=diff
==
--- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
+++ cfe/trunk/include/clang/Basic/TypeTraits.h Tue Oct 24 14:31:50 2017
@@ -70,7 +70,8 @@ namespace clang {
 UTT_IsUnsigned,
 UTT_IsVoid,
 UTT_IsVolatile,
-UTT_Last = UTT_IsVolatile,
+UTT_HasUniqueObjectRepresentations,
+UTT_Last = UTT_HasUniqueObjectRepresentations,
 BTT_IsBaseOf,
 BTT_IsConvertible,
 BTT_IsConvertibleTo,

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=316518=316517=316518=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Oct 24 14:31:50 2017
@@ -2166,6 +2166,152 @@ bool QualType::isTriviallyCopyableType(c
   return false;
 }

+bool QualType::unionHasUniqueObjectRepresentations(
+const ASTContext ) const {
+  assert((*this)->isUnionType() && "must be union type");
+  CharUnits UnionSize = Context.getTypeSizeInChars(*this);
+  const RecordDecl *Union = getTypePtr()->getAs()->getDecl();
+
+  for (const auto *Field : Union->fields()) {
+if (!Field->getType().hasUniqueObjectRepresentations(Context))
+  return false;
+CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
+if (FieldSize != UnionSize)
+  return false;
+  }
+  return true;
+}
+
+bool isStructEmpty(QualType Ty) {
+  

Re: r316518 - mplement __has_unique_object_representations

2017-10-26 Thread Richard Smith via cfe-commits
On 24 Oct 2017 14:32, "Erich Keane via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: erichkeane
Date: Tue Oct 24 14:31:50 2017
New Revision: 316518

URL: http://llvm.org/viewvc/llvm-project?rev=316518=rev
Log:
mplement __has_unique_object_representations

A helper builtin to facilitate implementing the
std::has_unique_object_representations type trait.

Requested here: https://bugs.llvm.org/show_bug.cgi?id=34942
Also already exists in GCC and MSVC.

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

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Basic/TypeTraits.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
clang/AST/Type.h?rev=316518=316517=316518=diff

==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Oct 24 14:31:50 2017
@@ -770,6 +770,10 @@ public:
   /// Return true if this is a trivially copyable type (C++0x
[basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;

+  /// Return true if this has unique object representations according to
(C++17
+  /// [meta.unary.prop]p9)
+  bool hasUniqueObjectRepresentations(const ASTContext ) const;


I think this would make more sense as a member of ASTContext. The Type
object generally doesn't know or care about its representation.

+
   // Don't promise in the API that anything besides 'const' can be
   // easily added.

@@ -1114,6 +1118,8 @@ public:
   QualType getAtomicUnqualifiedType() const;

 private:
+  bool unionHasUniqueObjectRepresentations(const ASTContext& Context)
const;
+  bool structHasUniqueObjectRepresentations(const ASTContext& Context)
const;
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
   // caller.

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
clang/Basic/TokenKinds.def?rev=316518=316517=316518=diff

==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Oct 24 14:31:50 2017
@@ -455,6 +455,8 @@ TYPE_TRAIT_1(__is_pod, IsPOD, KEYCXX)
 TYPE_TRAIT_1(__is_polymorphic, IsPolymorphic, KEYCXX)
 TYPE_TRAIT_1(__is_trivial, IsTrivial, KEYCXX)
 TYPE_TRAIT_1(__is_union, IsUnion, KEYCXX)
+TYPE_TRAIT_1(__has_unique_object_representations,
+ HasUniqueObjectRepresentations, KEYCXX)

 // Clang-only C++ Type Traits
 TYPE_TRAIT_N(__is_trivially_constructible, IsTriviallyConstructible,
KEYCXX)

Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
clang/Basic/TypeTraits.h?rev=316518=316517=316518=diff

==
--- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
+++ cfe/trunk/include/clang/Basic/TypeTraits.h Tue Oct 24 14:31:50 2017
@@ -70,7 +70,8 @@ namespace clang {
 UTT_IsUnsigned,
 UTT_IsVoid,
 UTT_IsVolatile,
-UTT_Last = UTT_IsVolatile,
+UTT_HasUniqueObjectRepresentations,
+UTT_Last = UTT_HasUniqueObjectRepresentations,
 BTT_IsBaseOf,
 BTT_IsConvertible,
 BTT_IsConvertibleTo,

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
Type.cpp?rev=316518=316517=316518=diff

==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Oct 24 14:31:50 2017
@@ -2166,6 +2166,152 @@ bool QualType::isTriviallyCopyableType(c
   return false;
 }

+bool QualType::unionHasUniqueObjectRepresentations(
+const ASTContext ) const {
+  assert((*this)->isUnionType() && "must be union type");
+  CharUnits UnionSize = Context.getTypeSizeInChars(*this);
+  const RecordDecl *Union = getTypePtr()->getAs()->getDecl();
+
+  for (const auto *Field : Union->fields()) {
+if (!Field->getType().hasUniqueObjectRepresentations(Context))
+  return false;
+CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
+if (FieldSize != UnionSize)
+  return false;
+  }
+  return true;
+}
+
+bool isStructEmpty(QualType Ty) {
+  assert(Ty.getTypePtr()->isStructureOrClassType() &&
+ "Must be struct or class");
+  const RecordDecl *RD = Ty.getTypePtr()->getAs()->getDecl();
+
+  if (!RD->field_empty())
+return false;
+
+  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
+return ClassDecl->isEmpty();
+  }
+
+  return true;
+}
+
+bool QualType::structHasUniqueObjectRepresentations(
+const ASTContext 

Re: [PATCH] D39317: Use -fuse-init-array if no gcc installation is found.

2017-10-26 Thread Nico Weber via cfe-commits
*the wrong thing

On Thu, Oct 26, 2017 at 12:43 PM, Nico Weber  wrote:

> I don't know of one. ruiu said he's considering making lld error out on
> mixed init_array + ctors instead of having it silently do the same thing.
>
> On Thu, Oct 26, 2017 at 12:28 PM, Shoaib Meenai via Phabricator via
> cfe-commits  wrote:
>
>> smeenai added a comment.
>>
>> > And lld currently silently mislinks inputs with .ctors sections
>>
>> Is there a bug for this? I see https://bugs.llvm.org/show_bug
>> .cgi?id=31224, which links to https://reviews.llvm.org/D35509, but
>> neither seems active.
>>
>>
>> https://reviews.llvm.org/D39317
>>
>>
>>
>> ___
>> 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] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1651
   StartFunction(FD, C.VoidTy, Fn, FI, args);
-  // Create a scope with an artificial location for the body of this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();

vsk wrote:
> JDevlieghere wrote:
> > You probably have a good reason for doing so, but why do we need 
> > {}-initialization? 
> It's just a personal idiosyncrasy. I like braced-init because it doesn't have 
> a vexing parse issue, it works with list/aggregate init, and it makes it 
> clear that operator= isn't being called.
Fair enough. Thanks for clarifying!


https://reviews.llvm.org/D39310



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


[PATCH] D39310: [CGBlocks] Improve line info in backtraces containing *_helper_block

2017-10-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Thanks! This looks generally good, I have one pending question inline.




Comment at: test/CodeGenObjC/debug-info-blocks.m:13
 
-// rdar://problem/14386148
-// Test that we don't emit bogus line numbers for the helper functions.
-// Test that we do emit scope info for the helper functions.
+// rdar://problem/32907581
+// Test that we do emit scope info for the helper functions, and that the

We nowadays usually try to avoid rdar links in anything but commit messages 
because it is not helpful information for the LLVM community. It's better to 
just describe the issue at hand (which you are doing!) or create a PR with that 
contents and link to it.



Comment at: test/CodeGenObjC/debug-info-blocks.m:20
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]

What's the location used for the ret? I think it should also be` ![[DBG_LINE]]` 
since we are not actually executing the block.


https://reviews.llvm.org/D39310



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


[PATCH] D39293: Add objcCategoryImplDecl matcher

2017-10-26 Thread Dave Lee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316670: Add objcCategoryImplDecl matcher (authored by 
kastiglione).

Changed prior to commit:
  https://reviews.llvm.org/D39293?vs=120269=120431#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39293

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -375,6 +375,7 @@
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcCategoryImplDecl);
   REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1590,7 +1590,7 @@
 )));
 }
 
-TEST(ObjCDeclMacher, CoreDecls) {
+TEST(ObjCDeclMatcher, CoreDecls) {
   std::string ObjCString =
 "@protocol Proto "
 "- (void)protoDidThing; "
@@ -1605,6 +1605,9 @@
 "{ id _ivar; } "
 "- (void)anything {} "
 "@end "
+"@implementation Thing (ABC) "
+"- (void)abc_doThing {} "
+"@end "
 ;
 
   EXPECT_TRUE(matchesObjC(
@@ -1618,6 +1621,9 @@
 objcCategoryDecl(hasName("ABC";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
+objcCategoryImplDecl(hasName("ABC";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
 objcMethodDecl(hasName("protoDidThing";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -346,6 +346,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcCategoryImplDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html;>ObjCCategoryImplDecl...
+Matches 
Objective-C category definitions.
+
+Example matches Foo (Additions)
+  @implementation Foo (Additions)
+  @end
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcImplementationDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html;>ObjCImplementationDecl...
 Matches 
Objective-C implementation declarations.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -1178,6 +1178,17 @@
   Decl,
   ObjCCategoryDecl> objcCategoryDecl;
 
+/// \brief Matches Objective-C category definitions.
+///
+/// Example matches Foo (Additions)
+/// \code
+///   @implementation Foo (Additions)
+///   @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  ObjCCategoryImplDecl> objcCategoryImplDecl;
+
 /// \brief Matches Objective-C method declarations.
 ///
 /// Example matches both declaration and definition of -[Foo method]


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -375,6 +375,7 @@
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcCategoryImplDecl);
   REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1590,7 +1590,7 @@
 )));
 }
 
-TEST(ObjCDeclMacher, CoreDecls) {
+TEST(ObjCDeclMatcher, CoreDecls) {
   std::string ObjCString =
 "@protocol Proto "
 "- (void)protoDidThing; "
@@ -1605,6 +1605,9 @@
 "{ id _ivar; } "
 "- (void)anything {} "
 "@end "
+"@implementation Thing (ABC) "
+"- (void)abc_doThing {} "
+"@end "
 ;
 
   EXPECT_TRUE(matchesObjC(
@@ -1618,6 +1621,9 @@
 objcCategoryDecl(hasName("ABC";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
+objcCategoryImplDecl(hasName("ABC";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
 objcMethodDecl(hasName("protoDidThing";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
Index: cfe/trunk/docs/LibASTMatchersReference.html

r316670 - Add objcCategoryImplDecl matcher

2017-10-26 Thread Dave Lee via cfe-commits
Author: kastiglione
Date: Thu Oct 26 08:53:37 2017
New Revision: 316670

URL: http://llvm.org/viewvc/llvm-project?rev=316670=rev
Log:
Add objcCategoryImplDecl matcher

Summary:
Add `objcCategoryImplDecl` which matches ObjC category definitions
(`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`)
which was added in D30854.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=316670=316669=316670=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Oct 26 08:53:37 2017
@@ -346,6 +346,15 @@ Example matches Foo (Additions)
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcCategoryImplDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html;>ObjCCategoryImplDecl...
+Matches 
Objective-C category definitions.
+
+Example matches Foo (Additions)
+  @implementation Foo (Additions)
+  @end
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcImplementationDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html;>ObjCImplementationDecl...
 Matches 
Objective-C implementation declarations.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=316670=316669=316670=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Oct 26 08:53:37 2017
@@ -1178,6 +1178,17 @@ const internal::VariadicDynCastAllOfMatc
   Decl,
   ObjCCategoryDecl> objcCategoryDecl;
 
+/// \brief Matches Objective-C category definitions.
+///
+/// Example matches Foo (Additions)
+/// \code
+///   @implementation Foo (Additions)
+///   @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  ObjCCategoryImplDecl> objcCategoryImplDecl;
+
 /// \brief Matches Objective-C method declarations.
 ///
 /// Example matches both declaration and definition of -[Foo method]

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=316670=316669=316670=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Thu Oct 26 08:53:37 2017
@@ -375,6 +375,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcCategoryImplDecl);
   REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=316670=316669=316670=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Thu Oct 26 08:53:37 
2017
@@ -1590,7 +1590,7 @@ TEST(ObjCMessageExprMatcher, SimpleExprs
 )));
 }
 
-TEST(ObjCDeclMacher, CoreDecls) {
+TEST(ObjCDeclMatcher, CoreDecls) {
   std::string ObjCString =
 "@protocol Proto "
 "- (void)protoDidThing; "
@@ -1605,6 +1605,9 @@ TEST(ObjCDeclMacher, CoreDecls) {
 "{ id _ivar; } "
 "- (void)anything {} "
 "@end "
+"@implementation Thing (ABC) "
+"- (void)abc_doThing {} "
+"@end "
 ;
 
   EXPECT_TRUE(matchesObjC(
@@ -1618,6 +1621,9 @@ TEST(ObjCDeclMacher, CoreDecls) {
 objcCategoryDecl(hasName("ABC";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
+objcCategoryImplDecl(hasName("ABC";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
 objcMethodDecl(hasName("protoDidThing";
   EXPECT_TRUE(matchesObjC(
 ObjCString,


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


[PATCH] D38798: [OpenMP] Support for implicit "declare target" functions - Sema patch

2017-10-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Tests?




Comment at: include/clang/Basic/LangOptions.def:193
 LANGOPT(OpenMPUseTLS  , 1, 0, "Use TLS for threadprivates or runtime 
calls")
+LANGOPT(OpenMPImplicitDeclareTarget , 1, 0, "Enable implicit declare target 
extension - marks automatically declarations and definitions with declare 
target attribute")
 LANGOPT(OpenMPIsDevice, 1, 0, "Generate code only for OpenMP target 
device")

Where is it assigned a value 1? Currently it is disabled by default (initial 
value is 0).



Comment at: include/clang/Sema/SemaInternal.h:65
+// mode.
+inline bool DeclAttrsMatchOffloadMode(const LangOptions , Decl *D,
+  bool InOpenMPDeviceRegion) {

Function should start from small letter



Comment at: include/clang/Sema/SemaInternal.h:70
+
+  return DeclAttrsMatchCUDAMode(LangOpts, D);
+}

This function should be called only we're using CUDA NVPTX as an offloading 
device. Also, this function requires that `LangOpts.CUDA` was true. Do we set 
`LangOpts.CUDA` to trues when trying to offload to CUDE devices at all? If no, 
this function is useless.



Comment at: lib/Parse/ParseOpenMP.cpp:785-789
+  // Save the declarations so that we can create the declare target group
+  // later on.
+  if (Ptr)
+for (auto *V : Ptr.get())
+  Decls.push_back(V);

Why do you need it?



Comment at: lib/Parse/ParseOpenMP.cpp:810-813
+// If we have decls generate the group so that code can be generated for it
+// later on.
+if (!Decls.empty())
+  return Actions.BuildDeclaratorGroup(Decls);

Again, why do you need it?



Comment at: lib/Sema/SemaDecl.cpp:12661-12665
+  // In case of OpenMPImplicitDeclareTarget, semantically parsed function body
+  // is visited to mark inner callexpr with OMPDeclareTargetDeclAttr attribute.
+  if (getLangOpts().OpenMP && getLangOpts().OpenMPImplicitDeclareTarget)
+checkDeclImplicitlyUsedOpenMPTargetContext(dcl);
+

I think this should be done only if the function has attached 
`OMPDeclareTargetDeclAttr` and if `!getLangOpts().IsOpenMPDevice`. Also, I 
don't like the idea of recursive scanning. It is better to add such markings on 
the fly (when trying to build the expression)



Comment at: lib/Sema/SemaOpenMP.cpp:1170
+
+/// Traverse declaration of /param D to check whether it has
+/// OMPDeclareTargetDeclAttr or not. If so, it marks definition with

`\param`



Comment at: lib/Sema/SemaOpenMP.cpp:1177-1178
+// Revealed function calls are marked with OMPDeclareTargetDeclAttr
+// attribute,
+// in case -fopenmp-implicit-declare-target extension is enabled.
+ImplicitDeviceFunctionChecker FunctionCallChecker(SemaRef);

Formatting



Comment at: lib/Sema/SemaOpenMP.cpp:1178
+// attribute,
+// in case -fopenmp-implicit-declare-target extension is enabled.
+ImplicitDeviceFunctionChecker FunctionCallChecker(SemaRef);

There is no such option yet.



Comment at: lib/Sema/SemaOpenMP.cpp:1191
+
+  if (FunctionDecl *FD = dyn_cast(D)) {
+if (FD->hasBody()) {

`auto *FD`



Comment at: lib/Sema/SemaOpenMP.cpp:1193
+if (FD->hasBody()) {
+  for (auto RI : FD->redecls()) {
+if (RI->hasAttr()) {

`const auto *RI`



Comment at: lib/Sema/SemaOpenMP.cpp:1194-1201
+if (RI->hasAttr()) {
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  Context, OMPDeclareTargetDeclAttr::MT_To);
+  D->addAttr(A);
+
+  ImplicitDeclareTargetCheck(*this, FD);
+  return;

Could you reuse the same attribute attached to one of the redeclarations? 



Comment at: lib/Sema/SemaOpenMP.cpp:1212-1214
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+  Class->addAttr(A);

Reuse the existing attribute



Comment at: lib/Sema/SemaOpenMP.cpp:1233-1235
+  if (FunctionDecl *Callee = Call->getDirectCallee()) {
+return VisitFunctionDecl(Callee);
+  }

Remove braces



Comment at: lib/Sema/SemaOpenMP.cpp:1245-1247
+  const RecordType *RT =
+  SemaRef.Context.getBaseElementType(Ty)->getAs();
+  CXXRecordDecl *RD = cast(RT->getDecl());

`const auto *RD = SemaRef.Context.getBaseElementType(Ty)->getAsCXXRecordDecl();`


Repository:
  rL LLVM

https://reviews.llvm.org/D38798



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


[PATCH] D39281: [libunwind] Express Registers_*::lastDwarfReg using _LIBUNWIND_HIGHEST_DWARF_REGISTER

2017-10-26 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

I think one source of truth is better than two.  I do find the constant's value 
a bit off in general though.  That is, the name 'HIGHEST' implies to me that it 
is the highest value used, not N + 1 as we currently define it.


https://reviews.llvm.org/D39281



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


Re: r316653 - [Tooling] A new framework for executing clang frontend actions.

2017-10-26 Thread Eric Liu via cfe-commits
It's not intended, but r316661 indeed fixed
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15 ;)

On Thu, Oct 26, 2017 at 3:16 PM Eric Liu  wrote:

> Hi Maxim,
>
> Thanks for the email! I'll look into this right now.
>
> Thanks,
> Eric
>
> On Thu, Oct 26, 2017 at 3:11 PM Maxim Kuvyrkov 
> wrote:
>
>> Hi Eric,
>>
>> This seems to have broken clang-cmake-thumbv7-a15 buildbot [*].  Would
>> you please investigate?
>>
>> Or did you fix this while I was writing this email in 316661 :-) ?
>>
>> Thank you,
>>
>> [*]
>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/12511
>>
>> --
>> Maxim Kuvyrkov
>> www.linaro.org
>>
>>
>>
>> > On Oct 26, 2017, at 1:38 PM, Eric Liu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >
>> > Author: ioeric
>> > Date: Thu Oct 26 03:38:14 2017
>> > New Revision: 316653
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=316653=rev
>> > Log:
>> > [Tooling] A new framework for executing clang frontend actions.
>> >
>> > Summary:
>> > This defines a `clang::tooling::ToolExecutor` interface that can be
>> extended to support different execution plans including standalone
>> execution on a given set of TUs or parallel execution on all TUs in a
>> codebase.
>> >
>> > In order to enable multiprocessing execution, tool actions are expected
>> to output result into a `ToolResults` interface provided by executors. The
>> `ToolResults` interface abstracts how results are stored e.g. in-memory for
>> standalone executions or on-disk for large-scale execution.
>> >
>> > New executors can be registered as `ToolExecutorPlugin`s via the
>> `ToolExecutorPluginRegistry`. CLI tools can use
>> `createExecutorFromCommandLineArgs` to create a specific registered
>> executor according to the command-line arguments.
>> >
>> > This patch also implements `StandaloneToolExecutor` which has the same
>> behavior as the current `ClangTool` interface, i.e. execute frontend
>> actions on a given set of TUs. At this point, it's simply a wrapper around
>> `ClangTool` at this point.
>> >
>> > This is still experimental but expected to replace the existing
>> `ClangTool` interface so that specific tools would not need to worry about
>> execution.
>> >
>> > Reviewers: klimek, arphaman, hokein, sammccall
>> >
>> > Reviewed By: klimek
>> >
>> > Subscribers: cfe-commits, djasper, mgorny, omtcyfz
>> >
>> > Differential Revision: https://reviews.llvm.org/D34272
>> >
>> > Added:
>> >cfe/trunk/include/clang/Tooling/Execution.h
>> >cfe/trunk/include/clang/Tooling/StandaloneExecution.h
>> >cfe/trunk/include/clang/Tooling/ToolExecutorPluginRegistry.h
>> >cfe/trunk/lib/Tooling/Execution.cpp
>> >cfe/trunk/lib/Tooling/StandaloneExecution.cpp
>> >cfe/trunk/unittests/Tooling/ExecutionTest.cpp
>> > Modified:
>> >cfe/trunk/include/clang/Tooling/CommonOptionsParser.h
>> >cfe/trunk/include/clang/Tooling/Tooling.h
>> >cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp
>> >cfe/trunk/lib/Tooling/CMakeLists.txt
>> >cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
>> >cfe/trunk/lib/Tooling/Tooling.cpp
>> >cfe/trunk/unittests/Tooling/CMakeLists.txt
>> >
>> > Modified: cfe/trunk/include/clang/Tooling/CommonOptionsParser.h
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CommonOptionsParser.h?rev=316653=316652=316653=diff
>> >
>> ==
>> > --- cfe/trunk/include/clang/Tooling/CommonOptionsParser.h (original)
>> > +++ cfe/trunk/include/clang/Tooling/CommonOptionsParser.h Thu Oct 26
>> 03:38:14 2017
>> > @@ -109,6 +109,10 @@ public:
>> > return SourcePathList;
>> >   }
>> >
>> > +  /// Returns the argument adjuster calculated from "--extra-arg" and
>> > +  //"--extra-arg-before" options.
>> > +  ArgumentsAdjuster getArgumentsAdjuster() { return Adjuster; }
>> > +
>> >   static const char *const HelpMessage;
>> >
>> > private:
>> > @@ -121,6 +125,7 @@ private:
>> >
>> >   std::unique_ptr Compilations;
>> >   std::vector SourcePathList;
>> > +  ArgumentsAdjuster Adjuster;
>> > };
>> >
>> > class ArgumentsAdjustingCompilations : public CompilationDatabase {
>> >
>> > Added: cfe/trunk/include/clang/Tooling/Execution.h
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Execution.h?rev=316653=auto
>> >
>> ==
>> > --- cfe/trunk/include/clang/Tooling/Execution.h (added)
>> > +++ cfe/trunk/include/clang/Tooling/Execution.h Thu Oct 26 03:38:14 2017
>> > @@ -0,0 +1,168 @@
>> > +//===--- Execution.h - Executing clang frontend actions -*- C++
>> -*-===//
>> > +//
>> > +// The LLVM Compiler Infrastructure
>> > +//
>> > +// This file is distributed under the University of Illinois Open
>> Source
>> > +// License. See LICENSE.TXT for details.
>> > +//
>> >
>> 

[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp:64-67
+  const auto StrLenText = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(StrLen->getSourceRange()),
+  *Result.SourceManager, getLangOpts());
+  const auto StrLenBegin = StrLenText.substr(0, StrLenText.find('(') + 1);

Please don't use `auto` as the type is not spelled out in the initialization. 
Same elsewhere as well.



Comment at: docs/ReleaseNotes.rst:63
+
+  Finds cases a value is added to or subtracted from the string in the 
parameter
+  of ``strlen()`` method instead of to the result and use its return value as 
an

aaron.ballman wrote:
> This comment is no longer accurate and should be reworded.
Still not quite right because it's talking about subtraction.



Comment at: 
docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst:6
+
+Finds cases a value is added to or subtracted from the string in the parameter
+of ``strlen()`` method instead of to the result and use its return value as an

aaron.ballman wrote:
> This comment is no longer accurate and should be reworded.
Same comment about subtraction.



Comment at: 
docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst:12
+the parameter and the result of the ``strlen()``-like function are ignored,
+similarily to cases where the whole addition is surrounded by extra 
parentheses.
+

similarly to -> as are



Comment at: 
docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst:23
+
+The suggested fix is to add ``1`` to the return value of ``strlen()`` and not
+to its argument. In the example above the fix would be

You should also add an example showing how to silence the warning with parens.


https://reviews.llvm.org/D39121



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


[libunwind] r316664 - Merging r316657: fixing libunwind tests

2017-10-26 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Thu Oct 26 06:53:36 2017
New Revision: 316664

URL: http://llvm.org/viewvc/llvm-project?rev=316664=rev
Log:
Merging r316657: fixing libunwind tests

Modified:
libunwind/branches/release_50/test/libunwind/test/config.py

Modified: libunwind/branches/release_50/test/libunwind/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_50/test/libunwind/test/config.py?rev=316664=316663=316664=diff
==
--- libunwind/branches/release_50/test/libunwind/test/config.py (original)
+++ libunwind/branches/release_50/test/libunwind/test/config.py Thu Oct 26 
06:53:36 2017
@@ -43,10 +43,11 @@ class Configuration(LibcxxConfiguration)
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBUNWIND_NO_TIMER']
-if self.get_lit_bool('enable_exceptions', True):
-self.cxx.compile_flags += ['-funwind-tables']
-else:
+if not self.get_lit_bool('enable_exceptions', True):
 self.cxx.compile_flags += ['-fno-exceptions', 
'-DLIBUNWIND_HAS_NO_EXCEPTIONS']
+# Stack unwinding tests need unwinding tables and these are not
+# generated by default on all Targets.
+self.cxx.compile_flags += ['-funwind-tables']
 if not self.get_lit_bool('enable_threads', True):
 self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS']
 self.config.available_features.add('libunwind-no-threads')


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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-10-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:499
+  functionDecl(
+  allOf(isDefinition(), unless(anyOf(isInstantiated(), isImplicit()
+  .bind("func"),

aaron.ballman wrote:
> Since we're restricting this, might as well add deleted and defaulted 
> functions to the list of `unless` items (as I think those are still 
> definitions).
Good idea!
It seems only the deleted were still matched, not defaulted.


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-10-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 120407.
lebedev.ri marked 3 inline comments as done.
lebedev.ri added a comment.

Rebased.
Tighten matchers.
Add an assert that the function we matched does have the body (the check 
analyses the function bodies, so if there is no body, there is nothing to do.)


Repository:
  rL LLVM

https://reviews.llvm.org/D36836

Files:
  LICENSE.TXT
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/FunctionCognitiveComplexityCheck.LICENSE.txt
  clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  test/clang-tidy/readability-function-cognitive-complexity.cpp

Index: test/clang-tidy/readability-function-cognitive-complexity.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-function-cognitive-complexity.cpp
@@ -0,0 +1,954 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- -config='{CheckOptions: [{key: readability-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11
+
+// any function should be checked.
+
+extern int ext_func(int x = 0);
+
+int some_func(int x = 0);
+
+static int some_other_func(int x = 0) {}
+
+template void some_templ_func(T x = 0) {}
+
+class SomeClass {
+public:
+  int *begin(int x = 0);
+  int *end(int x = 0);
+  static int func(int x = 0);
+  template void some_templ_func(T x = 0) {}
+  SomeClass() = default;
+  SomeClass(SomeClass&) = delete;
+};
+
+// nothing ever decreases cognitive complexity, so we can check all the things
+// in one go. none of the following should increase cognitive complexity:
+void unittest_false() {
+  {};
+  ext_func();
+  some_func();
+  some_other_func();
+  some_templ_func();
+  some_templ_func();
+  SomeClass::func();
+  SomeClass C;
+  C.some_templ_func();
+  C.some_templ_func();
+  C.func();
+  C.end();
+  int i = some_func();
+  i = i;
+  i++;
+  --i;
+  i < 0;
+  int j = 0 ?: 1;
+  auto k = new int;
+  delete k;
+  throw i;
+  {
+throw i;
+  }
+end:
+  return;
+}
+
+#if 1
+#define CC100
+#else
+// this macro has cognitive complexity of 100.
+// it is needed to be able to compare the testcases with the
+// reference Sonar implementation. please place it right after the first
+// CHECK-NOTES in each function
+#define CC100 if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){}if(1){}
+#endif
+
+////
+//-- B1. Increments --//
+////
+// Check that every thing listed in B1 of the specification does indeed   //
+// recieve the base increment, and that not-body does not increase nesting//
+////
+
+// break does not increase cognitive complexity.
+// only  break LABEL  does, but it is unavaliable in C or C++
+
+// continue does not increase cognitive complexity.
+// only  continue LABEL  does, but it is unavaliable in C or C++
+
+void unittest_b1_00() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_00' has cognitive complexity of 33 (threshold 0) [readability-function-cognitive-complexity]
+  CC100;
+
+  if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:9: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+
+if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+} else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting level increased to 3{{$}}
+} else {
+// CHECK-NOTES: :[[@LINE-1]]:7: note: +1, nesting level increased to 2{{$}}
+}
+  } else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:16: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+
+if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+} else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, 

[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-10-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 120408.
baloghadamsoftware added a comment.

Updated according to comments.


https://reviews.llvm.org/D39121

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
  clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.c
  test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.cpp

Index: test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-operator-in-strlen-in-alloc %t
+
+namespace std {
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+size_t strlen(const char*);
+}
+
+namespace non_std {
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+size_t strlen(const char*);
+}
+
+void bad_std_malloc_std_strlen(char *name) {
+  char *new_name = (char*) std::malloc(std::strlen(name + 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Addition operator is applied to the argument of strlen
+  // CHECK-FIXES: {{^  char \*new_name = \(char\*\) std::malloc\(}}std::strlen(name) + 1{{\);$}}
+}
+
+void ignore_non_std_malloc_std_strlen(char *name) {
+  char *new_name = (char*) non_std::malloc(std::strlen(name + 1));
+  // Ignore functions of the malloc family in custom namespaces
+}
+
+void ignore_std_malloc_non_std_strlen(char *name) {
+  char *new_name = (char*) std::malloc(non_std::strlen(name + 1));
+  // Ignore functions of the strlen family in custom namespaces
+}
Index: test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.c
===
--- /dev/null
+++ test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.c
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-operator-in-strlen-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+size_t strlen(const char*);
+size_t strnlen(const char*, size_t);
+size_t strnlen_s(const char*, size_t);
+
+typedef unsigned wchar_t;
+
+size_t wcslen(const wchar_t*);
+size_t wcsnlen(const wchar_t*, size_t);
+size_t wcsnlen_s(const wchar_t*, size_t);
+
+void bad_malloc(char *name) {
+  char *new_name = (char*) malloc(strlen(name + 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Addition operator is applied to the argument of strlen
+  // CHECK-FIXES: {{^  char \*new_name = \(char\*\) malloc\(}}strlen(name) + 1{{\);$}}
+  new_name = (char*) malloc(strnlen(name + 1, 10));
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: Addition operator is applied to the argument of strnlen
+  // CHECK-FIXES: {{^  new_name = \(char\*\) malloc\(}}strnlen(name, 10) + 1{{\);$}}
+  new_name = (char*) malloc(strnlen_s(name + 1, 10));
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: Addition operator is applied to the argument of strnlen_s
+  // CHECK-FIXES: {{^  new_name = \(char\*\) malloc\(}}strnlen_s(name, 10) + 1{{\);$}}
+}
+
+void bad_malloc_wide(wchar_t *name) {
+  wchar_t *new_name = (wchar_t*) malloc(wcslen(name + 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: Addition operator is applied to the argument of wcslen
+  // CHECK-FIXES: {{^  wchar_t \*new_name = \(wchar_t\*\) malloc\(}}wcslen(name) + 1{{\);$}}
+  new_name = (wchar_t*) malloc(wcsnlen(name + 1, 10));
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: Addition operator is applied to the argument of wcsnlen
+  // CHECK-FIXES: {{^  new_name = \(wchar_t\*\) malloc\(}}wcsnlen(name, 10) + 1{{\);$}}
+  new_name = (wchar_t*) malloc(wcsnlen_s(name + 1, 10));
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: Addition operator is applied to the argument of wcsnlen_s
+  // CHECK-FIXES: {{^  new_name = \(wchar_t\*\) malloc\(}}wcsnlen_s(name, 10) + 1{{\);$}}
+}
+
+void bad_alloca(char *name) {
+  char *new_name = (char*) alloca(strlen(name + 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Addition operator is applied to the argument of strlen
+  // CHECK-FIXES: {{^  char \*new_name = \(char\*\) alloca\(}}strlen(name) + 1{{\);$}}
+}
+
+void bad_calloc(char *name) {
+  char *new_names = (char*) calloc(2, strlen(name + 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: Addition operator is applied to the argument of strlen
+  // CHECK-FIXES: {{^  char \*new_names = \(char\*\) calloc\(2, }}strlen(name) + 1{{\);$}}
+}
+
+void bad_realloc(char * old_name, char *name) {
+  char *new_name = (char*) realloc(old_name, strlen(name + 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Addition operator is applied to the argument of strlen
+  

  1   2   >