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

2017-10-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: include/unwind.h:125
   uintptr_t private_2; // holds sp that phase1 found for phase2 to use
-#ifndef __LP64__
+#if !defined(__LP64__) && !defined(_WIN64)
   // The implementation of _Unwind_Exception uses an attribute mode on the

compnerd wrote:
> I think I would prefer that we do this generically as:
> 
> #if __POINTER_WIDTH__ == 32
It seems like GCC doesn't set `__POINTER_WIDTH__`, but both GCC and clang set 
`__SIZEOF_POINTER__`, so I can use that.



Comment at: src/AddressSpace.hpp:145
 public:
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   typedef uint64_t pint_t;

compnerd wrote:
> I think I prefer the generic:
> 
> #if __POINTER_WIDTH__ == 64
This one probably could be simplified even further by just using `intptr_t` and 
`uintptr_t`, right?



Comment at: src/UnwindRegistersRestore.S:68
 #
+#if defined(_WIN32)
+# On entry, thread_state pointer is in rcx

compnerd wrote:
> This is confusing.  Why is this `_WIN32`?  Shouldn't this be `_WIN64`?
I guess I could use that as well. I just used `_WIN32` out of habit as generic 
identifier for windows-in-whatever-form; both `_WIN32` and `_WIN64` are 
defined, and we're within an `#ifdef __x86_64__` anyway. I can change it into 
`_WIN64` for clarity.



Comment at: src/UnwindRegistersRestore.S:72
+  movq  56(%rcx), %rax # rax holds new stack pointer
+  subq  $16, %rax
+  movq  %rax, 56(%rcx)

compnerd wrote:
> Hmm, why is this `$16`?  The `$rsp` was adjusted by `$8` in the `setjmp`.
This is the exact same thing as is done right now for x86_64 on unixy systems 
already, just with different registers.

The adjustment by 16 bytes is because we store `rcx` and `rip` on the stack 
here to restore them slightly differently than the others. See the `store new 
rcx/rip on new stack`, `restore rcx later` and `rcx was saved here earlier` and 
`rip was saved here` comments below.



Comment at: src/UnwindRegistersSave.S:66
 DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+#if defined(_WIN32)
+  movq  %rax,   (%rcx)

compnerd wrote:
> Shouldn't this be `_WIN64`?
Same as the otherone; we're within `#ifdef __x86_64__`, but I can change it 
into `_WIN64` for clarity.


https://reviews.llvm.org/D38819



___
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-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 119068.
mstorsjo added a comment.

Use `__SIZEOF_POINTER__` instead of checking `__LP64__` together with `_WIN64`. 
Changed `_WIN32` into `_WIN64` within the assembly sources for 
consistency/clarity. Removed one type definition ifdef by just using 
`(u)intptr_t` instead.


https://reviews.llvm.org/D38819

Files:
  docs/index.rst
  include/unwind.h
  src/AddressSpace.hpp
  src/UnwindLevel1.c
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S

Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -63,6 +63,27 @@
 #  thread_state pointer is in rdi
 #
 DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+#if defined(_WIN64)
+  movq  %rax,   (%rcx)
+  movq  %rbx,  8(%rcx)
+  movq  %rcx, 16(%rcx)
+  movq  %rdx, 24(%rcx)
+  movq  %rdi, 32(%rcx)
+  movq  %rsi, 40(%rcx)
+  movq  %rbp, 48(%rcx)
+  movq  %rsp, 56(%rcx)
+  addq  $8,   56(%rcx)
+  movq  %r8,  64(%rcx)
+  movq  %r9,  72(%rcx)
+  movq  %r10, 80(%rcx)
+  movq  %r11, 88(%rcx)
+  movq  %r12, 96(%rcx)
+  movq  %r13,104(%rcx)
+  movq  %r14,112(%rcx)
+  movq  %r15,120(%rcx)
+  movq  (%rsp),%rdx
+  movq  %rdx,128(%rcx) # store return address as rip
+#else
   movq  %rax,   (%rdi)
   movq  %rbx,  8(%rdi)
   movq  %rcx, 16(%rdi)
@@ -82,6 +103,7 @@
   movq  %r15,120(%rdi)
   movq  (%rsp),%rsi
   movq  %rsi,128(%rdi) # store return address as rip
+#endif
   # skip rflags
   # skip cs
   # skip fs
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -65,6 +65,40 @@
 #
 # void libunwind::Registers_x86_64::jumpto()
 #
+#if defined(_WIN64)
+# On entry, thread_state pointer is in rcx
+
+  movq  56(%rcx), %rax # rax holds new stack pointer
+  subq  $16, %rax
+  movq  %rax, 56(%rcx)
+  movq  16(%rcx), %rdx  # store new rcx on new stack
+  movq  %rdx, 0(%rax)
+  movq  128(%rcx), %rdx # store new rip on new stack
+  movq  %rdx, 8(%rax)
+  # restore all registers
+  movq0(%rcx), %rax
+  movq8(%rcx), %rbx
+  # restore rcx later
+  movq   24(%rcx), %rdx
+  movq   32(%rcx), %rdi
+  movq   40(%rcx), %rsi
+  movq   48(%rcx), %rbp
+  # restore rsp later
+  movq   64(%rcx), %r8
+  movq   72(%rcx), %r9
+  movq   80(%rcx), %r10
+  movq   88(%rcx), %r11
+  movq   96(%rcx), %r12
+  movq  104(%rcx), %r13
+  movq  112(%rcx), %r14
+  movq  120(%rcx), %r15
+  # skip rflags
+  # skip cs
+  # skip fs
+  # skip gs
+  movq  56(%rcx), %rsp  # cut back rsp to new location
+  pop%rcx  # rcx was saved here earlier
+#else
 # On entry, thread_state pointer is in rdi
 
   movq  56(%rdi), %rax # rax holds new stack pointer
@@ -97,6 +131,7 @@
   # skip gs
   movq  56(%rdi), %rsp  # cut back rsp to new location
   pop%rdi  # rdi was saved here earlier
