[PATCH] D63031: DebugInfo: Render the canonical name of a class template specialization, even when nested in another class template specialization

2019-07-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63031/new/

https://reviews.llvm.org/D63031



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


[PATCH] D64576: [Syntax] Do not add a node for 'eof' into the tree

2019-07-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

While useful as a sentinel value when iterating over tokens, having
'eof' in the tree, seems to do more harm than good.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64576

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -138,15 +138,14 @@
 | `-CompoundStatement
 |   |-2: {
 |   `-3: }
-|-TopLevelDeclaration
-| |-void
-| |-foo
-| |-(
-| |-)
-| `-CompoundStatement
-|   |-2: {
-|   `-3: }
-`-
+`-TopLevelDeclaration
+  |-void
+  |-foo
+  |-(
+  |-)
+  `-CompoundStatement
+|-2: {
+`-3: }
 )txt"},
   };
 
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -58,8 +58,11 @@
   /// Finish building the tree and consume the root node.
   syntax::TranslationUnit *finalize() && {
 auto Tokens = Arena.tokenBuffer().expandedTokens();
+assert(!Tokens.empty());
+assert(Tokens.back().kind() == tok::eof);
+
 // Build the root of the tree, consuming all the children.
-Pending.foldChildren(Tokens,
+Pending.foldChildren(Tokens.drop_back(),
  new (Arena.allocator()) syntax::TranslationUnit);
 
 return cast(std::move(Pending).finalize());
@@ -96,10 +99,11 @@
   /// Ensures that added nodes properly nest and cover the whole token stream.
   struct Forest {
 Forest(syntax::Arena &A) {
-  // FIXME: do not add 'eof' to the tree.
-
+  assert(!A.tokenBuffer().expandedTokens().empty());
+  assert(A.tokenBuffer().expandedTokens().back().kind() == tok::eof);
   // Create all leaf nodes.
-  for (auto &T : A.tokenBuffer().expandedTokens())
+  // Note that we do not have 'eof' in the tree.
+  for (auto &T : A.tokenBuffer().expandedTokens().drop_back())
 Trees.insert(Trees.end(),
  {&T, NodeAndRole{new (A.allocator()) syntax::Leaf(&T)}});
 }


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -138,15 +138,14 @@
 | `-CompoundStatement
 |   |-2: {
 |   `-3: }
-|-TopLevelDeclaration
-| |-void
-| |-foo
-| |-(
-| |-)
-| `-CompoundStatement
-|   |-2: {
-|   `-3: }
-`-
+`-TopLevelDeclaration
+  |-void
+  |-foo
+  |-(
+  |-)
+  `-CompoundStatement
+|-2: {
+`-3: }
 )txt"},
   };
 
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -58,8 +58,11 @@
   /// Finish building the tree and consume the root node.
   syntax::TranslationUnit *finalize() && {
 auto Tokens = Arena.tokenBuffer().expandedTokens();
+assert(!Tokens.empty());
+assert(Tokens.back().kind() == tok::eof);
+
 // Build the root of the tree, consuming all the children.
-Pending.foldChildren(Tokens,
+Pending.foldChildren(Tokens.drop_back(),
  new (Arena.allocator()) syntax::TranslationUnit);
 
 return cast(std::move(Pending).finalize());
@@ -96,10 +99,11 @@
   /// Ensures that added nodes properly nest and cover the whole token stream.
   struct Forest {
 Forest(syntax::Arena &A) {
-  // FIXME: do not add 'eof' to the tree.
-
+  assert(!A.tokenBuffer().expandedTokens().empty());
+  assert(A.tokenBuffer().expandedTokens().back().kind() == tok::eof);
   // Create all leaf nodes.
-  for (auto &T : A.tokenBuffer().expandedTokens())
+  // Note that we do not have 'eof' in the tree.
+  for (auto &T : A.tokenBuffer().expandedTokens().drop_back())
 Trees.insert(Trees.end(),
  {&T, NodeAndRole{new (A.allocator()) syntax::Leaf(&T)}});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks

2019-07-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaExprCXX.cpp:4229
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =

Anastasia wrote:
> rjmccall wrote:
> > Anastasia wrote:
> > > rjmccall wrote:
> > > > All of this can be much simpler:
> > > > 
> > > > ```
> > > > LangAS AddrSpaceL = 
> > > > ToType->castAs()->getPointeeType().getAddressSpace();
> > > > LangAS AddrSpaceR = 
> > > > FromType->castAs()->getPointeeType().getAddressSpace();
> > > > ```
> > > > 
> > > > Is there something actually checking the validity of this address-space 
> > > > cast somewhere?
> > > > Is there something actually checking the validity of this address-space 
> > > > cast somewhere?
> > > 
> > > The address spaces for blocks are currently added by clang implicitly. It 
> > > doesn't seem possible to write kernel code qualifying blocks with address 
> > > spaces. Although I have to say the error is not given properly because 
> > > the parser gets confused at least for the examples I have tried. The 
> > > OpenCL spec doesn't detail much regarding this use case. Potentially this 
> > > is the area for improvement.
> > > 
> > > So for now we can add an assert to check the cast validity if you think 
> > > it makes sense and maybe a FIXME in the  code to explain that address 
> > > spaces aren't working with blocks
> > > The address spaces for blocks are currently added by clang implicitly. It 
> > > doesn't seem possible to write kernel code qualifying blocks with address 
> > > spaces.
> > 
> > There's no way that just fell out from the existing implementation; it was 
> > a change someone must have made for OpenCL.  Unless you care about blocks 
> > existing in multiple address spaces — which, given that you depend on 
> > eliminating them, I'm pretty sure you don't — the compiler just shouldn't 
> > do that if it's causing you problems.
> So the reasons why we add addr spaces to blocks is that if they are declared 
> in program scope they will be inferred as `__global` AS and if they are 
> declared in kernel scope they are inferred as `__private` AS.
> 
> When there is a common code i.e. we pass block into a function or invoke the 
> block we use generic AS so that blocks in different addr spaces can be work 
> correctly but we are adding addr space cast.
> 
> This is the review that added this logic for OpenCL C: 
> https://reviews.llvm.org/D28814
> 
> However in C++ we follow slightly different program path and therefore addr 
> space cast isn't performed correctly.
Okay, so users can't write block pointer types with explicit address spaces.  
What exactly do you mean by "declaring" a block?  Do you mean that block 
pointer *types* are inferred to have different qualification based on where 
they're written, or do you mean that block *literals* have different 
qualification based on where they're written?  Because I'm not sure the latter 
is actually distinguishable from a language model in which blocks are always 
pointers into `__generic` and the compiler just immediately promotes them when 
emitting the expression.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64083/new/

https://reviews.llvm.org/D64083



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage for non-PIC cases

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum marked 20 inline comments as done.
quantum added a comment.

I'll clean up the table gen stuff.




Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:33
+// Thread-local storage
+TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+

aheejin wrote:
> Why is it `c`(const)? According to [[ 
> https://github.com/llvm/llvm-project/blob/e6695821e592f95bffe1340b28be7bcfcce04284/clang/include/clang/Basic/Builtins.h#L104-L108
>  | this comment ]], this is true if this function has no side effects and 
> doesn't read memory, i.e., the result should be only dependent on its 
> arguments. Can't wasm globals be memory locations in machines?
I was thinking that since the global is immutable, so the value is always a 
constant.



Comment at: lld/test/wasm/tls.ll:57
+;   memory.init 0, 0
+;   end
+

aheejin wrote:
> Hmm, I think there might be a way to actually print disassembly results. 
> There are '*.test' files in test directory, in which we have some examples. 
> For example, [[ 
> https://github.com/llvm/llvm-project/blob/master/lld/test/wasm/export-table.test
>  | this test ]] has a sequence of commands you want to run, and you can put 
> input files in a separate directory. That test uses `obj2yaml`, but can we 
> possibly use `llvm-objdump` or something to disassemble?
We already know that we can do something like

Run: obj2yaml %t.wasm | sed -n '/Body:/{s/^\s*Body:\s*//;s/../0x& /gp}'  | 
llvm-mc -disassemble -triple=wasm32

to compare the actual assembly. As for `llvm-objdump`, it seems to be unable to 
disassemble the WASM properly:


```
.../tools/lld/test/wasm/Output/tls.ll.tmp.wasm: file format WASM


Disassembly of section CODE:

 CODE:
# 4 functions in section.
   1: 02 00 block   invalid_type
   3: 0bend
   4: 10 00 call0
   6: 20 00 local.get   0
   8: 24 01 global.set  1
   a: 20 00 local.get   0
   c: 41 00 i32.const   0
   e: 41 08 i32.const   8
  10: fc 08 00 00   memory.init 0, 0
  14: 0bend
  15: 0freturn
  16: 00llvm-objdump: 
lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc:2032: void 
llvm::WebAssemblyInstPrinter::printInstruction(const llvm::MCInst *, 
llvm::raw_ostream &): Assertion `Bits != 0 && "Cannot print this instruction."' 
failed.

```



Comment at: lld/wasm/Driver.cpp:543
+  "__wasm_init_tls", WASM_SYMBOL_VISIBILITY_HIDDEN,
+  make(I32ArgSignature, "__wasm_init_tls"));
+

aheejin wrote:
> Does this TLS thing work when `Config->Shared == true`, i.e., do we create 
> TLS globals even when this is a library?
Since TLS is module specific (we can't allocate memory for other modules), we 
must in fact generate this symbol for every module. Shared library support will 
not be implemented in this diff, however.



Comment at: lld/wasm/Writer.cpp:431
+error("'bulk-memory' feature must be used in order to use thread-local "
+  "storage");
+

aheejin wrote:
> Should we check for "mutable-global" feature too?
Do we need to? I thought it's always available since we use it for the stack 
pointer.



Comment at: lld/wasm/Writer.cpp:514
   if (G->getGlobalType()->Mutable) {
 // Only the __stack_pointer should ever be create as mutable.
+assert(G == WasmSym::StackPointer || G == WasmSym::TLSBase);

aheejin wrote:
> Now `__tls_base` is also mutable, I think we should fix the comment
Will do.



Comment at: lld/wasm/Writer.cpp:769
+  std::string BodyContent;
+  {
+raw_string_ostream OS(BodyContent);

aheejin wrote:
> Any reason for the new block scope?
Yes, the `raw_string_ostream` must destruct by the end of the scope. This is 
the pattern used in other functions above.



Comment at: lld/wasm/Writer.cpp:777
+  break;
+}
+

aheejin wrote:
> Is it guaranteed that there's only one TLS segment?
Yes, all the TLS input segments will be merged into `.tdata`.



Comment at: llvm/include/llvm/IR/IntrinsicsWebAssembly.td:134
+[],
+[IntrNoMem, IntrSpeculatable]>;
+

aheejin wrote:
> - Why is it speculatable?
> - I'm not sure if it's `InstNoMem`, because wasm globals can be memory 
> locations after all. What do other people think?
@tlively suggested that I do this. It should be speculatable because it has no 
side effects (since it returns a constant). As for `InstrNoMem`, I am not sure 
if globals are memory, and whether reading a constant counts as memo

[PATCH] D64537: [WebAssembly] Implement thread-local storage for non-PIC cases

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209271.
quantum marked 6 inline comments as done.
quantum added a comment.

Update comments regarding multable globals. Use `CHECK-DAG`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64537/new/

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-layout.ll
  lld/test/wasm/data-segment-merging.ll
  lld/test/wasm/data-segments.ll
  lld/test/wasm/gc-imports.ll
  lld/test/wasm/gc-sections.ll
  lld/test/wasm/load-undefined.test
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,61 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
+; RUN: llc -O0 < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls
+define i32* @ptr_to_tls() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load
+define i32 @tls_load() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.load 0
+  ; CHECK-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store
+define void @tls_store(i32 %x) {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.store 0
+  ; CHECK-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+declare i32 @llvm.wasm.tls.size.i32()
+define i32 @tls_size() {
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; CHECK-NEXT: .section .tbss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
Index: llvm/test/CodeGen/WebAssembly/target-features-tls.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features-tls.ll
+++ llvm/test/CodeGen/WebAssembly/target-features-tls.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes CHECK,NO-ATOMICS
-; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes CHECK,ATOMICS
+; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes NO-ATOMICS
+; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes ATOMICS
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,16 +9,13 @@
 
 @foo = internal thread_local global i32 0
 
-; CHECK-LABEL: .custom_section.target_features,"",@
 
 ; -atomics
-; NO-ATOMICS-NEXT: .int8 1
-; NO-ATOMICS-NEXT: .int8 45
-; NO-ATOMICS-NEXT: .int8 7
-; NO-ATOMICS-NEXT: .ascii "atomics"
-; NO-ATOMICS-NEXT: .bss.foo,"",@
+; NO-ATOMICS-NOT: .custom_section.target_features,"",@
+; NO-ATOMICS: .tbss.foo,"",@
 
 ; +atomics
+; ATOMICS-LABEL: .custom_section.target_features,"",@
 ; ATOMICS-NEXT: .int8 1
 ; ATOMICS-NEXT: .int8 43
 ; ATOMICS-NEXT: .int8 7
Index: llvm/lib/Target/WebAsse

[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-11 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman marked 3 inline comments as done.
emmettneyman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1948
+def RequiresDesignator : InheritableAttr {
+  let Spellings = [Clang<"requires_designator">];
+  let Subjects = SubjectList<[Record]>;

compnerd wrote:
> aaron.ballman wrote:
> > Hmm, after making this suggestion, I noticed that GCC seems to support a 
> > similar attribute named `designated_init` 
> > (https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#Common-Type-Attributes).
> >  Was your goal to support the same thing GCC supported?
> `designated_init` is a suggestion, the original patch seemed to be a stronger 
> version.  I think that we should be supporting the GNU spelling for 
> `designated_init` and can support a Clang spelling of 
> `requires_designated_init` if the goal is to have the stronger guarantee that 
> this *must* happen.
I hadn't known about the GCC attribute until now. Yes, the 
`requires_designator` (originally `require_designated_init`) attribute wants to 
enforce the same thing I believe. I couldn't find more documentation for the 
GCC `designated_init` attribute so it's a little tough to tell whether the 
behavior is the exact same. The attribute in this patch allows a field to be 
default constructed (unless the other attribute is applied to that specific 
field) but enforces that a brace initializer must be used. So `Foo foo {};` 
would be valid (every field is default constructed) but `Foo foo;` would not be 
valid. I'm not sure if that's the same behavior the GCC attribute is trying to 
enforce. But on a high level, both are trying to prohibit using positional args 
when declaring a struct.

@compnerd I don't mind this attribute generating warnings rather than errors. 
It's ok for this attribute to be a "suggestion" as well. Like @aaron.ballman 
mentioned, "users can always use -Werror to strengthen their own requirements."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64380/new/

https://reviews.llvm.org/D64380



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


[clang-tools-extra] r365804 - [clangd][NFC] Decrease template depth limit in RecursiveHierarchyUnbounded test

2019-07-11 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Jul 11 11:21:21 2019
New Revision: 365804

URL: http://llvm.org/viewvc/llvm-project?rev=365804&view=rev
Log:
[clangd][NFC] Decrease template depth limit in RecursiveHierarchyUnbounded test

...to minimize the chance of stack overflow before reaching the limit.

Modified:
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp?rev=365804&r1=365803&r2=365804&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp Thu Jul 11 
11:21:21 2019
@@ -390,6 +390,7 @@ TEST(TypeHierarchy, RecursiveHierarchyUn
   )cpp");
 
   TestTU TU = TestTU::withCode(Source.code());
+  TU.ExtraArgs.push_back("-ftemplate-depth=10");
   auto AST = TU.build();
 
   // The compiler should produce a diagnostic for hitting the


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


[PATCH] D61479: Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"

2019-07-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: clang/docs/UndefinedBehaviorSanitizer.rst:207
+equivalence by pointer, not also by name (even on platforms that would
+otherwise fall back to checking equivalence by name).
 

I don't think this is true. As far as I can see, 
__ubsan_handle_function_type_mismatch in the minimal runtime simply prints a 
report and exits, i.e. -fsanitize=function is incompatible and should be 
rejected by the driver.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61479/new/

https://reviews.llvm.org/D61479



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage for non-PIC cases

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209274.
quantum added a comment.

Clean up table gen.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64537/new/

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-layout.ll
  lld/test/wasm/data-segment-merging.ll
  lld/test/wasm/data-segments.ll
  lld/test/wasm/gc-imports.ll
  lld/test/wasm/gc-sections.ll
  lld/test/wasm/load-undefined.test
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,61 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
+; RUN: llc -O0 < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls
+define i32* @ptr_to_tls() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load
+define i32 @tls_load() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.load 0
+  ; CHECK-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store
+define void @tls_store(i32 %x) {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.store 0
+  ; CHECK-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+declare i32 @llvm.wasm.tls.size.i32()
+define i32 @tls_size() {
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; CHECK-NEXT: .section .tbss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
Index: llvm/test/CodeGen/WebAssembly/target-features-tls.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features-tls.ll
+++ llvm/test/CodeGen/WebAssembly/target-features-tls.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes CHECK,NO-ATOMICS
-; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes CHECK,ATOMICS
+; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes NO-ATOMICS
+; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes ATOMICS
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,16 +9,13 @@
 
 @foo = internal thread_local global i32 0
 
-; CHECK-LABEL: .custom_section.target_features,"",@
 
 ; -atomics
-; NO-ATOMICS-NEXT: .int8 1
-; NO-ATOMICS-NEXT: .int8 45
-; NO-ATOMICS-NEXT: .int8 7
-; NO-ATOMICS-NEXT: .ascii "atomics"
-; NO-ATOMICS-NEXT: .bss.foo,"",@
+; NO-ATOMICS-NOT: .custom_section.target_features,"",@
+; NO-ATOMICS: .tbss.foo,"",@
 
 ; +atomics
+; ATOMICS-LABEL: .custom_section.target_features,"",@
 ; ATOMICS-NEXT: .int8 1
 ; ATOMICS-NEXT: .int8 43
 ; ATOMICS-NEXT: .int8 7
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
=

[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Not a huge fan of boolean parameters like this, perhaps factor out the context 
as well into the caller and then we don't need it at all? Something else?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540



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


[PATCH] D64308: [clangd] Implement typeHierarchy/resolve for subtypes

2019-07-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks, I forgot we hadn't hooked this part up!




Comment at: clang-tools-extra/clangd/XRefs.cpp:1222
+  if (Direction == TypeHierarchyDirection::Parents || ResolveLevels == 0)
+return llvm::None;
+

I think this should just return Item.
We're supposed to return null if the item is no longer valid, but AFAICT not if 
it's valid but already fully resolved.

Since we don't actually detect invalidity (e.g. when the location is no longer 
valid), I'd suggest just making all the functions here return TypeHierarchyItem 
rather than Optional (or take a mutable reference for this one, which is 
synchronous)



Comment at: clang-tools-extra/clangd/XRefs.h:144
+llvm::Optional
+resolveTypeHierarchy(TypeHierarchyItem Item, int ResolveLevels,
+ TypeHierarchyDirection Direction,

const TypeHierarchyItem &Item

(or mutable ref as suggested in the other comment, and return void)



Comment at: clang-tools-extra/clangd/test/type-hierarchy.test:1
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}

Please add a unit test to TypeHierarchyTests.

I'm on the fence about having a lit test: it's a new LSP method, though the 
binding is pretty simple.
But features that are **only** covered by lit tests are too painful to maintain.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64308/new/

https://reviews.llvm.org/D64308



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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, compnerd, phosek.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64579

Files:
  clang/tools/clang-shlib/CMakeLists.txt


Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -7,8 +7,33 @@
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute 
the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead 
of
+  # using the object library at all. However, CMake reorders static libraries 
on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, 
linking
+  # both the object and the static libraries seems like the least bad solution.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared


Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -7,8 +7,33 @@
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead of
+  # using the object library at all. However, CMake reorders static libraries on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, linking
+  # both the object and the static libraries seems like the least bad solution.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/

[PATCH] D64580: cmake: Add INSTALL_WITH_TOOLCHAIN option to add_*_library macros

2019-07-11 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added reviewers: beanz, smeenai.
Herald added subscribers: dexonsmith, steven_wu, mgorny, mehdi_amini.
Herald added projects: clang, LLVM.

This will simplify the macros by allowing us to remove the hard-coded
list of libraries that should be installed when
LLVM_INSTALL_TOOLCHAIN_ONLY is enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64580

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/libclang/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/llvm-shlib/CMakeLists.txt
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt

Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports)
 
-add_llvm_library(Remarks SHARED ${SOURCES})
+add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES})
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
   DESTINATION include/llvm-c
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -20,7 +20,7 @@
 
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports)
 
-add_llvm_library(LTO SHARED ${SOURCES} DEPENDS intrinsics_gen)
+add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
   DESTINATION include/llvm-c
Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -39,7 +39,10 @@
 add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE})
   endif()
 
-  add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
+  if (LLVM_LINK_LLVM_DYLIB)
+set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
+  endif()
+  add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
@@ -105,7 +108,7 @@
 
   add_custom_target(libLLVMCExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE})
 
-  add_llvm_library(LLVM-C SHARED ${SOURCES})
+  add_llvm_library(LLVM-C SHARED ${SOURCES} INSTALL_WITH_TOOLCHAIN)
   
   target_link_libraries(LLVM-C PUBLIC LLVM)
   add_dependencies(LLVM-C libLLVMCExports)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -657,7 +657,7 @@
 
 macro(add_llvm_library name)
   cmake_parse_arguments(ARG
-"SHARED;BUILDTREE_ONLY;MODULE"
+"SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN"
 ""
 ""
 ${ARGN})
@@ -685,11 +685,7 @@
   elseif(ARG_BUILDTREE_ONLY)
 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS_BUILDTREE_ONLY ${name})
   else()
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR
-${name} STREQUAL "LTO" OR
-${name} STREQUAL "LLVM-C" OR
-${name} STREQUAL "Remarks" OR
-(LLVM_LINK_LLVM_DYLIB AND ${name} STREQUAL "LLVM"))
+if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
 
   set(export_to_llvmexports)
   if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -94,7 +94,7 @@
 remove_definitions("-D_XOPEN_SOURCE=700")
 endif()
 
-add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC}
+add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCHAIN
   OUTPUT_NAME ${output_name}
   ${SOURCES}
   DEPENDS clang-resource-headers
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -44,7 +44,7 @@
 
 macro(add_clang_library name)
   cmake_parse_arguments(ARG
-"SHARED"
+"SHARED;INSTALL_WITH_TOOLCHAIN"
 ""
 "ADDITIONAL_HEADERS"
 ${ARGN})
@@ -97,7 +97,7 @@
   if(TARGET ${name})
 target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
 
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
+if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
   set(export_to_clangtargets)
   if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
   "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

@beanz, what do you think of this? I think it's kinda awful, but I can't think 
of a better alternative short of upgrading to CMake 3.12 (as detailed in my 
comment).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579



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


r365808 - [Driver] -noprofilelib flag

2019-07-11 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Jul 11 12:06:38 2019
New Revision: 365808

URL: http://llvm.org/viewvc/llvm-project?rev=365808&view=rev
Log:
[Driver] -noprofilelib flag

This flag is analoguous to other flags like -nostdlib or -nolibc
and could be used to disable linking of profile runtime library.
This is useful in certain environments like kernel, where profile
instrumentation is still desirable, but we cannot use the standard
runtime library.

Added:
cfe/trunk/test/Driver/noprofilelib.c
Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=365808&r1=365807&r2=365808&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Jul 11 12:06:38 2019
@@ -346,6 +346,8 @@ Disable builtin #include directories
 
 .. option:: -noprebind
 
+.. option:: -noprofilelib
+
 .. option:: -noseglinkedit
 
 .. option:: -nostartfiles

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=365808&r1=365807&r2=365808&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Jul 11 12:06:38 2019
@@ -2512,6 +2512,7 @@ def nomultidefs : Flag<["-"], "nomultide
 def nopie : Flag<["-"], "nopie">;
 def no_pie : Flag<["-"], "no-pie">, Alias;
 def noprebind : Flag<["-"], "noprebind">;
+def noprofilelib : Flag<["-"], "noprofilelib">;
 def noseglinkedit : Flag<["-"], "noseglinkedit">;
 def nostartfiles : Flag<["-"], "nostartfiles">;
 def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=365808&r1=365807&r2=365808&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Jul 11 12:06:38 2019
@@ -450,6 +450,9 @@ std::string ToolChain::getArchSpecificLi
 }
 
 bool ToolChain::needsProfileRT(const ArgList &Args) {
+  if (Args.hasArg(options::OPT_noprofilelib))
+return false;
+
   if (needsGCovInstrumentation(Args) ||
   Args.hasArg(options::OPT_fprofile_generate) ||
   Args.hasArg(options::OPT_fprofile_generate_EQ) ||

Added: cfe/trunk/test/Driver/noprofilelib.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/noprofilelib.c?rev=365808&view=auto
==
--- cfe/trunk/test/Driver/noprofilelib.c (added)
+++ cfe/trunk/test/Driver/noprofilelib.c Thu Jul 11 12:06:38 2019
@@ -0,0 +1,5 @@
+// RUN: %clang -target i686-pc-linux-gnu -### %s 2>&1 \
+// RUN: -fprofile-generate -noprofilelib | FileCheck %s
+// RUN: %clang -target i686-pc-linux-gnu -### %s 2>&1 \
+// RUN: -fprofile-instr-generate -noprofilelib | FileCheck %s
+// CHECK-NOT: clang_rt.profile


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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added a comment.

Thanks for the review! I will update the patch soon. As there is a dependency 
that is not accepted yet Richard (who authored the code I extended) might have 
some chance to take a look at this patch.




Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:25
+
+struct [[gsl::Owner(int)]] OwnerWithConv {
+  OwnerWithConv();

gribozavr wrote:
> Would be nice if the second pair of types had clearly related names, like the 
> first pair (MyOwner/MyPointer).
Would renaming `MyPtrFromConv` to `PointerFromConv ` be enough to suggest the 
relationship?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64256/new/

https://reviews.llvm.org/D64256



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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

While upgrading to newer CMake would be nice, I think it's unlikely that we 
could move all the way to 3.12 since that version was only released a year ago 
and still isn't available in most distributions, so this LGTM. Maybe leave a 
TODO that this should be revisited after we bump minimum CMake requirement to 
3.12 or newer?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579



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


r365809 - [CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC

2019-07-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jul 11 12:11:46 2019
New Revision: 365809

URL: http://llvm.org/viewvc/llvm-project?rev=365809&view=rev
Log:
[CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC

Replace a `llvm::Function *` parameter with a bool, which seems harder
to set to the wrong value by accident.

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=365809&r1=365808&r2=365809&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jul 11 12:11:46 2019
@@ -3621,18 +3621,19 @@ void CGDebugInfo::EmitFunctionStart(Glob
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+  bool IsDeclForCallSite) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return;
+return nullptr;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
-  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3665,11 +3666,8 @@ void CGDebugInfo::EmitFunctionDecl(Globa
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
-
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
-
   DBuilder.retainType(SP);
+  return SP;
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
@@ -3691,8 +3689,13 @@ void CGDebugInfo::EmitFuncDeclForCallSit
   if (Func->getSubprogram())
 return;
 
-  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
-EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
+  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined()) {
+llvm::DISubprogram *SP =
+EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType,
+ /*IsDeclForCallSite=*/true);
+assert(SP && "Could not find decl for callee?");
+Func->setSubprogram(SP);
+  }
 }
 
 void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) 
{

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=365809&r1=365808&r2=365809&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jul 11 12:11:46 2019
@@ -408,10 +408,11 @@ public:
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy &Builder);
 
-  /// Emit debug info for a function declaration.
-  /// \p Fn is set only when a declaration for a debug call site gets created.
-  void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-QualType FnType, llvm::Function *Fn = nullptr);
+  /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
+  /// a call site entry must reference the declaration.
+  llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+   QualType FnType,
+   bool IsDeclForCallSite = false);
 
   /// Emit debug info for an extern function being called.
   /// This is needed for call site debug info.


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


[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365809: [CGDebugInfo] Simplify EmitFunctionDecl parameters, 
NFC (authored by vedantk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64540?vs=209082&id=209289#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3621,18 +3621,19 @@
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+  bool IsDeclForCallSite) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return;
+return nullptr;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
-  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3665,11 +3666,8 @@
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
-
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
-
   DBuilder.retainType(SP);
+  return SP;
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
@@ -3691,8 +3689,13 @@
   if (Func->getSubprogram())
 return;
 
-  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
-EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
+  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined()) {
+llvm::DISubprogram *SP =
+EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType,
+ /*IsDeclForCallSite=*/true);
+assert(SP && "Could not find decl for callee?");
+Func->setSubprogram(SP);
+  }
 }
 
 void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) 
{
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -408,10 +408,11 @@
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy &Builder);
 
-  /// Emit debug info for a function declaration.
-  /// \p Fn is set only when a declaration for a debug call site gets created.
-  void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-QualType FnType, llvm::Function *Fn = nullptr);
+  /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
+  /// a call site entry must reference the declaration.
+  llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+   QualType FnType,
+   bool IsDeclForCallSite = false);
 
   /// Emit debug info for an extern function being called.
   /// This is needed for call site debug info.


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3621,18 +3621,19 @@
 RegionMap[D].reset(SP);
 }
 
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+  SourceLocation Loc,
+  QualType FnType,
+  bool IsDeclForCallSite) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return;
+return nullptr;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
-  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3665,11 +3666,8 @@
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
-
-  if (IsDeclForCallSite)
-Fn->setSu

[PATCH] D63954: Add lifetime categories attributes

2019-07-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2770
+def Owner : InheritableAttr {
+  let Spellings = [CXX11<"gsl", "Owner">];
+  let Subjects = SubjectList<[CXXRecord]>;

aaron.ballman wrote:
> xazax.hun wrote:
> > aaron.ballman wrote:
> > > Has Microsoft already added support for this? We had an unfortunate 
> > > problem with `gsl::suppress` where we introduced the attribute first and 
> > > MSVC introduced it under a different, incompatible syntax. I would 
> > > strongly like to avoid repeating that.
> > I will double check this. Her Sutter's paper have this spelling and I 
> > believe that the Microsoft implementation is following the same spelling. 
> > The main difference is that the MSVC version does not have a type argument 
> > at this point but they do plan to add it as an optional argument. (They 
> > want to infer the pointee type when it is not provided.) The clang 
> > community do not want the inference, hence we made the type argument 
> > required. Always providing the type argument should be compatible with 
> > future versions of the MSVC implementation.
> I take this to mean that we're not implementing the same attribute as MSVC 
> is, and that worries me.
> 
> > Always providing the type argument should be compatible with future 
> > versions of the MSVC implementation.
> 
> The problem is that code written for MSVC (where the type argument is not 
> required) will not compile with Clang (where the type argument is required), 
> if I understand properly.
> 
> Generally speaking, when we implement an attribute from another vendor 
> namespace, we expect the attribute to have the same semantics as whoever 
> "owns" that vendor namespace. It's a bit trickier here because `gsl` isn't 
> really a vendor so much as a collective, so I don't know who is the authority 
> to turn to.
> 
> On a completely different note: would this attribute also make sense within C 
> with a C2x spelling?
I see, that is a valid concern. A followup patch makes the type argument 
optional so it will be fully compatible with MSVC.  I don't think it makes 
sense with C or at least I am not sure what would I annotate using these 
attributes in C code as the subjects are classes. I know that it is possible to 
simulate classes in C but I am not sure how well the analysis would work in 
such cases. 

Are you OK with making the argument optional in a followup patch or do you want 
us to cherry-pick that modification into this one?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63954/new/

https://reviews.llvm.org/D63954



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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D64579#1581172 , @phosek wrote:

> While upgrading to newer CMake would be nice, I think it's unlikely that we 
> could move all the way to 3.12 since that version was only released a year 
> ago and still isn't available in most distributions, so this LGTM. Maybe 
> leave a TODO that this should be revisited after we bump minimum CMake 
> requirement to 3.12 or newer?


FWIW, CMake 3.4.3 was released Jan 25 2016 
(https://cmake.org/pipermail/cmake/2016-January/062616.html) and we started 
requiring it on May 31 2016 (https://reviews.llvm.org/D20822), so we do have 
precedence for requiring a pretty recent CMake version. I guess we should 
figure out what other compelling reasons we'd have for moving to that version 
though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579



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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D64579#1581194 , @smeenai wrote:

> In D64579#1581172 , @phosek wrote:
>
> > While upgrading to newer CMake would be nice, I think it's unlikely that we 
> > could move all the way to 3.12 since that version was only released a year 
> > ago and still isn't available in most distributions, so this LGTM. Maybe 
> > leave a TODO that this should be revisited after we bump minimum CMake 
> > requirement to 3.12 or newer?
>
>
> FWIW, CMake 3.4.3 was released Jan 25 2016 
> (https://cmake.org/pipermail/cmake/2016-January/062616.html) and we started 
> requiring it on May 31 2016 (https://reviews.llvm.org/D20822), so we do have 
> precedence for requiring a pretty recent CMake version. I guess we should 
> figure out what other compelling reasons we'd have for moving to that version 
> though.


I'll wait a bit in case @beanz has any thoughts and then commit this with the 
added TODO.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579



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


[PATCH] D64582: cmake: Fix install of libclang_shared.so when LLVM_INSTALL_TOOLCHAIN_ONLY=ON

2019-07-11 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added reviewers: beanz, smeenai.
Herald added a subscriber: mgorny.
Herald added a project: clang.
tstellar added a parent revision: D64580: cmake: Add INSTALL_WITH_TOOLCHAIN 
option to add_*_library macros.

If CLANG_LINK_CLANG_DYLIB is also enabled, then this library needs to be
installed.

Fixes PR42575.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64582

Files:
  clang/tools/clang-shlib/CMakeLists.txt


Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -11,8 +11,13 @@
   list(APPEND _DEPS $)
 endforeach ()
 
+if (CLANG_LINK_CLANG_DYLIB)
+  set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
+endif()
+
 add_clang_library(clang_shared
   SHARED
+  ${INSTALL_WITH_TOOLCHAIN}
   clang-shlib.cpp
   ${_OBJECTS}
   LINK_LIBS


Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -11,8 +11,13 @@
   list(APPEND _DEPS $)
 endforeach ()
 
+if (CLANG_LINK_CLANG_DYLIB)
+  set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
+endif()
+
 add_clang_library(clang_shared
   SHARED
+  ${INSTALL_WITH_TOOLCHAIN}
   clang-shlib.cpp
   ${_OBJECTS}
   LINK_LIBS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365814 - Revert "[CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC"

2019-07-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jul 11 12:28:07 2019
New Revision: 365814

URL: http://llvm.org/viewvc/llvm-project?rev=365814&view=rev
Log:
Revert "[CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC"

This reverts commit 1af41074445229fea66b99710a850e5f42ecfa95.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=365814&r1=365813&r2=365814&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jul 11 12:28:07 2019
@@ -3621,19 +3621,18 @@ void CGDebugInfo::EmitFunctionStart(Glob
 RegionMap[D].reset(SP);
 }
 
-llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
-  SourceLocation Loc,
-  QualType FnType,
-  bool IsDeclForCallSite) {
+void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+   QualType FnType, llvm::Function *Fn) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-return nullptr;
+return;
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
+  bool IsDeclForCallSite = Fn ? true : false;
   llvm::DIScope *FDContext =
   IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
   llvm::DINodeArray TParamsArray;
@@ -3666,8 +3665,11 @@ llvm::DISubprogram *CGDebugInfo::EmitFun
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
+
+  if (IsDeclForCallSite)
+Fn->setSubprogram(SP);
+
   DBuilder.retainType(SP);
-  return SP;
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
@@ -3689,13 +3691,8 @@ void CGDebugInfo::EmitFuncDeclForCallSit
   if (Func->getSubprogram())
 return;
 
-  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined()) {
-llvm::DISubprogram *SP =
-EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType,
- /*IsDeclForCallSite=*/true);
-assert(SP && "Could not find decl for callee?");
-Func->setSubprogram(SP);
-  }
+  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
+EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
 }
 
 void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) 
{

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=365814&r1=365813&r2=365814&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jul 11 12:28:07 2019
@@ -408,11 +408,10 @@ public:
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy &Builder);
 
-  /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
-  /// a call site entry must reference the declaration.
-  llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
-   QualType FnType,
-   bool IsDeclForCallSite = false);
+  /// Emit debug info for a function declaration.
+  /// \p Fn is set only when a declaration for a debug call site gets created.
+  void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+QualType FnType, llvm::Function *Fn = nullptr);
 
   /// Emit debug info for an extern function being called.
   /// This is needed for call site debug info.


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


[PATCH] D64564: Loop pragma parsing. NFC.

2019-07-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 209299.
SjoerdMeijer marked an inline comment as not done.
SjoerdMeijer added a comment.

thanks for taking a look and the suggestions!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64564/new/

https://reviews.llvm.org/D64564

Files:
  lib/Parse/ParsePragma.cpp


Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -1006,18 +1006,14 @@
 } // end anonymous namespace
 
 static std::string PragmaLoopHintString(Token PragmaName, Token Option) {
-  std::string PragmaString;
-  if (PragmaName.getIdentifierInfo()->getName() == "loop") {
-PragmaString = "clang loop ";
-PragmaString += Option.getIdentifierInfo()->getName();
-  } else if (PragmaName.getIdentifierInfo()->getName() == "unroll_and_jam") {
-PragmaString = "unroll_and_jam";
-  } else {
-assert(PragmaName.getIdentifierInfo()->getName() == "unroll" &&
-   "Unexpected pragma name");
-PragmaString = "unroll";
-  }
-  return PragmaString;
+  StringRef Str = PragmaName.getIdentifierInfo()->getName();
+  Str = llvm::StringSwitch(Str)
+   .Case("loop", "clang loop " + Str.str())
+   .Case("unroll_and_jam", Str)
+   .Case("unroll", Str)
+   .Default("");
+  assert(Str.size() && "Unexpected pragma name");
+  return std::string(Str);
 }
 
 bool Parser::HandlePragmaLoopHint(LoopHint &Hint) {
@@ -1041,12 +1037,12 @@
 
   // Return a valid hint if pragma unroll or nounroll were specified
   // without an argument.
-  bool PragmaUnroll = PragmaNameInfo->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameInfo->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameInfo->getName() == "unroll_and_jam";
-  bool PragmaNoUnrollAndJam = PragmaNameInfo->getName() == "nounroll_and_jam";
-  if (Toks.empty() && (PragmaUnroll || PragmaNoUnroll || PragmaUnrollAndJam ||
-   PragmaNoUnrollAndJam)) {
+  auto IsLoopHint = llvm::StringSwitch(PragmaNameInfo->getName())
+.Cases("unroll", "nounroll", "unroll_and_jam",
+   "nounroll_and_jam", true)
+.Default(false);
+
+  if (Toks.empty() && IsLoopHint) {
 ConsumeAnnotationToken();
 Hint.Range = Info->PragmaName.getLocation();
 return true;


Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -1006,18 +1006,14 @@
 } // end anonymous namespace
 
 static std::string PragmaLoopHintString(Token PragmaName, Token Option) {
-  std::string PragmaString;
-  if (PragmaName.getIdentifierInfo()->getName() == "loop") {
-PragmaString = "clang loop ";
-PragmaString += Option.getIdentifierInfo()->getName();
-  } else if (PragmaName.getIdentifierInfo()->getName() == "unroll_and_jam") {
-PragmaString = "unroll_and_jam";
-  } else {
-assert(PragmaName.getIdentifierInfo()->getName() == "unroll" &&
-   "Unexpected pragma name");
-PragmaString = "unroll";
-  }
-  return PragmaString;
+  StringRef Str = PragmaName.getIdentifierInfo()->getName();
+  Str = llvm::StringSwitch(Str)
+   .Case("loop", "clang loop " + Str.str())
+   .Case("unroll_and_jam", Str)
+   .Case("unroll", Str)
+   .Default("");
+  assert(Str.size() && "Unexpected pragma name");
+  return std::string(Str);
 }
 
 bool Parser::HandlePragmaLoopHint(LoopHint &Hint) {
@@ -1041,12 +1037,12 @@
 
   // Return a valid hint if pragma unroll or nounroll were specified
   // without an argument.
-  bool PragmaUnroll = PragmaNameInfo->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameInfo->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameInfo->getName() == "unroll_and_jam";
-  bool PragmaNoUnrollAndJam = PragmaNameInfo->getName() == "nounroll_and_jam";
-  if (Toks.empty() && (PragmaUnroll || PragmaNoUnroll || PragmaUnrollAndJam ||
-   PragmaNoUnrollAndJam)) {
+  auto IsLoopHint = llvm::StringSwitch(PragmaNameInfo->getName())
+.Cases("unroll", "nounroll", "unroll_and_jam",
+   "nounroll_and_jam", true)
+.Default(false);
+
+  if (Toks.empty() && IsLoopHint) {
 ConsumeAnnotationToken();
 Hint.Range = Info->PragmaName.getLocation();
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Vedant Kumar via Phabricator via cfe-commits
vsk reopened this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Sorry about that, reopening per Eric's comment.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540



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


[PATCH] D64564: Loop pragma parsing. NFC.

2019-07-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

oh no, the diff got messed up here. I.e. Phab shows 2 modified files, because 
the first patch set was created in a monorepo, and the 2nd patch set in a 
another and separate clang repo.

Just for clarity, file `lib/Parse/ParsePragma.cpp` is the latest with the 
feedback addressed.
Tomorrow I will see if I can fix this in Phab...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64564/new/

https://reviews.llvm.org/D64564



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


[PATCH] D64539: [clang-doc] Add stylesheet to generated html docs

2019-07-11 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 209302.
DiegoAstiazaran marked an inline comment as done.
DiegoAstiazaran added a comment.

Move the generation of css stylesheet to a function inside the HTMLGenerator.
A virtual function createResources was declared for Generator class. This is 
no-op for the YAML and MD generators. For the HTML it contains the generation 
of css stylesheet.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64539/new/

https://reviews.llvm.org/D64539

Files:
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/clang-doc/stylesheets/clang-doc-default-stylesheet.css
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -43,6 +43,7 @@
   std::string Expected = R"raw(
 
 namespace Namespace
+
 
   namespace Namespace
   Namespaces
@@ -100,6 +101,7 @@
   std::string Expected = R"raw(
 
 class r
+
 
   class r
   
@@ -157,6 +159,7 @@
   std::string Expected = R"raw(
 
 
+
 
   f
   
@@ -194,6 +197,7 @@
   std::string Expected = R"raw(
 
 
+
 
   enum class e
   
@@ -254,6 +258,7 @@
   std::string Expected = R"raw(
 
 
+
 
   f
   
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -196,7 +196,7 @@
   // Mapping phase
   llvm::outs() << "Mapping decls...\n";
   clang::doc::ClangDocContext CDCtx = {Exec->get()->getExecutionContext(),
-   PublicOnly};
+   PublicOnly, OutDirectory};
   auto Err =
   Exec->get()->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster);
   if (Err) {
@@ -239,5 +239,8 @@
   llvm::errs() << toString(std::move(Err)) << "\n";
   }
 
+  if (!G->get()->createResources(CDCtx))
+return 1;
+
   return 0;
 }
Index: clang-tools-extra/clang-doc/stylesheets/clang-doc-default-stylesheet.css
===
--- /dev/null
+++ clang-tools-extra/clang-doc/stylesheets/clang-doc-default-stylesheet.css
@@ -0,0 +1,205 @@
+body,div {
+  margin: 0;
+  padding: 0;
+}
+
+body[no-overflow] {
+  overflow: hidden;
+}
+
+li>p:first-child {
+  margin-top: 0;
+}
+
+li>p:last-child {
+  margin-bottom: 0;
+}
+
+html {
+  -webkit-box-sizing: border-box;
+  box-sizing: border-box;
+}
+
+*,*::before,*::after {
+  -webkit-box-sizing: inherit;
+  box-sizing: inherit;
+}
+
+body,html {
+  color: #202124;
+  font: 400 16px/24px Roboto,sans-serif;
+  -moz-osx-font-smoothing: grayscale;
+  -webkit-font-smoothing: antialiased;
+  height: 100%;
+  margin: 36px;
+  -webkit-text-size-adjust: 100%;
+  -moz-text-size-adjust: 100%;
+  -ms-text-size-adjust: 100%;
+  text-size-adjust: 100%;
+}
+
+body[devsite-framebox] {
+  overflow: hidden;
+  padding: 20px;
+}
+
+body[sitemask--active] {
+  overflow: hidden;
+}
+
+p {
+  margin: 16px 0;
+  padding: 0;
+}
+
+:link,:visited {
+  color: #039be5;
+  outline: 0;
+  text-decoration: none;
+}
+
+ul {
+  margin: 0;
+  padding-left: 40px;
+}
+
+ul {
+  list-style: disc outside;
+}
+
+li,li p {
+  margin: 12px 0;
+  padding: 0;
+}
+
+*[visually-hidden] {
+  opacity: 0 !important;
+  pointer-events: none !important;
+  visibility: hidden !important;
+}
+
+*[hidden] {
+  display: none !important;
+}
+
+[render-hidden] {
+  display: inline !important;
+  position: absolute !important;
+  visibility: hidden !important;
+}
+
+*[no-scroll] {
+  overflow: hidden;
+}
+
+@supports (display: flex) {
+  body[ready] .devsite-wrapper {
+display: -webkit-box;
+display: -ms-flexbox;
+display: flex;
+-webkit-box-orient: vertical;
+-webkit-box-direction: normal;
+-ms-flex-direction: column;
+flex-direction: column;
+  }
+}
+
+@media screen and (max-width: 840px) {
+  body[devsite-book-nav--open] {
+overflow: hidden;
+  }
+}
+
+h1,h2,h3,h4,h5,h6 {
+  overflow: hidden;
+  padding: 0;
+  text-overflow: ellipsis;
+}
+
+h1 {
+  color: #80868b;
+  font: 300 34px/40px Roboto,sans-serif;
+  letter-spacing: -0.01em;
+  margin: 40px 0 20px;
+}
+
+[layout=docs] h2 {
+  border-bottom: 1px solid #e8eaed;
+  padding-bottom: 3px;
+}
+
+h2 {
+  font: 300 24px/32px Roboto,sans-serif;
+  letter-spacing: -0.01em;
+  margin: 40px 0 20px;
+}
+
+h3 {
+  font: 400 20px/32px Roboto,sans-serif;
+  margin: 32px 0 16px;
+}
+
+h4,h5,h6 {
+  margin: 32px 0 16px;
+}
+
+h4 {
+  font: 500 16px/24px Roboto,sans-serif;
+}
+
+h5 {
+  font: 700 1

[PATCH] D64537: [WebAssembly] Implement thread-local storage for non-PIC cases

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum marked 5 inline comments as done.
quantum added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:33
+// Thread-local storage
+TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+

quantum wrote:
> aheejin wrote:
> > Why is it `c`(const)? According to [[ 
> > https://github.com/llvm/llvm-project/blob/e6695821e592f95bffe1340b28be7bcfcce04284/clang/include/clang/Basic/Builtins.h#L104-L108
> >  | this comment ]], this is true if this function has no side effects and 
> > doesn't read memory, i.e., the result should be only dependent on its 
> > arguments. Can't wasm globals be memory locations in machines?
> I was thinking that since the global is immutable, so the value is always a 
> constant.
According to @tlively, there is no solid definition on whether a global 
(especially a constant one), counts as memory access. For now, I am going to 
change this to not constant. We can always change it back later.



Comment at: llvm/include/llvm/IR/IntrinsicsWebAssembly.td:134
+[],
+[IntrNoMem, IntrSpeculatable]>;
+

quantum wrote:
> aheejin wrote:
> > - Why is it speculatable?
> > - I'm not sure if it's `InstNoMem`, because wasm globals can be memory 
> > locations after all. What do other people think?
> @tlively suggested that I do this. It should be speculatable because it has 
> no side effects (since it returns a constant). As for `InstrNoMem`, I am not 
> sure if globals are memory, and whether reading a constant counts as memory 
> access.
I think I am going to remove these attributes for now. We can add them back if 
we end up deciding that immutable globals are not memory accesses.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64537/new/

https://reviews.llvm.org/D64537



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


[PATCH] D62960: Add SVE opaque built-in types

2019-07-11 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

Ping, and thanks for the reviews so far.  I think I've addressed all the 
comments to date and I've tried to make the patch ready to commit in its 
current state (rather than the RFC that it originally was).

It would be really useful if we could apply the patch soon, so that we can 
start implementing the intrinsic functions.  The patch is now independent of 
the "sizeless type" stuff, if there are concerns about that.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62960/new/

https://reviews.llvm.org/D62960



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage for non-PIC cases

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209304.
quantum added a comment.

Treat global.get of an immutable global as a memory access for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64537/new/

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-layout.ll
  lld/test/wasm/data-segment-merging.ll
  lld/test/wasm/data-segments.ll
  lld/test/wasm/gc-imports.ll
  lld/test/wasm/gc-sections.ll
  lld/test/wasm/load-undefined.test
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,61 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
+; RUN: llc -O0 < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls
+define i32* @ptr_to_tls() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load
+define i32 @tls_load() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.load 0
+  ; CHECK-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store
+define void @tls_store(i32 %x) {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.store 0
+  ; CHECK-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+declare i32 @llvm.wasm.tls.size.i32()
+define i32 @tls_size() {
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; CHECK-NEXT: .section .tbss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
Index: llvm/test/CodeGen/WebAssembly/target-features-tls.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features-tls.ll
+++ llvm/test/CodeGen/WebAssembly/target-features-tls.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes CHECK,NO-ATOMICS
-; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes CHECK,ATOMICS
+; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes NO-ATOMICS
+; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes ATOMICS
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,16 +9,13 @@
 
 @foo = internal thread_local global i32 0
 
-; CHECK-LABEL: .custom_section.target_features,"",@
 
 ; -atomics
-; NO-ATOMICS-NEXT: .int8 1
-; NO-ATOMICS-NEXT: .int8 45
-; NO-ATOMICS-NEXT: .int8 7
-; NO-ATOMICS-NEXT: .ascii "atomics"
-; NO-ATOMICS-NEXT: .bss.foo,"",@
+; NO-ATOMICS-NOT: .custom_section.target_features,"",@
+; NO-ATOMICS: .tbss.foo,"",@
 
 ; +atomics
+; ATOMICS-LABEL: .custom_section.target_features,"",@
 ; ATOMICS-NEXT: .int8 1
 ; ATOMICS-NEXT: .int8 43
 ; ATOMICS-NEXT: .int8 7
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
=

[PATCH] D64062: Remove both -dumpversion and __VERSION__

2019-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I still have this open concern:

In D64062#1574868 , @rnk wrote:

> One concern that I have is that we don't have a replacement for 
> `-dumpversion`. I thought I saw someone propose adding such a flag, but I 
> can't find it. Basically, we should do something to handle this user's use 
> case:
>  
> http://clang-developers.42468.n3.nabble.com/How-to-dump-clang-version-td4025542.html


Perhaps we should just remove `__VERSION__` and keep `-dumpversion`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64062/new/

https://reviews.llvm.org/D64062



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


Re: r365724 - clang-cl: Remove -O0 option

2019-07-11 Thread Reid Kleckner via cfe-commits
This seems to have caused a libfuzzer test to fail here:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/48261

It's not easy to fix because -O0 is passed to clang-cl on Windows and clang
elsewhere, so /Od won't do the trick without a substitution. This was kind
of why I added -O0 in the first place. clang-cl more or less accepts all
options unless they conflict, so I applied that logic to O0 as well.

I think the right thing to do is to make %cpp_compiler not expand to
clang-cl if possible. I'll mark UNSUPPORTED for now and try to do that next.

On Wed, Jul 10, 2019 at 6:17 PM Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Wed Jul 10 18:18:05 2019
> New Revision: 365724
>
> URL: http://llvm.org/viewvc/llvm-project?rev=365724&view=rev
> Log:
> clang-cl: Remove -O0 option
>
> cl.exe doesn't understand it; there's /Od instead. See also the review
> thread for r229575.
>
> Update lots of compiler-rt tests to use -Od instead of -O0.
> Ran `rg -l 'clang_cl.*O0' compiler-rt/test/ | xargs sed -i -c 's/-O0/-Od/'`
>
> Differential Revision: https://reviews.llvm.org/D64506
>
> Modified:
> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>
> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=365724&r1=365723&r2=365724&view=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed Jul 10 18:18:05
> 2019
> @@ -120,8 +120,6 @@ def _SLASH_J : CLFlag<"J">, HelpText<"Ma
>  def _SLASH_O : CLJoined<"O">,
>HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
>MetaVarName<"">;
> -// FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
> -def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
>  def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
>HelpText<"Optimize for size  (like /Og /Os /Oy /Ob2 /GF /Gy)">;
>  def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64586: [WebAssembly] Make -pthread imply -bulk-memory

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: cfe-commits, jfb, sunfish, jgravelle-google, sbc100.
Herald added a project: clang.

This paves the way for using passive segments in pthread builds, which
will make separate memory files unnecessary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64586

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


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,12 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=BULK_MEM_NO_ATOMICS %s
+// BULK_MEM_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies target features atomics and bulk-memory
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,15 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,12 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=BULK_MEM_NO_ATOMICS %s
+// BULK_MEM_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-bulk-memory'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===

[PATCH] D64585: [OpenMP] With nested parallelism, threadprivate variables become shared on outer parallel when appearing in inner parallel copyin clause

2019-07-11 Thread Princeton Ferro via Phabricator via cfe-commits
Prince781 created this revision.
Prince781 added reviewers: ABataev, faisalv, malcolm.parsons, efriedma, 
eli.friedman, maskray0, MaskRay, tareqsiraj, rsmith.
Prince781 added projects: clang, OpenMP.
Herald added subscribers: jdoerfert, jfb, guansong.

There is a bug since at least clang 8.0.0 wherein a static threadprivate 
variable appearing in a copyin() clause on a parallel construct (that is nested 
within another parallel construct) becomes shared on the outer parallel. This 
happens only when the threadprivate variable is backed by TLS and does not 
appear in global scope. Here is an example that compiles incorrectly:

  #include 
  #include 
  #include 
  #include 
  #define NT 4
   
  int main(void) {
  static int threadprivate_var = 1;
  #pragma omp threadprivate(threadprivate_var)
   
  omp_set_dynamic(false);
  omp_set_num_threads(NT);
  omp_set_nested(true);
   
  #pragma omp parallel
  {
  threadprivate_var = 1;
  printf("[B] thread %d: val %d: threadprivate @ %p\n", 
omp_get_thread_num(), threadprivate_var, &threadprivate_var);
   
  #pragma omp master
  {
  threadprivate_var = 2;
  #pragma omp parallel copyin(threadprivate_var)
  {
  printf("[B] thread %d, %d: val %d: threadprivate @ %p\n", 
omp_get_ancestor_thread_num(1), omp_get_thread_num(), threadprivate_var, 
&threadprivate_var);
  // check that copyin succeeded
  assert(threadprivate_var == 2);
  }
  }
  #pragma omp barrier
  printf("[A] thread %d: val %d: threadprivate @ %p\n", 
omp_get_thread_num(), threadprivate_var, &threadprivate_var);
  if (omp_get_thread_num() != 0)  // 0 is the master thread
  // non-master threads should not have seen changes
  assert(threadprivate_var == 1);
  }
  }

The resulting IR looks something like this:

  @main.threadprivate_var = internal thread_local global i32 1, align 4
  …
  main() {
 call void __kmpc_fork_call(omp_outlined_outer_parallel_region, 
&main.threadprivate_var)
  }
  …
  omp_outlined_outer_parallel_region(…, i32* %threadprivate_var) {
  if (I am the master thread)
  call void __kmpc_fork_call(omp_outlined_inner_parallel_region, 
%threadprivate_var)
  }
  …
  omp_outlined_inner_parallel_region(…, i32* %threadprivate_var) {
  }

When it should look something like this:

  @main.threadprivate_var = internal thread_local global i32 1, align 4
  …
  main() {
 call void __kmpc_fork_call(omp_outlined_outer_parallel_region)
  }
  …
  omp_outlined_outer_parallel_region(…) {
  if (I am the master thread)
  call void __kmpc_fork_call(omp_outlined_inner_parallel_region, 
&main.threadprivate_var)
  }
  …
  omp_outlined_inner_parallel_region(…, i32* %threadprivate_var) {
  }

Without the copyin, the function for the outer parallel region does not have 
the extra parameter. For the copyin clause above to work, the inner parallel 
needs a reference to the thread-local variable of the encountering thread (in 
this case, the master thread) in an extra parameter. It does not make sense for 
the outer parallel function(s) to capture the thread-local variable.

I’ve made a patch that prevents TLS-backed threadprivate variables from being 
captured in outer scopes. I don’t know if this is the best way to go about it, 
so I welcome feedback from someone with much more knowledge on clang’s OpenMP 
backend.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64585

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/OpenMP/nested_parallel_threadprivate_copyin.cpp


Index: clang/test/OpenMP/nested_parallel_threadprivate_copyin.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nested_parallel_threadprivate_copyin.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -fopenmp -emit-llvm -o - | FileCheck %s
+#define NT 4   /* default number of threads */
+
+extern "C" {
+extern int printf(const char *, ...);
+extern void assert(int);
+extern void omp_set_dynamic(bool);
+extern void omp_set_num_threads(int);
+extern void omp_set_nested(bool);
+extern int omp_get_thread_num(void);
+extern int omp_get_ancestor_thread_num(int);
+};
+
+int main(void) {
+static int threadprivate_var = 1;
+#pragma omp threadprivate(threadprivate_var)
+
+// These commands are not strictly necessary, but they make it easier to
+// see when things go wrong.
+omp_set_dynamic(false);
+omp_set_num_threads(NT);
+omp_set_nested(true);
+
+// CHECK-NOT: call 
void.*@__kmpc_fork_call({{.*}}%{{\w+}}threadprivate{{.*}})
+// CHECK-NOT: define internal void 
@.omp_outlined.({{.*}}%threadprivate_var{{.*}})
+#pragma omp parallel
+{
+threadprivate_var = 1;
+printf("[B] thread %d: val %d: threadprivate @ %p\n", 
omp_get_thread_num(), threadprivate_var, &threadprivate_var);
+
+ 

[PATCH] D64585: [OpenMP] With nested parallelism, threadprivate variables become shared on outer parallel when appearing in inner parallel copyin clause

2019-07-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15329
 
+if (getLangOpts().OpenMP && getLangOpts().OpenMPUseTLS) {
+  // Avoid capturing TLS-backed threadprivate variables in outer scopes.

this is not the right place to fix this bug, it must be fixed in 
SemaOpenMP.cpp. If you want, I can try to fix it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64585/new/

https://reviews.llvm.org/D64585



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


[PATCH] D64585: [OpenMP] With nested parallelism, threadprivate variables become shared on outer parallel when appearing in inner parallel copyin clause

2019-07-11 Thread Princeton Ferro via Phabricator via cfe-commits
Prince781 added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15329
 
+if (getLangOpts().OpenMP && getLangOpts().OpenMPUseTLS) {
+  // Avoid capturing TLS-backed threadprivate variables in outer scopes.

ABataev wrote:
> this is not the right place to fix this bug, it must be fixed in 
> SemaOpenMP.cpp. If you want, I can try to fix it.
I see. Thanks for your comment. I noticed elsewhere in this function 
`tryCaptureVariable` that there is a `if (getLangOpts().OpenMP) ...`, so I 
thought it would be okay.

If you don't mind, I wish to take another look at this and get back to you 
later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64585/new/

https://reviews.llvm.org/D64585



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


r365821 - [OPENMP]Improve handling of analysis of unsupported VLAs in reductions.

2019-07-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 11 13:35:31 2019
New Revision: 365821

URL: http://llvm.org/viewvc/llvm-project?rev=365821&view=rev
Log:
[OPENMP]Improve handling of analysis of unsupported VLAs in reductions.

Fixed the processing of the unsupported VLAs in the reduction clauses.
Used targetDiag if the diagnostics can be delayed and emit it
immediately if the target does not support VLAs and we're parsing target
directive with the reduction clauses.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_vla_messages.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=365821&r1=365820&r2=365821&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 11 13:35:31 2019
@@ -9132,12 +9132,6 @@ public:
   }
   /// Return true inside OpenMP target region.
   bool isInOpenMPTargetExecutionDirective() const;
-  /// Return true if (un)supported features for the current target should be
-  /// diagnosed if OpenMP (offloading) is enabled.
-  bool shouldDiagnoseTargetSupportFromOpenMP() const {
-return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() ||
-  isInOpenMPTargetExecutionDirective();
-  }
 
   /// Return the number of captured regions created for an OpenMP directive.
   static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=365821&r1=365820&r2=365821&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 11 13:35:31 2019
@@ -12140,10 +12140,14 @@ static bool actOnOMPReductionKindClause(
 if ((OASE && !ConstantLengthOASE) ||
 (!OASE && !ASE &&
  D->getType().getNonReferenceType()->isVariablyModifiedType())) {
-  if (!Context.getTargetInfo().isVLASupported() &&
-  S.shouldDiagnoseTargetSupportFromOpenMP()) {
-S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
-S.Diag(ELoc, diag::note_vla_unsupported);
+  if (!Context.getTargetInfo().isVLASupported()) {
+if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective())) {
+  S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
+  S.Diag(ELoc, diag::note_vla_unsupported);
+} else {
+  S.targetDiag(ELoc, diag::err_omp_reduction_vla_unsupported) << 
!!OASE;
+  S.targetDiag(ELoc, diag::note_vla_unsupported);
+}
 continue;
   }
   // For arrays/array sections only:

Modified: cfe/trunk/test/OpenMP/target_vla_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_vla_messages.cpp?rev=365821&r1=365820&r2=365821&view=diff
==
--- cfe/trunk/test/OpenMP/target_vla_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_vla_messages.cpp Thu Jul 11 13:35:31 2019
@@ -206,4 +206,10 @@ void for_reduction(int arg) {
 #pragma omp parallel
 #pragma omp for reduction(+: vla[0:arg])
   for (int i = 0; i < arg; i++) ;
+#ifdef NO_VLA
+  // expected-error@+3 {{cannot generate code for reduction on array section, 
which requires a variable length array}}
+  // expected-note@+2 {{variable length arrays are not supported for the 
current target}}
+#endif
+#pragma omp target reduction(+ : vla[0:arg])
+  for (int i = 0; i < arg; i++) ;
 }


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


[PATCH] D64585: [OpenMP] With nested parallelism, threadprivate variables become shared on outer parallel when appearing in inner parallel copyin clause

2019-07-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15329
 
+if (getLangOpts().OpenMP && getLangOpts().OpenMPUseTLS) {
+  // Avoid capturing TLS-backed threadprivate variables in outer scopes.

Prince781 wrote:
> ABataev wrote:
> > this is not the right place to fix this bug, it must be fixed in 
> > SemaOpenMP.cpp. If you want, I can try to fix it.
> I see. Thanks for your comment. I noticed elsewhere in this function 
> `tryCaptureVariable` that there is a `if (getLangOpts().OpenMP) ...`, so I 
> thought it would be okay.
> 
> If you don't mind, I wish to take another look at this and get back to you 
> later.
Ok, no problems


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64585/new/

https://reviews.llvm.org/D64585



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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-11 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:25
+
+struct [[gsl::Owner(int)]] OwnerWithConv {
+  OwnerWithConv();

xazax.hun wrote:
> gribozavr wrote:
> > Would be nice if the second pair of types had clearly related names, like 
> > the first pair (MyOwner/MyPointer).
> Would renaming `MyPtrFromConv` to `PointerFromConv ` be enough to suggest the 
> relationship?
Yes, that would be sufficient. However my best suggestion would be:

MyOwner => MyIntOwner
MyPointer => MyIntPointer

OwnerWithConv => MyLongOwnerWithConversion
MyPtrFromConv => MyLongPointerFromConversion

Also makes it clear which two types are related together.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64256/new/

https://reviews.llvm.org/D64256



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


[PATCH] D62888: [NewPM] Port Sancov

2019-07-11 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62888/new/

https://reviews.llvm.org/D62888



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py:67
+  with open(os.path.join(__location__, checker["FullPackageName"]+".rst"),"w") 
as f:
+f.write(".. title:: clang-tidy - %s\n" % checker["FullPackageName"])
+f.write("\n")

For our other aliased checks, we usually add:
```
.. meta::
   :http-equiv=refresh: 5;URL=whatever.html
```
so that the redirect is automatic. I think we should probably retain that here 
as well, WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64454/new/

https://reviews.llvm.org/D64454



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


[PATCH] D64592: [OpenMP] Fix unified memory implementation for multiple compilation units

2019-07-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, jdoerfert, caomhin.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

This patch fixes the case where variables in different compilation units have 
the same name.


Repository:
  rC Clang

https://reviews.llvm.org/D64592

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_target_codegen.cpp
  test/OpenMP/declare_target_link_codegen.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -39,11 +39,11 @@
 // CHECK-HOST: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
 // CHECK-HOST: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
 
-// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [21 x i8]
-// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* getelementptr inbounds ([21 x i8], [21 x i8]* [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries"
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [23 x i8]
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries"
 
-// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [24 x i8]
-// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*), i8* getelementptr inbounds ([24 x i8], [24 x i8]* [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 0, i32 0 }, section ".omp_offloading.entries"
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [26 x i8]
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*), i8* getelementptr inbounds ([26 x i8], [26 x i8]* [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 0, i32 0 }, section ".omp_offloading.entries"
 
 // CHECK-HOST: @llvm.used = appending global [2 x i8*] [i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*)], section "llvm.metadata"
 
Index: test/OpenMP/declare_target_link_codegen.cpp
===
--- test/OpenMP/declare_target_link_codegen.cpp
+++ test/OpenMP/declare_target_link_codegen.cpp
@@ -18,15 +18,15 @@
 #define HEADER
 
 // HOST-DAG: @c = external global i32,
-// HOST-DAG: @c_decl_tgt_ref_ptr = global i32* @c
+// HOST-DAG: @c_0_decl_tgt_ref_ptr = global i32* @c
 // DEVICE-NOT: @c =
-// DEVICE: @c_decl_tgt_ref_ptr = common global i32* null
+// DEVICE: @c_0_decl_tgt_ref_ptr = common global i32* null
 // HOST: [[SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 4]
 // HOST: [[MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 35, i64 531]
-// HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00"
-// HOST: @.omp_offloading.entry.c_decl_tgt_ref_ptr = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name, i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries", align 1
-// DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00"
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*)]
+// HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_0_decl_tgt_ref_ptr\00"
+// HOST: @.omp_offloading.entry.c_0_decl_tgt_ref_ptr = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @c_0_decl_tgt_ref_ptr to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name, i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries", align 1
+// DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_0_decl_tgt_ref_ptr\00"
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32** @c_0_decl_tgt_ref_ptr to i8*)]
 
 extern int c;
 #pragma omp declare target link(c)
@@ -44,7 +44,7 @@
 }
 
 // DEVICE: define weak void @__omp_offloadin

[PATCH] D63954: Add lifetime categories attributes

2019-07-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2770
+def Owner : InheritableAttr {
+  let Spellings = [CXX11<"gsl", "Owner">];
+  let Subjects = SubjectList<[CXXRecord]>;

xazax.hun wrote:
> aaron.ballman wrote:
> > xazax.hun wrote:
> > > aaron.ballman wrote:
> > > > Has Microsoft already added support for this? We had an unfortunate 
> > > > problem with `gsl::suppress` where we introduced the attribute first 
> > > > and MSVC introduced it under a different, incompatible syntax. I would 
> > > > strongly like to avoid repeating that.
> > > I will double check this. Her Sutter's paper have this spelling and I 
> > > believe that the Microsoft implementation is following the same spelling. 
> > > The main difference is that the MSVC version does not have a type 
> > > argument at this point but they do plan to add it as an optional 
> > > argument. (They want to infer the pointee type when it is not provided.) 
> > > The clang community do not want the inference, hence we made the type 
> > > argument required. Always providing the type argument should be 
> > > compatible with future versions of the MSVC implementation.
> > I take this to mean that we're not implementing the same attribute as MSVC 
> > is, and that worries me.
> > 
> > > Always providing the type argument should be compatible with future 
> > > versions of the MSVC implementation.
> > 
> > The problem is that code written for MSVC (where the type argument is not 
> > required) will not compile with Clang (where the type argument is 
> > required), if I understand properly.
> > 
> > Generally speaking, when we implement an attribute from another vendor 
> > namespace, we expect the attribute to have the same semantics as whoever 
> > "owns" that vendor namespace. It's a bit trickier here because `gsl` isn't 
> > really a vendor so much as a collective, so I don't know who is the 
> > authority to turn to.
> > 
> > On a completely different note: would this attribute also make sense within 
> > C with a C2x spelling?
> I see, that is a valid concern. A followup patch makes the type argument 
> optional so it will be fully compatible with MSVC.  I don't think it makes 
> sense with C or at least I am not sure what would I annotate using these 
> attributes in C code as the subjects are classes. I know that it is possible 
> to simulate classes in C but I am not sure how well the analysis would work 
> in such cases. 
> 
> Are you OK with making the argument optional in a followup patch or do you 
> want us to cherry-pick that modification into this one?
> I don't think it makes sense with C or at least I am not sure what would I 
> annotate using these attributes in C code as the subjects are classes. I know 
> that it is possible to simulate classes in C but I am not sure how well the 
> analysis would work in such cases.

I couldn't think of a reason to expose this in C either, so I think the current 
spelling is good as-is.

> Are you OK with making the argument optional in a followup patch or do you 
> want us to cherry-pick that modification into this one?

I'd prefer the argument be optional in this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63954/new/

https://reviews.llvm.org/D63954



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


r365822 - CodeGen, NFC: Test for auto-init for 32bit pointers

2019-07-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jul 11 13:51:59 2019
New Revision: 365822

URL: http://llvm.org/viewvc/llvm-project?rev=365822&view=rev
Log:
CodeGen, NFC: Test for auto-init for 32bit pointers

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365822&r1=365821&r2=365822&view=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Thu Jul 11 13:51:59 2019
@@ -5,6 +5,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O0,ZERO,ZERO-O0
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fno-experimental-new-pass-manager 
-emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-LEGACY
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fexperimental-new-pass-manager -emit-llvm 
-o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-NEWPM
+// RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=PATTERN-I386
 
 template void used(T &) noexcept;
 
@@ -64,6 +65,9 @@ struct smallpartinit { char c = 42, d; }
 // PATTERN-O1-NOT: @__const.test_nullinit_uninit.uninit
 // PATTERN-O1-NOT: @__const.test_nullinit_braces.braces
 // PATTERN-O1-NOT: @__const.test_nullinit_custom.custom
+// PATTERN-I386: @__const.test_nullinit_uninit.uninit = private unnamed_addr 
constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_braces.braces = private unnamed_addr 
constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_custom.custom = private unnamed_addr 
constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
 struct nullinit { char* null = nullptr; };
 // PATTERN-O0: @__const.test_padded_uninit.uninit = private unnamed_addr 
constant { i8, [3 x i8], i32 } { i8 -86, [3 x i8] c"\AA\AA\AA", i32 -1431655766 
}, align 4
 // PATTERN-O0: @__const.test_padded_custom.custom = private unnamed_addr 
constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 
}, align 4
@@ -139,6 +143,7 @@ struct arraytail { int i; int arr[]; };
 // PATTERN-O1-NOT: @__const.test_tailpad4_uninit.uninit
 // PATTERN: @__const.test_tailpad4_custom.custom = private unnamed_addr 
constant [4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 257, i8 1, [1 
x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }], align 16
 // ZERO: @__const.test_tailpad4_custom.custom = private unnamed_addr constant 
[4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }], align 16
+// PATTERN-I386: @__const.test_intptr4_custom.custom = private unnamed_addr 
constant [4 x i32*] [i32* inttoptr (i32 572662306 to i32*), i32* inttoptr (i32 
572662306 to i32*), i32* inttoptr (i32 572662306 to i32*), i32* inttoptr (i32 
572662306 to i32*)], align 4
 struct tailpad { short s; char c; };
 // PATTERN-O0: @__const.test_atomicnotlockfree_uninit.uninit = private 
unnamed_addr constant %struct.notlockfree { [4 x i64] [i64 
-6148914691236517206, i64 -6148914691236517206, i64 -6148914691236517206, i64 
-6148914691236517206] }, align 8
 // PATTERN-O1-NOT: @__const.test_atomicnotlockfree_uninit.uninit
@@ -176,16 +181,19 @@ struct semivolatileinit { int i = 0x
 // PATTERN-O1-NOT: @__const.test_base_uninit.uninit
 // PATTERN-O0: @__const.test_base_braces.braces = private unnamed_addr 
constant %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 
(...)**) }, align 8
 // PATTERN-O1-NOT: @__const.test_base_braces.braces
+// PATTERN-I386: @__const.test_base_uninit.uninit = private unnamed_addr 
constant %struct.base { i32 (...)** inttoptr (i32 170 to i32 (...)**) }, align 4
 struct base { virtual ~base(); };
 // PATTERN-O0: @__const.test_derived_uninit.uninit = private unnamed_addr 
constant %struct.derived { %struct.base { i32 (...)** inttoptr (i64 
-6148914691236517206 to i32 (...)**) } }, align 8
 // PATTERN-O1-NOT: @__const.test_derived_uninit.uninit
 // PATTERN-O0: @__const.test_derived_braces.braces = private unnamed_addr 
constant %struct.derived { %struct.base { i32 (...)** inttoptr (i64 
-614891469123

[PATCH] D64592: [OpenMP] Fix unified memory implementation for multiple compilation units

2019-07-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Description lacking.
Why is that bad?
How does this play wrt reproducibility of the output?
Normally value names in IR are completely discarded in Release build mode, why 
do they matter here?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592



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


[PATCH] D63967: Handle IntToPtr in isBytewiseValue

2019-07-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63967/new/

https://reviews.llvm.org/D63967



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


[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1948
+def RequiresDesignator : InheritableAttr {
+  let Spellings = [Clang<"requires_designator">];
+  let Subjects = SubjectList<[Record]>;

emmettneyman wrote:
> compnerd wrote:
> > aaron.ballman wrote:
> > > Hmm, after making this suggestion, I noticed that GCC seems to support a 
> > > similar attribute named `designated_init` 
> > > (https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#Common-Type-Attributes).
> > >  Was your goal to support the same thing GCC supported?
> > `designated_init` is a suggestion, the original patch seemed to be a 
> > stronger version.  I think that we should be supporting the GNU spelling 
> > for `designated_init` and can support a Clang spelling of 
> > `requires_designated_init` if the goal is to have the stronger guarantee 
> > that this *must* happen.
> I hadn't known about the GCC attribute until now. Yes, the 
> `requires_designator` (originally `require_designated_init`) attribute wants 
> to enforce the same thing I believe. I couldn't find more documentation for 
> the GCC `designated_init` attribute so it's a little tough to tell whether 
> the behavior is the exact same. The attribute in this patch allows a field to 
> be default constructed (unless the other attribute is applied to that 
> specific field) but enforces that a brace initializer must be used. So `Foo 
> foo {};` would be valid (every field is default constructed) but `Foo foo;` 
> would not be valid. I'm not sure if that's the same behavior the GCC 
> attribute is trying to enforce. But on a high level, both are trying to 
> prohibit using positional args when declaring a struct.
> 
> @compnerd I don't mind this attribute generating warnings rather than errors. 
> It's ok for this attribute to be a "suggestion" as well. Like @aaron.ballman 
> mentioned, "users can always use -Werror to strengthen their own 
> requirements."
I think the correct approach then is: add this attribute under the name 
`designated_init` with the `GCC` spelling kind and match GCC's behavior for it 
(or, if we don't want to match GCC's behavior, note where we differ and why). 
We should put its diagnostics under a `-Wdesignated-init` warning group.

The next question is: are you interested in finding out whether GCC would be 
willing to implement the `requires_init` attribute? If GCC is interested in 
picking it up, then we can name it with the `GCC` spelling as well. If the GCC 
folks are not interested in picking up the attribute, then we should probably 
leave it with the `Clang` spelling. I'd recommend we put the diagnostics into 
the `-Wdesignated-init` warning group as well.

I think both of these attributes should also be available in C2x mode as well, 
but that can probably be done in a follow-up patch as it will involve tablegen 
changes and opens up other questions (i.e., does GCC handle C2x attributes yet, 
and if they do, are they making `designated_init` available in that mode?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64380/new/

https://reviews.llvm.org/D64380



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


[PATCH] D63967: Handle IntToPtr in isBytewiseValue

2019-07-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: llvm/lib/Analysis/ValueTracking.cpp:3222
 
+  if (auto *CE = dyn_cast(C)) {
+if (CE->getOpcode() == Instruction::IntToPtr) {

@pcc BTW, your original patch just gave up on size mismatch
Something like:
```
if (auto *CE = dyn_cast(C)) {
if (CE->getOpcode() == Instruction::IntToPtr &&
cast(CE->getOperand(0)->getType())->getBitWidth() ==
DL.getPointerSizeInBits(
cast(CE->getType())->getAddressSpace())) {
  return isBytewiseValue(CE->getOperand(0), DL);
}
return nullptr;
  }
```

Both versions affect binary size about the same.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63967/new/

https://reviews.llvm.org/D63967



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


[PATCH] D64580: cmake: Add INSTALL_WITH_TOOLCHAIN option to add_*_library macros

2019-07-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64580/new/

https://reviews.llvm.org/D64580



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


[PATCH] D64592: [OpenMP] Fix unified memory implementation for multiple compilation units

2019-07-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2567
+  std::hash HashFn;
+  size_t hash = 0;
+  if (!CGM.getCodeGenOpts().MainFileName.empty())

1. Capitalize the first letter in tbe variable name.
2. Why do you need to use hash? Could you use variable sourcelocation instead?
Also, what if the variable is defined in one file but declared in another one 
file. Will it be linked correctly?



Comment at: lib/Sema/SemaOpenMP.cpp:2625
+  bool IsUsingUnifiedMemory =
+  Stack->hasRequiresDeclWithClause();
   if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&

I assume the changes in this file are from the different fix.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592



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


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xAAAAAAAA

2019-07-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: pcc, eugenis, glider, jfb.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Patch extends effect of D63967  to 32bit 
platforms and improves pattern
initialization there. It cuts size of 32bit binary compiled with 
-ftrivial-auto-var-init=pattern by 2%.

Using pointer on the first page was useful but is not worth of 2%

Binary size change on CTMark, (with -fuse-ld=lld -Wl,--icf=all, similar results 
with default linker options)

 master   patch  diff
  Os pattern   7.915580e+057.727164e+05 -0.026256 
  O3 pattern   9.953688e+059.769336e+05 -0.018545 

Zero vs Pattern on master

 zero   pattern  diff
  Os 7.689712e+05  7.915580e+05  0.031380
  O3 9.744796e+05  9.953688e+05  0.021133

Zero vs Pattern with the patch

 zero   pattern  diff
  Os 7.689712e+05  7.727164e+05  0.003025
  O3 9.744796e+05  9.769336e+05  0.001525


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64597

Files:
  clang/lib/CodeGen/PatternInit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp

Index: clang/test/CodeGenCXX/auto-var-init.cpp
===
--- clang/test/CodeGenCXX/auto-var-init.cpp
+++ clang/test/CodeGenCXX/auto-var-init.cpp
@@ -65,9 +65,9 @@
 // PATTERN-O1-NOT: @__const.test_nullinit_uninit.uninit
 // PATTERN-O1-NOT: @__const.test_nullinit_braces.braces
 // PATTERN-O1-NOT: @__const.test_nullinit_custom.custom
-// PATTERN-I386: @__const.test_nullinit_uninit.uninit = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
-// PATTERN-I386: @__const.test_nullinit_braces.braces = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
-// PATTERN-I386: @__const.test_nullinit_custom.custom = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_uninit.uninit = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i32 -1431655766 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_braces.braces = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i32 -1431655766 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_custom.custom = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i32 -1431655766 to i8*) }, align 4
 struct nullinit { char* null = nullptr; };
 // PATTERN-O0: @__const.test_padded_uninit.uninit = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 -86, [3 x i8] c"\AA\AA\AA", i32 -1431655766 }, align 4
 // PATTERN-O0: @__const.test_padded_custom.custom = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, align 4
@@ -181,19 +181,19 @@
 // PATTERN-O1-NOT: @__const.test_base_uninit.uninit
 // PATTERN-O0: @__const.test_base_braces.braces = private unnamed_addr constant %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 (...)**) }, align 8
 // PATTERN-O1-NOT: @__const.test_base_braces.braces
-// PATTERN-I386: @__const.test_base_uninit.uninit = private unnamed_addr constant %struct.base { i32 (...)** inttoptr (i32 170 to i32 (...)**) }, align 4
+// PATTERN-I386: @__const.test_base_uninit.uninit = private unnamed_addr constant %struct.base { i32 (...)** inttoptr (i32 -1431655766 to i32 (...)**) }, align 4
 struct base { virtual ~base(); };
 // PATTERN-O0: @__const.test_derived_uninit.uninit = private unnamed_addr constant %struct.derived { %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 (...)**) } }, align 8
 // PATTERN-O1-NOT: @__const.test_derived_uninit.uninit
 // PATTERN-O0: @__const.test_derived_braces.braces = private unnamed_addr constant %struct.derived { %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 (...)**) } }, align 8
 // PATTERN-O1-NOT: @__const.test_derived_braces.braces
-// PATTERN-I386: @__const.test_derived_uninit.uninit = private unnamed_addr constant %struct.derived { %struct.base { i32 (...)** inttoptr (i32 170 to i32 (...)**) } }, align 4
+// PATTERN-I386: @__const.test_derived_uninit.uninit = private unnamed_addr constant %struct.derived { %struct.base { i32 (...)** inttoptr (i32 -1431655766 to i32 (...)**) } }, align 4
 struct derived : public base {};
 // PATTERN-O0: @__const.test_virtualderived_uninit.uninit = private unnamed_addr constant %struct.virtualderived { %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 (...)**) }, %struct.derived { %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 (...)**) } } }, align 8
 // PATTERN-O1-NOT: @__const.test_virtualderived_uninit.uninit
 // PATTERN-O0: @__const.test_virtualderived_braces.braces = private unnamed_addr constant %struct.virtualderived { %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 (.

[PATCH] D64582: cmake: Fix install of libclang_shared.so when LLVM_INSTALL_TOOLCHAIN_ONLY=ON

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64582/new/

https://reviews.llvm.org/D64582



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


[PATCH] D64580: cmake: Add INSTALL_WITH_TOOLCHAIN option to add_*_library macros

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Nice.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64580/new/

https://reviews.llvm.org/D64580



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


[PATCH] D64598: fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic

2019-07-11 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: eli.friedman, jdoerfert, ast.
Herald added subscribers: kristina, arphaman, aprantl.
Herald added a project: clang.

This is a followup patch for https://reviews.llvm.org/D61809.
Handle unnamed bitfield properly and add more test cases

Fixed the unnamed bitfield issue. The unnamed bitfield is ignored
by debug info, so we need to ignore such a struct/union member
when we try to get the member index in the debug info.

D61809  contains two test cases but not enough 
as it does
not checking generated IRs in the fine grain level, and also
it does not have semantics checking tests.
This patch added unit tests for both code gen and semantics checking for
the new intrinsic.


Repository:
  rC Clang

https://reviews.llvm.org/D64598

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/builtin-preserve-access-index.c
  test/Sema/builtin-preserve-access-index.c

Index: test/Sema/builtin-preserve-access-index.c
===
--- /dev/null
+++ test/Sema/builtin-preserve-access-index.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+const void *invalid1(const int *arg) {
+  return __builtin_preserve_access_index(&arg[1], 1); // expected-error {{too many arguments to function call, expected 1, have 2}}
+}
+
+void *invalid2(const int *arg) {
+  return __builtin_preserve_access_index(&arg[1]); // expected-warning {{returning 'const void *' from a function with result type 'void *' discards qualifiers}}
+}
+
+const void *invalid3(const int *arg) {
+  return __builtin_preserve_access_index(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *'}}
+}
Index: test/CodeGen/builtin-preserve-access-index.c
===
--- /dev/null
+++ test/CodeGen/builtin-preserve-access-index.c
@@ -0,0 +1,167 @@
+// RUN: %clang -target x86_64 -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x) (__builtin_preserve_access_index(x))
+
+const void *unit1(const void *arg) {
+  return _(arg);
+}
+// CHECK: define dso_local i8* @unit1(i8* %arg)
+// CHECK-NOT: llvm.preserve.array.access.index
+// CHECK-NOT: llvm.preserve.struct.access.index
+// CHECK-NOT: llvm.preserve.union.access.index
+
+const void *unit2(void) {
+  return _((const void *)0xULL);
+}
+// CHECK: define dso_local i8* @unit2()
+// CHECK-NOT: llvm.preserve.array.access.index
+// CHECK-NOT: llvm.preserve.struct.access.index
+// CHECK-NOT: llvm.preserve.union.access.index
+
+const void *unit3(const int *arg) {
+  return _(arg + 1);
+}
+// CHECK: define dso_local i8* @unit3(i32* %arg)
+// CHECK-NOT: llvm.preserve.array.access.index
+// CHECK-NOT: llvm.preserve.struct.access.index
+// CHECK-NOT: llvm.preserve.union.access.index
+
+const void *unit4(const int *arg) {
+  return _(&arg[1]);
+}
+// CHECK: define dso_local i8* @unit4(i32* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %0, i32 0, i32 1)
+
+const void *unit5(const int *arg[5]) {
+  return _(&arg[1][2]);
+}
+// CHECK: define dso_local i8* @unit5(i32** %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32** @llvm.preserve.array.access.index.p0p0i32.p0p0i32(i32** %0, i32 0, i32 1)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %2, i32 0, i32 2)
+
+struct s1 {
+  char a;
+  int b;
+};
+
+struct s2 {
+  char a1:1;
+  char a2:1;
+  int b;
+};
+
+struct s3 {
+  char a1:1;
+  char a2:1;
+  char :6;
+  int b;
+};
+
+const void *unit6(struct s1 *arg) {
+  return _(&arg->a);
+}
+// CHECK: define dso_local i8* @unit6(%struct.s1* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.s1s(%struct.s1* %0, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}
+
+const void *unit7(struct s1 *arg) {
+  return _(&arg->b);
+}
+// CHECK: define dso_local i8* @unit7(%struct.s1* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s1s(%struct.s1* %0, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}
+
+const void *unit8(struct s2 *arg) {
+  return _(&arg->b);
+}
+// CHECK: define dso_local i8* @unit8(%struct.s2* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s2s(%struct.s2* %0, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}
+
+const void *unit9(struct s3 *arg) {
+  return _(&arg->b);
+}
+// CHECK: define dso_local i8* @unit9(%struct.s3* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s3s(%struct.s3* %0, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]

[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.

Yea, this makes sense even if it is a bit sad. We do use the `--whole-archive` 
approach for `libLLVM`, and it works. I was hoping to avoid it here in part to 
free up the ability to link `libclang_shared` before or in parallel to 
archiving the `libclang*.a` archives.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579



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


r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: http://llvm.org/viewvc/llvm-project?rev=365825&view=rev
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

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

Modified:
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=365825&r1=365824&r2=365825&view=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Thu Jul 11 14:20:38 2019
@@ -7,8 +7,35 @@ get_property(clang_libs GLOBAL PROPERTY
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute 
the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead 
of
+  # using the object library at all. However, CMake reorders static libraries 
on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, 
linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared


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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365825: [clang-shlib] Fix clang-shlib for PRIVATE 
dependencies (authored by smeenai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64579?vs=209283&id=209336#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579

Files:
  cfe/trunk/tools/clang-shlib/CMakeLists.txt


Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -7,8 +7,35 @@
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute 
the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead 
of
+  # using the object library at all. However, CMake reorders static libraries 
on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, 
linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared


Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -7,8 +7,35 @@
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead of
+  # using the object library at all. However, CMake reorders static libraries on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared
___
cfe-commits mailing list
cfe

[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D64579#1581557 , @beanz wrote:

> Yea, this makes sense even if it is a bit sad. We do use the 
> `--whole-archive` approach for `libLLVM`, and it works. I was hoping to avoid 
> it here in part to free up the ability to link `libclang_shared` before or in 
> parallel to archiving the `libclang*.a` archives.


Yeah, makes sense. I've had issues with static libraries getting reordered out 
of the `--whole-archive` with other projects in the past, which makes me wary 
of it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64579/new/

https://reviews.llvm.org/D64579



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


r365827 - [analyzer] exploded-graph-rewriter: Fix filenames in program point.

2019-07-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jul 11 14:27:42 2019
New Revision: 365827

URL: http://llvm.org/viewvc/llvm-project?rev=365827&view=rev
Log:
[analyzer] exploded-graph-rewriter: Fix filenames in program point.

Fix a typo in JSON field name.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot?rev=365827&r1=365826&r2=365827&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot 
(original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot Thu Jul 
11 14:27:42 2019
@@ -52,7 +52,7 @@ Node0x1 [shape=record,label=
 // CHECK-SAME: 
 // CHECK-SAME:   
 // CHECK-SAME: 
-// CHECK-SAME:   (main file):4:5:
+// CHECK-SAME:   main.cpp:4:5:
 // CHECK-SAME: 
 // CHECK-SAME: 
 // CHECK-SAME:   DeclRefExpr
@@ -83,6 +83,7 @@ Node0x2 [shape=record,label=
 "pointer": "0x3",
 "pretty": "x",
 "location": {
+  "file": "main.cpp",
   "line": 4,
   "column": 5
 },

Modified: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/exploded-graph-rewriter.py?rev=365827&r1=365826&r2=365827&view=diff
==
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py (original)
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Thu Jul 11 14:27:42 2019
@@ -16,6 +16,7 @@ import collections
 import difflib
 import json
 import logging
+import os
 import re
 
 
@@ -50,8 +51,8 @@ class SourceLocation(object):
 super(SourceLocation, self).__init__()
 self.line = json_loc['line']
 self.col = json_loc['column']
-self.filename = json_loc['filename'] \
-if 'filename' in json_loc else '(main file)'
+self.filename = os.path.basename(json_loc['file']) \
+if 'file' in json_loc else '(main file)'
 
 
 # A deserialized program point.


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


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xAAAAAAAA

2019-07-11 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

The problem with `0x` on 32-bit is that it is likely to be a valid 
address.

When I discussed this with JF I proposed a pointer initialization of 
`0x` which he agreed to. This value is very likely to trap when 
accessed (due to accesses likely wrapping to zero) and also has the benefit of 
being the same pattern as for floats.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64597/new/

https://reviews.llvm.org/D64597



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


[PATCH] D64582: cmake: Fix install of libclang_shared.so when LLVM_INSTALL_TOOLCHAIN_ONLY=ON

2019-07-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64582/new/

https://reviews.llvm.org/D64582



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


[PATCH] D64278: Rename libclang_shared to libclang-cpp

2019-07-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

This is fine with me. I have no real attachment to the name.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64278/new/

https://reviews.llvm.org/D64278



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


[PATCH] D62888: [NewPM] Port Sancov

2019-07-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM, thanks so much for sticking through this, I know it was ... nontrivial!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62888/new/

https://reviews.llvm.org/D62888



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


r365831 - Rename libclang_shared to libclang-cpp

2019-07-11 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Thu Jul 11 14:42:55 2019
New Revision: 365831

URL: http://llvm.org/viewvc/llvm-project?rev=365831&view=rev
Log:
Rename libclang_shared to libclang-cpp

Summary: Fix bug 42475

Reviewers: beanz, tstellar

Reviewed By: beanz

Subscribers: kimgr, mgorny, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=365831&r1=365830&r2=365831&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jul 11 14:42:55 2019
@@ -324,7 +324,7 @@ set(CLANG_PYTHON_BINDINGS_VERSIONS "" CA
 "Python versions to install libclang python bindings for")
 
 set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
-"Link tools against libclang_shared.so")
+"Link tools against libclang-cpp.so")
 
 if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
   message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=365831&r1=365830&r2=365831&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Thu Jul 11 14:42:55 2019
@@ -175,7 +175,7 @@ endmacro()
 
 function(clang_target_link_libraries target type)
   if (CLANG_LINK_CLANG_DYLIB)
-target_link_libraries(${target} ${type} clang_shared)
+target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=365831&r1=365830&r2=365831&view=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Thu Jul 11 14:42:55 2019
@@ -1,4 +1,4 @@
-# Building libclang_shared.so fails if LLVM_ENABLE_PIC=Off
+# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()
 endif()
@@ -38,7 +38,7 @@ foreach (lib ${clang_libs})
   list(APPEND _DEPS ${lib})
 endforeach ()
 
-add_clang_library(clang_shared
+add_clang_library(clang-cpp
   SHARED
   clang-shlib.cpp
   ${_OBJECTS}


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


[PATCH] D64278: Rename libclang_shared to libclang-cpp

2019-07-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365831: Rename libclang_shared to libclang-cpp (authored by 
sylvestre, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64278?vs=208258&id=209346#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64278/new/

https://reviews.llvm.org/D64278

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/cmake/modules/AddClang.cmake
  cfe/trunk/tools/clang-shlib/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -324,7 +324,7 @@
 "Python versions to install libclang python bindings for")
 
 set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
-"Link tools against libclang_shared.so")
+"Link tools against libclang-cpp.so")
 
 if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
   message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "
Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Building libclang_shared.so fails if LLVM_ENABLE_PIC=Off
+# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()
 endif()
@@ -38,7 +38,7 @@
   list(APPEND _DEPS ${lib})
 endforeach ()
 
-add_clang_library(clang_shared
+add_clang_library(clang-cpp
   SHARED
   clang-shlib.cpp
   ${_OBJECTS}
Index: cfe/trunk/cmake/modules/AddClang.cmake
===
--- cfe/trunk/cmake/modules/AddClang.cmake
+++ cfe/trunk/cmake/modules/AddClang.cmake
@@ -175,7 +175,7 @@
 
 function(clang_target_link_libraries target type)
   if (CLANG_LINK_CLANG_DYLIB)
-target_link_libraries(${target} ${type} clang_shared)
+target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -324,7 +324,7 @@
 "Python versions to install libclang python bindings for")
 
 set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
-"Link tools against libclang_shared.so")
+"Link tools against libclang-cpp.so")
 
 if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
   message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "
Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Building libclang_shared.so fails if LLVM_ENABLE_PIC=Off
+# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()
 endif()
@@ -38,7 +38,7 @@
   list(APPEND _DEPS ${lib})
 endforeach ()
 
-add_clang_library(clang_shared
+add_clang_library(clang-cpp
   SHARED
   clang-shlib.cpp
   ${_OBJECTS}
Index: cfe/trunk/cmake/modules/AddClang.cmake
===
--- cfe/trunk/cmake/modules/AddClang.cmake
+++ cfe/trunk/cmake/modules/AddClang.cmake
@@ -175,7 +175,7 @@
 
 function(clang_target_link_libraries target type)
   if (CLANG_LINK_CLANG_DYLIB)
-target_link_libraries(${target} ${type} clang_shared)
+target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xAAAAAAAA

2019-07-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D64597#1581605 , @pcc wrote:

> The problem with `0x` on 32-bit is that it is likely to be a valid 
> address.
>
> When I discussed this with JF I proposed a pointer initialization of 
> `0x` which he agreed to. This value is very likely to trap when 
> accessed (due to accesses likely wrapping to zero) and also has the benefit 
> of being the same pattern as for floats.


Indeed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64597/new/

https://reviews.llvm.org/D64597



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


r365832 - Fix a Python3 compatibility error

2019-07-11 Thread Azharuddin Mohammed via cfe-commits
Author: azhar
Date: Thu Jul 11 14:45:48 2019
New Revision: 365832

URL: http://llvm.org/viewvc/llvm-project?rev=365832&view=rev
Log:
Fix a Python3 compatibility error

  File "clang/test/lit.cfg.py", line 186, in 
config.available_features.add('macos-sdk-' + macOSSDKVersion)
TypeError: must be str, not bytes

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=365832&r1=365831&r2=365832&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Thu Jul 11 14:45:48 2019
@@ -183,7 +183,7 @@ if run_console_tests != 0:
 lit.util.usePlatformSdkOnDarwin(config, lit_config)
 macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
 if macOSSDKVersion is not None:
-config.available_features.add('macos-sdk-' + macOSSDKVersion)
+config.available_features.add('macos-sdk-' + str(macOSSDKVersion))
 
 if os.path.exists('/etc/gentoo-release'):
 config.available_features.add('gentoo')


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


[PATCH] D63975: Warn when ScopeDepthOrObjCQuals overflows

2019-07-11 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:6587
+return;
+  }
+

rjmccall wrote:
> Comment indentation.
> 
> Should we do this when starting to parse a function prototype instead of when 
> parsing a parameter?
Thanks I noticed I forgot to change the tabs to spaces.

I looked at your suggestion to move the code, but I think this is the proper 
place. Now it also validates whether lambdas exceed the limit, else we need to 
check at two places.
I'll also add a unit test to test for the lambda.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63975/new/

https://reviews.llvm.org/D63975



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


[PATCH] D64062: Remove both -dumpversion and __VERSION__

2019-07-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

In D64062#1581290 , @rnk wrote:

> Perhaps we should just remove `__VERSION__` and keep `-dumpversion`.


As you wish. clang --version seems an alternative and dumpversion never 
//worked// for clang. so, I don't expect software to use it for clang.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64062/new/

https://reviews.llvm.org/D64062



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


[PATCH] D63975: Warn when ScopeDepthOrObjCQuals overflows

2019-07-11 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 209348.
Mordante added a comment.

tab -> space
adds an extra unit test for lambdas
fixes an off by one error found while testing the lambdas


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63975/new/

https://reviews.llvm.org/D63975

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/nested_function_prototype_overflow.cpp
  clang/test/Parser/nested_lambda_overflow.cpp


Index: clang/test/Parser/nested_lambda_overflow.cpp
===
--- /dev/null
+++ clang/test/Parser/nested_lambda_overflow.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: not %clang_cc1 %s -fsyntax-only -DFAIL 2>&1 | FileCheck %s
+
+auto foo = [](void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(
+#ifdef FAIL
+void (*f)()
+#endif
+)
 {};
+// CHECK: fatal error: function scope depth exceeded maximum of 127
Index: clang/test/Parser/nested_function_prototype_overflow.cpp
===
--- /dev/null
+++ clang/test/Parser/nested_function_prototype_overflow.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: not %clang_cc1 %s -fsyntax-only -DFAIL 2>&1 | FileCheck %s
+
+void foo(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(
+#ifdef FAIL
+void (*f)()
+#endif
+);
+// CHECK: fatal error: function scope depth exceeded maximum of 127
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6576,6 +6576,18 @@
   Actions.containsUnexpandedParameterPacks(ParmDeclarator))
 DiagnoseMisplacedEllipsisInDeclarator(ConsumeToken(), ParmDeclarator);
 
+  // Avoid exceeding the maximum function scope depth.
+  // See https://bugs.llvm.org/show_bug.cgi?id=19607
+  // Note Sema::ActOnParamDeclarator calls ParmVarDecl::setScopeInfo with
+  // getFunctionPrototypeDepth() - 1.
+  if (getCurScope()->getFunctionPrototypeDepth() - 1 >
+  ParmVarDecl::getMaxFunctionScopeDepth()) {
+Diag(DSStart, diag::err_function_scope_depth_e

r365835 - CodeGen: Suppress c++ warnings in test

2019-07-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jul 11 14:59:09 2019
New Revision: 365835

URL: http://llvm.org/viewvc/llvm-project?rev=365835&view=rev
Log:
CodeGen: Suppress c++ warnings in test

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365835&r1=365834&r2=365835&view=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Thu Jul 11 14:59:09 2019
@@ -7,6 +7,8 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fexperimental-new-pass-manager -emit-llvm 
-o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-NEWPM
 // RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=PATTERN-I386
 
+#pragma clang diagnostic ignored "-Winaccessible-base"
+
 template void used(T &) noexcept;
 
 #define TEST_UNINIT(NAME, TYPE) \


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


[PATCH] D64600: [ObjC] Add an attribute that "clamps" signed char BOOLs to {0,1}

2019-07-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rjmccall, aaron.ballman, steven_wu.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

This attribute can be applied to typedefs of BOOL in Objective-C. It causes 
loads, stores, and casts to BOOL to clamp into {0,1}. This is useful for us 
because a lot of code is going to be moving from a platform where BOOL is a 
typedef for a native bool type (iOS) to a platform where its a typedef for 
signed char (macOS) because of macCatalyst. We can't change the type of the 
BOOL, since its ABI.

rdar://6510042

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D64600

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenObjC/objc-clamping-bool.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/objc-clamping-bool.m

Index: clang/test/SemaObjC/objc-clamping-bool.m
===
--- /dev/null
+++ clang/test/SemaObjC/objc-clamping-bool.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+typedef __attribute__((objc_clamping_bool)) signed char BOOL;
+
+// expected-error@+1 {{'objc_clamping_bool' attribute takes no arguments}}
+typedef __attribute__((objc_clamping_bool(1))) signed char BOOL2;
+
+// expected-warning@+1 {{'objc_clamping_bool' attribute only applies to typedefs}}
+__attribute__((objc_clamping_bool)) signed char x;
+
+// expected-error@+1 {{objc_clamping_bool must appertain to a signed char type}}
+typedef __attribute__((objc_clamping_bool)) unsigned char UNSIGNED_BOOL;
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -98,6 +98,7 @@
 // CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
 // CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCBridgeRelated (SubjectMatchRule_record)
+// CHECK-NEXT: ObjCClampingBool (SubjectMatchRule_type_alias)
 // CHECK-NEXT: ObjCClassStub (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCDesignatedInitializer (SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCException (SubjectMatchRule_objc_interface)
Index: clang/test/CodeGenObjC/objc-clamping-bool.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/objc-clamping-bool.m
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.14 -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef __attribute__((objc_clamping_bool)) signed char BOOL;
+
+BOOL b;
+
+void store() {
+  // CHECK-LABEL: define void @store
+
+  b = 2;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  b = 1;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  b = -1;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  b = 0;
+  // CHECK: store i8 0, i8* @b, align 1
+
+  b = 256;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  int unknown_value;
+  b = unknown_value;
+
+  // CHECK: [[CMPNE:%.*]] = icmp ne i32 %{{.*}}, 0
+  // CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMPNE]] to i8
+}
+
+void load() {
+  // CHECK-LABEL: define void @load
+  int load = b;
+
+  // CHECK: [[LOAD:%.*]] = load i8, i8* @b, align 1
+  // CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 %0, 0
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+}
+
+void cast() {
+  // CHECK-LABEL: define void @cast
+  int i;
+  float f;
+  long double ld;
+  int* p;
+  _Bool real_bool;
+
+  (BOOL)i;
+  // CHECK: [[CMP:%.*]] = icmp ne i32 %{{.*}}, 0
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)f;
+  // CHECK: [[CMP:%.*]] = fcmp une float %{{.*}}, 0.00e+00
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)ld;
+  // CHECK: [[CMP:%.*]] = fcmp une x86_fp80 %{{.*}}, 0xK
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)p;
+  // CHECK: [[CMP:%.*]] = icmp ne i32* %{{.*}}, null
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)real_bool;
+  // CHECK: [[CMP:%.*]] = icmp ne i1 %{{.*}}, false
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+}
+
+void bits() {
+  // CHECK-LABEL: define void @bits
+  struct bit_field {
+BOOL b : 1;
+  };
+
+  struct bit_field bf;
+
+  bf.b = 1;
+  // CHECK: [[SET_BIT:%.*]] = or i8 %{{.*}}, 1
+  // CHECK-NEXT: store i8 [[SET_BIT]]
+
+  bf.b = 2;
+  // CHECK: [[SET_BIT:%.*]] = or i8 %{{.*}}, 1
+  // CHECK-NEXT: store i8 [[SET_BIT]]
+
+  bf.b = 0;
+  // CHECK: [[ZERO_BIT:%.*]] = and i8 %{{.*}}, -2
+  // CHECK-NEXT: store i8 [[ZERO_BIT]]
+
+  bf.b = -1;
+  // CHECK: [[SET_BIT:%.*]] = or i8 %{{.*}}, 1
+  // CHECK-NEXT: store i8 [[SET_BIT]]
+
+  (int)

[PATCH] D64146: [ConstExprPreter][WIP] Initial patch for the constexpr interpreter

2019-07-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: clang/lib/AST/ExprVM/Compiler.cpp:85
+/* isArray */ false,
+/* isGlobal */ false);
+  ParamDescriptors.insert({ParamOffset, std::move(Desc)});

Usually the style used is `/*isMutable=*/true`



Comment at: clang/lib/AST/ExprVM/Compiler.h:69
+public:
+  /// Creates a compiler for a funciton.
+  Compiler(Context &Ctx, Program &P, const FunctionDecl *F);

"function"



Comment at: clang/lib/AST/ExprVM/Compiler.h:125
+/// Size of the local, in bytes.
+unsigned Size;
+  };

`ByteSize` since it's the size in bytes :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64146/new/

https://reviews.llvm.org/D64146



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


[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked 5 inline comments as done.
mgehre added a comment.

In D64448#159 , @gribozavr wrote:

> For example, libc++ wraps everything in std in an inline namespace.


I believed that I had written a test for inline namespaces, but seems that I 
shouldn't be working in the middle of the night.
I will add one.

In D64448#159 , @gribozavr wrote:

> I don't know how various versions of libstdc++ differ.


The current implementation passed the (partial) test case
https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
for different standard libraries, namely libc++ 7.1.0, libc++ 8.0.1rc2, 
libstdc++ 4.6.4, libstdc++ 4.8.5,
libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
libstdc++ 8.3.0 and libstdc++ 9.1.0.




Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

gribozavr wrote:
> I'd suggest to split type trait implementations into a separate patch.
> 
> Are these type traits being exposed only for testing? I'm not sure it is a 
> good idea to do that -- people will end up using them in production code -- 
> is that a concern? If so, maybe it would be better to test through warnings.
I copied that approach from https://reviews.llvm.org/D50119.
If people do it in production code, then at least the two leading underscores 
should tell them "I'm not supposed to use this".

I considered a test through warnings, but how would I trigger them? Add 
`-Wlifetime-categories-debug` which emits notes whenever a 
[[gsl::Owner/Pointer]] is implicitly/explicitly attached to class?



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

gribozavr wrote:
> This test and related code changes could be split off into a separate patch.
I was thinking whether it made sense to separate
- fixing the AST dump of attributes with optional type parameter when there is 
not such attribute
- introduce and attribute with optional type parameter while AST dumping it is 
broken
so I decided that both are closely related. Otherwise the fix and its test are 
in separate PRs?



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace std {

gribozavr wrote:
> I feel like these tests would be better off in a separate file.
> 
> It would be also good to explain which exact library we are trying to imitate 
> in this test. Different libraries use different coding patterns.
This is imitating techniques from different libraries - all techniques that 
this implementation supports.

To check if all techniques that this implementation supports are enough for 
real standard library implementations,
I use 
https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp 
against them. Various versions of libstdc++
and libc++ passed. I will test MSVC standard library next. If they would use a 
technique that this implementation does not support yet,
I will add support for that and the corresponding test here.
I might fix MSVC support (if needed) only in the following PR:



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:103
+template 
+class set_iterator {};
+

gribozavr wrote:
> Is it actually defined like that?
There might be a standard library implementation that does it like this. This 
tests that we will use the `using iterator = set_iterator;` in `class set {` 
to attach the [[gsl::Pointer]] to the `set_iterator`. 



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:140
+
+class thread;
+static_assert(!__is_gsl_pointer(thread), "");

gribozavr wrote:
> Unclear what this test is testing.
> 
> If there's something special about thread (e.g., it looks very much like an 
> owner or a pointer, and a buggy implementation can easily declare thread to 
> be an owner or a pointer), please explain that in a comment.
> 
> If you're testing that some random name is not being picked up by inference 
> rules, I'd suggest to use an obviously-fictional name ("class 
> type_unknown_to_compiler;")
Agreed, I will rename this to an obviously-fictional name.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64448/new/

https://reviews.llvm.org/D64448



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:33
+// Thread-local storage
+TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+

quantum wrote:
> quantum wrote:
> > aheejin wrote:
> > > Why is it `c`(const)? According to [[ 
> > > https://github.com/llvm/llvm-project/blob/e6695821e592f95bffe1340b28be7bcfcce04284/clang/include/clang/Basic/Builtins.h#L104-L108
> > >  | this comment ]], this is true if this function has no side effects and 
> > > doesn't read memory, i.e., the result should be only dependent on its 
> > > arguments. Can't wasm globals be memory locations in machines?
> > I was thinking that since the global is immutable, so the value is always a 
> > constant.
> According to @tlively, there is no solid definition on whether a global 
> (especially a constant one), counts as memory access. For now, I am going to 
> change this to not constant. We can always change it back later.
I think this requires more conversation.



Comment at: lld/test/wasm/data-layout.ll:43
+; CHECK-NEXT:   - Index:   3
+; CHECK-NEXT: Type:I32
 ; CHECK-NEXT: Mutable: false

These globals don't have enough information to tell the reader what they even 
are, and they don't have anything to do with the data layout, so how about 
skipping these in the test with a comment saying what is being skipped?



Comment at: lld/test/wasm/tls.ll:57
+;   memory.init 0, 0
+;   end
+

quantum wrote:
> aheejin wrote:
> > Hmm, I think there might be a way to actually print disassembly results. 
> > There are '*.test' files in test directory, in which we have some examples. 
> > For example, [[ 
> > https://github.com/llvm/llvm-project/blob/master/lld/test/wasm/export-table.test
> >  | this test ]] has a sequence of commands you want to run, and you can put 
> > input files in a separate directory. That test uses `obj2yaml`, but can we 
> > possibly use `llvm-objdump` or something to disassemble?
> We already know that we can do something like
> 
> Run: obj2yaml %t.wasm | sed -n '/Body:/{s/^\s*Body:\s*//;s/../0x& /gp}'  
> | llvm-mc -disassemble -triple=wasm32
> 
> to compare the actual assembly. As for `llvm-objdump`, it seems to be unable 
> to disassemble the WASM properly:
> 
> 
> ```
> .../tools/lld/test/wasm/Output/tls.ll.tmp.wasm:   file format WASM
> 
> 
> Disassembly of section CODE:
> 
>  CODE:
> # 4 functions in section.
>1: 02 00   block   invalid_type
>3: 0b  end
>4: 10 00   call0
>6: 20 00   local.get   0
>8: 24 01   global.set  1
>a: 20 00   local.get   0
>c: 41 00   i32.const   0
>e: 41 08   i32.const   8
>   10: fc 08 00 00 memory.init 0, 0
>   14: 0b  end
>   15: 0f  return
>   16: 00  llvm-objdump: 
> lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc:2032: void 
> llvm::WebAssemblyInstPrinter::printInstruction(const llvm::MCInst *, 
> llvm::raw_ostream &): Assertion `Bits != 0 && "Cannot print this 
> instruction."' failed.
> 
> ```
It might be worth filing an LLVM bug for this (or possibly fixing in a separate 
CL).



Comment at: lld/wasm/Symbols.cpp:208
+if (Segment->OutputSeg->Name == ".tdata")
+  return Segment->OutputSegmentOffset + Offset;
 return Segment->OutputSeg->StartVA + Segment->OutputSegmentOffset + Offset;

It would be great to have an explanatory comment here.



Comment at: lld/wasm/Writer.cpp:777
+  break;
+}
+

quantum wrote:
> aheejin wrote:
> > Is it guaranteed that there's only one TLS segment?
> Yes, all the TLS input segments will be merged into `.tdata`.
--no-merge-data-segments!



Comment at: lld/wasm/Writer.cpp:250
+  TLSSize->Global->Global.InitExpr.Value.Int32 = Seg->Size;
+}
   }

What happens when there are multiple TLS sections and 
`--no-merge-data-segments` is used? I assume their sizes should be added 
together?



Comment at: lld/wasm/Writer.cpp:638
+  if (Name.startswith(".tbss."))
+return ".tdata";
   return Name;

Does this mean we can't control whether .tdata or .tbss comes first? Is that 
important for anything?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1095
+WebAssemblyTargetLowering::LowerGlobalTLSAddress(SDValue Op,
+ SelectionDAG &DAG) const

[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

LGTM, but please wait for @pcc to make sure he is satisfied.
I think it would be good to port the file type deduction to clang (possibly as 
a follow on), to make these consistent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64458/new/

https://reviews.llvm.org/D64458



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


r365838 - [NewPM] Port Sancov

2019-07-11 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jul 11 15:35:40 2019
New Revision: 365838

URL: http://llvm.org/viewvc/llvm-project?rev=365838&view=rev
Log:
[NewPM] Port Sancov

This patch contains a port of SanitizerCoverage to the new pass manager. This 
one's a bit hefty.

Changes:

- Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over
  functions and ModuleSanitizerCoverage for passing over modules.
- ModuleSanitizerCoverage exists for adding 2 module level calls to 
initialization
  functions but only if there's a function that was instrumented by sancov.
- Added legacy and new PM wrapper classes that own instances of the 2 new 
classes.
- Update llvm tests and add clang tests.

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

Added:
cfe/trunk/test/CodeGen/sancov-new-pm.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=365838&r1=365837&r2=365838&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 11 15:35:40 2019
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -195,11 +196,8 @@ static void addBoundsCheckingPass(const
   PM.add(createBoundsCheckingLegacyPass());
 }
 
-static void addSanitizerCoveragePass(const PassManagerBuilder &Builder,
- legacy::PassManagerBase &PM) {
-  const PassManagerBuilderWrapper &BuilderWrapper =
-  static_cast(Builder);
-  const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
+static SanitizerCoverageOptions
+getSancovOptsFromCGOpts(const CodeGenOptions &CGOpts) {
   SanitizerCoverageOptions Opts;
   Opts.CoverageType =
   static_cast(CGOpts.SanitizeCoverageType);
@@ -215,7 +213,17 @@ static void addSanitizerCoveragePass(con
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
   Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
-  PM.add(createSanitizerCoverageModulePass(Opts));
+  return Opts;
+}
+
+static void addSanitizerCoveragePass(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM) {
+  const PassManagerBuilderWrapper &BuilderWrapper =
+  static_cast(Builder);
+  const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
+  auto Opts = getSancovOptsFromCGOpts(CGOpts);
+  PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
+  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1135,6 +1143,21 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+PB.registerPipelineStartEPCallback(
+[SancovOpts](ModulePassManager &MPM) {
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+});
+PB.registerOptimizerLastEPCallback(
+[SancovOpts](FunctionPassManager &FPM,
+ PassBuilder::OptimizationLevel Level) {
+  FPM.addPass(SanitizerCoveragePass(SancovOpts));
+});
+  }
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1219,8 +1242,18 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
-if (CodeGenOpts.OptimizationLevel == 0)
+if (CodeGenOpts.OptimizationLevel == 0) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+SanitizerCoveragePass(SancovOpts)));
+  }
+
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
+}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Added: cfe/trunk/test/CodeGen/sancov-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=365838&view=auto
==

[PATCH] D62888: [NewPM] Port Sancov

2019-07-11 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365838: [NewPM] Port Sancov (authored by leonardchan, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62888?vs=207698&id=209358#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62888/new/

https://reviews.llvm.org/D62888

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/sancov-new-pm.c
  llvm/trunk/include/llvm/InitializePasses.h
  llvm/trunk/include/llvm/Transforms/Instrumentation.h
  llvm/trunk/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/trunk/lib/Passes/PassBuilder.cpp
  llvm/trunk/lib/Passes/PassRegistry.def
  llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/trunk/test/Instrumentation/SanitizerCoverage/abort-in-entry-block.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/backedge-pruning.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/chains.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_32.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_64.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/cmp-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coff-comdat.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-8bit-counters.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coff-used-ctor.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/div-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/gep-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/no-func.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/postdominator_check.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/seh.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-8bit-counters.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/wineh.ll

Index: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/EHPersonalities.h"
@@ -176,24 +177,168 @@
   return Options;
 }
 
-class SanitizerCoverageModule : public ModulePass {
+bool canInstrumentWithSancov(const Function &F) {
+  if (F.empty())
+return false;
+  if (F.getName().find(".module_ctor") != std::string::npos)
+return false; // Should not instrument sanitizer init functions.
+  if (F.getName().startswith("__sanitizer_"))
+return false; // Don't instrument __sanitizer_* callbacks.
+  // Don't touch available_externally functions, their actual body is elewhere.
+  if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage)
+return false;
+  // Don't instrument MSVC CRT configuration helpers. They may run before normal
+  // initialization.
+  if (F.getName() == "__local_stdio_printf_options" ||
+  F.getName() == "__local_stdio_scanf_options")
+return false;
+  if (isa(F.getEntryBlock().getTerminator()))
+return false;
+  // Don't instrument functions using SEH for now. Splitting basic blocks like
+  // we do for coverage breaks WinEHPrepare.
+  // FIXME: Remove this when SEH no longer uses landingpad pattern matching.
+  if (F.hasPersonalityFn() &&
+  isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn(
+return false;
+  return true;
+}
+
+std::string getSectionStartImpl(const Triple &TargetTriple,
+const std::str

[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D64448#1581719 , @mgehre wrote:

> In D64448#159 , @gribozavr wrote:
>
> > I don't know how various versions of libstdc++ differ.
>
>
> The current implementation passed the (partial) test case
>  
> https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
>  for different standard libraries, namely libc++ 7.1.0, libc++ 8.0.1rc2, 
> libstdc++ 4.6.4, libstdc++ 4.8.5,
>  libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
>  libstdc++ 8.3.0 and libstdc++ 9.1.0.


Yes, I saw the testcase -- but how do different libstdc++ versions differ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64448/new/

https://reviews.llvm.org/D64448



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


[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

mgehre wrote:
> gribozavr wrote:
> > I'd suggest to split type trait implementations into a separate patch.
> > 
> > Are these type traits being exposed only for testing? I'm not sure it is a 
> > good idea to do that -- people will end up using them in production code -- 
> > is that a concern? If so, maybe it would be better to test through warnings.
> I copied that approach from https://reviews.llvm.org/D50119.
> If people do it in production code, then at least the two leading underscores 
> should tell them "I'm not supposed to use this".
> 
> I considered a test through warnings, but how would I trigger them? Add 
> `-Wlifetime-categories-debug` which emits notes whenever a 
> [[gsl::Owner/Pointer]] is implicitly/explicitly attached to class?
> If people do it in production code, then at least the two leading underscores 
> should tell them "I'm not supposed to use this".

That's not what two underscores mean. These custom type traits, being language 
extensions, must have a name that won't collide with any user-defined name, 
hence two underscores. Two underscores mean nothing about whether the user is 
allowed to use it or not. Sure the code might become non-portable to other 
compilers, but that's not what the concern is. My concern is that code that 
people write might become unportable to future versions of Clang, where we 
would have to change behavior of these type traits (or it would just subtly 
change in some corner case and we won't notice since we don't consider it a 
public API).

> I considered a test through warnings, but how would I trigger them?

I meant regular warnings, that are the objective of this analysis -- warnings 
about dereferencing dangling pointers. If we get those warnings for the 
types-under-test, then obviously they have the correct annotations from the 
compiler's point of view.



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

mgehre wrote:
> gribozavr wrote:
> > This test and related code changes could be split off into a separate patch.
> I was thinking whether it made sense to separate
> - fixing the AST dump of attributes with optional type parameter when there 
> is not such attribute
> - introduce and attribute with optional type parameter while AST dumping it 
> is broken
> so I decided that both are closely related. Otherwise the fix and its test 
> are in separate PRs?
Totally makes sense to have the fix and the test is the same PR, but they seem 
to be separable from attribute inference for std types, right?



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace std {

mgehre wrote:
> gribozavr wrote:
> > I feel like these tests would be better off in a separate file.
> > 
> > It would be also good to explain which exact library we are trying to 
> > imitate in this test. Different libraries use different coding patterns.
> This is imitating techniques from different libraries - all techniques that 
> this implementation supports.
> 
> To check if all techniques that this implementation supports are enough for 
> real standard library implementations,
> I use 
> https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
>  against them. Various versions of libstdc++
> and libc++ passed. I will test MSVC standard library next. If they would use 
> a technique that this implementation does not support yet,
> I will add support for that and the corresponding test here.
> I might fix MSVC support (if needed) only in the following PR:
> This is imitating techniques from different libraries - all techniques that 
> this implementation supports.

Okay -- please add comments about each technique then (and ideally, which 
libraries use them). Right now (for me, who didn't write the patch), the test 
looks like it is testing inference for a bunch of types, not for a bunch of 
techniques -- the differences are subtle and non-obvious.



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:103
+template 
+class set_iterator {};
+

mgehre wrote:
> gribozavr wrote:
> > Is it actually defined like that?
> There might be a standard library implementation that does it like this. This 
> tests that we will use the `using iterator = set_iterator;` in `class set 
> {` to attach the [[gsl::Pointer]] to the `set_iterator`. 
Then std::set_iterator must have an implementation-reserved name, like 
std::__set_iterator.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D6

[PATCH] D61749: [clang-tidy] initial version of readability-convert-member-functions-to-static

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 209360.
mgehre added a comment.

Implement comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61749/new/

https://reviews.llvm.org/D61749

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
  clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst
  
clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp

Index: clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
@@ -0,0 +1,218 @@
+// RUN: %check_clang_tidy %s readability-convert-member-functions-to-static %t
+
+class DoNotMakeEmptyStatic {
+  void emptyMethod() {}
+  void empty_method_out_of_line();
+};
+
+void DoNotMakeEmptyStatic::empty_method_out_of_line() {}
+
+class A {
+  int field;
+  const int const_field;
+  static int static_field;
+
+  void no_use() {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'no_use' can be made static
+// CHECK-FIXES: {{^}}  static void no_use() {
+int i = 1;
+  }
+
+  int read_field() {
+return field;
+  }
+
+  void write_field() {
+field = 1;
+  }
+
+  int call_non_const_member() { return read_field(); }
+
+  int call_static_member() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'call_static_member' can be made static
+// CHECK-FIXES: {{^}}  static int call_static_member() {
+already_static();
+  }
+
+  int read_static() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'read_static' can be made static
+// CHECK-FIXES: {{^}}  static int read_static() {
+return static_field;
+  }
+  void write_static() {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'write_static' can be made static
+// CHECK-FIXES: {{^}}  static void write_static() {
+static_field = 1;
+  }
+
+  static int already_static() { return static_field; }
+
+  int already_const() const { return field; }
+
+  int already_const_convert_to_static() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'already_const_convert_to_static' can be made static
+// CHECK-FIXES: {{^}}  static int already_const_convert_to_static() {
+return static_field;
+  }
+
+  static int out_of_line_already_static();
+
+  void out_of_line_call_static();
+  // CHECK-FIXES: {{^}}  static void out_of_line_call_static();
+  int out_of_line_const_to_static() const;
+  // CHECK-FIXES: {{^}}  static int out_of_line_const_to_static() ;
+};
+
+int A::out_of_line_already_static() { return 0; }
+
+void A::out_of_line_call_static() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: method 'out_of_line_call_static' can be made static
+  // CHECK-FIXES: {{^}}void A::out_of_line_call_static() {
+  already_static();
+}
+
+int A::out_of_line_const_to_static() const {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'out_of_line_const_to_static' can be made static
+  // CHECK-FIXES: {{^}}int A::out_of_line_const_to_static() {
+  return 0;
+}
+
+struct KeepVirtual {
+  virtual int f() { return 0; }
+  virtual int h() const { return 0; }
+};
+
+struct KeepVirtualDerived : public KeepVirtual {
+  int f() { return 0; }
+  int h() const override { return 0; }
+};
+
+// Don't add 'static' to special member functions and operators.
+struct KeepSpecial {
+  KeepSpecial() { int L = 0; }
+  ~KeepSpecial() { int L = 0; }
+  int operator+() { return 0; }
+  operator int() { return 0; }
+};
+
+void KeepLambdas() {
+  using FT = int (*)();
+  auto F = static_cast([]() { return 0; });
+  auto F2 = []() { return 0; };
+}
+
+template 
+struct KeepWithTemplateBase : public Base {
+  int i;
+  // We cannot make these methods static because they might need to override
+  // a function from Base.
+  int static_f() { return 0; }
+};
+
+template 
+struct KeepTemplateClass {
+  int i;
+  // We cannot make these methods static because a specialization
+  // might use *this differently.
+  int static_f() { return 0; }
+};
+
+struct KeepTemplateMethod {
+  int i;
+  // We cannot make these methods static because a specialization
+  // might use *this differently.
+  template 
+  static int static_f() { return 0; }
+};
+
+void instantiate() {
+  struct S {};
+  KeepWithTemplateBase I1;
+  I1.static_f();
+
+  KeepTemplateClass I2;
+  I2.static_f();
+
+  KeepTemplateMethod I3;
+  I3.static_f();
+}
+
+struct Trailing {
+  auto g() const -> int {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'g' can be made static
+// CHECK-FIXES: {{^}}  static

[PATCH] D61749: [clang-tidy] initial version of readability-convert-member-functions-to-static

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

This should address all remaining comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61749/new/

https://reviews.llvm.org/D61749



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


[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-11 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 209362.
emmettneyman marked 2 inline comments as done.
emmettneyman added a comment.

Added documentation about using the attributes with unions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64380/new/

https://reviews.llvm.org/D64380

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/attr-requires-designator.cpp
  clang/test/SemaCXX/attr-requires-init.cpp

Index: clang/test/SemaCXX/attr-requires-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-requires-init.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+[[clang::requires_init]] int x;// expected-warning{{'requires_init' attribute only applies to non-static data members}}
+[[clang::requires_init]] void fun(int x) { // expected-warning{{'requires_init' attribute only applies to non-static data members}}
+  return;
+}
+struct [[clang::requires_init]] Foo { // expected-warning{{'requires_init' attribute only applies to non-static data members}}
+  int x;
+};
+
+// Struct with one required field
+struct Bar {
+  [[clang::requires_init]] int y; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+};
+
+// The following are invalid ways of initializing instances of this struct.
+Bar b1;// expected-warning{{initializer for variable b1 must explicitly initialize field y}}
+Bar b2{};  // expected-warning{{initializer for variable b2 must explicitly initialize field y}}
+Bar b3{1}; // expected-warning{{initializer for variable b3 must explicitly initialize field y}}
+
+// The following are valid ways of initializing instances of this struct.
+Bar b6{.y = 1};
+
+// Struct with multiple required fields
+struct Baz {
+  [[clang::requires_init]] int x; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+  int y;
+  [[clang::requires_init]] int z; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+};
+
+// The following are invalid ways of initializing instances of this struct.
+Baz z1; // expected-warning{{initializer for variable z1 must explicitly initialize field x}} expected-warning{{initializer for variable z1 must explicitly initialize field z}}
+Baz z2{};   // expected-warning{{initializer for variable z2 must explicitly initialize field x}} expected-warning{{initializer for variable z2 must explicitly initialize field z}}
+Baz z3{1, 2};   // expected-warning{{initializer for variable z3 must explicitly initialize field x}} expected-warning{{initializer for variable z3 must explicitly initialize field z}}
+Baz z4{1, 2, 3};// expected-warning{{initializer for variable z4 must explicitly initialize field x}} expected-warning{{initializer for variable z4 must explicitly initialize field z}}
+Baz z5{.x = 1, 2};  // expected-warning{{initializer for variable z5 must explicitly initialize field z}}
+Baz z6{.x = 1, .y = 2}; // expected-warning{{initializer for variable z6 must explicitly initialize field z}}
+
+// The following are valid ways of initializing instances of this struct.
+Baz z7{.x = 1, .y = 2, .z = 3};
+Baz z8{.x = 1, .z = 3};
+Baz z9{.x = 1, 2, .z = 3};
+
+// The required attribute can also be applied to public fields of classes.
+class Cla {
+public:
+  [[clang::requires_init]] int x; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+  int y;
+};
+
+// The following are invalid ways of initializing instances of this class.
+Cla c1;// expected-warning{{initializer for variable c1 must explicitly initialize field x}}
+Cla c2{};  // expected-warning{{initializer for variable c2 must explicitly initialize field x}}
+Cla c3{1}; // expected-warning{{initializer for variable c3 must explicitly initialize field x}}
+Cla c4{1, 2};  // expected-warning{{initializer for variable c4 must explicitly initialize field x}}
+Cla c5{1, .y = 2}; // expected-warning{{initializer for variable c5 must explicitly initialize field x}}
+
+// The following are valid ways of initializing instances of this class.
+Cla c6{.x = 1};
+Cla c7{.x = 1, .y = 2};
+Cla c8{.x = 1, 2};
+
+// This attribute cannot be applied to fields of a union.
+union Uni {
+  [[clang::requires_init]] int x; // expected-warning{{'requires_init' attribute ignored}}
+  int y;
+};
Index: clang/test/SemaCXX/attr-requires-designator.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-requires-designator.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// The requires_designator attribute only applies to types. It will
+// generate a warning when attached to vari

[PATCH] D64603: [Target] Use IEEE quad format for long double on Fuchsia x86_64

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, jakehehrlich.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

This change unifies the long double format between x86_64 and aarch64
targets making it easier to write code that's independent of the target.


Repository:
  rC Clang

https://reviews.llvm.org/D64603

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/X86.h


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -848,6 +848,18 @@
 
   const char *getLongDoubleMangling() const override { return "g"; }
 };
+
+// x86_64 Fuchsia target
+class LLVM_LIBRARY_VISIBILITY FuchsiaX86_64TargetInfo
+: public FuchsiaTargetInfo {
+public:
+  FuchsiaX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions 
&Opts)
+  : FuchsiaTargetInfo(Triple, Opts) {
+LongDoubleFormat = &llvm::APFloat::IEEEquad();
+  }
+};
+
 } // namespace targets
 } // namespace clang
+
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -517,7 +517,7 @@
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
+  return new FuchsiaX86_64TargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Solaris:


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -848,6 +848,18 @@
 
   const char *getLongDoubleMangling() const override { return "g"; }
 };
+
+// x86_64 Fuchsia target
+class LLVM_LIBRARY_VISIBILITY FuchsiaX86_64TargetInfo
+: public FuchsiaTargetInfo {
+public:
+  FuchsiaX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : FuchsiaTargetInfo(Triple, Opts) {
+LongDoubleFormat = &llvm::APFloat::IEEEquad();
+  }
+};
+
 } // namespace targets
 } // namespace clang