+#endif
   ret# rip was saved here
 
 
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -86,7 +86,7 @@
 // this frame.
 if (frameInfo.handler != 0) {
   __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  (__personality_routine)(uintptr_t)(frameInfo.handler);
   _LIBUNWIND_TRACE_UNWINDING(
   "unwind_phase1(ex_ojb=%p): calling personality function %p",
   (void *)exception_object, (void *)(uintptr_t)p);
@@ -181,7 +181,7 @@
 // If there is a personality routine, tell it we are unwinding.
 if (frameInfo.handler != 0) {
   __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  (__personality_routine)(uintptr_t)(frameInfo.handler);
   _Unwind_Action action = _UA_CLEANUP_PHASE;
   if (sp == exception_object->private_2) {
 // Tell personality this was the frame it marked in phase 1.
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -142,13 +142,8 @@
 /// making local unwinds fast.
 class __attribute__((visibility("hidden"))) LocalAddressSpace {
 public:
-#ifdef __LP64__
-  typedef uint64_t pint_t;
-  typedef int64_t  sint_t;
-#else
-  typedef uint32_t pint_t;
-  typedef int32_t  sint_t;
-#endif
+  typedef uintptr_t pint_t;
+  typedef intptr_t  sint_t;
   uint8_t get8(pint_t addr) {
 uint8_t val;
 memcpy(&val, (void *)addr, sizeof(val));
@@ -194,7 +189,7 @@
 };
 
 inline uintptr_t LocalAddressSpace::getP(pint_t addr) {
-#ifdef __LP64__
+#if __SIZEOF_POINTER__ == 8
   return get64(addr);
 #else
   return get32(addr);
Index: include/unwind.h
===
--- include/unwind.h
+++ include/unwind.h
@@ -122,7 +122,7 @@
 _Unwind_Exception *exc);
   uintptr_t private_1; // non-zero means forced unwind
   uintptr_t private_2; // holds sp that

[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

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

In https://reviews.llvm.org/D38704#897935, @majnemer wrote:

> I don't think we should depend on LLVM for the locking stuff. This sort of 
> infrastructure is in the same bucket as the demangler which we haven't really 
> solved.
>
> I *do* find it weird to do it this way though. I think you should have some 
> mutex functions which include read/write unlock. This way you don't need the 
> weird state.


Ok, sure. I can add a new class with an API similar to the one in LLVM, but 
only the bare essentials (i.e. exactly what libunwind has got right now, plus 
SRW locks for windows) for now.


https://reviews.llvm.org/D38704



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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

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



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:104
+
+  diag(Tok.getLocation(),
+   "calling an inherited constructor other than the copy constructor")

szdominik wrote:
> aaron.ballman wrote:
> > Insteaad of having to re-lex the physical source, can the AST should be 
> > modified to carry the information you need if it doesn't already have it? 
> > For instance, you can tell there is not initializer list by looking at 
> > `CXXConstructorDecl::getNumCtorInitializers()`.
> The getNumCtorInitializers method counts the generated initializers as well, 
> not just the manually written ones.
> My basic problem was that the AST's methods can't really distinguish the 
> generated and the manually written initializers, so it's quite complicated to 
> find the locations what we need. I found easier & more understandable if I 
> start reading the tokens.
This sounds like a deficiency with the AST that should be rectified rather than 
worked around. Going back to lexing the source can be very expensive (think 
about source files that live on a network drive, for instance) and is often 
tricky to get correct. For instance, it seems the lexing starts at the 
constructor declaration itself, so does a default argument to that copy 
constructor using `?:` cause issues? e.g., `S(const S&, int = 0 ? 1 : 2)`



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:27
+   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]
+   // CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) 
{};
+};

szdominik wrote:
> aaron.ballman wrote:
> > Don't we want the ctor-inits to be in the same order as the bases are 
> > specified?
> I think it's more readable if we put the FixIts to the beginning of the 
> expression - it's easier to check that everyting is correct & it's more 
> obvious what the changes are.
However, that then produces additional warnings because the ctor-inits are not 
in the canonical order (`-Wreorder`). See 
http://coliru.stacked-crooked.com/a/a9d77afe87618c13



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:9
+class X : public Copyable {
+   X(const X& other) : Copyable(other) {}
+   //Good code: the copy ctor call the ctor of the base class.

Please clang-format this file so it meets our usual formatting requirements.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:19
+class X2 : public Copyable2 {
+   X2(const X2& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]

Spurious semicolon.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:25
+class X3 : public Copyable, public Copyable2 {
+   X3(const X3& other): Copyable(other) {};
+   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]

Spurious semicolon (check the remainder of the file, this seems to be a common 
issue).


https://reviews.llvm.org/D33722



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-10-15 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp requested changes to this revision.
dkrupp added a comment.
This revision now requires changes to proceed.

Please fix the incompatibility between analyze-build and lib/CrossTU in the 
format of externalFnMap.txt mappfing file.




Comment at: tools/scan-build-py/libscanbuild/analyze.py:535
+ast_path = os.path.join("ast", triple_arch, path + ".ast")
+func_ast_list.append(mangled_name + "@" + triple_arch + " " + ast_path)
+return func_ast_list

There is a incompatibility between this scan-build (analyze-build actually) 
implementation and new lib/CrossTU library.

CrossTranslationUnitContext::loadExternalAST(
StringRef LookupName, StringRef CrossTUDir, StringRef IndexName)

expects the externalFnMap.txt to be in
"functionName astFilename" format.
however currently we generate here
"functionName@arch astFilename" lines.

One possible fix could be to 
create one externalFnMap.txt indexes per arch
/ast/x86_64/externalFnMap.txt
/ast/ppc64/externalFnMap.txt
etc.
and call clang analyze with the architecture specific map directory: 
e.g. ctu-dir=/ast/x86_64

This would then work if the "to-be-analyzed" source-code is cross-compiled into 
multiple architectures.

Would be useful to add a test-case too to check if the map file and ctu-dir 
content generated by analyze-build is compatible.



Comment at: tools/scan-build-py/libscanbuild/analyze.py:585
++ [opts['file']]
+triple_arch = get_triple_arch(cmd, cwd)
+generate_ast(triple_arch)

Maybe we could use the full target-triple for distinguishing the AST binaries, 
not only the architecture part. The sys part for example is probably important 
too and a "win32" AST may not be compatible with a "linux" AST.


https://reviews.llvm.org/D30691



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


r315856 - Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a propos

2017-10-15 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Sun Oct 15 08:01:42 2017
New Revision: 315856

URL: http://llvm.org/viewvc/llvm-project?rev=315856&view=rev
Log:
Add -f[no-]double-square-bracket-attributes as new driver options to control 
use of [[]] attributes in all language modes. This is the initial 
implementation of WG14 N2165, which is a proposal to add [[]] attributes to 
C2x, but also allows you to enable these attributes in C++98, or disable them 
in C++11 or later.

Added:
cfe/trunk/test/Misc/ast-dump-c-attr.c
cfe/trunk/test/Parser/c2x-attributes.c
cfe/trunk/test/Parser/c2x-attributes.m
cfe/trunk/test/Sema/attr-deprecated-c2x.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/Attributes.h
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/AttributeList.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=315856&r1=315855&r2=315856&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sun Oct 15 08:01:42 2017
@@ -210,6 +210,10 @@ class CXX11 : Spelling {
+  string Namespace = namespace;
+}
+
 class Keyword : Spelling;
 class Pragma : Spelling {
   string Namespace = namespace;
@@ -958,7 +962,7 @@ def RenderScriptKernel : Attr {
 
 def Deprecated : InheritableAttr {
   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
-   CXX11<"","deprecated", 201309>];
+   CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
   let Args = [StringArgument<"Message", 1>,
   // An optional string argument that enables us to provide a
   // Fix-It.

Modified: cfe/trunk/include/clang/Basic/Attributes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attributes.h?rev=315856&r1=315855&r2=315856&view=diff
==
--- cfe/trunk/include/clang/Basic/Attributes.h (original)
+++ cfe/trunk/include/clang/Basic/Attributes.h Sun Oct 15 08:01:42 2017
@@ -26,6 +26,8 @@ enum class AttrSyntax {
   Microsoft,
   // Is the identifier known as a C++-style attribute?
   CXX,
+  // Is the identifier known as a C-style attribute?
+  C,
   // Is the identifier known as a pragma attribute?
   Pragma
 };

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=315856&r1=315855&r2=315856&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Sun Oct 15 08:01:42 2017
@@ -137,6 +137,8 @@ LANGOPT(GNUAsm, 1, 1, "GNU-s
 LANGOPT(CoroutinesTS  , 1, 0, "C++ coroutines TS")
 LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of template 
template arguments")
 
+LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for 
all language standard modes")
+
 BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
 LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")
 LANGOPT(Blocks, 1, 0, "blocks extension to C")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=315856&r1=315855&r2=315856&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sun Oct 15 08:01:42 2017
@@ -606,6 +606,13 @@ def fastf : Flag<["-"], "fastf">, Group<
 def fast : Flag<["-"], "fast">, Group;
 def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, 
Group;
 
+def fdouble_square_bracket_attributes : Flag<[ "-" ], 
"fdouble-square-bracket-attributes">,
+  Group, Flags<[DriverOption, CC1Option]>,
+  HelpText<"Enable '[[]]' attributes in all C and C++ language modes">;
+def fno_double_square_bracket_attributes : Flag<[ "-" ], 
"fno-fdouble-square-bracket-attributes">,
+  Group, Flags<[DriverOption]>,
+  HelpText<"Disable '[[]]' attributes in all C and C++ language modes">;
+
 def fautolink : Flag <["-"], "fautolink">, Group;
 def fno_autolink : Flag <["-"], "fno-autolink">, Group,
   Flags<[DriverOption, CC1Option]>,

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=315856&

[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)

2017-10-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

I've commit in r315856, thank you for the reviews!




Comment at: ../llvm/tools/clang/include/clang/Driver/Options.td:609-616
+def fdouble_square_bracket_attributes
+: Flag<[ "-" ], "fdouble-square-bracket-attributes">,
+  Group, Flags<[ DriverOption, CC1Option ]>,
+  HelpText<"Enable '[[]]' attributes in all C and C++ language modes">;
+def fno_double_square_bracket_attributes
+: Flag<[ "-" ], "fno-fdouble-square-bracket-attributes">,
+  Group, Flags<[ DriverOption ]>,

rsmith wrote:
> This is not formatted how we normally format tablegen files.
I'll fix it up -- I think this was clang-formatted.



Comment at: ../llvm/tools/clang/lib/Parse/ParseDecl.cpp:4422
+if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
   if (!getLangOpts().CPlusPlus1z)
 Diag(Tok.getLocation(), diag::warn_cxx14_compat_attribute)

rsmith wrote:
> Is this warning appropriate in C? I don't recall whether your proposal 
> permits attributes on enumerators or not.
> 
> ... in fact, this warning is completely wrong. Fixed in r315784. This should 
> presumably be guarded by an `if (getLangOpts().CPlusPlus)` with your change, 
> though.
> Is this warning appropriate in C? I don't recall whether your proposal 
> permits attributes on enumerators or not.

Yes, my proposal allows attributes on enumerators. I will fix up with your 
merge, thanks!



Comment at: ../llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3856-3857
+  const LangOptions &LO = getLangOpts();
+  bool AsCXX =
+  LO.CPlusPlus11 || (LO.DoubleSquareBracketAttributes && LO.CPlusPlus);
+  AttributeList::Syntax Syntax =

rsmith wrote:
> I think you can simplify this to `LO.CPlusPlus`, because 
> `LO.DoubleSquareBracketAttributes` should always be `true` if we get here. 
> (Right?)
Correct, I've simplified.


https://reviews.llvm.org/D37436



___
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-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

(I've not had the chance to complete a full review, but these are some thoughts 
thus far.)




Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:76
+  // So either static out-of-line or non-static in-line.
+  const std::array Msgs = {{
+  // FIXME: these messages somehow trigger an assertion:

I don't think this needs to be a member of the class -- it can be a `static 
const char *[]` at file scope, can it not?



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:77
+  const std::array Msgs = {{
+  // FIXME: these messages somehow trigger an assertion:
+  // Fix conflicts with existing fix! The new replacement overlaps with an

Are you intending to fix this -- that sounds rather serious?



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:97
+
+  /// The helper struct used to record one increment occurence, with all the
+  /// details nessesary

occurence -> occurrence



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:98
+  /// The helper struct used to record one increment occurence, with all the
+  /// details nessesary
+  struct Detail final {

Missing a full stop.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:99
+  /// details nessesary
+  struct Detail final {
+const SourceLocation Loc; /// What caused the increment?

I don't think the `final` adds value here.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:102
+const unsigned short Nesting; /// How deeply nested is Loc located?
+const Criteria C : 3; /// The criteria of the increment
+

Why is this turned into a bit-field? If that is important, it should be of type 
`unsigned` to prevent differences between compilers (MSVC treats bit-fields 
differently than GCC and Clang).



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:118
+
+  unsigned MsgId;   /// The id of the message to output
+  unsigned short Increment; /// How much of an increment?

We use `//` instead of `///` unless we're specifically documenting something 
for doxygen.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:139
+  };
+  // static_assert(sizeof(Detail) <= 8, "it's best to keep the size minimal");
+

Why is this commented out?



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:150
+
+  /// The grand total Cognitive Complexity of the function
+  unsigned Total = 0;

Missing full-stop (here and elsewhere, I'll stop commenting on them).



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:191
+  Details.emplace_back(Loc, Nesting, C);
+  const Detail &D(Details.back());
+

Please use `=` instead of `()` here.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:210
+  /// new sequence, thus it is a stack.
+  std::stack,
+ SmallVector, 4>>

What's with the comment?



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:215-218
+#define TraverseWithIncreasedNestingLevel(CLASS, Node) 
\
+  ++CurrentNestingLevel;   
\
+  ShouldContinue = Base::Traverse##CLASS(Node);
\
+  --CurrentNestingLevel;

I don't think this macro adds clarify for its two uses.


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


Re: r315856 - Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a pr

2017-10-15 Thread Saleem Abdulrasool via cfe-commits
On Sun, Oct 15, 2017 at 8:01 AM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Sun Oct 15 08:01:42 2017
> New Revision: 315856
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315856&view=rev
> Log:
> Add -f[no-]double-square-bracket-attributes as new driver options to
> control use of [[]] attributes in all language modes. This is the initial
> implementation of WG14 N2165, which is a proposal to add [[]] attributes to
> C2x, but also allows you to enable these attributes in C++98, or disable
> them in C++11 or later.
>

Since this is a new option and one that GCC doesn't have ... it seems
pretty cumbersome to write.  Would you be open to renaming this?  Perhaps
something like `-fgeneralized-attributes` which IIRC was the name for the
C++11 specification.


> Added:
> cfe/trunk/test/Misc/ast-dump-c-attr.c
> cfe/trunk/test/Parser/c2x-attributes.c
> cfe/trunk/test/Parser/c2x-attributes.m
> cfe/trunk/test/Sema/attr-deprecated-c2x.c
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/Attributes.h
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Lex/Lexer.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/AttributeList.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Attr.td?rev=315856&r1=315855&r2=315856&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Sun Oct 15 08:01:42 2017
> @@ -210,6 +210,10 @@ class CXX11string Namespace = namespace;
>int Version = version;
>  }
> +class C2x : Spelling {
> +  string Namespace = namespace;
> +}
> +
>  class Keyword : Spelling;
>  class Pragma : Spelling {
>string Namespace = namespace;
> @@ -958,7 +962,7 @@ def RenderScriptKernel : Attr {
>
>  def Deprecated : InheritableAttr {
>let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
> -   CXX11<"","deprecated", 201309>];
> +   CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
>let Args = [StringArgument<"Message", 1>,
>// An optional string argument that enables us to provide a
>// Fix-It.
>
> Modified: cfe/trunk/include/clang/Basic/Attributes.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Attributes.h?rev=315856&r1=315855&r2=315856&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Attributes.h (original)
> +++ cfe/trunk/include/clang/Basic/Attributes.h Sun Oct 15 08:01:42 2017
> @@ -26,6 +26,8 @@ enum class AttrSyntax {
>Microsoft,
>// Is the identifier known as a C++-style attribute?
>CXX,
> +  // Is the identifier known as a C-style attribute?
> +  C,
>// Is the identifier known as a pragma attribute?
>Pragma
>  };
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/LangOptions.def?rev=315856&r1=315855&r2=315856&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Sun Oct 15 08:01:42 2017
> @@ -137,6 +137,8 @@ LANGOPT(GNUAsm, 1, 1, "GNU-s
>  LANGOPT(CoroutinesTS  , 1, 0, "C++ coroutines TS")
>  LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of
> template template arguments")
>
> +LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes
> extension for all language standard modes")
> +
>  BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static
> initializers")
>  LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")
>  LANGOPT(Blocks, 1, 0, "blocks extension to C")
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=315856&r1=315855&r2=315856&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Sun Oct 15 08:01:42 2017
> @@ -606,6 +606,13 @@ def fastf : Flag<["-"], "fastf">, Group<
>  def fast : Flag<["-"], "fast">, Group;
>  def fasynchronous_unwind_tables : Flag<["-"],
> "fasynchronous-unwind-tables">, Group;
>
> +def fdouble_square_bracket_attributes : Flag<[ "-" ],
> "fdouble-square-bracket-attributes

Re: r315856 - Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a pr

2017-10-15 Thread Aaron Ballman via cfe-commits
On Sun, Oct 15, 2017 at 12:52 PM, Saleem Abdulrasool
 wrote:
>
>
> On Sun, Oct 15, 2017 at 8:01 AM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Sun Oct 15 08:01:42 2017
>> New Revision: 315856
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315856&view=rev
>> Log:
>> Add -f[no-]double-square-bracket-attributes as new driver options to
>> control use of [[]] attributes in all language modes. This is the initial
>> implementation of WG14 N2165, which is a proposal to add [[]] attributes to
>> C2x, but also allows you to enable these attributes in C++98, or disable
>> them in C++11 or later.
>
>
> Since this is a new option and one that GCC doesn't have ... it seems pretty
> cumbersome to write.  Would you be open to renaming this?  Perhaps something
> like `-fgeneralized-attributes` which IIRC was the name for the C++11
> specification.

I have no problems renaming it, but I'm not keen on "generalized". The
name used in the WG21 proposal papers was "general attributes" (sort
of, the term was used once in the paper, and not in the title), but I
don't think I've seen any community consensus on calling them that.
While the current name is a mouthful, it's at least descriptive as to
which of the four attribute syntaxes we're talking about.

~Aaron
___
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-15 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: docs/index.rst:55
 NetBSD   x86_64   Clang, GCC   DWARF CFI
-Windows  i386 ClangDWARF CFI
+Windows  i386, x86_64 ClangDWARF CFI
    

Based on your comments above I assume this supports GCC also ?
If so, replace
`Windows  i386, x86_64 ClangDWARF CFI`
with
`Windows  i386, x86_64 Clang, GCC   DWARF CFI`

This is exciting stuff Martin :)


https://reviews.llvm.org/D38819



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


r315864 - [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via cfe-commits
Author: martell
Date: Sun Oct 15 10:27:58 2017
New Revision: 315864

URL: http://llvm.org/viewvc/llvm-project?rev=315864&view=rev
Log:
[driver] [cl] Add/fix c++17/c++latest

Patch by: daxpedda

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=315864&r1=315863&r2=315864&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sun Oct 15 10:27:58 2017
@@ -4075,7 +4075,8 @@ void Clang::ConstructJob(Compilation &C,
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=315864&r1=315863&r2=315864&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Sun Oct 15 10:27:58 2017
@@ -520,8 +520,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck 
-check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"


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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315864: [driver] [cl] Add/fix c++17/c++latest (authored by 
martell).

Changed prior to commit:
  https://reviews.llvm.org/D38123?vs=116154&id=119086#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38123

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -520,8 +520,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck 
-check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4075,7 +4075,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -520,8 +520,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4075,7 +4075,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Landed, @rnk I missed this message in my travels from Ireland back to Mountain 
View.
Just catching up with everything now :)


Repository:
  rL LLVM

https://reviews.llvm.org/D38123



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315865: MACHO: ld64.lld alias for the MACHO LLD target 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D38290?vs=116801&id=119087#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38290

Files:
  lld/trunk/tools/lld/CMakeLists.txt
  lld/trunk/tools/lld/lld.cpp


Index: lld/trunk/tools/lld/CMakeLists.txt
===
--- lld/trunk/tools/lld/CMakeLists.txt
+++ lld/trunk/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: lld/trunk/tools/lld/lld.cpp
===
--- lld/trunk/tools/lld/lld.cpp
+++ lld/trunk/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 


Index: lld/trunk/tools/lld/CMakeLists.txt
===
--- lld/trunk/tools/lld/CMakeLists.txt
+++ lld/trunk/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: lld/trunk/tools/lld/lld.cpp
===
--- lld/trunk/tools/lld/lld.cpp
+++ lld/trunk/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315867 - Driver: use ld64.lld when -fuse-ld=lld for darwin

2017-10-15 Thread Martell Malone via cfe-commits
Author: martell
Date: Sun Oct 15 10:53:45 2017
New Revision: 315867

URL: http://llvm.org/viewvc/llvm-project?rev=315867&view=rev
Log:
Driver: use ld64.lld when -fuse-ld=lld for darwin

When using lld on macOS the current level of detection between ld and
ld64 forces us to rename lld to ld.

For ELF targets we have the ld.lld alias so for MACHO we should have
ld64.lld so we can use lld without replacing the system compiler.

This also solves the additional issue of cross compiling for MACHO
where renaming lld to ld with only target ELF.

This is the clang driver component change to use this new alias.

Reviewers: ruiu, rnk

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

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=315867&r1=315866&r2=315867&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Sun Oct 15 10:53:45 2017
@@ -390,7 +390,11 @@ std::string ToolChain::GetLinkerPath() c
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if (Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


___
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-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: docs/index.rst:55
 NetBSD   x86_64   Clang, GCC   DWARF CFI
-Windows  i386 ClangDWARF CFI
+Windows  i386, x86_64 ClangDWARF CFI
    

martell wrote:
> Based on your comments above I assume this supports GCC also ?
> If so, replace
> `Windows  i386, x86_64 ClangDWARF CFI`
> with
> `Windows  i386, x86_64 Clang, GCC   DWARF CFI`
> 
> This is exciting stuff Martin :)
I'm not sure if gcc supports dwarf exceptions on x86_64 or how much hacking is 
needed to enable it; the comment about gcc for `__SIZEOF_POINTER__` was because 
it was in generic code that could be used by gcc in one of the existing cases 
where gcc actually is supported.


https://reviews.llvm.org/D38819



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


r315868 - Fix test case regresstion from rL315864

2017-10-15 Thread Martell Malone via cfe-commits
Author: martell
Date: Sun Oct 15 11:01:28 2017
New Revision: 315868

URL: http://llvm.org/viewvc/llvm-project?rev=315868&view=rev
Log:
Fix test case regresstion from rL315864

The patch should have been checking against STDCXX17 not STDCXX14.

Modified:
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=315868&r1=315867&r2=315868&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Sun Oct 15 11:01:28 2017
@@ -521,7 +521,7 @@
 // STDCXX14: -std=c++14
 
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
-// STDCXX14: -std=c++17
+// STDCXX17: -std=c++17
 
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXXLATEST %s
 // STDCXXLATEST: -std=c++2a


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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: cfe/trunk/test/Driver/cl-options.c:524
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+

This was incorrect, it should have been `STDCXX17`.
I fixed this is rL315868


Repository:
  rL LLVM

https://reviews.llvm.org/D38123



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


[PATCH] D38678: [Sema] Warn about unused variables if we can constant evaluate the initializer.

2017-10-15 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

For the record, this found 5 actual useless variables in Firefox code.


Repository:
  rL LLVM

https://reviews.llvm.org/D38678



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-15 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315871: Convert clang::LangAS to a strongly typed enum 
(authored by arichardson).

Changed prior to commit:
  https://reviews.llvm.org/D38816?vs=118915&id=119090#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38816

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/AddressSpaces.h
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
  cfe/trunk/lib/Basic/Targets/AMDGPU.h
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGValue.h
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/CodeGenTypeCache.h
  cfe/trunk/lib/CodeGen/ConstantEmitter.h
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaDeclObjC.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/tools/libclang/CXType.cpp

Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -403,7 +403,10 @@
   if (T.getAddressSpace() >= LangAS::FirstTargetAddressSpace) {
 return T.getQualifiers().getAddressSpaceAttributePrintValue();
   }
-  return T.getAddressSpace();
+  // FIXME: this function returns either a LangAS or a target AS
+  // Those values can overlap which makes this function rather unpredictable
+  // for any caller
+  return (unsigned)T.getAddressSpace();
 }
 
 CXString clang_getTypedefName(CXType CT) {
Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -328,32 +328,34 @@
   }
 
   bool hasAddressSpace() const { return Mask & AddressSpaceMask; }
-  unsigned getAddressSpace() const { return Mask >> AddressSpaceShift; }
+  LangAS getAddressSpace() const {
+return static_cast(Mask >> AddressSpaceShift);
+  }
   bool hasTargetSpecificAddressSpace() const {
-return getAddressSpace() >= LangAS::FirstTargetAddressSpace;
+return isTargetAddressSpace(getAddressSpace());
   }
   /// Get the address space attribute value to be printed by diagnostics.
   unsigned getAddressSpaceAttributePrintValue() const {
 auto Addr = getAddressSpace();
 // This function is not supposed to be used with language specific
 // address spaces. If that happens, the diagnostic message should consider
 // printing the QualType instead of the address space value.
-assert(Addr == 0 || hasTargetSpecificAddressSpace());
-if (Addr)
-  return Addr - LangAS::FirstTargetAddressSpace;
+assert(Addr == LangAS::Default || hasTargetSpecificAddressSpace());
+if (Addr != LangAS::Default)
+  return toTargetAddressSpace(Addr);
 // TODO: The diagnostic messages where Addr may be 0 should be fixed
 // since it cannot differentiate the situation where 0 denotes the default
 // address space or user specified __attribute__((address_space(0))).
 return 0;
   }
-  void setAddressSpace(unsigned space) {
-assert(space <= MaxAddressSpace);
+  void setAddressSpace(LangAS space) {
+assert((unsigned)space <= MaxAddressSpace);
 Mask = (Mask & ~AddressSpaceMask)
  | (((uint32_t) space) << AddressSpaceShift);
   }
-  void removeAddressSpace() { setAddressSpace(0); }
-  void addAddressSpace(unsigned space) {
-assert(space);
+  void removeAddressSpace() { setAddressSpace(LangAS::Default); }
+  void addAddressSpace(LangAS space) {
+assert(space != LangAS::Default);
 setAddressSpace(space);
   }
 
@@ -1005,7 +1007,7 @@
   }
 
   /// Return the address space of this type.
-  inline unsigned getAddressSpace() const;
+  inline LangAS getAddressSpace() const;
 
   /// Returns gc attribute of this type.
   inline Qualifiers::GC getObjCGCAttr() const;
@@ -1230,7 +1232,7 @@
   }
 
   bool hasAddressSpace() const { return Quals.hasAddressSpace(); }
-  unsigned getAddressSpace() const { return Quals.getAddressSpace(); }
+  LangAS getAddressSpace() const { return Quals.getAddressSpace(); }
 
   const Type *getBaseType() const { return BaseType; }
 
@@ -5654,7 +5656,7 @@
 }
 
 /// Return the address space of this type.
-inline unsigned QualType::getAddressSpace() co

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

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



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:76
+  // So either static out-of-line or non-static in-line.
+  const std::array Msgs = {{
+  // FIXME: these messages somehow trigger an assertion:

aaron.ballman wrote:
> I don't think this needs to be a member of the class -- it can be a `static 
> const char *[]` at file scope, can it not?
It seemed  fitting to keep it in the class, because it is directly related to 
the previous `enum`.
But i guess i agree, it is better to move it back out of the class...



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:77
+  const std::array Msgs = {{
+  // FIXME: these messages somehow trigger an assertion:
+  // Fix conflicts with existing fix! The new replacement overlaps with an

aaron.ballman wrote:
> Are you intending to fix this -- that sounds rather serious?
I do intend to fix it, as soon as i'm aware of how to fix this.
Specifically, https://reviews.llvm.org/D36836#889350
```
Question:
Is it expected that clang-tidy somehow parses the DiagnosticIDs::Note's as 
FixIt's, and thus fails with the following assert:
...
```
I.e. what is the proper way to fix this, should i change the message, or change 
the code not to parse the message as FixIt?



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:99
+  /// details nessesary
+  struct Detail final {
+const SourceLocation Loc; /// What caused the increment?

aaron.ballman wrote:
> I don't think the `final` adds value here.
I don't think it hurts, either?
I *personally* prefer to specify it always, and remove if subclassing is needed.
But if you insist i can certainly drop it



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:102
+const unsigned short Nesting; /// How deeply nested is Loc located?
+const Criteria C : 3; /// The criteria of the increment
+

aaron.ballman wrote:
> Why is this turned into a bit-field? If that is important, it should be of 
> type `unsigned` to prevent differences between compilers (MSVC treats 
> bit-fields differently than GCC and Clang).
The comment right after this member variable should have explained it:
```
/// Criteria C is a bitfield. Even though Criteria is an unsigned char; and
/// only using 3 bits will still result in padding, the fact that it is a
/// bitfield is a reminder that it is important to min(sizeof(Detail))
```
It is already `unsigned`:
```
enum Criteria : unsigned char {
```



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:150
+
+  /// The grand total Cognitive Complexity of the function
+  unsigned Total = 0;

aaron.ballman wrote:
> Missing full-stop (here and elsewhere, I'll stop commenting on them).
Poured-in some full-stops. I doubt i caught all the places / did not add it in 
wrong places.



Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:210
+  /// new sequence, thus it is a stack.
+  std::stack,
+ SmallVector, 4>>

aaron.ballman wrote:
> What's with the comment?
An ugly attempt to align the same substring `Optional` 
on both lines.
I can either drop the comment, or do `using OBO = 
Optional;` and use it.


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-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 119091.
lebedev.ri marked 9 inline comments as done and an inline comment as not done.
lebedev.ri added a comment.

@aaron.ballman, thank you for the review!

Rebased, addressed most of review notes.


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,952 @@
+// 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) {}
+};
+
+// 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, nesting level increased to 3{{$}}
+} else {
+// CHECK-NOTES: :[[@LINE-1]]:7: note: +1, nesting level increased to 2{{$}}
+  

[PATCH] D38704: [libunwind] Abstract rwlocks into a class, provide a SRW lock implementation for windows

2017-10-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 119094.
mstorsjo retitled this revision from "[libunwind] Emulate pthread rwlocks via 
SRW locks for windows" to "[libunwind] Abstract rwlocks into a class, provide a 
SRW lock implementation for windows".
mstorsjo edited the summary of this revision.
mstorsjo added reviewers: majnemer, zturner.
mstorsjo removed subscribers: majnemer, zturner.
mstorsjo added a comment.
Herald added a subscriber: mgorny.

Instead of trying to emulate the pthread rwlocks api with windows 
implementations, add a RWMutex class (with an interface similar to SmartRWMutex 
from LLVM) with inline implementations, which can either be no-ops (for 
no-threads configurations), implemented with SRW locks for windows or pthreads.


https://reviews.llvm.org/D38704

Files:
  src/CMakeLists.txt
  src/RWMutex.hpp
  src/UnwindCursor.hpp
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -93,20 +93,15 @@
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
 #endif
 
-#if defined(_LIBUNWIND_HAS_NO_THREADS)
-  // only used with pthread calls, not needed for the single-threaded builds
-  #define _LIBUNWIND_LOG_NON_ZERO(x)
+#if defined(NDEBUG)
+  #define _LIBUNWIND_LOG_IF_FALSE(x) x
 #else
-  #if defined(NDEBUG)
-#define _LIBUNWIND_LOG_NON_ZERO(x) x
-  #else
-#define _LIBUNWIND_LOG_NON_ZERO(x) \
-  do { \
-int _err = x;  \
-if (_err != 0) \
-  _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__);   \
-  } while (0)
-  #endif
+  #define _LIBUNWIND_LOG_IF_FALSE(x)   \
+do {   \
+  bool _ret = x;   \
+  if (!_ret)   \
+_LIBUNWIND_LOG("" #x " failed in %s", __FUNCTION__);   \
+} while (0)
 #endif
 
 // Macros that define away in non-Debug builds
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -16,9 +16,6 @@
 #include 
 #include 
 #include 
-#ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
-#endif
 #include 
 
 #ifdef __APPLE__
@@ -34,6 +31,7 @@
 #include "EHHeaderParser.hpp"
 #include "libunwind.h"
 #include "Registers.hpp"
+#include "RWMutex.hpp"
 #include "Unwind-EHABI.h"
 
 namespace libunwind {
@@ -62,9 +60,7 @@
 
   // These fields are all static to avoid needing an initializer.
   // There is only one instance of this class per process.
-#ifndef _LIBUNWIND_HAS_NO_THREADS
-  static pthread_rwlock_t _lock;
-#endif
+  static RWMutex _lock;
 #ifdef __APPLE__
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
@@ -91,10 +87,8 @@
 template 
 typename DwarfFDECache::entry DwarfFDECache::_initialBuffer[64];
 
-#ifndef _LIBUNWIND_HAS_NO_THREADS
 template 
-pthread_rwlock_t DwarfFDECache::_lock = PTHREAD_RWLOCK_INITIALIZER;
-#endif
+RWMutex DwarfFDECache::_lock;
 
 #ifdef __APPLE__
 template 
@@ -104,24 +98,24 @@
 template 
 typename A::pint_t DwarfFDECache::findFDE(pint_t mh, pint_t pc) {
   pint_t result = 0;
-  _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_rdlock(&_lock));
+  _LIBUNWIND_LOG_IF_FALSE(_lock.lock_shared());
   for (entry *p = _buffer; p < _bufferUsed; ++p) {
 if ((mh == p->mh) || (mh == 0)) {
   if ((p->ip_start <= pc) && (pc < p->ip_end)) {
 result = p->fde;
 break;
   }
 }
   }
-  _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock));
+  _LIBUNWIND_LOG_IF_FALSE(_lock.unlock_shared());
   return result;
 }
 
 template 
 void DwarfFDECache::add(pint_t mh, pint_t ip_start, pint_t ip_end,
pint_t fde) {
 #if !defined(_LIBUNWIND_NO_HEAP)
-  _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_wrlock(&_lock));
+  _LIBUNWIND_LOG_IF_FALSE(_lock.lock());
   if (_bufferUsed >= _bufferEnd) {
 size_t oldSize = (size_t)(_bufferEnd - _buffer);
 size_t newSize = oldSize * 4;
@@ -145,13 +139,13 @@
 _registeredForDyldUnloads = true;
   }
 #endif
-  _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock));
+  _LIBUNWIND_LOG_IF_FALSE(_lock.unlock());
 #endif
 }
 
 template 
 void DwarfFDECache::removeAllIn(pint_t mh) {
-  _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_wrlock(&_lock));
+  _LIBUNWIND_LOG_IF_FALSE(_lock.lock());
   entry *d = _buffer;
   for (const entry *s = _buffer; s < _bufferUsed; ++s) {
 if (s->mh != mh) {
@@ -161,7 +155,7 @@
 }
   }
   _bufferUsed = d;
-  _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock));
+  _LIBUNWIND_LOG_IF_FALSE(_lock.unlock());
 }

[PATCH] D38796: [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info

2017-10-15 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

With this patch applied we fail on bootstrapping stages of release builds 
(meaning enabled TBAA).

The reason is that for some casts we do not generate TBAA info that corresponds 
to the target type and leave them with TBAA info for the cast's operand 
expression. This results in invalid TBAA access descriptors. For example, for 
the following store we generate a TBAA descriptor with ##S## as the base type 
and ##unsigned## as the access type while the expected descriptor shall have 
##V## as the base type and ##unsigned## as the access type.

  struct V {
unsigned n;
  };
  
  struct S {
char bytes[4];
  };
  
  void foo(S *p) {
((V*)p->bytes)->n = 0;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D38796



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


[PATCH] D38796: [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info

2017-10-15 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 119089.
kosarev edited the summary of this revision.
kosarev added a comment.

- Fixed handling of explicit casts.
- Added a test case.


https://reviews.llvm.org/D38796

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/CodeGenTBAA.h
  test/CodeGen/tbaa-cast.cpp

Index: test/CodeGen/tbaa-cast.cpp
===
--- test/CodeGen/tbaa-cast.cpp
+++ test/CodeGen/tbaa-cast.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
+// RUN: -emit-llvm -o - | FileCheck %s
+//
+// Check that we generate correct TBAA information for lvalues constructed
+// with use of casts.
+
+struct V {
+  unsigned n;
+};
+
+struct S {
+  char bytes[4];
+};
+
+void foo(S *p) {
+// CHECK-LABEL: _Z3fooP1S
+// CHECK: store i32 5, {{.*}}, !tbaa [[TAG_V_n:!.*]]
+  ((V*)p->bytes)->n = 5;
+}
+
+// CHECK-DAG: [[TAG_V_n]] = !{[[TYPE_V:!.*]], [[TYPE_int:!.*]], i64 0}
+// CHECK-DAG: [[TYPE_V]] = !{!"_ZTS1V", !{{.*}}, i64 0}
+// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0}
Index: lib/CodeGen/CodeGenTBAA.h
===
--- lib/CodeGen/CodeGenTBAA.h
+++ lib/CodeGen/CodeGenTBAA.h
@@ -47,6 +47,12 @@
 : TBAAAccessInfo(/* AccessType= */ nullptr)
   {}
 
+  bool operator==(const TBAAAccessInfo &Other) const {
+return BaseType == Other.BaseType &&
+   AccessType == Other.AccessType &&
+   Offset == Other.Offset;
+  }
+
   /// BaseType - The base/leading access type. May be null if this access
   /// descriptor represents an access that is not considered to be an access
   /// to an aggregate or union member.
@@ -136,6 +142,11 @@
   /// getMayAliasAccessInfo - Get TBAA information that represents may-alias
   /// accesses.
   TBAAAccessInfo getMayAliasAccessInfo();
+
+  /// mergeTBAAInfoForCast - Get merged TBAA information for the purpose of
+  /// type casts.
+  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+  TBAAAccessInfo TargetInfo);
 };
 
 }  // end namespace CodeGen
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -309,3 +309,11 @@
 TBAAAccessInfo CodeGenTBAA::getMayAliasAccessInfo() {
   return TBAAAccessInfo(getChar());
 }
+
+TBAAAccessInfo CodeGenTBAA::mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+ TBAAAccessInfo TargetInfo) {
+  TBAAAccessInfo MayAliasInfo = getMayAliasAccessInfo();
+  if (SourceInfo == MayAliasInfo || TargetInfo == MayAliasInfo)
+return MayAliasInfo;
+  return TargetInfo;
+}
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -677,6 +677,11 @@
   /// may-alias accesses.
   TBAAAccessInfo getTBAAMayAliasAccessInfo();
 
+  /// mergeTBAAInfoForCast - Get merged TBAA information for the purposes of
+  /// type casts.
+  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+  TBAAAccessInfo TargetInfo);
+
   bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
 
   bool isPaddedAtomicType(QualType type);
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -612,6 +612,13 @@
   return TBAA->getMayAliasAccessInfo();
 }
 
+TBAAAccessInfo CodeGenModule::mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+   TBAAAccessInfo TargetInfo) {
+  if (!TBAA)
+return TBAAAccessInfo();
+  return TBAA->mergeTBAAInfoForCast(SourceInfo, TargetInfo);
+}
+
 void CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction *Inst,
 TBAAAccessInfo TBAAInfo) {
   if (llvm::MDNode *Tag = getTBAAAccessTagInfo(TBAAInfo))
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1942,7 +1942,8 @@
 TBAAAccessInfo *TBAAInfo = nullptr,
 bool forPointeeType = false);
   CharUnits getNaturalPointeeTypeAlignment(QualType T,
-   LValueBaseInfo *BaseInfo = nullptr);
+   LValueBaseInfo *BaseInfo = nullptr,
+   TBAAAccessInfo *TBAAInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
   LValueBaseInfo *BaseInfo = nullptr,
@@ -3

[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315875: [Sema] Re-land: Diagnose tautological comparison 
with type's min/max values (authored by lebedevri).

Changed prior to commit:
  https://reviews.llvm.org/D38101?vs=118835&id=119095#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Analysis/conversion.c
  cfe/trunk/test/Analysis/null-deref-ps.c
  cfe/trunk/test/Sema/outof-range-constant-compare.c
  cfe/trunk/test/Sema/tautological-constant-compare.c
  cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5938,18 +5938,18 @@
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned expression %0 is always %select{false|true}1">,
+def warn_unsigned_always_true_comparison : Warning<
+  "comparison of %select{%3|unsigned expression}0 %2 "
+  "%select{unsigned expression|%3}0 is always %select{false|true}4">,
   InGroup;
-def warn_runsigned_always_true_comparison : Warning<
-  "comparison of %0 unsigned expression is always %select{false|true}1">,
-  InGroup;
-def warn_lunsigned_enum_always_true_comparison : Warning<
-  "comparison of unsigned enum expression %0 is always %select{false|true}1">,
-  InGroup;
-def warn_runsigned_enum_always_true_comparison : Warning<
-  "comparison of %0 unsigned enum expression is always %select{false|true}1">,
+def warn_unsigned_enum_always_true_comparison : Warning<
+  "comparison of %select{%3|unsigned enum expression}0 %2 "
+  "%select{unsigned enum expression|%3}0 is always %select{false|true}4">,
   InGroup;
+def warn_tautological_constant_compare : Warning<
+  "comparison %select{%3|%1}0 %2 "
+  "%select{%1|%3}0 is always %select{false|true}4">,
+  InGroup;
 
 def warn_mixed_sign_comparison : Warning<
   "comparison of integers of different signs: %0 and %1">,
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -432,13 +432,15 @@
 def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
+def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
+[TautologicalUnsignedZeroCompare,
+ TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare,
+[TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;
Index: cfe/trunk/test/Sema/outof-range-constant-compare.c
===
--- cfe/trunk/test/Sema/outof-range-constant-compare.c
+++ cfe/trunk/test/Sema/outof-range-constant-compare.c
@@ -7,58 +7,6 @@
 {
 int a = value();
 
-if (a == 0xL)
-return 0;
-if (a != 0xL)
-return 0;
-if (a < 0xL)
-return 0;
-if (a <= 0xL)
-return 0;
-if (a > 0xL)
-return 0;
-if (a >= 0xL)
-return 0;
-
-if (0xL == a)
-return 0;
-if (0xL != a)
-return 0;
-if (0xL < a)
-return 0;
-if (0xL <= a)
-return 0;
-if (0xL > a)
-return 0;
-if (0xL >= a)
-return 0;
-
-if (a == 0xUL)
-return 0;
-if (

r315875 - [Sema] Re-land: Diagnose tautological comparison with type's min/max values

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 13:13:17 2017
New Revision: 315875

URL: http://llvm.org/viewvc/llvm-project?rev=315875&view=rev
Log:
[Sema] Re-land: Diagnose tautological comparison with type's min/max values

The first attempt, rL315614 was reverted because one libcxx
test broke, and i did not know at the time how to deal with it.

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. 
`char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons 
with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Sema/tautological-constant-compare.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Analysis/conversion.c
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Sema/outof-range-constant-compare.c
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315875&r1=315874&r2=315875&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sun Oct 15 13:13:17 2017
@@ -78,6 +78,10 @@ Improvements to Clang's diagnostics
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
+- ``-Wtautological-constant-compare`` is a new warning that warns on
+  tautological comparisons between integer variable of the type ``T`` and the
+  largest/smallest possible integer constant of that same type.
+
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=315875&r1=315874&r2=315875&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun Oct 15 13:13:17 2017
@@ -432,13 +432,15 @@ def StrncatSize : DiagGroup<"strncat-siz
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
+def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
+[TautologicalUnsignedZeroCompare,
+ 
TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare,
+[TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315875&r1=315874&r2=315875&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Oct 15 13:13:17 
2017
@@ -5938,18 +5938,18 @@ def note_typecheck_assign_const : Note<
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned expression %0 is always %select{false|true}1">,
+def warn_unsigned_always_true_comparison : Wa

[libcxx] r315874 - Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 13:12:42 2017
New Revision: 315874

URL: http://llvm.org/viewvc/llvm-project?rev=315874&view=rev
Log:
Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp

Previously this broke the builders, when D38101 was committed.
Silence the warning so that it can be re-landed.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315874&r1=315873&r2=315874&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Sun Oct 15 13:12:42 2017
@@ -88,6 +88,13 @@ bool TestSupportsNegativeTimes() {
 return !ec && new_write_time <= -5;
 }
 
+// In some configurations, the comparison is tautological and the test is 
valid.
+// We disable the warning so that we can actually test it regardless.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-constant-compare"
+#endif
+
 bool TestSupportsMaxTime() {
 using namespace std::chrono;
 using Lim = std::numeric_limits;
@@ -106,11 +113,22 @@ bool TestSupportsMaxTime() {
 return !ec && new_write_time > max_sec - 1;
 }
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
 static const bool SupportsMaxTime = TestSupportsMaxTime();
 
 } // end namespace
 
+// In some configurations, the comparison is tautological and the test is 
valid.
+// We disable the warning so that we can actually test it regardless.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-constant-compare"
+#endif
+
 // Check if a time point is representable on a given filesystem. Check that:
 // (A) 'tp' is representable as a time_t
 // (B) 'tp' is non-negative or the filesystem supports negative times.
@@ -127,6 +145,10 @@ inline bool TimeIsRepresentableByFilesys
 return true;
 }
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 TEST_SUITE(exists_test_suite)
 
 TEST_CASE(signature_test)


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


r315871 - Convert clang::LangAS to a strongly typed enum

2017-10-15 Thread Alexander Richardson via cfe-commits
Author: arichardson
Date: Sun Oct 15 11:48:14 2017
New Revision: 315871

URL: http://llvm.org/viewvc/llvm-project?rev=315871&view=rev
Log:
Convert clang::LangAS to a strongly typed enum

Summary:
Convert clang::LangAS to a strongly typed enum

Currently both clang AST address spaces and target specific address spaces
are represented as unsigned which can lead to subtle errors if the wrong
type is passed. It is especially confusing in the CodeGen files as it is
not possible to see what kind of address space should be passed to a
function without looking at the implementation.
I originally made this change for our LLVM fork for the CHERI architecture
where we make extensive use of address spaces to differentiate between
capabilities and pointers. When merging the upstream changes I usually
run into some test failures or runtime crashes because the wrong kind of
address space is passed to a function. By converting the LangAS enum to a
C++11 we can catch these errors at compile time. Additionally, it is now
obvious from the function signature which kind of address space it expects.

I found the following errors while writing this patch:

- ItaniumRecordLayoutBuilder::LayoutField was passing a clang AST address
  space to  TargetInfo::getPointer{Width,Align}()
- TypePrinter::printAttributedAfter() prints the numeric value of the
  clang AST address space instead of the target address space.
  However, this code is not used so I kept the current behaviour
- initializeForBlockHeader() in CGBlocks.cpp was passing
  LangAS::opencl_generic to TargetInfo::getPointer{Width,Align}()
- CodeGenFunction::EmitBlockLiteral() was passing a AST address space to
  TargetInfo::getPointerWidth()
- CGOpenMPRuntimeNVPTX::translateParameter() passed a target address space
  to Qualifiers::addAddressSpace()
- CGOpenMPRuntimeNVPTX::getParameterAddress() was using
  llvm::Type::getPointerTo() with a AST address space
- clang_getAddressSpace() returns either a LangAS or a target address
  space. As this is exposed to C I have kept the current behaviour and
  added a comment stating that it is probably not correct.

Other than this the patch should not cause any functional changes.

Reviewers: yaxunl, pcc, bader

Reviewed By: yaxunl, bader

Subscribers: jlebar, jholewinski, nhaehnle, Anastasia, cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGValue.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTypeCache.h
cfe/trunk/lib/CodeGen/ConstantEmitter.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=315871&r1=315870&r2=315871&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sun Oct 15 11:48:14 2017
@@ -496,7 +496,7 @@ private:
   CXXABI *createCXXABI(const TargetInfo &T);
 
   /// \brief The logical -> physical address space map.
-  const LangAS::Map *AddrSpaceMap;
+  const LangASMap *AddrSpaceMap;
 
   /// \brief Address space map mangling must be used with language specific
   /// address spaces (e.g. OpenCL/CUDA)
@@ -1070,7 +1070,7 @@ public:
   /// The resulting type has a union of the qualifiers from T and the address
   /// space. If T already has an address space specifier, it is silently
   /// replaced.
-  QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const;
+  QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const;
 
   /// \brief Remove any existing address space on the type and returns the type
   /// with qualifiers intact (or that's the idea anyway)
@@ -2363,14 +2363,14 @@ public:
 return getTargetAddressSpace(Q.getAddressSpace());
   

[libcxx] r315876 - Really do make sure that last_write_time.pass.cpp still works with old clang

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 13:46:12 2017
New Revision: 315876

URL: http://llvm.org/viewvc/llvm-project?rev=315876&view=rev
Log:
Really do make sure that last_write_time.pass.cpp still works with old clang

I *did* try to check that such kind of an issue was not introduced
by the rL315874, but clearly i failed to finish verification.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315876&r1=315875&r2=315876&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Sun Oct 15 13:46:12 2017
@@ -89,9 +89,11 @@ bool TestSupportsNegativeTimes() {
 }
 
 // In some configurations, the comparison is tautological and the test is 
valid.
-// We disable the warning so that we can actually test it regardless.
+// We disable the warning so that we can actually test it regardless. Also, 
that
+// diagnostic is pretty new, so also don't fail if old clang does not support 
it
 #if defined(__clang__)
 #pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-warning-option"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 
@@ -123,9 +125,11 @@ static const bool SupportsMaxTime = Test
 } // end namespace
 
 // In some configurations, the comparison is tautological and the test is 
valid.
-// We disable the warning so that we can actually test it regardless.
+// We disable the warning so that we can actually test it regardless. Also, 
that
+// diagnostic is pretty new, so also don't fail if old clang does not support 
it
 #if defined(__clang__)
 #pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-warning-option"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 


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


[libcxx] r315882 - Fix last_write_time.pass.cpp to work with clang-3.9 and earlier

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 14:52:53 2017
New Revision: 315882

URL: http://llvm.org/viewvc/llvm-project?rev=315882&view=rev
Log:
Fix last_write_time.pass.cpp to work with clang-3.9 and earlier

At least with clang-3.9 and earlier, -Wunknown-pragmas is also needed.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315882&r1=315881&r2=315882&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Sun Oct 15 14:52:53 2017
@@ -94,6 +94,7 @@ bool TestSupportsNegativeTimes() {
 #if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunknown-warning-option"
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 
@@ -130,6 +131,7 @@ static const bool SupportsMaxTime = Test
 #if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunknown-warning-option"
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 


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


[PATCH] D38939: [clangd] Handle exit notification (proper shutdown)

2017-10-15 Thread Raoul Wols via Phabricator via cfe-commits
rwols created this revision.

This changes the onShutdown handler to do essentially nothing (for now), and
instead exits the runloop when we receive the exit notification from the client.

Some clients may wait on the reply from the shutdown request before sending an
exit notification. If we exit the runloop already in the shutdown request, a
client might block forever.

This also gives us the opportunity to do any global cleanups and/or
serializations of PCH preambles to disk, but I've left that out for now.

See the LSP protocol documentation for details.


https://reviews.llvm.org/D38939

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/authority-less-uri.test
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/definitions.test
  test/clangd/diagnostics-preamble.test
  test/clangd/diagnostics.test
  test/clangd/did-change-watch-files.test
  test/clangd/extra-flags.test
  test/clangd/fixits.test
  test/clangd/formatting.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/input-mirror.test
  test/clangd/signature-help.test
  test/clangd/unsupported-method.test

Index: test/clangd/unsupported-method.test
===
--- test/clangd/unsupported-method.test
+++ test/clangd/unsupported-method.test
@@ -17,3 +17,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":2,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/signature-help.test
===
--- test/clangd/signature-help.test
+++ test/clangd/signature-help.test
@@ -40,3 +40,7 @@
 Content-Length: 49
 
 {"jsonrpc":"2.0","id":10,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":10,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/input-mirror.test
===
--- test/clangd/input-mirror.test
+++ test/clangd/input-mirror.test
@@ -152,3 +152,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -20,3 +20,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -20,3 +20,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/formatting.test
===
--- test/clangd/formatting.test
+++ test/clangd/formatting.test
@@ -65,3 +65,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":6,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":6,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/fixits.test
===
--- test/clangd/fixits.test
+++ test/clangd/fixits.test
@@ -26,3 +26,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/extra-flags.test
===
--- test/clangd/extra-flags.test
+++ test/clangd/extra-flags.test
@@ -18,5 +18,9 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":5,"result":null}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
 
 
Index: test/clangd/did-change-watch-files.test
===
--- test/clangd/did-change-watch-files.test
+++ test/clangd/did-change-watch-files.test
@@ -59,3 +59,6 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: test/clangd/diagnostics.test
===
--- test/clangd/diagnostics.test
+++ test/clangd/diagnostics.test
@@ -15,3 +15,7 @@
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
+# CHECK: {"jsonrpc":"2.0","id":5,"result":null}
+Content-Length

[PATCH] D35782: [C++2a][Preprocessor] Implement p0306 __VA_OPT__ (Comma omission and comma deletion)

2017-10-15 Thread Faisal Vali via Phabricator via cfe-commits
faisalv abandoned this revision.
faisalv marked 12 inline comments as done.
faisalv added a comment.

committed as r315840.
https://reviews.llvm.org/rL315840


Repository:
  rL LLVM

https://reviews.llvm.org/D35782



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


[PATCH] D32199: [TySan] A Type Sanitizer (Clang)

2017-10-15 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel updated this revision to Diff 119103.
hfinkel added a comment.

Rebased.


https://reviews.llvm.org/D32199

Files:
  include/clang/Basic/Sanitizers.def
  include/clang/Driver/SanitizerArgs.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/SanitizerMetadata.cpp
  lib/CodeGen/SanitizerMetadata.h
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/sanitize-type-attr.cpp
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -239,6 +239,18 @@
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
+// RUN: -fsanitize=type \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TYSAN-LINUX-CXX %s
+//
+// CHECK-TYSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-TYSAN-LINUX-CXX-NOT: stdc++
+// CHECK-TYSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tysan-x86_64.a" "-no-whole-archive"
+// CHECK-TYSAN-LINUX-CXX: stdc++
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=memory \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: test/CodeGen/sanitize-type-attr.cpp
===
--- /dev/null
+++ test/CodeGen/sanitize-type-attr.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type | FileCheck -check-prefix=TYSAN %s
+// RUN: echo "src:%s" | sed -e 's/\\//g' > %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
+
+// The sanitize_type attribute should be attached to functions
+// when TypeSanitizer is enabled, unless no_sanitize("type") attribute
+// is present.
+
+// WITHOUT:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// TYSAN:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN1(int *a) { return *a; }
+
+// WITHOUT:  NoTYSAN2{{.*}}) [[NOATTR]]
+// BL:  NoTYSAN2{{.*}}) [[NOATTR]]
+// TYSAN:  NoTYSAN2{{.*}}) [[NOATTR]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN2(int *a);
+int NoTYSAN2(int *a) { return *a; }
+
+// WITHOUT:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// TYSAN:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN3(int *a) { return *a; }
+
+// WITHOUT:  TYSANOk{{.*}}) [[NOATTR]]
+// BL:  TYSANOk{{.*}}) [[NOATTR]]
+// TYSAN: TYSANOk{{.*}}) [[WITH:#[0-9]+]]
+int TYSANOk(int *a) { return *a; }
+
+// WITHOUT:  TemplateTYSANOk{{.*}}) [[NOATTR]]
+// BL:  TemplateTYSANOk{{.*}}) [[NOATTR]]
+// TYSAN: TemplateTYSANOk{{.*}}) [[WITH]]
+template
+int TemplateTYSANOk() { return i; }
+
+// WITHOUT:  TemplateNoTYSAN{{.*}}) [[NOATTR]]
+// BL:  TemplateNoTYSAN{{.*}}) [[NOATTR]]
+// TYSAN: TemplateNoTYSAN{{.*}}) [[NOATTR]]
+template
+__attribute__((no_sanitize("type")))
+int TemplateNoTYSAN() { return i; }
+
+int force_instance = TemplateTYSANOk<42>()
+   + TemplateNoTYSAN<42>();
+
+// Check that __cxx_global_var_init* get the sanitize_type attribute.
+int global1 = 0;
+int global2 = *(int*)((char*)&global1+1);
+// WITHOUT: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
+// BL: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
+// TYSAN: @__cxx_global_var_init{{.*}}[[WITH:#[0-9]+]]
+
+// Make sure that we don't add globals to the list for which we don't have a
+// specific type description.
+struct SX { int a, b; };
+SX sx;
+
+// WITHOUT: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+
+// BL: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+
+// TYSAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+// TYSAN: attributes [[WITH]] = { noinline nounwind sanitize_type{{.*}} }
+
+// TYSAN-DAG: !llvm.tysan.globals = !{[[G1MD:![0-9]+]], [[G2MD:![0-9]+]], [[G3MD:![0-9]+]]}
+// TYSAN-DAG: [[G1MD]] = !{i32* @force_instance, [[INTMD:![0-9]+]]}
+// TYSAN-DAG: [[INTMD]] = !{!"int",
+// TYSAN-DAG: [[G2MD]] = !{i32* @global1, [[INTMD]]}
+// TYSAN-DAG: [[G3MD]] = !{i32* @global2, [[INTMD]]}
+// TYSAN-DAG: Simple C++ TBAA
+
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1138,6 +1138,