+
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -517,7 +517,7 @@
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
+  return new FuchsiaX86_64TargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Solaris:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64562: [clangd] Fixed toHalfOpenFileRange

2019-07-11 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 209363.
SureYeaah marked 12 inline comments as done.
SureYeaah added a comment.

Added comments and minor changes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64562/new/

https://reviews.llvm.org/D64562

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -10,6 +10,7 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -421,6 +422,53 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
+// Test for functions toHalfOpenFileRange and getHalfOpenFileRange
+// FIXME: Need better testing support to be able to check more than just Decls.
+// e.g. TemplateSpecializationTypeLoc SourceRange in nested templates.
+TEST(SourceCodeTests, HalfOpenFileRange) {
+  // Each marked range should be the file range of the decl with the same name
+  // and each name should be unique.
+  Annotations Test(R"cpp(
+#define FOO(X, Y) int Y = ++X
+#define BAR(X) X + 1
+#define ECHO(X) X
+template
+class P {};
+void f() {
+  $a[[P a]];
+  $b[[int b = 1]];
+  $c[[FOO(b, c)]]; 
+  $d[[FOO(BAR(BAR(b)), d)]];
+  // FIXME: We might want to select everything inside the outer ECHO.
+  ECHO(ECHO($e[[int) ECHO(e]]));
+}
+  )cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();
+  const SourceManager &SM = AST.getSourceManager();
+  const LangOptions &LangOpts = AST.getASTContext().getLangOpts();
+  // Turn a SourceLocation into a pair of positions
+  auto SourceRangeToRange = [&SM](SourceRange SrcRange) {
+return Range{sourceLocToPosition(SM, SrcRange.getBegin()),
+ sourceLocToPosition(SM, SrcRange.getEnd())};
+  };
+  auto CheckRange = [&](llvm::StringRef Name) {
+const NamedDecl &Decl = findUnqualifiedDecl(AST, Name);
+auto FileRange = toHalfOpenFileRange(SM, LangOpts, Decl.getSourceRange());
+SCOPED_TRACE("Checking range: " + Name);
+ASSERT_NE(FileRange, llvm::None);
+Range HalfOpenRange = SourceRangeToRange(*FileRange);
+EXPECT_EQ(HalfOpenRange, Test.ranges(Name)[0]);
+  };
+
+  CheckRange("a");
+  CheckRange("b");
+  CheckRange("c");
+  CheckRange("d");
+  CheckRange("e");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -20,8 +20,9 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/SHA1.h"
 
 namespace clang {
 class SourceManager;
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -12,6 +12,8 @@
 #include "Logger.h"
 #include "Protocol.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
@@ -244,20 +246,106 @@
   return L == R.getEnd() || halfOpenRangeContains(Mgr, R, L);
 }
 
-llvm::Optional toHalfOpenFileRange(const SourceManager &Mgr,
+static unsigned getTokenLengthAtLoc(SourceLocation Loc, const SourceManager &SM,
+const LangOptions &LangOpts) {
+  Token TheTok;
+  if (Lexer::getRawToken(Loc, TheTok, SM, LangOpts))
+return 0;
+  // FIXME: Here we check whether the token at the location is a greatergreater
+  // (>>) token and consider it as a single greater (>). This is to get it
+  // working for templates but it isn't correct for the right shift operator. We
+  // can avoid this by using half open char ranges in getFileRange() but getting
+  // token ending is not well supported in macroIDs.
+  if (TheTok.is(tok::greatergreater))
+return 1;
+  return TheTok.getLength();
+}
+
+// Returns location of the last character of the token at a given loc
+static SourceLocation getLocForTokenEnd(SourceLocation BeginLoc,
+const SourceManager &SM,
+const LangOptions &LangOpts) {
+  unsigned Len = getTokenLengthAtLoc(BeginLoc, SM, LangOpts);
+  return BeginLoc.g

[PATCH] D64562: [clangd] Fixed toHalfOpenFileRange

2019-07-11 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:410
+// Test for functions toHalfOpenFileRange and getHalfOpenFileRange
+// FIXME: Need better testing support to be able to check more than just Decls.
+TEST(SourceCodeTests, HalfOpenFileRange) {

sammccall wrote:
> this is a function on ranges, so only using decls isn't a limitation per se.
> 
> Is there a type of range you're unable to test because you can't construct it 
> as the source range of a decl? If so, please say which. If not I think we 
> should just drop this comment.
e.g. Nested template instantiation (TemplateSpecializationTypeLoc)



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:421
+  $c[[FOO(b, c)]]; 
+  $d[[FOO(BAR(BAR(b)), d)]];
+}

sammccall wrote:
> some tests where the expansion range is a macro arg? e.g.
> ```
> #define ECHO(X) X
> ECHO($e[[ECHO(int) ECHO(e)]])
> ```
> 
> (if I'm understanding right)
In this case, the FileRange would be

```
ECHO(ECHO($e[[int) ECHO(e]]));
```

So the code works correctly. But it's not how we want it to behave right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64562/new/

https://reviews.llvm.org/D64562



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


[PATCH] D64586: [WebAssembly] Make pthread imply bulk-memory, mutable-globals

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 209367.
tlively added a comment.

- Update comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64586/new/

https://reviews.llvm.org/D64586

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


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
+// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
+// '-pthread' not allowed with '-mno-mutable-globals'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
+// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with 
'-mno-mutable-globals'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies atomics, bulk-memory, and mutable-globals
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,22 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
+if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+   options::OPT_mmutable_globals, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-mutable-globals";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+mutable-globals");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %

[PATCH] D64586: [WebAssembly] Make pthread imply bulk-memory, mutable-globals

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 209365.
tlively added a comment.

- Add mutable-globals


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64586/new/

https://reviews.llvm.org/D64586

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


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
+// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
+// '-pthread' not allowed with '-mno-mutable-globals'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
+// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with 
'-mno-mutable-globals'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies target features atomics and bulk-memory
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,22 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
+if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+   options::OPT_mmutable_globals, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-mutable-globals";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+mutable-globals");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN

[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 209370.
mgehre marked 9 inline comments as done.
mgehre added a comment.

- Implement comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64448/new/

https://reviews.llvm.org/D64448

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/test/SemaCXX/attr-gsl-owner-pointer.cpp

Index: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
===
--- clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
+++ clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
@@ -83,14 +83,14 @@
 static_assert(__is_gsl_pointer(int &), "");
 static_assert(__is_gsl_pointer(int *), "");
 
-// Test builtin annotation for std types.
+// Test builtin attributes for std types.
 namespace std {
-// Complete class
+// Attributes are added to a (complete) class.
 class any {
 };
 static_assert(__is_gsl_owner(any), "");
 
-// Complete template
+// Attributes are added to a instantiatons of a complete template.
 template 
 class vector {
 public:
@@ -99,45 +99,60 @@
 static_assert(__is_gsl_owner(vector), "");
 static_assert(__is_gsl_pointer(vector::iterator), "");
 
+// If std::container::iterator is a using declaration, Attributes are added to
+// the underlying class
 template 
-class set_iterator {};
+class __set_iterator {};
 
 template 
 class set {
 public:
-  using iterator = set_iterator;
+  using iterator = __set_iterator;
 };
 static_assert(__is_gsl_pointer(set::iterator), "");
 
+// If std::container::iterator is a typedef, Attributes are added to the
+// underlying class. Inline namespaces are ignored when checking if
+// the class lives in the std namespace.
+inline namespace inlinens {
 template 
-class map_iterator {};
+class __map_iterator {};
 
 template 
 class map {
 public:
-  typedef map_iterator iterator;
+  typedef __map_iterator iterator;
 };
+} // namespace inlinens
 static_assert(__is_gsl_pointer(map::iterator), "");
 
-// list has an implicit gsl::Owner attribute,
+// std::list has an implicit gsl::Owner attribute,
 // but explicit attributes take precedence.
 template 
 class [[gsl::Pointer]] list{};
 static_assert(!__is_gsl_owner(list), "");
 static_assert(__is_gsl_pointer(list), "");
 
-// Forward declared template
+// Forward declared template (Owner)
 template <
 class CharT,
 class Traits>
 class basic_regex;
 static_assert(__is_gsl_owner(basic_regex), "");
 
+// Forward declared template (Pointer)
 template 
 class reference_wrapper;
 static_assert(__is_gsl_pointer(reference_wrapper), "");
 
-class thread;
-static_assert(!__is_gsl_pointer(thread), "");
-static_assert(!__is_gsl_owner(thread), "");
+class some_unknown_type;
+static_assert(!__is_gsl_pointer(some_unknown_type), "");
+static_assert(!__is_gsl_owner(some_unknown_type), "");
 } // namespace std
+
+namespace user {
+// If a class is not in the std namespace, we don't add implicit attributes.
+class any {
+};
+static_assert(!__is_gsl_owner(any), "");
+} // namespace user
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4164,7 +4164,7 @@
 When annotating a class ``O`` with ``[[gsl::Owner(T)]]``, then each function
 that returns cv-qualified ``T&`` or ``T*`` is assumed to return a
 pointer/reference to the data owned by ``O``. The owned data is assumed to end
-its lifetime once the owning object's lifetime ends. The argument is ``T`` is
+its lifetime once the owning object's lifetime ends. The argument ``T`` is
 optional.
 
 This attribute may be used by analysis tools but will not have effect on code
@@ -4177,7 +4177,7 @@
   let Content = [{
 When annotating a class with ``[[gsl::Pointer(T)]]``, it assumed to be a
 non-owning type whose objects can point to ``T`` type objects or dangle.
-The argument is ``T`` is optional.
+The argument ``T`` is optional.
 
 This attribute may be used by analysis tools but will not have effect on code
 generation.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64586: [WebAssembly] Make pthread imply bulk-memory, mutable-globals

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 209369.
tlively added a comment.

- and other comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64586/new/

https://reviews.llvm.org/D64586

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


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, +mutable-globals, and 
--shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
+// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
+// '-pthread' not allowed with '-mno-mutable-globals'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
+// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with 
'-mno-mutable-globals'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies atomics, bulk-memory, and mutable-globals
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,22 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
+if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+   options::OPT_mmutable_globals, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-mutable-globals";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+mutable-globals");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, +mutable-globals, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not al

[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

In D64448#1581771 , @gribozavr wrote:

> In D64448#1581719 , @mgehre wrote:
>
> > In D64448#159 , @gribozavr 
> > wrote:
> >
> > > I don't know how various versions of libstdc++ differ.
> >
> >
> > The current implementation passed the (partial) test case
> >  
> > https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
> >  for different standard libraries, namely libc++ 7.1.0, libc++ 8.0.1rc2, 
> > libstdc++ 4.6.4, libstdc++ 4.8.5,
> >  libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
> >  libstdc++ 8.3.0 and libstdc++ 9.1.0.
>
>
> Yes, I saw the testcase -- but how do different libstdc++ versions differ?


I didn't know whether they would differ, but the test tells me that they don't 
differ significantly (i.e. in introducing new techniques). 
Would you like me to test with other standard libraries (besides MSVC, which I 
already planned)?




Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

gribozavr wrote:
> mgehre wrote:
> > gribozavr wrote:
> > > I'd suggest to split type trait implementations into a separate patch.
> > > 
> > > Are these type traits being exposed only for testing? I'm not sure it is 
> > > a good idea to do that -- people will end up using them in production 
> > > code -- is that a concern? If so, maybe it would be better to test 
> > > through warnings.
> > I copied that approach from https://reviews.llvm.org/D50119.
> > If people do it in production code, then at least the two leading 
> > underscores should tell them "I'm not supposed to use this".
> > 
> > I considered a test through warnings, but how would I trigger them? Add 
> > `-Wlifetime-categories-debug` which emits notes whenever a 
> > [[gsl::Owner/Pointer]] is implicitly/explicitly attached to class?
> > If people do it in production code, then at least the two leading 
> > underscores should tell them "I'm not supposed to use this".
> 
> That's not what two underscores mean. These custom type traits, being 
> language extensions, must have a name that won't collide with any 
> user-defined name, hence two underscores. Two underscores mean nothing about 
> whether the user is allowed to use it or not. Sure the code might become 
> non-portable to other compilers, but that's not what the concern is. My 
> concern is that code that people write might become unportable to future 
> versions of Clang, where we would have to change behavior of these type 
> traits (or it would just subtly change in some corner case and we won't 
> notice since we don't consider it a public API).
> 
> > I considered a test through warnings, but how would I trigger them?
> 
> I meant regular warnings, that are the objective of this analysis -- warnings 
> about dereferencing dangling pointers. If we get those warnings for the 
> types-under-test, then obviously they have the correct annotations from the 
> compiler's point of view.
I spent a lot of time debugging on the full lifetime analysis, and knowing 
exactly which type has which Attribute (especially if inference is involved) 
was quite important.
I would say that adding additional code to trigger a real lifetime warning 
- requires that we first add some lifetime warnings to clang (currently in a 
different PR)
- obscures the purpose of the check, i.e. checking the attributes and not the 
warnings themselves
- and makes debugging hard when the test fails (warnings involve at least one 
Owner and one Pointer, so either of those could have made the test fail)
I'd prefer if we can test the attributes directly.



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

gribozavr wrote:
> mgehre wrote:
> > gribozavr wrote:
> > > This test and related code changes could be split off into a separate 
> > > patch.
> > I was thinking whether it made sense to separate
> > - fixing the AST dump of attributes with optional type parameter when there 
> > is not such attribute
> > - introduce and attribute with optional type parameter while AST dumping it 
> > is broken
> > so I decided that both are closely related. Otherwise the fix and its test 
> > are in separate PRs?
> Totally makes sense to have the fix and the test is the same PR, but they 
> seem to be separable from attribute inference for std types, right?
Yes, you are right. And Aaron would like to have the type parameter already 
optional in D63954, so I will move this part over there.



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace s

[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-11 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:1448
 
+def RequireDesignatedInitDocs : Documentation {
+  let Category = DocCatType;

aaron.ballman wrote:
> The behavior should be documented as to what happens when you apply these 
> attributes to unions.
For now, adding a `requires_init` attribute to a field of a union will result 
in a warning that the attribute is ignored. In the future, I might submit 
another patch in the future adding behavior for this attribute for fields of a 
union.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64380/new/

https://reviews.llvm.org/D64380



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


[PATCH] D64062: Remove both -dumpversion and __VERSION__

2019-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D64062#1581662 , @sylvestre.ledru 
wrote:

> In D64062#1581290 , @rnk wrote:
>
> > Perhaps we should just remove `__VERSION__` and keep `-dumpversion`.
>
>
> As you wish. clang --version seems an alternative and dumpversion never 
> //worked// for clang. so, I don't expect software to use it for clang.


That's true, but users seem to want some programmatic way to extract the 
compiler version number without having to resort to sed & co, and we don't 
provide that right now. `-dumpversion` can easily be the name for that feature.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64062/new/

https://reviews.llvm.org/D64062



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


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm with suggestion




Comment at: lib/Driver/ToolChains/Clang.cpp:4009
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  CmdArgs.push_back(A->getOption().matches(options::OPT_mlong_double_64)
+? "-mlong-double-64"

There should be a shorthand for passing through the argument, `A->render()` or 
something.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



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


[PATCH] D64605: [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, aprantl, mgorny.
Herald added a project: clang.

We want to preserve debug info in our runtimes to aid symbolization and
debugging; for shared libraries this will be stripped away during
install-stripped step and distributed via .build-id, for static archives
it's part of the archive and it's a responsibility of the consumer to
strip it away in the final binary if not needed.


Repository:
  rC Clang

https://reviews.llvm.org/D64605

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
@@ -119,7 +119,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-unknown-fuchsia")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-

[PATCH] D64605: [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

Lgtm


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64605/new/

https://reviews.llvm.org/D64605



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


[clang-tools-extra] r365844 - [clangd] Fix MSVC build failure.

2019-07-11 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Jul 11 16:48:06 2019
New Revision: 365844

URL: http://llvm.org/viewvc/llvm-project?rev=365844&view=rev
Log:
[clangd] Fix MSVC build failure.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26898

Modified:
clang-tools-extra/trunk/clangd/AST.cpp

Modified: clang-tools-extra/trunk/clangd/AST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=365844&r1=365843&r2=365844&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.cpp (original)
+++ clang-tools-extra/trunk/clangd/AST.cpp Thu Jul 11 16:48:06 2019
@@ -184,7 +184,7 @@ std::string shortenNamespace(const llvm:
 DifferentAt++;
   }
 
-  for (u_int i = DifferentAt; i < OriginalParts.size(); ++i) {
+  for (unsigned i = DifferentAt; i < OriginalParts.size(); ++i) {
 Result.push_back(OriginalParts[i]);
   }
   return join(Result, "::");


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


[PATCH] D64605: [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365845: [CMake][Fuchsia] Use RelWithDebInfo to build 
runtimes (authored by phosek, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64605?vs=209372&id=209373#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64605/new/

https://reviews.llvm.org/D64605

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
@@ -119,7 +119,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-unknown-fuchsia")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_

r365845 - [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Jul 11 16:49:39 2019
New Revision: 365845

URL: http://llvm.org/viewvc/llvm-project?rev=365845&view=rev
Log:
[CMake][Fuchsia] Use RelWithDebInfo to build runtimes

We want to preserve debug info in our runtimes to aid symbolization and
debugging; for shared libraries this will be stripped away during
install-stripped step and distributed via .build-id, for static archives
it's part of the archive and it's a responsibility of the consumer to
strip it away in the final binary if not needed.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=365845&r1=365844&r2=365845&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Thu Jul 11 16:49:39 2019
@@ -58,7 +58,7 @@ foreach(target aarch64-unknown-linux-gnu
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -67,7 +67,7 @@ foreach(target aarch64-unknown-linux-gnu
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -107,7 +107,7 @@ if(FUCHSIA_SDK)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
@@ -119,7 +119,7 @@ if(FUCHSIA_SDK)
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-unknown-fuchsia")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")


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


  1   2   3   >