[PATCH] D64653: clang/test/Driver/fsanitize.c: Fix -fsanitize=vptr using default target

2019-07-12 Thread James Nagurne via Phabricator via cfe-commits
JamesNagurne added a comment.

In D64653#1584155 , @MaskRay wrote:

> I committed this for you in rL365981  (it 
> may have broken a Windows build for a long time. I wanted to fix it soon..). 
> Thanks!
>
> > any platform that runs this test will fail with the error:
>
> Not-too-ancient Darwin, FreeBSD, Linux, NetBSD, OpenBSD, Solaris, etc support 
> this, but notable exception is Windows:
>
>   % clang -target x86_64-windows -fsanitize=vptr -fno-rtti fsanitize.c '-###'
>   clang-9: error: unsupported option '-fsanitize=vptr' for target 
> 'x86_64-unknown-windows-msvc'
>


Yes, my comment was rather misguided here. I didn't mean to say "All 
platforms", more like "All platforms that don't support -fsanitize=vptr". 
Specifically, this was affecting our embedded arm target.
Thanks for getting this in!


Repository:
  rC Clang

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

https://reviews.llvm.org/D64653



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


[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D64680#1584130 , @Charusso wrote:

> Here is an example of the mentioned use-after-free by pointer-escaping as an 
> argument:
>  
> https://llvm.org/reports/scan-build/report-DeclBase.cpp-getFromVoidPointer-0-1.html#EndPath


Not sure how is this false positive related to that report, but this false 
positive looks super weird and i'd love to debug it more.

P.S. I think you should attach the report to Phabricator directly, as the link 
will expire as soon as these reports get regenerated.




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:56-58
+// If this checker does not model the allocation.
+DoNothing,
+// Reference to allocated memory.

Charusso wrote:
> NoQ wrote:
> > We already have `Escaped`, it's the same thing in practice.
> It is more strict than `Escaped`, also it made for the purpose of 
> `PSK_EscapeOther` to force out we lost the entire pointer and do not make 
> false warnings of use-after-free.
How exactly is it more strict? I.e., what warnings are getting suppressed by 
you that aren't going to be suppressed if you use `Escaped` instead?


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

https://reviews.llvm.org/D64680



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


[PATCH] D64613: [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 2 inline comments as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1238
   Optional Result =
-  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet, ResolveParents);
   if (!Result)

kadircet wrote:
> having a function named `getTypeAncestors` with a parameter `ResolveParents` 
> doesn't make much sense. maybe move the check to caller side and simply don't 
> call it if we are not interested in parents?
> 
> I think it makes sense to  make this part also similar to subtypes:
> - let's generate the item in here with `Optional Result = 
> declToTypeHierarchyItem(ASTCtx, CXXRD);`, which is used by both parents and 
> children.
> - bail out if we couldn't get the item.
> - fill in parents if need be
> - fill in children if need be
> 
> WDYT?
Agreed, this makes the code cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64613



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


[PATCH] D64613: [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 209677.
nridge added a comment.

Address review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64613

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp


Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -630,7 +630,8 @@
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
 Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
ParentsNotResolved(), ChildrenNotResolved();
 
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1132,15 +1132,9 @@
 
 using RecursionProtectionSet = llvm::SmallSet;
 
-static Optional
-getTypeAncestors(const CXXRecordDecl , ASTContext ,
- RecursionProtectionSet ) {
-  Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
-return Result;
-
-  Result->parents.emplace();
-
+static void fillSuperTypes(const CXXRecordDecl , ASTContext ,
+   std::vector ,
+   RecursionProtectionSet ) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1149,22 +1143,22 @@
   auto *Pattern = CXXRD.getDescribedTemplate() ?  : nullptr;
   if (Pattern) {
 if (!RPSet.insert(Pattern).second) {
-  return Result;
+  return;
 }
   }
 
   for (const CXXRecordDecl *ParentDecl : typeParents()) {
 if (Optional ParentSym =
-getTypeAncestors(*ParentDecl, ASTCtx, RPSet)) {
-  Result->parents->emplace_back(std::move(*ParentSym));
+declToTypeHierarchyItem(ASTCtx, *ParentDecl)) {
+  ParentSym->parents.emplace();
+  fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet);
+  SuperTypes.emplace_back(std::move(*ParentSym));
 }
   }
 
   if (Pattern) {
 RPSet.erase(Pattern);
   }
-
-  return Result;
 }
 
 const CXXRecordDecl *findRecordTypeAt(ParsedAST , Position Pos) {
@@ -1231,12 +1225,19 @@
   if (!CXXRD)
 return llvm::None;
 
-  RecursionProtectionSet RPSet;
   Optional Result =
-  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  declToTypeHierarchyItem(AST.getASTContext(), *CXXRD);
   if (!Result)
 return Result;
 
+  if (Direction == TypeHierarchyDirection::Parents ||
+  Direction == TypeHierarchyDirection::Both) {
+Result->parents.emplace();
+
+RecursionProtectionSet RPSet;
+fillSuperTypes(*CXXRD, AST.getASTContext(), *Result->parents, RPSet);
+  }
+
   if ((Direction == TypeHierarchyDirection::Children ||
Direction == TypeHierarchyDirection::Both) &&
   ResolveLevels > 0) {


Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -630,7 +630,8 @@
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
 Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
ParentsNotResolved(), ChildrenNotResolved();
 
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1132,15 +1132,9 @@
 
 using RecursionProtectionSet = llvm::SmallSet;
 
-static Optional
-getTypeAncestors(const CXXRecordDecl , ASTContext ,
- RecursionProtectionSet ) {
-  Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
-return Result;
-
-  Result->parents.emplace();
-
+static void fillSuperTypes(const CXXRecordDecl , ASTContext ,
+   std::vector ,
+   RecursionProtectionSet ) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1149,22 +1143,22 @@
   auto *Pattern = CXXRD.getDescribedTemplate() ?  : nullptr;
   if (Pattern) {
 if 

[PATCH] D64614: [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/docs/clangd/Features.rst:264
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+

malaperle wrote:
> nridge wrote:
> > sammccall wrote:
> > > nridge wrote:
> > > > Should I perhaps change type hierarchy's entry in the LSP column from 
> > > > "No" to "Proposed"?
> > > I'm not sure what "no" means, if it doesn't mean "proposed".
> > > 
> > > Changing the "no" links to say "proposal" and link to it would be useful, 
> > > I think.
> > > (And we could delete any rows that don't have a proposal)
> > Good idea -- I'll look at that in a separate commit.
> The rows that have "no" and don't have proposals meant that we wanted to make 
> proposals for the LSP eventually in order to match other IDEs feature. Many 
> didn't have proposals at the time.
Right! I wouldn't delete any rows -- just maybe file (and link to) an LSP issue 
for any rows that don't already have proposals.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64614



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


r365989 - Initialize the non-trivial C union bits I added to RecordDeclBitfields

2019-07-12 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Jul 12 20:59:55 2019
New Revision: 365989

URL: http://llvm.org/viewvc/llvm-project?rev=365989=rev
Log:
Initialize the non-trivial C union bits I added to RecordDeclBitfields
in r365985

These bits weren't being initialized in the RecordDecl's constructor,
which probably caused test/Modules/stress1.cpp to fail on a couple of
bots.

Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=365989=365988=365989=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 12 20:59:55 2019
@@ -4252,6 +4252,9 @@ RecordDecl::RecordDecl(Kind DK, TagKind
   setNonTrivialToPrimitiveDefaultInitialize(false);
   setNonTrivialToPrimitiveCopy(false);
   setNonTrivialToPrimitiveDestroy(false);
+  setHasNonTrivialToPrimitiveDefaultInitializeCUnion(false);
+  setHasNonTrivialToPrimitiveDestructCUnion(false);
+  setHasNonTrivialToPrimitiveCopyCUnion(false);
   setParamDestroyedInCallee(false);
   setArgPassingRestrictions(APK_CanPassInRegs);
 }


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


[PATCH] D64614: [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-12 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clang-tools-extra/docs/clangd/Features.rst:264
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+

nridge wrote:
> sammccall wrote:
> > nridge wrote:
> > > Should I perhaps change type hierarchy's entry in the LSP column from 
> > > "No" to "Proposed"?
> > I'm not sure what "no" means, if it doesn't mean "proposed".
> > 
> > Changing the "no" links to say "proposal" and link to it would be useful, I 
> > think.
> > (And we could delete any rows that don't have a proposal)
> Good idea -- I'll look at that in a separate commit.
The rows that have "no" and don't have proposals meant that we wanted to make 
proposals for the LSP eventually in order to match other IDEs feature. Many 
didn't have proposals at the time.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64614



___
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-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



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

quantum wrote:
> 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.
Until we do implement TLS for shared modules, would it make sense to omit these 
globals and function from shared modules, since we can't use them in that 
context anyway?



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

quantum wrote:
> tlively wrote:
> > Does this mean we can't control whether .tdata or .tbss comes first? Is 
> > that important for anything?
> Yes, it does mean that. The only reason why .tbss is supposed to be separate 
> is so that its memory can just be zeroed whereas .tdata has to have the bytes 
> stored in the program image. Currently, we just explicitly store the zero 
> bytes, so this won't be a problem.
It would be really great if we could find a way to elide the .bss 0 bytes as a 
code size optimization. Since we can't assume that the memory is already zeroed 
the way we can with passive segments, perhaps we can use a memory.fill 
instruction to zero the memory? Pursuing this in a follow-on CL should be fine.



Comment at: lld/wasm/Writer.cpp:805
+  writeUleb128(os, 0, "num locals");
+  writeU8(os, WASM_OPCODE_END, "end function");
+}

You could avoid duplicating these lines by making them unconditional.



Comment at: lld/wasm/Writer.cpp:905
+  if (config->sharedMemory)
+createInitTLSFunction();
+

Can you remind me how the InitTLSFunction interacts with relocatable code? I'm 
wondering if this should be called up in the condition with the other synthetic 
functions.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:193
+
+if (!Features[WebAssembly::FeatureBulkMemory])
   Stripped |= stripThreadLocals(M);

I just realized that if we have atomics but not bulk memory and TLS is 
stripped, then we will be in the awkward situation of both using atomics and 
disallowing atomics because the module is not thread safe. I think the best 
solution would be to go back and forcibly strip both atomics and TLS if either 
of them would be stripped.



Comment at: llvm/test/CodeGen/WebAssembly/tls.ll:2
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt 
-wasm-disable-explicit-locals -mattr=+bulk-memory | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt 
-wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"

It would be good to check the negative case, too, i.e with bulk-memory disabled.



Comment at: llvm/test/CodeGen/WebAssembly/tls.ll:6
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {

Is `CHECK` still used as a prefix if it not listed in the invocation of 
FileCheck?


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] D64614: [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/docs/clangd/Features.rst:264
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+

sammccall wrote:
> nridge wrote:
> > Should I perhaps change type hierarchy's entry in the LSP column from "No" 
> > to "Proposed"?
> I'm not sure what "no" means, if it doesn't mean "proposed".
> 
> Changing the "no" links to say "proposal" and link to it would be useful, I 
> think.
> (And we could delete any rows that don't have a proposal)
Good idea -- I'll look at that in a separate commit.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64614



___
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-12 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365986: [clangd] Implement typeHierarchy/resolve for 
subtypes (authored by nridge, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64308?vs=209666=209669#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64308

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/clangd/XRefs.h
  clang-tools-extra/trunk/clangd/test/type-hierarchy.test
  clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Index: clang-tools-extra/trunk/clangd/XRefs.h
===
--- clang-tools-extra/trunk/clangd/XRefs.h
+++ clang-tools-extra/trunk/clangd/XRefs.h
@@ -141,6 +141,10 @@
 ParsedAST , Position Pos, int Resolve, TypeHierarchyDirection Direction,
 const SymbolIndex *Index = nullptr, PathRef TUPath = PathRef{});
 
+void resolveTypeHierarchy(TypeHierarchyItem , int ResolveLevels,
+  TypeHierarchyDirection Direction,
+  const SymbolIndex *Index);
+
 /// Retrieves the deduced type at a given location (auto, decltype).
 /// Retuns None unless SourceLocationBeg starts an auto/decltype token.
 /// It will return the underlying type.
Index: clang-tools-extra/trunk/clangd/Protocol.h
===
--- clang-tools-extra/trunk/clangd/Protocol.h
+++ clang-tools-extra/trunk/clangd/Protocol.h
@@ -1127,7 +1127,7 @@
   SymbolKind kind;
 
   /// `true` if the hierarchy item is deprecated. Otherwise, `false`.
-  bool deprecated;
+  bool deprecated = false;
 
   /// The URI of the text document where this type hierarchy item belongs to.
   URIForFile uri;
@@ -1153,13 +1153,26 @@
   /// descendants. If not defined, the children have not been resolved.
   llvm::Optional> children;
 
-  /// The protocol has a slot here for an optional 'data' filed, which can
-  /// be used to identify a type hierarchy item in a resolve request. We don't
-  /// need this (the item itself is sufficient to identify what to resolve)
-  /// so don't declare it.
+  /// An optional 'data' filed, which can be used to identify a type hierarchy
+  /// item in a resolve request.
+  llvm::Optional data;
 };
 llvm::json::Value toJSON(const TypeHierarchyItem &);
 llvm::raw_ostream <<(llvm::raw_ostream &, const TypeHierarchyItem &);
+bool fromJSON(const llvm::json::Value &, TypeHierarchyItem &);
+
+/// Parameters for the `typeHierarchy/resolve` request.
+struct ResolveTypeHierarchyItemParams {
+  /// The item to resolve.
+  TypeHierarchyItem item;
+
+  /// The hierarchy levels to resolve. `0` indicates no level.
+  int resolve;
+
+  /// The direction of the hierarchy levels to resolve.
+  TypeHierarchyDirection direction;
+};
+bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &);
 
 struct ReferenceParams : public TextDocumentPositionParams {
   // For now, no options like context.includeDeclaration are supported.
Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -893,7 +893,7 @@
 
 /// Retrieves the deduced type at a given location (auto, decltype).
 bool hasDeducedType(ParsedAST , SourceLocation SourceLocationBeg) {
-  return (bool) getDeducedType(AST, SourceLocationBeg);
+  return (bool)getDeducedType(AST, SourceLocationBeg);
 }
 
 llvm::Optional getHover(ParsedAST , Position Pos,
@@ -1104,6 +1104,10 @@
   // (https://github.com/clangd/clangd/issues/59).
   THI.range = THI.selectionRange;
   THI.uri = Loc->uri;
+  // Store the SymbolID in the 'data' field. The client will
+  // send this back in typeHierarchy/resolve, allowing us to
+  // continue resolving additional levels of the type hierarchy.
+  THI.data = S.ID.str();
 
   return std::move(THI);
 }
@@ -1247,6 +1251,25 @@
   return Result;
 }
 
+void resolveTypeHierarchy(TypeHierarchyItem , int ResolveLevels,
+  TypeHierarchyDirection Direction,
+  const SymbolIndex *Index) {
+  // We only support typeHierarchy/resolve for children, because for parents
+  // we ignore ResolveLevels and return all levels of parents eagerly.
+  if (Direction == TypeHierarchyDirection::Parents || ResolveLevels == 0)
+return;
+
+  Item.children.emplace();
+
+  if (Index && Item.data) {
+// We store the item's SymbolID in the 'data' field, and the client
+// passes it back to us in typeHierarchy/resolve.
+if (Expected ID = 

[PATCH] D64614: [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-12 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365987: [clangd] Mark type hierarchy as a supported feature 
in the docs (authored by nridge, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64614?vs=209408=209670#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64614

Files:
  clang-tools-extra/trunk/docs/clangd/Features.rst


Index: clang-tools-extra/trunk/docs/clangd/Features.rst
===
--- clang-tools-extra/trunk/docs/clangd/Features.rst
+++ clang-tools-extra/trunk/docs/clangd/Features.rst
@@ -261,7 +261,7 @@
 +-++--+
 | Call hierarchy  | No |   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+
 | Organize Includes   | No |   No |
 +-++--+


Index: clang-tools-extra/trunk/docs/clangd/Features.rst
===
--- clang-tools-extra/trunk/docs/clangd/Features.rst
+++ clang-tools-extra/trunk/docs/clangd/Features.rst
@@ -261,7 +261,7 @@
 +-++--+
 | Call hierarchy  | No |   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+
 | Organize Includes   | No |   No |
 +-++--+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r365987 - [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-12 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Fri Jul 12 20:24:54 2019
New Revision: 365987

URL: http://llvm.org/viewvc/llvm-project?rev=365987=rev
Log:
[clangd] Mark type hierarchy as a supported feature in the docs

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/clangd/Features.rst

Modified: clang-tools-extra/trunk/docs/clangd/Features.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clangd/Features.rst?rev=365987=365986=365987=diff
==
--- clang-tools-extra/trunk/docs/clangd/Features.rst (original)
+++ clang-tools-extra/trunk/docs/clangd/Features.rst Fri Jul 12 20:24:54 2019
@@ -261,7 +261,7 @@ developed outside clangd or become clang
 +-++--+
 | Call hierarchy  | No |   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+
 | Organize Includes   | No |   No |
 +-++--+


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


[clang-tools-extra] r365986 - [clangd] Implement typeHierarchy/resolve for subtypes

2019-07-12 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Fri Jul 12 20:24:48 2019
New Revision: 365986

URL: http://llvm.org/viewvc/llvm-project?rev=365986=rev
Log:
[clangd] Implement typeHierarchy/resolve for subtypes

Summary:
This allows the client to resolve subtypes one level at a time.

For supertypes, this is not necessary, because we eagerly compute
supertypes and return all levels.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/XRefs.h
clang-tools-extra/trunk/clangd/test/type-hierarchy.test
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=365986=365985=365986=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Jul 12 20:24:48 2019
@@ -926,6 +926,13 @@ void ClangdLSPServer::onTypeHierarchy(
 Params.resolve, Params.direction, std::move(Reply));
 }
 
+void ClangdLSPServer::onResolveTypeHierarchy(
+const ResolveTypeHierarchyItemParams ,
+Callback> Reply) {
+  Server->resolveTypeHierarchy(Params.item, Params.resolve, Params.direction,
+   std::move(Reply));
+}
+
 void ClangdLSPServer::applyConfiguration(
 const ConfigurationSettings ) {
   // Per-file update to the compilation database.
@@ -1021,6 +1028,7 @@ ClangdLSPServer::ClangdLSPServer(
   MsgHandler->bind("workspace/didChangeConfiguration", 
::onChangeConfiguration);
   MsgHandler->bind("textDocument/symbolInfo", ::onSymbolInfo);
   MsgHandler->bind("textDocument/typeHierarchy", 
::onTypeHierarchy);
+  MsgHandler->bind("typeHierarchy/resolve", 
::onResolveTypeHierarchy);
   // clang-format on
 }
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=365986=365985=365986=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Fri Jul 12 20:24:48 2019
@@ -100,6 +100,8 @@ private:
Callback>);
   void onTypeHierarchy(const TypeHierarchyParams &,
Callback>);
+  void onResolveTypeHierarchy(const ResolveTypeHierarchyItemParams &,
+  Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
   void onSymbolInfo(const TextDocumentPositionParams &,
 Callback>);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=365986=365985=365986=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Fri Jul 12 20:24:48 2019
@@ -528,6 +528,13 @@ void ClangdServer::typeHierarchy(PathRef
   WorkScheduler.runWithAST("Type Hierarchy", File, Bind(Action, 
std::move(CB)));
 }
 
+void ClangdServer::resolveTypeHierarchy(
+TypeHierarchyItem Item, int Resolve, TypeHierarchyDirection Direction,
+Callback> CB) {
+  clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
+  CB(Item);
+}
+
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams ) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=365986=365985=365986=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Fri Jul 12 20:24:48 2019
@@ -210,6 +210,11 @@ public:
  TypeHierarchyDirection Direction,
  Callback> CB);
 
+  /// Resolve type hierarchy item in the given direction.
+  void resolveTypeHierarchy(TypeHierarchyItem Item, int Resolve,
+TypeHierarchyDirection Direction,
+Callback> CB);
+
   /// Retrieve the top symbols from the workspace matching a query.
   void workspaceSymbols(StringRef 

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

2019-07-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 209666.
nridge added a comment.

Fix Windows test failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64308

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/test/type-hierarchy.test
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -42,8 +42,17 @@
 MATCHER_P(SelectionRangeIs, R, "") { return arg.selectionRange == R; }
 template 
 ::testing::Matcher Parents(ParentMatchers... ParentsM) {
-  return Field(::parents, HasValue(ElementsAre(ParentsM...)));
+  return Field(::parents,
+   HasValue(UnorderedElementsAre(ParentsM...)));
 }
+template 
+::testing::Matcher Children(ChildMatchers... ChildrenM) {
+  return Field(::children,
+   HasValue(UnorderedElementsAre(ChildrenM...)));
+}
+// Note: "not resolved" is differnt from "resolved but empty"!
+MATCHER(ParentsNotResolved, "") { return !arg.parents; }
+MATCHER(ChildrenNotResolved, "") { return !arg.children; }
 
 TEST(FindRecordTypeAt, TypeOrVariable) {
   Annotations Source(R"cpp(
@@ -603,6 +612,41 @@
   EXPECT_THAT(collectSubtypes(Parent, Index.get()), ElementsAre(Child));
 }
 
+TEST(Subtypes, LazyResolution) {
+  Annotations Source(R"cpp(
+struct P^arent {};
+struct Child1 : Parent {};
+struct Child2a : Child1 {};
+struct Child2b : Child1 {};
+)cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+
+  llvm::Optional Result = getTypeHierarchy(
+  AST, Source.point(), /*ResolveLevels=*/1,
+  TypeHierarchyDirection::Children, Index.get(), testPath(TU.Filename));
+  ASSERT_TRUE(bool(Result));
+  EXPECT_THAT(
+  *Result,
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
+   ParentsNotResolved(), ChildrenNotResolved();
+
+  resolveTypeHierarchy((*Result->children)[0], /*ResolveLevels=*/1,
+   TypeHierarchyDirection::Children, Index.get());
+
+  EXPECT_THAT(
+  (*Result->children)[0],
+  AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
+Children(AllOf(WithName("Child2a"), WithKind(SymbolKind::Struct),
+   ParentsNotResolved(), ChildrenNotResolved()),
+ AllOf(WithName("Child2b"), WithKind(SymbolKind::Struct),
+   ParentsNotResolved(), ChildrenNotResolved();
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/test/type-hierarchy.test
===
--- clang-tools-extra/clangd/test/type-hierarchy.test
+++ clang-tools-extra/clangd/test/type-hierarchy.test
@@ -1,7 +1,7 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct Parent {};\nstruct Child1 : Parent {};\nstruct Child2 : Child1 {};\nstruct Child3 : Child2 {};"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct Parent {};\nstruct Child1 : Parent {};\nstruct Child2 : Child1 {};\nstruct Child3 : Child2 {};\nstruct Child4 : Child3 {};"}}}
 ---
 {"jsonrpc":"2.0","id":1,"method":"textDocument/typeHierarchy","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":11},"direction":2,"resolve":1}}
 #  CHECK:  "id": 1
@@ -9,6 +9,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"children": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"data": "A6576FE083F2949A",
 # CHECK-NEXT:"kind": 23,
 # CHECK-NEXT:"name": "Child3",
 # CHECK-NEXT:"range": {
@@ -114,6 +115,64 @@
 # CHECK-NEXT:"uri": "file:///clangd-test/main.cpp"
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"shutdown"}

[PATCH] D64062: Remove __VERSION__

2019-07-12 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

The revert is at https://reviews.llvm.org/D64687, which I will commit shortly 
if there are no objections.


Repository:
  rL LLVM

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] D64062: Remove __VERSION__

2019-07-12 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

This revision breaks python 2.7.16 builds, which are still supported by 
upstream python for a few more months. I'm preparing a revert.

The file is getcompiler.c:

/* Return the compiler identification, if possible. */

#include "Python.h"

#ifndef COMPILER

#ifdef __GNUC__
#define COMPILER "\n[GCC " __VERSION__ "]"
#endif

#endif /* !COMPILER */

#ifndef COMPILER

#ifdef __cplusplus
#define COMPILER "[C++]"
#else
#define COMPILER "[C]"
#endif

#endif /* !COMPILER */

const char *
Py_GetCompiler(void)
{

  return COMPILER;

}


Repository:
  rL LLVM

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: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
I struggled for a while thinking why PRIVATE might be useful in a 
target_link_libraries call for a shared library, and then I found 
https://cmake.org/pipermail/cmake/2016-May/063400.html. The relevant bit is:

If you were paying careful attention, you would have noticed that when A
links in B as PRIVATE, the include directories of B never propagate to
something linking to A, but if A is a static library, then the *linking* of
B behaves as though the relationship was PUBLIC. This
PRIVATE-becomes-PUBLIC behaviour for static libraries only applies to the
*linking*, not to the other dependencies (compiler options/flags and
include search paths).

So PRIVATE/INTERFACE/PUBLIC doesn’t make any difference as far as the actual 
linking goes, but it does affect propagation of other options, and I think it’s 
valid to want to have a PRIVATE dependency for a static library.

From:  on behalf of Chris Bieneman 
Date: Friday, July 12, 2019 at 9:08 AM
To: Shoaib Meenai 
Cc: Alex Bradbury , cfe-commits 
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

Ah! I see what is going on here. This is kinda a silliness of CMake. `PRIVATE` 
linkage for a static archive is silly, and shouldn't be possible. All link 
dependencies for static archives are really `INTERFACE` dependencies, and it 
looks like CMake is doing something kinda silly instead of producing a 
reasonable error or warning like it probably should do.

For context, `PRIVATE` linkage in the context of that change would mean 
DirectoryWalker links something, but things that link DirectoryWalker don't. 
That just isn't possible with static archives, so they become interface 
dependencies (and CMake seems to insert a generator expression to make that 
work).

In `llvm_add_library` we always use `PRIVATE` linkage for shared libraries, and 
`INTERFACE` for static, which does the right thing.

Unless there is a better reason than a new patch coming in, I think the right 
fix is to revert this back and expect the new patch to correct its linkage 
behavior.

-Chris


On Jul 12, 2019, at 8:53 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

See 
https://reviews.llvm.org/D58418#1577670.
 More generally it would appear for any static library with a PRIVATE 
dependency though.

I guess an alternative would be to use the LINK_LIBRARIES property (which 
should be free of generator expressions, I believe) to propagate dependencies 
instead of INTERFACE_LINK_LIBRARIES, and just assume that no one is gonna set 
an INTERFACE dependency on a static library. (Supporting PRIVATE dependencies 
on a static library definitely seems more valuable than supporting INTERFACE 
dependencies.)

From: mailto:cbiene...@apple.com>> on behalf of Chris 
Bieneman mailto:be...@apple.com>>
Date: Friday, July 12, 2019 at 8:49 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: Alex Bradbury mailto:a...@lowrisc.org>>, cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

One of the benefits of the object library approach for generating the clang 
dylib is that it was compatible with BUILD_SHARED_LIBS. We had lots of issues 
with libLLVM where people using BUILD_SHARED_LIBS would make changes that broke 
it, so I was trying to make the clang dylib in a way that it could always be 
enabled.

Do we know where the nested generator expression was coming from?

-Chris



On Jul 12, 2019, at 8:32 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury mailto:a...@lowrisc.org>>
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
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 

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

2019-07-12 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: lld/test/wasm/data-segments.ll:7
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
%t.atomics.o -o %t.atomics.wasm
-; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefix ACTIVE
+; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefixes 
ACTIVE,ACTIVE-TLS
 

quantum wrote:
> aheejin wrote:
> > What is the difference between `ACTIVE` and `ACTIVE-TLS`? It looks we don't 
> > have different build processes for them. And as what @sbc100 said, can we 
> > exclude TLS from build?
> `ACTIVE-TLS` is for builds with TLS enabled. Currently, we use 
> `--shared-memory` to determine that, per @tlively's recommendation. The 
> rationale is that we don't want even more flags that need to be passed in a 
> proper threaded build.
Then if we don't enable `--shared-memory`, we don't generate those globals? Do 
we have a test for that?


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] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.

2019-07-12 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365985: [Sema] Diagnose default-initialization, destruction, 
and copying of (authored by ahatanak, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63753?vs=209626=209663#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63753

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
  cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h
  cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m
  cfe/trunk/test/PCH/non-trivial-c-union.m
  cfe/trunk/test/SemaObjC/arc-decls.m
  cfe/trunk/test/SemaObjC/non-trivial-c-union.m

Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1130,12 +1130,6 @@
   };
 
   /// Check if this is a non-trivial type that would cause a C struct
-  /// transitively containing this type to be non-trivial. This function can be
-  /// used to determine whether a field of this type can be declared inside a C
-  /// union.
-  bool isNonTrivialPrimitiveCType(const ASTContext ) const;
-
-  /// Check if this is a non-trivial type that would cause a C struct
   /// transitively containing this type to be non-trivial to copy and return the
   /// kind.
   PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const;
@@ -1164,6 +1158,22 @@
 return isDestructedTypeImpl(*this);
   }
 
+  /// Check if this is or contains a C union that is non-trivial to
+  /// default-initialize, which is a union that has a member that is non-trivial
+  /// to default-initialize. If this returns true,
+  /// isNonTrivialToPrimitiveDefaultInitialize returns PDIK_Struct.
+  bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const;
+
+  /// Check if this is or contains a C union that is non-trivial to destruct,
+  /// which is a union that has a member that is non-trivial to destruct. If
+  /// this returns true, isDestructedType returns DK_nontrivial_c_struct.
+  bool hasNonTrivialToPrimitiveDestructCUnion() const;
+
+  /// Check if this is or contains a C union that is non-trivial to copy, which
+  /// is a union that has a member that is non-trivial to copy. If this returns
+  /// true, isNonTrivialToPrimitiveCopy returns PCK_Struct.
+  bool hasNonTrivialToPrimitiveCopyCUnion() const;
+
   /// Determine whether expressions of the given type are forbidden
   /// from being lvalues in C.
   ///
@@ -1236,6 +1246,11 @@
  const ASTContext );
   static QualType IgnoreParens(QualType T);
   static DestructionKind isDestructedTypeImpl(QualType type);
+
+  /// Check if \param RD is or contains a non-trivial C union.
+  static bool hasNonTrivialToPrimitiveDefaultInitializeCUnion(const RecordDecl *RD);
+  static bool hasNonTrivialToPrimitiveDestructCUnion(const RecordDecl *RD);
+  static bool hasNonTrivialToPrimitiveCopyCUnion(const RecordDecl *RD);
 };
 
 } // namespace clang
@@ -6249,6 +6264,24 @@
   return getQualifiers().getObjCGCAttr();
 }
 
+inline bool QualType::hasNonTrivialToPrimitiveDefaultInitializeCUnion() const {
+  if (auto *RD = getTypePtr()->getBaseElementTypeUnsafe()->getAsRecordDecl())
+return hasNonTrivialToPrimitiveDefaultInitializeCUnion(RD);
+  return false;
+}
+
+inline bool QualType::hasNonTrivialToPrimitiveDestructCUnion() const {
+  if (auto *RD = getTypePtr()->getBaseElementTypeUnsafe()->getAsRecordDecl())
+return hasNonTrivialToPrimitiveDestructCUnion(RD);
+  return false;
+}
+
+inline bool QualType::hasNonTrivialToPrimitiveCopyCUnion() const {
+  if (auto *RD = getTypePtr()->getBaseElementTypeUnsafe()->getAsRecordDecl())
+return hasNonTrivialToPrimitiveCopyCUnion(RD);
+  return false;
+}
+
 inline FunctionType::ExtInfo getFunctionExtInfo(const Type ) {
   if (const auto *PT = t.getAs()) {
 if (const auto *FT = PT->getPointeeType()->getAs())
Index: cfe/trunk/include/clang/AST/DeclBase.h
===
--- cfe/trunk/include/clang/AST/DeclBase.h
+++ cfe/trunk/include/clang/AST/DeclBase.h
@@ -1440,6 +1440,13 @@
 uint64_t NonTrivialToPrimitiveCopy : 1;
 uint64_t NonTrivialToPrimitiveDestroy : 1;
 
+/// The following bits indicate whether this is or contains a C union that
+/// is non-trivial to default-initialize, destruct, or copy. These bits
+/// imply the associated basic 

r365985 - [Sema] Diagnose default-initialization, destruction, and copying of

2019-07-12 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Jul 12 18:47:15 2019
New Revision: 365985

URL: http://llvm.org/viewvc/llvm-project?rev=365985=rev
Log:
[Sema] Diagnose default-initialization, destruction, and copying of
non-trivial C union types

This patch diagnoses uses of non-trivial C unions and structs/unions
containing non-trivial C unions in the following contexts, which require
default-initialization, destruction, or copying of the union objects,
instead of disallowing fields of non-trivial types in C unions, which is
what we currently do:

- function parameters.
- function returns.
- assignments.
- compound literals.
- block captures except capturing of `__block` variables by non-escaping
  blocks.
- local and global variable definitions.
- lvalue-to-rvalue conversions of volatile types.

See the discussion in https://reviews.llvm.org/D62988 for more background.

rdar://problem/50679094

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

Added:
cfe/trunk/test/PCH/non-trivial-c-union.m
cfe/trunk/test/SemaObjC/non-trivial-c-union.m
Removed:
cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m
cfe/trunk/test/SemaObjC/arc-decls.m

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=365985=365984=365985=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jul 12 18:47:15 2019
@@ -3746,6 +3746,30 @@ public:
 RecordDeclBits.NonTrivialToPrimitiveDestroy = V;
   }
 
+  bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const {
+return RecordDeclBits.HasNonTrivialToPrimitiveDefaultInitializeCUnion;
+  }
+
+  void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V) {
+RecordDeclBits.HasNonTrivialToPrimitiveDefaultInitializeCUnion = V;
+  }
+
+  bool hasNonTrivialToPrimitiveDestructCUnion() const {
+return RecordDeclBits.HasNonTrivialToPrimitiveDestructCUnion;
+  }
+
+  void setHasNonTrivialToPrimitiveDestructCUnion(bool V) {
+RecordDeclBits.HasNonTrivialToPrimitiveDestructCUnion = V;
+  }
+
+  bool hasNonTrivialToPrimitiveCopyCUnion() const {
+return RecordDeclBits.HasNonTrivialToPrimitiveCopyCUnion;
+  }
+
+  void setHasNonTrivialToPrimitiveCopyCUnion(bool V) {
+RecordDeclBits.HasNonTrivialToPrimitiveCopyCUnion = V;
+  }
+
   /// Determine whether this class can be passed in registers. In C++ mode,
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=365985=365984=365985=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Jul 12 18:47:15 2019
@@ -1440,6 +1440,13 @@ class DeclContext {
 uint64_t NonTrivialToPrimitiveCopy : 1;
 uint64_t NonTrivialToPrimitiveDestroy : 1;
 
+/// The following bits indicate whether this is or contains a C union that
+/// is non-trivial to default-initialize, destruct, or copy. These bits
+/// imply the associated basic non-triviality predicates declared above.
+uint64_t HasNonTrivialToPrimitiveDefaultInitializeCUnion : 1;
+uint64_t HasNonTrivialToPrimitiveDestructCUnion : 1;
+uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
+
 /// Indicates whether this struct is destroyed in the callee.
 uint64_t ParamDestroyedInCallee : 1;
 
@@ -1448,7 +1455,7 @@ class DeclContext {
   };
 
   /// Number of non-inherited bits in RecordDeclBitfields.
-  enum { NumRecordDeclBits = 11 };
+  enum { NumRecordDeclBits = 14 };
 
   /// Stores the bits used by OMPDeclareReductionDecl.
   /// If modified NumOMPDeclareReductionDeclBits and the accessor

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=365985=365984=365985=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Jul 12 18:47:15 2019
@@ -1130,12 +1130,6 @@ public:
   };
 
   /// Check if this is a non-trivial type that would cause a C struct
-  /// transitively containing this type 

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

2019-07-12 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added inline comments.



Comment at: lld/test/wasm/data-segments.ll:7
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
%t.atomics.o -o %t.atomics.wasm
-; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefix ACTIVE
+; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefixes 
ACTIVE,ACTIVE-TLS
 

aheejin wrote:
> What is the difference between `ACTIVE` and `ACTIVE-TLS`? It looks we don't 
> have different build processes for them. And as what @sbc100 said, can we 
> exclude TLS from build?
`ACTIVE-TLS` is for builds with TLS enabled. Currently, we use 
`--shared-memory` to determine that, per @tlively's recommendation. The 
rationale is that we don't want even more flags that need to be passed in a 
proper threaded build.



Comment at: lld/test/wasm/tls.ll:6
+@tls1 = thread_local(localexec) global i32 1, align 4
+@tls2 = thread_local(localexec) global i32 1, align 4
+

aheejin wrote:
> Can we possibly mix one non-tls global variable between `tls1` and `tls2`, 
> just to see they work together?
Done.



Comment at: lld/wasm/Writer.cpp:629
+  // Merge .tbss into .tdata so that they share the same offsets.
+  if (name.startswith(".tbss."))
+return ".tdata";

aheejin wrote:
> quantum wrote:
> > sbc100 wrote:
> > > Maybe write this as a single conditional so its clear even without this 
> > > comment?
> > Changed in latest diff.
> Has it been reflected? It says it has been changed but it doesn't look like 
> it has
I think you are commenting on an old version? It is a single condition on the 
latest version.



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:
> quantum wrote:
> > aheejin wrote:
> > > Now `__tls_base` is also mutable, I think we should fix the comment
> > Will do.
> PIng. It doesn't look like fixed yet
Looks like the fix got rebasing against the change that made everything 
lowerCamelCase. Going to do it again.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:203
+ReplaceUses(SDValue(Node, 0), SDValue(TLSAddress, 0));
+CurDAG->RemoveDeadNode(Node);
+return;

aheejin wrote:
> These two lines can be shortened to
> ```
> ReplaceNode(Node, TLSAddress);
> ```
> The same applies to the code below for `__tls_size` too.
Nice. I didn't know that was possible. Changing.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:208
+  case ISD::INTRINSIC_WO_CHAIN:
+switch (cast(Node->getOperand(0))->getZExtValue()) {
+case Intrinsic::wasm_tls_size: {

aheejin wrote:
> Nit: Might be a bit cleaner to extract the expression, which is complicated, 
> like
> ```
> unsigned IntNo = cast(Node->getOperand(0))->getZExtValue());
> switch (IntNo) {
>  ...
> ```
Done.


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] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

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

Change per review feedback.


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-segments.ll
  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/WebAssemblyISelDAGToDAG.cpp
  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 -mattr=+bulk-memory | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel | 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=-bulk-memory | FileCheck %s --check-prefixes NO-BULK-MEM
+; RUN: llc < %s -mattr=+bulk-memory | FileCheck %s --check-prefixes BULK-MEM
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,18 +9,19 @@
 
 @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,"",@
+; -bulk-memory
+; NO-BULK-MEM-LABEL: .custom_section.target_features,"",@
+; NO-BULK-MEM-NEXT: .int8 1
+; NO-BULK-MEM-NEXT: .int8 45
+; NO-BULK-MEM-NEXT: .int8 7
+; NO-BULK-MEM-NEXT: .ascii "atomics"
+; NO-BULK-MEM-NEXT: .bss.foo,"",@
 
-; +atomics
-; ATOMICS-NEXT: .int8 1
-; ATOMICS-NEXT: .int8 43
-; ATOMICS-NEXT: .int8 7
-; ATOMICS-NEXT: .ascii "atomics"
-; ATOMICS-NEXT: .tbss.foo,"",@
+; +bulk-memory
+; BULK-MEM-LABEL: .custom_section.target_features,"",@
+; BULK-MEM-NEXT: .int8 1
+; BULK-MEM-NEXT: .int8 43
+; BULK-MEM-NEXT: .int8 11
+; BULK-MEM-NEXT: 

[PATCH] D64653: clang/test/Driver/fsanitize.c: Fix -fsanitize=vptr using default target

2019-07-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I committed this for you in rL365981  (it 
may have broken a Windows build for a long time. I wanted to fix it soon..). 
Thanks!

  % clang -target x86_64-windows -fsanitize=vptr -fno-rtti fsanitize.c '-###'
  clang-9: error: unsupported option '-fsanitize=vptr' for target 
'x86_64-unknown-windows-msvc'


Repository:
  rC Clang

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

https://reviews.llvm.org/D64653



___
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-12 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: lld/test/wasm/data-segments.ll:7
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
%t.atomics.o -o %t.atomics.wasm
-; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefix ACTIVE
+; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefixes 
ACTIVE,ACTIVE-TLS
 

What is the difference between `ACTIVE` and `ACTIVE-TLS`? It looks we don't 
have different build processes for them. And as what @sbc100 said, can we 
exclude TLS from build?



Comment at: lld/test/wasm/tls.ll:6
+@tls1 = thread_local(localexec) global i32 1, align 4
+@tls2 = thread_local(localexec) global i32 1, align 4
+

Can we possibly mix one non-tls global variable between `tls1` and `tls2`, just 
to see they work together?



Comment at: lld/wasm/Writer.cpp:629
+  // Merge .tbss into .tdata so that they share the same offsets.
+  if (name.startswith(".tbss."))
+return ".tdata";

quantum wrote:
> sbc100 wrote:
> > Maybe write this as a single conditional so its clear even without this 
> > comment?
> Changed in latest diff.
Has it been reflected? It says it has been changed but it doesn't look like it 
has



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

quantum wrote:
> quantum wrote:
> > 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.
> On second thought, the `mutable-global` feature is for import/export of 
> mutable globals. TLS does not need to do this.
Ah you're right.



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);

quantum wrote:
> aheejin wrote:
> > Now `__tls_base` is also mutable, I think we should fix the comment
> Will do.
PIng. It doesn't look like fixed yet



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:203
+ReplaceUses(SDValue(Node, 0), SDValue(TLSAddress, 0));
+CurDAG->RemoveDeadNode(Node);
+return;

These two lines can be shortened to
```
ReplaceNode(Node, TLSAddress);
```
The same applies to the code below for `__tls_size` too.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:208
+  case ISD::INTRINSIC_WO_CHAIN:
+switch (cast(Node->getOperand(0))->getZExtValue()) {
+case Intrinsic::wasm_tls_size: {

Nit: Might be a bit cleaner to extract the expression, which is complicated, 
like
```
unsigned IntNo = cast(Node->getOperand(0))->getZExtValue());
switch (IntNo) {
 ...
```


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] D64656: Ensure placeholder instruction for cleanup is created

2019-07-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:1
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions %s
+// PR40771: check that this input does not crash or assert

This will run the backend and (I think) drop an unwanted output file somewhere. 
You can use `-emit-llvm-only` instead of `-emit-obj` so that we stop after 
creating the IR and don't actually write it anywhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656



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


r365981 - clang/test/Driver/fsanitize.c: Fix -fsanitize=vptr using default target

2019-07-12 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Fri Jul 12 17:47:58 2019
New Revision: 365981

URL: http://llvm.org/viewvc/llvm-project?rev=365981=rev
Log:
clang/test/Driver/fsanitize.c: Fix -fsanitize=vptr using default target

The default implementation of getSupportedSanitizers isn't able to turn
on the vptr sanitizer, and thus, any platform that runs this test will
fail with the error:

clang: error: unsupported option '-fsanitize=vptr' for target ''

Patch by James Nagurne!

Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=365981=365980=365981=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Fri Jul 12 17:47:58 2019
@@ -97,7 +97,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr 
-fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-VPTR-TRAP-UNDEF
 // CHECK-VPTR-TRAP-UNDEF: error: invalid argument '-fsanitize=vptr' not 
allowed with '-fsanitize-trap=undefined'
 
-// RUN: %clang -fsanitize=vptr -fno-rtti %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-VPTR-NO-RTTI
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-rtti %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
 // CHECK-VPTR-NO-RTTI: '-fsanitize=vptr' not allowed with '-fno-rtti'
 
 // RUN: %clang -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-UNDEFINED-NO-RTTI


___
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-12 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209656.
quantum added a comment.

Use signed LEB128 for `i32.const`. Basically, do what D64612 
 did.


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-segments.ll
  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/WebAssemblyISelDAGToDAG.cpp
  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 -mattr=+bulk-memory | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel | 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=-bulk-memory | FileCheck %s --check-prefixes NO-BULK-MEM
+; RUN: llc < %s -mattr=+bulk-memory | FileCheck %s --check-prefixes BULK-MEM
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,18 +9,19 @@
 
 @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,"",@
+; -bulk-memory
+; NO-BULK-MEM-LABEL: .custom_section.target_features,"",@
+; NO-BULK-MEM-NEXT: .int8 1
+; NO-BULK-MEM-NEXT: .int8 45
+; NO-BULK-MEM-NEXT: .int8 7
+; NO-BULK-MEM-NEXT: .ascii "atomics"
+; NO-BULK-MEM-NEXT: .bss.foo,"",@
 
-; +atomics
-; ATOMICS-NEXT: .int8 1
-; ATOMICS-NEXT: .int8 43
-; ATOMICS-NEXT: .int8 7
-; ATOMICS-NEXT: .ascii "atomics"
-; ATOMICS-NEXT: .tbss.foo,"",@
+; +bulk-memory
+; BULK-MEM-LABEL: .custom_section.target_features,"",@
+; BULK-MEM-NEXT: .int8 1
+; BULK-MEM-NEXT: .int8 43
+; 

Buildbot numbers for the week of 06/23/2019 - 06/29/2019

2019-07-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 06/23/2019 - 06/29/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 netbsd-amd64  | 96:53:50
 sanitizer-x86_64-linux-fast   | 83:07:45
 sanitizer-x86_64-linux-bootstrap-ubsan| 81:53:48
 clang-with-lto-ubuntu | 56:20:55
 clang-cmake-aarch64-lld   | 40:52:47
 clang-cmake-aarch64-full  | 40:07:07
 clang-cmake-armv8-lld | 36:39:09
 clang-cmake-thumbv7-full-sh   | 36:24:12
 clang-cmake-armv7-selfhost| 35:43:59
 clang-cmake-armv7-selfhost-neon   | 35:32:21
 clang-cmake-armv7-quick   | 33:51:34
 clang-cmake-armv8-selfhost-neon   | 33:46:21
 clang-cmake-armv7-global-isel | 33:45:10
 clang-cmake-armv8-full| 33:22:23
 clang-cmake-armv7-full| 33:20:47
 clang-cmake-armv8-global-isel | 33:08:10
 clang-cmake-armv8-quick   | 32:34:42
 clang-cmake-thumbv8-full-sh   | 32:18:42
 clang-hexagon-elf | 32:12:50
 sanitizer-x86_64-linux-bootstrap-msan | 27:00:07
 clang-lld-x86_64-2stage   | 25:40:25
 llvm-clang-x86_64-expensive-checks-win| 20:12:52
 sanitizer-x86_64-linux-android| 15:03:37
 sanitizer-x86_64-linux-bootstrap  | 14:35:51
 sanitizer-ppc64le-linux   | 14:07:16
 clang-cmake-aarch64-global-isel   | 13:52:25
 clang-cmake-armv8-lnt | 11:52:27
 sanitizer-x86_64-linux| 11:41:46
 clang-with-thin-lto-ubuntu| 11:24:28
 sanitizer-ppc64be-linux   | 11:11:38
 sanitizer-x86_64-linux-autoconf   | 11:11:01
 clang-ppc64le-linux-lnt   | 11:05:31
 sanitizer-x86_64-linux-gn | 11:04:59
 ppc64le-lld-multistage-test   | 10:58:30
 clang-ppc64le-linux   | 10:22:39
 clang-cmake-aarch64-quick | 10:12:56
 lld-perf-testsuite| 10:00:02
 clang-sphinx-docs | 09:57:05
 clang-aarch64-linux-build-cache   | 09:52:07
 lld-x86_64-darwin13   | 09:51:14
 clang-tools-sphinx-docs   | 09:38:07
 clang-cmake-armv7-lnt | 09:30:44
 clang-s390x-linux-lnt | 09:30:13
 clang-armv7-linux-build-cache | 09:27:39
 lldb-sphinx-docs  | 09:20:02
 clang-cmake-x86_64-avx2-linux | 09:16:32
 clang-cmake-x86_64-sde-avx512-linux   | 09:09:38
 llvm-sphinx-docs  | 08:29:27
 clang-native-arm-lnt-perf | 08:21:29
 clang-s390x-linux | 07:34:07
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 06:48:56
 lld-sphinx-docs   | 06:19:32
 clang-atom-d525-fedora-rel| 06:03:07
 clang-ppc64le-linux-multistage| 05:19:25
 clang-cuda-build  | 05:01:58
 clang-s390x-linux-multistage  | 04:37:03
 sanitizer-x86_64-linux-fuzzer | 04:33:18
 llvm-hexagon-elf  | 04:20:26
 reverse-iteration | 03:57:13
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 03:46:20
 clang-ppc64be-linux-lnt   | 03:12:39
 clang-ppc64be-linux-multistage| 03:10:59
 polly-arm-linux   | 03:10:36
 sanitizer-windows | 03:05:25
 

Buildbot numbers for the week of 06/30/2019 - 07/6/2019

2019-07-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 06/30/2019 - 07/6/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 clang-cmake-armv7-quick   | 44:53:34
 clang-cmake-thumbv7-full-sh   | 44:31:17
 clang-cmake-armv8-global-isel | 44:31:07
 clang-cmake-armv8-full| 44:30:20
 clang-cmake-armv8-lld | 44:29:58
 clang-cmake-armv8-quick   | 44:29:33
 clang-cmake-thumbv8-full-sh   | 44:24:27
 llvm-clang-x86_64-expensive-checks-win| 43:39:40
 sanitizer-x86_64-linux-gn | 42:35:29
 ppc64le-lld-multistage-test   | 35:51:46
 sanitizer-x86_64-linux| 32:51:19
 clang-cmake-armv7-full| 31:41:05
 clang-cmake-armv7-global-isel | 31:37:47
 libcxx-libcxxabi-libunwind-armv8-linux| 28:48:58
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 28:39:45
 libcxx-libcxxabi-libunwind-armv7-linux| 27:05:56
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 25:50:55
 clang-ppc64le-linux-multistage| 25:00:01
 clang-ppc64le-linux-lnt   | 24:03:49
 clang-ppc64be-linux-multistage| 23:46:02
 sanitizer-ppc64be-linux   | 23:42:51
 sanitizer-ppc64le-linux   | 23:37:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 23:06:30
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 22:29:08
 clang-lld-x86_64-2stage   | 15:45:19
 clang-with-thin-lto-ubuntu| 14:15:21
 clang-tools-sphinx-docs   | 10:55:36
 sanitizer-x86_64-linux-android| 09:31:55
 clang-cmake-armv7-selfhost| 07:50:11
 sanitizer-x86_64-linux-bootstrap  | 07:46:49
 clang-with-lto-ubuntu | 07:38:03
 sanitizer-x86_64-linux-bootstrap-ubsan| 07:30:37
 clang-cmake-armv7-selfhost-neon   | 07:30:06
 clang-ppc64be-linux   | 06:56:05
 reverse-iteration | 06:34:20
 lld-x86_64-ubuntu-fast| 06:27:16
 clang-x86_64-debian-fast  | 06:25:27
 clang-atom-d525-fedora-rel| 06:21:02
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 06:19:57
 clang-cmake-x86_64-sde-avx512-linux   | 06:18:12
 clang-cuda-build  | 06:17:15
 clang-cmake-x86_64-avx2-linux | 06:15:00
 clang-cmake-aarch64-global-isel   | 06:09:52
 clang-cmake-aarch64-quick | 06:05:47
 sanitizer-x86_64-linux-fast   | 05:58:35
 clang-ppc64le-linux   | 05:53:55
 sanitizer-x86_64-linux-bootstrap-msan | 05:48:56
 clang-cmake-armv8-selfhost-neon   | 04:58:34
 clang-s390x-linux-multistage  | 04:38:50
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 04:31:57
 llvm-clang-x86_64-win-fast| 04:29:53
 libcxx-libcxxabi-libunwind-aarch64-linux  | 03:24:33
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 03:21:39
 lld-x86_64-freebsd| 03:05:06
 lld-x86_64-darwin13   | 03:04:51
 clang-s390x-linux | 02:46:14
 llvm-hexagon-elf  | 02:43:14
 lld-x86_64-win7   | 02:43:01
 clang-s390x-linux-lnt | 02:24:41
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 02:14:31
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit| 02:09:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 02:05:07
 sanitizer-x86_64-linux-autoconf   | 02:04:54
 clang-hexagon-elf | 02:03:28
 

Buildbot numbers for the week of 05/26/2019 - 06/01/2019

2019-07-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 05/26/2019 - 06/01/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 netbsd-amd64  | 74:58:53
 clang-s390x-linux-multistage  | 70:23:01
 clang-s390x-linux | 68:34:18
 clang-s390x-linux-lnt | 68:21:02
 clang-cmake-armv8-lld | 61:14:52
 clang-cmake-armv8-selfhost-neon   | 54:32:24
 clang-cmake-armv7-selfhost| 54:15:22
 clang-cmake-thumbv8-full-sh   | 54:12:28
 clang-cmake-armv8-global-isel | 53:05:04
 clang-cmake-armv7-selfhost-neon   | 52:50:40
 clang-cmake-armv7-quick   | 52:36:29
 clang-cmake-armv7-global-isel | 52:36:11
 clang-cmake-thumbv7-full-sh   | 52:24:57
 clang-cmake-armv7-full| 52:09:42
 clang-cmake-armv8-quick   | 51:48:11
 clang-cmake-armv8-full| 51:38:50
 llvm-clang-x86_64-expensive-checks-win| 27:46:53
 clang-x64-windows-msvc| 25:23:46
 clang-cmake-aarch64-full  | 22:11:37
 clang-cmake-aarch64-lld   | 20:25:36
 sanitizer-x86_64-linux-fast   | 19:22:17
 clang-cmake-aarch64-global-isel   | 17:05:43
 clang-cmake-aarch64-quick | 16:47:56
 clang-lld-x86_64-2stage   | 16:09:14
 sanitizer-x86_64-linux-bootstrap  | 15:43:44
 sanitizer-ppc64le-linux   | 10:25:09
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 10:07:03
 clang-with-lto-ubuntu | 06:57:32
 clang-ppc64le-linux-multistage| 06:44:25
 clang-ppc64le-linux   | 06:18:18
 clang-with-thin-lto-ubuntu| 05:48:43
 clang-cmake-x86_64-sde-avx512-linux   | 05:41:18
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 05:39:20
 lldb-x64-windows-ninja| 05:20:32
 sanitizer-ppc64be-linux   | 05:11:42
 clang-cmake-x86_64-avx2-linux | 05:09:24
 sanitizer-x86_64-linux-bootstrap-ubsan| 05:00:10
 sanitizer-x86_64-linux| 04:58:48
 clang-hexagon-elf | 04:57:09
 clang-cmake-x86_64-avx2-linux-perf| 04:56:41
 sanitizer-x86_64-linux-bootstrap-msan | 04:45:31
 clang-atom-d525-fedora-rel| 04:40:06
 clang-ppc64le-linux-lnt   | 04:40:05
 sanitizer-windows | 04:33:02
 clang-cuda-build  | 04:32:36
 lld-x86_64-ubuntu-fast| 04:26:01
 lld-perf-testsuite| 04:17:02
 lld-x86_64-win7   | 04:04:54
 reverse-iteration | 03:59:12
 libcxx-libcxxabi-libunwind-aarch64-linux  | 03:04:49
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 03:03:34
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 03:03:17
 libcxx-libcxxabi-libunwind-armv7-linux| 03:03:10
 libcxx-libcxxabi-libunwind-armv8-linux| 03:03:01
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 03:02:38
 clang-cmake-armv8-lnt | 02:35:09
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 01:56:21
 clang-x86_64-linux-abi-test   | 01:43:32
 sanitizer-x86_64-linux-autoconf   | 01:32:04
 sanitizer-x86_64-linux-fuzzer | 01:16:09
 lld-x86_64-darwin13   | 01:12:41
 llvm-hexagon-elf  | 00:55:26
 clang-armv7-linux-build-cache | 00:55:08
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 00:23:24
 

Buildbot numbers for the week of 06/2/2019 - 06/8/2019

2019-07-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 06/2/2019 - 06/8/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 netbsd-amd64 | 70:52:06
 sanitizer-x86_64-linux   | 47:40:54
 clang-ppc64be-linux-lnt  | 35:54:21
 clang-ppc64be-linux  | 35:49:32
 clang-ppc64be-linux-multistage   | 34:44:42
 lldb-x64-windows-ninja   | 34:43:24
 sanitizer-x86_64-linux-android   | 29:49:06
 sanitizer-x86_64-linux-bootstrap | 28:44:30
 sanitizer-x86_64-linux-bootstrap-ubsan   | 26:58:40
 clang-s390x-linux-lnt| 24:16:36
 clang-armv7-linux-build-cache| 23:30:19
 clang-aarch64-linux-build-cache  | 23:25:11
 clang-cmake-aarch64-lld  | 19:57:01
 clang-cmake-armv7-selfhost-neon  | 19:30:57
 llvm-clang-x86_64-expensive-checks-win   | 18:22:36
 sanitizer-x86_64-linux-fast  | 17:58:40
 clang-cmake-thumbv7-full-sh  | 17:39:47
 clang-cmake-aarch64-full | 17:37:00
 clang-cmake-armv8-lld| 17:35:09
 clang-cmake-thumbv8-full-sh  | 12:43:19
 clang-s390x-linux-multistage | 12:10:48
 clang-cmake-armv8-selfhost-neon  | 11:19:00
 sanitizer-x86_64-linux-bootstrap-msan| 10:56:56
 clang-ppc64le-linux-lnt  | 10:31:24
 clang-lld-x86_64-2stage  | 10:11:16
 clang-cmake-armv7-selfhost   | 10:01:11
 clang-cmake-x86_64-avx2-linux-perf   | 09:57:51
 clang-cmake-x86_64-sde-avx512-linux  | 09:43:37
 clang-cmake-x86_64-avx2-linux| 09:41:37
 clang-ppc64le-linux-multistage   | 08:36:05
 clang-cmake-armv7-full   | 08:00:21
 clang-with-lto-ubuntu| 06:54:20
 lld-x86_64-darwin13  | 06:39:35
 clang-cmake-armv8-global-isel| 06:07:41
 clang-cmake-armv8-full   | 06:06:19
 reverse-iteration| 05:35:47
 clang-cmake-armv7-global-isel| 05:11:47
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 04:59:05
 clang-with-thin-lto-ubuntu   | 04:47:24
 clang-hexagon-elf| 04:41:46
 clang-x64-windows-msvc   | 04:36:47
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 04:34:59
 clang-cmake-armv8-quick  | 04:17:40
 sanitizer-ppc64le-linux  | 04:02:36
 clang-cmake-aarch64-global-isel  | 03:53:06
 clang-cmake-aarch64-quick| 03:48:21
 polly-amd64-linux| 03:40:28
 polly-arm-linux  | 03:29:34
 clang-cmake-armv7-quick  | 03:02:04
 clang-s390x-linux| 02:50:49
 llvm-hexagon-elf | 02:49:35
 clang-ppc64le-linux  | 02:44:00
 clang-cuda-build | 02:41:48
 lld-x86_64-ubuntu-fast   | 02:35:32
 clang-atom-d525-fedora-rel   | 02:16:33
 sanitizer-ppc64be-linux  | 01:47:04
 lld-perf-testsuite   | 01:19:28
 lld-x86_64-win7  | 01:17:42
 lld-x86_64-freebsd   | 01:15:19
 clang-cmake-armv7-lnt| 01:14:26
 clang-x86_64-linux-abi-test  | 00:56:33
 sanitizer-x86_64-linux-fuzzer| 00:37:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan| 00:36:28
 sanitizer-windows| 00:34:09
(64 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   buildername   | builds | changes
| status_change_ratio
-++-+
 

[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-12 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Here is an example of the mentioned use-after-free by pointer-escaping as an 
argument:
https://llvm.org/reports/scan-build/report-DeclBase.cpp-getFromVoidPointer-0-1.html#EndPath


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

https://reviews.llvm.org/D64680



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


[PATCH] D64653: clang/test/Driver/fsanitize.c: Fix -fsanitize=vptr using default target

2019-07-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Sorry, I accidentally updated this one by mistake. vptr is not always 
available. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D64653



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


[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-12 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 209654.
Charusso marked 2 inline comments as done.
Charusso added a comment.

- Fix.
- Move the logic to `free()` for better matching.


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

https://reviews.llvm.org/D64680

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/retain-count-alloc.cpp

Index: clang/test/Analysis/retain-count-alloc.cpp
===
--- /dev/null
+++ clang/test/Analysis/retain-count-alloc.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix.Malloc \
+// RUN:  -verify %s
+
+// expected-no-diagnostics: We do not model Integer Set Library's retain-count
+//  based allocation.
+
+#define __isl_take
+#define __isl_keep
+
+struct Object { int Ref; };
+void free(void *);
+
+Object *copyObj(__isl_keep Object *O) {
+  O->Ref++;
+  return O;
+}
+
+void freeObj(__isl_take Object *O) {
+  if (--O->Ref > 0)
+return;
+
+  free(O);
+}
+
+void useAfterFree(__isl_take Object *A) {
+  if (!A)
+return;
+
+  Object *B = copyObj(A);
+  freeObj(B);
+
+  A->Ref = 13;
+  // no-warning: 'Use of memory after it is freed' was here.
+}
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/ParentMap.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -41,6 +42,7 @@
 // Used to check correspondence between allocators and deallocators.
 enum AllocationFamily {
   AF_None,
+  AF_NotModeled,
   AF_Malloc,
   AF_CXXNew,
   AF_CXXNewArray,
@@ -50,19 +52,22 @@
 };
 
 class RefState {
-  enum Kind { // Reference to allocated memory.
-  Allocated,
-  // Reference to zero-allocated memory.
-  AllocatedOfSizeZero,
-  // Reference to released/freed memory.
-  Released,
-  // The responsibility for freeing resources has transferred from
-  // this reference. A relinquished symbol should not be freed.
-  Relinquished,
-  // We are no longer guaranteed to have observed all manipulations
-  // of this pointer/memory. For example, it could have been
-  // passed as a parameter to an opaque function.
-  Escaped
+  enum Kind {
+// If this checker does not model the allocation.
+DoNothing,
+// Reference to allocated memory.
+Allocated,
+// Reference to zero-allocated memory.
+AllocatedOfSizeZero,
+// Reference to released/freed memory.
+Released,
+// The responsibility for freeing resources has transferred from
+// this reference. A relinquished symbol should not be freed.
+Relinquished,
+// We are no longer guaranteed to have observed all manipulations
+// of this pointer/memory. For example, it could have been
+// passed as a parameter to an opaque function.
+Escaped
   };
 
   const Stmt *S;
@@ -75,6 +80,7 @@
 assert(family != AF_None);
   }
 public:
+  bool isDoNothing() const { return K == DoNothing; }
   bool isAllocated() const { return K == Allocated; }
   bool isAllocatedOfSizeZero() const { return K == AllocatedOfSizeZero; }
   bool isReleased() const { return K == Released; }
@@ -105,6 +111,9 @@
   static RefState getEscaped(const RefState *RS) {
 return RefState(Escaped, RS->getStmt(), RS->getAllocationFamily());
   }
+  static RefState getDoNothing(const Stmt *S) {
+return RefState(DoNothing, S, AF_NotModeled);
+  }
 
   void Profile(llvm::FoldingSetNodeID ) const {
 ID.AddInteger(K);
@@ -115,6 +124,7 @@
   void dump(raw_ostream ) const {
 switch (static_cast(K)) {
 #define CASE(ID) case ID: OS << #ID; break;
+CASE(DoNothing)
 CASE(Allocated)
 CASE(AllocatedOfSizeZero)
 CASE(Released)
@@ -359,6 +369,9 @@
   /// Check if the memory associated with this symbol was released.
   bool isReleased(SymbolRef Sym, CheckerContext ) const;
 
+  /// Check whether we do not model the memory allocation.
+  bool isNotModeled(const CallExpr *CE, CheckerContext ) const;
+
   bool checkUseAfterFree(SymbolRef Sym, CheckerContext , const Stmt *S) const;
 
   void checkUseZeroAllocated(SymbolRef Sym, CheckerContext ,
@@ -877,6 +890,9 @@
   State = ProcessZeroAllocation(C, CE, 0, State);
   State = ProcessZeroAllocation(C, CE, 1, State);
 } else if (FunI == II_free || FunI == II_g_free || FunI == II_kfree) {
+  if (isNotModeled(CE, C))
+return;
+
   State = FreeMemAux(C, CE, State, 0, false, 

[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-12 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D64680#1584076 , @NoQ wrote:

> Change of plans: let's suppress the warning when our `free()` is done within 
> the function that has `__isl_take` in its definition. So, like, ascend the 
> chain of location contexts and check your callers when you're about to mark 
> the pointer as released. If any of the callers contain `__isl_take`, mark it 
> as escaped instead.


I think if the `__isl_*` macro is in use it should be used in the immediate 
StackFrame. Btw: some magic happened and with the previous approach we did not 
suppress some reports, now we do. Thanks!




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:56-58
+// If this checker does not model the allocation.
+DoNothing,
+// Reference to allocated memory.

NoQ wrote:
> We already have `Escaped`, it's the same thing in practice.
It is more strict than `Escaped`, also it made for the purpose of 
`PSK_EscapeOther` to force out we lost the entire pointer and do not make false 
warnings of use-after-free.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2937-2942
+  const Stmt *S = PathDiagnosticLocation::getStmt(N);
+
+  if (RS && RS->isDoNothing()) {
+BR.markInvalid(getTag(), S);
+return nullptr;
+  }

NoQ wrote:
> {F9551724}
I wanted to make it bulletproof, but your meme-proof is way more better.


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

https://reviews.llvm.org/D64680



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan added a comment.

In D64666#1583792 , @xbolva00 wrote:

> In D64666#1583667 , @ziangwan wrote:
>
> > In D64666#1583633 , @xbolva00 
> > wrote:
> >
> > > You can check also https://reviews.llvm.org/D52835. I hit there issue 
> > > which I didn't know how to solve.
> >
> >
> > Hi David,
> >
> > Can you elaborate what issues you encountered? Thank you.
>
>
> I had duplicated warning for C++11+ - my new warning and C++11’s narrowing 
> warning.
>
> Did you run ‘ninja check-clang’?


I ran `ninja check-clang` and got all passed.


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

https://reviews.llvm.org/D64666



___
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-12 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added a comment.

In D64537#1584069 , @dschuff wrote:

> Oh, btw, any reason these have to be passive segments? Why can't we just make 
> them active segments and let the VM initialize them for us?


These need to be passive segments so that we can initialize it in different 
locations in linear memory for every thread.

If we had multiple memories, TLS could have been implemented as a separate 
linear memory, but we are stuck with `malloc`ing and initializing for now.

In D64537#1584067 , @dschuff wrote:

> If there's any chance this TLS ABI could be useful for WASI (I don't know if 
> there's been any WASI work on threads yet, but it seems like there's no 
> reason it couldn't be), then we should start a doc in tool-conventions for 
> it. If not then we should get it behind the emscripten OS in LLVM. (and 
> document it anyway; either in tool-conventions or somewhere in the emscripten 
> site).


Documenting this in tool-conventions is planned.


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] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.

LGTM with the comment fix from @MaskRay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64610



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


[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Oh damn, i just realized that this way we track much more pointers than before, 
because we cannot restrict ourselves to pointers that have been explicitly 
malloc()ed during analysis. After all, we don't need to see the allocation site 
to diagnose use-after-free.

I'm afraid that it's going to be too many pointers.

Change of plans: let's suppress the warning when our `free()` is done within 
the function that has `__isl_take` in its definition. So, like, ascend the 
chain of location contexts and check your callers when you're about to mark the 
pointer as released. If any of the callers contain `__isl_take`, mark it as 
escaped instead.




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:56-58
+// If this checker does not model the allocation.
+DoNothing,
+// Reference to allocated memory.

We already have `Escaped`, it's the same thing in practice.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2937-2942
+  const Stmt *S = PathDiagnosticLocation::getStmt(N);
+
+  if (RS && RS->isDoNothing()) {
+BR.markInvalid(getTag(), S);
+return nullptr;
+  }

{F9551724}


Repository:
  rC Clang

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

https://reviews.llvm.org/D64680



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


[PATCH] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2123
+
+  // If running with -thinlto-index=, extensions that normally identify
+  // native object files actually identify LLVM bitcode files.

`-fthinlto-index=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64610



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


r365976 - [DirectoryWatcher][test][NFC] Add information to test failure reports

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 17:09:04 2019
New Revision: 365976

URL: http://llvm.org/viewvc/llvm-project?rev=365976=rev
Log:
[DirectoryWatcher][test][NFC] Add information to test failure reports

Modified:
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=365976=365975=365976=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Fri Jul 12 
17:09:04 2019
@@ -97,7 +97,9 @@ std::string eventKindToString(const Dire
 
 struct VerifyingConsumer {
   std::vector ExpectedInitial;
+  const std::vector ExpectedInitialCopy;
   std::vector ExpectedNonInitial;
+  const std::vector ExpectedNonInitialCopy;
   std::vector OptionalNonInitial;
   std::vector UnexpectedInitial;
   std::vector UnexpectedNonInitial;
@@ -108,8 +110,8 @@ struct VerifyingConsumer {
   const std::vector ,
   const std::vector ,
   const std::vector  = {})
-  : ExpectedInitial(ExpectedInitial),
-ExpectedNonInitial(ExpectedNonInitial),
+  : ExpectedInitial(ExpectedInitial), ExpectedInitialCopy(ExpectedInitial),
+ExpectedNonInitial(ExpectedNonInitial), 
ExpectedNonInitialCopy(ExpectedNonInitial),
 OptionalNonInitial(OptionalNonInitial) {}
 
   // This method is used by DirectoryWatcher.
@@ -181,6 +183,26 @@ struct VerifyingConsumer {
   }
 
   void printUnmetExpectations(llvm::raw_ostream ) {
+// If there was any issue, print the expected state
+if (
+  !ExpectedInitial.empty()
+  ||
+  !ExpectedNonInitial.empty()
+  ||
+  !UnexpectedInitial.empty()
+  ||
+  !UnexpectedNonInitial.empty()
+) {
+  OS << "Expected initial events: \n";
+  for (const auto  : ExpectedInitialCopy) {
+OS << eventKindToString(E.Kind) << " " << E.Filename << "\n";
+  }
+  OS << "Expected non-initial events: \n";
+  for (const auto  : ExpectedNonInitialCopy) {
+OS << eventKindToString(E.Kind) << " " << E.Filename << "\n";
+  }
+}
+
 if (!ExpectedInitial.empty()) {
   OS << "Expected but not seen initial events: \n";
   for (const auto  : ExpectedInitial) {
@@ -218,6 +240,7 @@ void checkEventualResultWithTimeout(Veri
   EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
+  std::unique_lock L(TestConsumer.Mtx);
   EXPECT_TRUE(TestConsumer.result().hasValue());
   if (TestConsumer.result().hasValue()) {
 EXPECT_TRUE(*TestConsumer.result());


___
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-12 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Oh, btw, any reason these have to be passive segments? Why can't we just make 
them active segments and let the VM initialize them for us?


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] D64675: WIP: Disable optimization in emitStoresForConstant

2019-07-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D64675#1584016 , @jfb wrote:

> I would keep single stores because it's pretty silly codegen to copy from a 
> global for that.
>
> I would also verify that `-O0` isn't affected too badly by this change.


I will. And maybe I'll measure compilation time as well.

So far I tried -O3 and -Os.
Also I tried Chromium arm, arm64, x86_64. No regression in binary size without 
autoinit, with zero or pattern init.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64675



___
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-12 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

If there's any chance this TLS ABI could be useful for WASI (I don't know if 
there's been any WASI work on threads yet, but it seems like there's no reason 
it couldn't be), then we should start a doc in tool-conventions for it. If not 
then we should get it behind the emscripten OS in LLVM. (and document it 
anyway; either in tool-conventions or somewhere in the emscripten site).


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] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-12 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64610



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


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-12 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209644.
Nathan-Huckleberry added a comment.

- Add warning-free test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-uninitialized-statement-expression.c


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+  int i = ({
+init();
+i;
+  });
+}
+
+void foo_bad(void) {
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used 
within its own initialization}}
+init();
+i;
+  });
+}
+
+struct widget {
+  int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+  struct widget my_widget = ({
+init2(_widget);
+my_widget;
+  });
+}
+
+void bar_bad(void) {
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is 
uninitialized when used within its own initialization}}
+int x = my_widget.x; //FIXME: There should be an uninitialized 
warning here
+init2(_widget);
+my_widget;
+  });
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a; // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget *a = ({
+init2(a); // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,11 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() &&
+dyn_cast_or_null(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+  int i = ({
+init();
+i;
+  });
+}
+
+void foo_bad(void) {
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+init();
+i;
+  });
+}
+
+struct widget {
+  int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+  struct widget my_widget = ({
+init2(_widget);
+my_widget;
+  });
+}
+
+void bar_bad(void) {
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+int x = my_widget.x; //FIXME: There should be an uninitialized warning here
+init2(_widget);
+my_widget;
+  });
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget *a = ({
+init2(a); // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,11 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() &&
+dyn_cast_or_null(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64676: Support __seg_fs and __seg_gs on x86

2019-07-12 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 209645.
jfb added a comment.

- Fix test order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64676

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/Preprocessor/x86_seg_fs_gs.c


Index: clang/test/Preprocessor/x86_seg_fs_gs.c
===
--- /dev/null
+++ clang/test/Preprocessor/x86_seg_fs_gs.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - %s | FileCheck 
-match-full-lines %s
+// RUN: %clang -target x86_64-unknown-unknown -x c -E -dM -o - %s | FileCheck 
-match-full-lines %s
+
+// CHECK: #define __SEG_FS 1
+// CHECK: #define __SEG_GS 1
+// CHECK: #define __seg_fs __attribute__((address_space(257)))
+// CHECK: #define __seg_gs __attribute__((address_space(256)))
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -917,6 +917,11 @@
 DefineStd(Builder, "i386", Opts);
   }
 
+  Builder.defineMacro("__SEG_GS");
+  Builder.defineMacro("__SEG_FS");
+  Builder.defineMacro("__seg_gs", "__attribute__((address_space(256)))");
+  Builder.defineMacro("__seg_fs", "__attribute__((address_space(257)))");
+
   // Subtarget options.
   // FIXME: We are hard-coding the tune parameters based on the CPU, but they
   // truly should be based on -mtune options.
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2467,6 +2467,10 @@
   movl%gs:(%eax), %eax
   ret
 
+You can also use the GCC compatibility macros ``__seg_fs`` and ``__seg_gs`` for
+the same purpose. The preprocessor symbols ``__SEG_FS`` and ``__SEG_GS``
+indicate their support.
+
 PowerPC Language Extensions
 --
 


Index: clang/test/Preprocessor/x86_seg_fs_gs.c
===
--- /dev/null
+++ clang/test/Preprocessor/x86_seg_fs_gs.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - %s | FileCheck -match-full-lines %s
+// RUN: %clang -target x86_64-unknown-unknown -x c -E -dM -o - %s | FileCheck -match-full-lines %s
+
+// CHECK: #define __SEG_FS 1
+// CHECK: #define __SEG_GS 1
+// CHECK: #define __seg_fs __attribute__((address_space(257)))
+// CHECK: #define __seg_gs __attribute__((address_space(256)))
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -917,6 +917,11 @@
 DefineStd(Builder, "i386", Opts);
   }
 
+  Builder.defineMacro("__SEG_GS");
+  Builder.defineMacro("__SEG_FS");
+  Builder.defineMacro("__seg_gs", "__attribute__((address_space(256)))");
+  Builder.defineMacro("__seg_fs", "__attribute__((address_space(257)))");
+
   // Subtarget options.
   // FIXME: We are hard-coding the tune parameters based on the CPU, but they
   // truly should be based on -mtune options.
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2467,6 +2467,10 @@
   movl%gs:(%eax), %eax
   ret
 
+You can also use the GCC compatibility macros ``__seg_fs`` and ``__seg_gs`` for
+the same purpose. The preprocessor symbols ``__SEG_FS`` and ``__SEG_GS``
+indicate their support.
+
 PowerPC Language Extensions
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for the patch. Minor nits looking for test cases that should have no 
warning (like the two examples provided in the bug).




Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:7
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used 
within its own initialization}}
+init();

Can you please add a case like `foo` without `z` in it (so that no warnings are 
expected, as in pr42604)? (You can keep both test cases, just looking for 1 
more, as the first case).



Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:20
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is 
uninitialized when used within its own initialization}}
+int x = my_widget.x;

Ditto about adding a clear case that should not warn.



Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:21
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is 
uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);

This needs a trailing comment like:
```
int x = my_widget.x; // fixme: we should probably warn about this case
```
and file a bug about it.  Doesn't need to be solved here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678



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


[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-12 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

Integer Set Library using retain-count based allocation which is not
modeled in MallocChecker.


Repository:
  rC Clang

https://reviews.llvm.org/D64680

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/retain-count-alloc.cpp

Index: clang/test/Analysis/retain-count-alloc.cpp
===
--- /dev/null
+++ clang/test/Analysis/retain-count-alloc.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix.Malloc \
+// RUN:  -verify %s
+
+// expected-no-diagnostics: We do not model Integer Set Library's retain-count
+//  based allocation.
+
+#define __isl_take
+#define __isl_keep
+
+struct Object { int Ref; };
+void free(void *);
+
+Object *copyObj(__isl_keep Object *O) {
+  O->Ref++;
+  return O;
+}
+
+void freeObj(__isl_take Object *O) {
+  if (--O->Ref > 0)
+return;
+
+  free(O);
+}
+
+void useAfterFree(__isl_take Object *A) {
+  if (!A)
+return;
+
+  Object *B = copyObj(A);
+  freeObj(B);
+
+  A->Ref = 13;
+  // no-warning: 'Use of memory after it is freed' was here.
+}
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/ParentMap.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -41,6 +42,7 @@
 // Used to check correspondence between allocators and deallocators.
 enum AllocationFamily {
   AF_None,
+  AF_NotModeled,
   AF_Malloc,
   AF_CXXNew,
   AF_CXXNewArray,
@@ -50,19 +52,22 @@
 };
 
 class RefState {
-  enum Kind { // Reference to allocated memory.
-  Allocated,
-  // Reference to zero-allocated memory.
-  AllocatedOfSizeZero,
-  // Reference to released/freed memory.
-  Released,
-  // The responsibility for freeing resources has transferred from
-  // this reference. A relinquished symbol should not be freed.
-  Relinquished,
-  // We are no longer guaranteed to have observed all manipulations
-  // of this pointer/memory. For example, it could have been
-  // passed as a parameter to an opaque function.
-  Escaped
+  enum Kind {
+// If this checker does not model the allocation.
+DoNothing,
+// Reference to allocated memory.
+Allocated,
+// Reference to zero-allocated memory.
+AllocatedOfSizeZero,
+// Reference to released/freed memory.
+Released,
+// The responsibility for freeing resources has transferred from
+// this reference. A relinquished symbol should not be freed.
+Relinquished,
+// We are no longer guaranteed to have observed all manipulations
+// of this pointer/memory. For example, it could have been
+// passed as a parameter to an opaque function.
+Escaped
   };
 
   const Stmt *S;
@@ -75,6 +80,7 @@
 assert(family != AF_None);
   }
 public:
+  bool isDoNothing() const { return K == DoNothing; }
   bool isAllocated() const { return K == Allocated; }
   bool isAllocatedOfSizeZero() const { return K == AllocatedOfSizeZero; }
   bool isReleased() const { return K == Released; }
@@ -105,6 +111,9 @@
   static RefState getEscaped(const RefState *RS) {
 return RefState(Escaped, RS->getStmt(), RS->getAllocationFamily());
   }
+  static RefState getDoNothing(const Stmt *S) {
+return RefState(DoNothing, S, AF_NotModeled);
+  }
 
   void Profile(llvm::FoldingSetNodeID ) const {
 ID.AddInteger(K);
@@ -115,6 +124,7 @@
   void dump(raw_ostream ) const {
 switch (static_cast(K)) {
 #define CASE(ID) case ID: OS << #ID; break;
+CASE(DoNothing)
 CASE(Allocated)
 CASE(AllocatedOfSizeZero)
 CASE(Released)
@@ -359,6 +369,9 @@
   /// Check if the memory associated with this symbol was released.
   bool isReleased(SymbolRef Sym, CheckerContext ) const;
 
+  /// Check whether we do not model the memory allocation.
+  bool isNotModeled(const CallExpr *CE, CheckerContext ) const;
+
   bool checkUseAfterFree(SymbolRef Sym, CheckerContext , const Stmt *S) const;
 
   void checkUseZeroAllocated(SymbolRef Sym, CheckerContext ,
@@ -822,13 +835,16 @@
 }
 
 void MallocChecker::checkPostStmt(const CallExpr *CE, CheckerContext ) const {
-  if (C.wasInlined)
-return;
-
   const FunctionDecl *FD = C.getCalleeDecl(CE);
   if (!FD)
 

[PATCH] D64655: [Clang][Driver] don't error for unsupported as options for -no-integrated-as

2019-07-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Sorry, I missed this thread (and the other one) yesterday. Thanks for sorting 
out my mess; I'll think about what I want to do for the reland.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64655



___
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-12 Thread Nico Weber via cfe-commits
Looks like you didn't add UNSUPPORTED and went for the right fix
immediately in https://reviews.llvm.org/D64587. Thanks for taking care of
this!

On Thu, Jul 11, 2019 at 4:04 PM Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> 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=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=365723=365724=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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365975 - Re-land [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from parsed commands.

2019-07-12 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Jul 12 16:38:31 2019
New Revision: 365975

URL: http://llvm.org/viewvc/llvm-project?rev=365975=rev
Log:
Re-land [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from 
parsed commands.

Use //net/dir like other test cases for windows compatibility

Modified:
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=365975=365974=365975=diff
==
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp Fri Jul 12 16:38:31 2019
@@ -256,15 +256,57 @@ JSONCompilationDatabase::getAllCompileCo
   return Commands;
 }
 
+static llvm::StringRef stripExecutableExtension(llvm::StringRef Name) {
+  Name.consume_back(".exe");
+  return Name;
+}
+
+// There are compiler-wrappers (ccache, distcc, gomacc) that take the "real"
+// compiler as an argument, e.g. distcc gcc -O3 foo.c.
+// These end up in compile_commands.json when people set CC="distcc gcc".
+// Clang's driver doesn't understand this, so we need to unwrap.
+static bool unwrapCommand(std::vector ) {
+  if (Args.size() < 2)
+return false;
+  StringRef Wrapper =
+  stripExecutableExtension(llvm::sys::path::filename(Args.front()));
+  if (Wrapper == "distcc" || Wrapper == "gomacc" || Wrapper == "ccache") {
+// Most of these wrappers support being invoked 3 ways:
+// `distcc g++ file.c` This is the mode we're trying to match.
+// We need to drop `distcc`.
+// `distcc file.c` This acts like compiler is cc or similar.
+// Clang's driver can handle this, no change needed.
+// `g++ file.c`g++ is a symlink to distcc.
+// We don't even notice this case, and all is well.
+//
+// We need to distinguish between the first and second case.
+// The wrappers themselves don't take flags, so Args[1] is a compiler flag,
+// an input file, or a compiler. Inputs have extensions, compilers don't.
+bool HasCompiler =
+(Args[1][0] != '-') &&
+!llvm::sys::path::has_extension(stripExecutableExtension(Args[1]));
+if (HasCompiler) {
+  Args.erase(Args.begin());
+  return true;
+}
+// If !HasCompiler, wrappers act like GCC. Fine: so do we.
+  }
+  return false;
+}
+
 static std::vector
 nodeToCommandLine(JSONCommandLineSyntax Syntax,
   const std::vector ) {
   SmallString<1024> Storage;
-  if (Nodes.size() == 1)
-return unescapeCommandLine(Syntax, Nodes[0]->getValue(Storage));
   std::vector Arguments;
-  for (const auto *Node : Nodes)
-Arguments.push_back(Node->getValue(Storage));
+  if (Nodes.size() == 1)
+Arguments = unescapeCommandLine(Syntax, Nodes[0]->getValue(Storage));
+  else
+for (const auto *Node : Nodes)
+  Arguments.push_back(Node->getValue(Storage));
+  // There may be multiple wrappers: using distcc and ccache together is 
common.
+  while (unwrapCommand(Arguments))
+;
   return Arguments;
 }
 

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=365975=365974=365975=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Fri Jul 12 16:38:31 
2019
@@ -370,6 +370,33 @@ TEST(findCompileArgsInJsonDatabase, Find
   EXPECT_EQ("command4", FoundCommand.CommandLine[0]) << ErrorMessage;
 }
 
+TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) {
+  StringRef Directory("//net/dir");
+  StringRef FileName("//net/dir/filename");
+  std::vector> Cases = {
+  {"distcc gcc foo.c", "gcc foo.c"},
+  {"gomacc clang++ foo.c", "clang++ foo.c"},
+  {"ccache gcc foo.c", "gcc foo.c"},
+  {"ccache.exe gcc foo.c", "gcc foo.c"},
+  {"ccache g++.exe foo.c", "g++.exe foo.c"},
+  {"ccache distcc gcc foo.c", "gcc foo.c"},
+
+  {"distcc foo.c", "distcc foo.c"},
+  {"distcc -I/foo/bar foo.c", "distcc -I/foo/bar foo.c"},
+  };
+  std::string ErrorMessage;
+
+  for (const auto  : Cases) {
+std::string DB =
+R"([{"directory":"//net/dir", "file":"//net/dir/foo.c", "command":")" +
+Case.first + "\"}]";
+CompileCommand FoundCommand =
+findCompileArgsInJsonDatabase("//net/dir/foo.c", DB, ErrorMessage);
+EXPECT_EQ(Case.second, llvm::join(FoundCommand.CommandLine, " "))
+<< Case.first;
+  }
+}
+
 static std::vector unescapeJsonCommandLine(StringRef Command) {
   std::string JsonDatabase =
 ("[{\"directory\":\"//net/root\", \"file\":\"test\", \"command\": \"" +



[PATCH] D64675: WIP: Disable optimization in emitStoresForConstant

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

I would keep single stores because it's pretty silly codegen to copy from a 
global for that.

I would also verify that `-O0` isn't affected too badly by this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64675



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


[PATCH] D64675: WIP: Disable optimization in emitStoresForConstant

2019-07-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 209638.
vitalybuka added a comment.

Remove single store


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64675

Files:
  clang/lib/CodeGen/CGDecl.cpp


Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1153,72 +1153,8 @@
   if (!ConstantSize)
 return;
 
-  bool canDoSingleStore = Ty->isIntOrIntVectorTy() ||
-  Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy();
-  if (canDoSingleStore) {
-Builder.CreateStore(constant, Loc, isVolatile);
-return;
-  }
-
   auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize);
 
-  // If the initializer is all or mostly the same, codegen with bzero / memset
-  // then do a few stores afterward.
-  if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal,
- isVolatile);
-
-bool valueAlreadyCorrect =
-constant->isNullValue() || isa(constant);
-if (!valueAlreadyCorrect) {
-  Loc = Builder.CreateBitCast(Loc, 
Ty->getPointerTo(Loc.getAddressSpace()));
-  emitStoresForInitAfterBZero(CGM, constant, Loc, isVolatile, Builder);
-}
-return;
-  }
-
-  // If the initializer is a repeated byte pattern, use memset.
-  llvm::Value *Pattern =
-  shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
-  if (Pattern) {
-uint64_t Value = 0x00;
-if (!isa(Pattern)) {
-  const llvm::APInt  = cast(Pattern)->getValue();
-  assert(AP.getBitWidth() <= 8);
-  Value = AP.getLimitedValue();
-}
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), 
SizeVal,
- isVolatile);
-return;
-  }
-
-  // If the initializer is small, use a handful of stores.
-  if (shouldSplitConstantStore(CGM, ConstantSize)) {
-if (auto *STy = dyn_cast(Ty)) {
-  // FIXME: handle the case when STy != Loc.getElementType().
-  if (STy == Loc.getElementType()) {
-for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-  Address EltPtr = Builder.CreateStructGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)));
-}
-return;
-  }
-} else if (auto *ATy = dyn_cast(Ty)) {
-  // FIXME: handle the case when ATy != Loc.getElementType().
-  if (ATy == Loc.getElementType()) {
-for (unsigned i = 0; i != ATy->getNumElements(); i++) {
-  Address EltPtr = Builder.CreateConstArrayGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)));
-}
-return;
-  }
-}
-  }
-
   // Copy from a global.
   Builder.CreateMemCpy(Loc,
createUnnamedGlobalForMemcpyFrom(


Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1153,72 +1153,8 @@
   if (!ConstantSize)
 return;
 
-  bool canDoSingleStore = Ty->isIntOrIntVectorTy() ||
-  Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy();
-  if (canDoSingleStore) {
-Builder.CreateStore(constant, Loc, isVolatile);
-return;
-  }
-
   auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize);
 
-  // If the initializer is all or mostly the same, codegen with bzero / memset
-  // then do a few stores afterward.
-  if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal,
- isVolatile);
-
-bool valueAlreadyCorrect =
-constant->isNullValue() || isa(constant);
-if (!valueAlreadyCorrect) {
-  Loc = Builder.CreateBitCast(Loc, Ty->getPointerTo(Loc.getAddressSpace()));
-  emitStoresForInitAfterBZero(CGM, constant, Loc, isVolatile, Builder);
-}
-return;
-  }
-
-  // If the initializer is a repeated byte pattern, use memset.
-  llvm::Value *Pattern =
-  shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
-  if (Pattern) {
-uint64_t Value = 0x00;
-if (!isa(Pattern)) {
-  const llvm::APInt  = cast(Pattern)->getValue();
-  assert(AP.getBitWidth() <= 8);
-  Value = AP.getLimitedValue();
-}
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), SizeVal,
- isVolatile);
-return;
-  }
-
-  // If the initializer is small, use a handful of stores.
-  if (shouldSplitConstantStore(CGM, ConstantSize)) {
-if (auto *STy = dyn_cast(Ty)) {
-  // FIXME: handle the case when STy != 

[PATCH] D64675: WIP: Disable optimization in emitStoresForConstant

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

That's interesting. If `MemCpyOpt` has picked up the slack and clang can be 
simpler here, then let's remove clang's "intelligence". I do want to make sure 
that it handles all the cases this handles though, and does indeed generate 
great code on both x86-64 and ARM64. I think we need to create a list of test 
cases and make sure `MemCpyOpt` covers them. Further, I'd also like to check 
that performance is also still the same (not just code size).

I would still keep scalar stores (as you did above), and maybe update 
`canDoSingleStore` to also handle stores to a struct that only has a single 
element.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64675



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


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-12 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209637.
Nathan-Huckleberry added a comment.

- Fixed style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-uninitialized-statement-expression.c


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used 
within its own initialization}}
+init();
+i;
+  });
+}
+
+struct widget {
+  int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is 
uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);
+my_widget;
+  });
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a; // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget *a = ({
+init2(a); // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,11 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() &&
+dyn_cast_or_null(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+init();
+i;
+  });
+}
+
+struct widget {
+  int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);
+my_widget;
+  });
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget *a = ({
+init2(a); // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,11 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() &&
+dyn_cast_or_null(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64671: New clang-tidy check: misc-init-local-variables

2019-07-12 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:8
+//===--===//
+#include "InitLocalVariablesCheck.h"
+#include "clang/AST/ASTContext.h"

Please separate header from include files with empty line.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:31
+
+  auto varName = MatchedDecl->getName();
+  if(varName.empty() || varName.front() == '_') {

Please don't use auto when type could not be deduced from same statement.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:41
+  if(typePtr->isIntegerType()) {
+replacement = "=0";
+  } else if(typePtr->isFloatingType()) {

lebedev.ri wrote:
> should be `var = ;`
May be spaces should be created around =? Same in other places.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:56
+diag(MatchedDecl->getLocation(), "insert initial value", 
DiagnosticIDs::Note)
+  << 
FixItHint::CreateInsertion(MatchedDecl->getLocation().getLocWithOffset(varName.size()),
 replacement);
+  }

Please run Clang-format.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.h:28
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+};

Unnecessary empty line.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst:6
+
+Finds local variables that are declared without an initial
+value. These may lead to unexpected behaviour if there is a code path

Please synchronize first statement with description in Release Notes.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst:31
+   void function() {
+ int x=0;
+ char *txt=nullptr;

Spaces around =. Same in other places.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D64671



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


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-12 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209636.
Nathan-Huckleberry added a comment.

- Adding fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-uninitialized-statement-expression.c


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int*);
+
+void foo(void) {
+int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when 
used within its own initialization}}
+init();
+i;
+});
+}
+
+struct widget {
+int x, y;
+};
+void init2(struct widget*);
+
+void bar(void) {
+struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' 
is uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);
+my_widget;
+});
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a;  // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget* a = ({
+init2(a);  // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,10 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() && 
dyn_cast_or_null(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int*);
+
+void foo(void) {
+int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+init();
+i;
+});
+}
+
+struct widget {
+int x, y;
+};
+void init2(struct widget*);
+
+void bar(void) {
+struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);
+my_widget;
+});
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a;  // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget* a = ({
+init2(a);  // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,10 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() && dyn_cast_or_null(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-12 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Do not automatically self references of structs in statement expression
as warnings. Instead wait for uninitialized cfg analysis.
https://bugs.llvm.org/show_bug.cgi?id=42604


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64678

Files:
  clang/test/Sema/warn-uninitialized-statement-expression.c


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int*);
+
+void foo(void) {
+int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when 
used within its own initialization}}
+init();
+i;
+});
+}
+
+struct widget {
+int x, y;
+};
+void init2(struct widget*);
+
+void bar(void) {
+struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' 
is uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);
+my_widget;
+});
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a;  // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget* a = ({
+init2(a);  // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+a;
+  });
+}


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int*);
+
+void foo(void) {
+int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+init();
+i;
+});
+}
+
+struct widget {
+int x, y;
+};
+void init2(struct widget*);
+
+void bar(void) {
+struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);
+my_widget;
+});
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a;  // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget* a = ({
+init2(a);  // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+a;
+  });
+}
___
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-12 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209634.
Nathan-Huckleberry added a comment.

- Forgot to fix list.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454

Files:
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.CallAndMessage.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.DivideZero.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.DynamicTypePropagation.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.NonNullParamChecker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.NullDereference.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.StackAddressEscape.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.UndefinedBinaryOperatorResult.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.VLASize.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.ArraySubscript.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.Assign.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.Branch.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.CapturedBlockVariable.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.UndefReturn.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.InnerPointer.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.Move.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.NewDelete.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.NewDeleteLeaks.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-deadcode.DeadStores.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullPassedToNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullReturnedFromNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullableDereferenced.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullablePassedToNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullableReturnedFromNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.cplusplus.UninitializedObject.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.cplusplus.VirtualCall.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.mpi.MPI-Checker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.osx.OSObjectCStyleCast.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.performance.GCDAntipattern.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.performance.Padding.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.portability.UnixAPI.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.API.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.MIG.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.NumberObjectConversion.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.OSObjectRetainCount.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.ObjCProperty.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.SecKeychainAPI.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.AtSync.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.AutoreleaseWrite.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.ClassRelease.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.Dealloc.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.IncompatibleMethodTypes.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.Loops.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.MissingSuperCall.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NSAutoreleasePool.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NSError.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NilArg.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NonNilReturnValue.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.ObjCGenerics.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.RetainCount.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.SelfInit.rst
  

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

2019-07-12 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209632.
Nathan-Huckleberry added a comment.

- Added script for generation of docs based off Checkers.td
- Updated to match newly standardized anchor urls
- Add auto redirect and remove alpha checkers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454

Files:
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.CallAndMessage.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.DivideZero.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.DynamicTypePropagation.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.NonNullParamChecker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.NullDereference.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.StackAddressEscape.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.UndefinedBinaryOperatorResult.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.VLASize.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.ArraySubscript.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.Assign.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.Branch.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.CapturedBlockVariable.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-core.uninitialized.UndefReturn.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.InnerPointer.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.Move.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.NewDelete.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-cplusplus.NewDeleteLeaks.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-deadcode.DeadStores.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullPassedToNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullReturnedFromNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullableDereferenced.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullablePassedToNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-nullability.NullableReturnedFromNonnull.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.cplusplus.UninitializedObject.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.cplusplus.VirtualCall.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.mpi.MPI-Checker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.osx.OSObjectCStyleCast.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.performance.GCDAntipattern.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.performance.Padding.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-optin.portability.UnixAPI.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.API.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.MIG.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.NumberObjectConversion.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.OSObjectRetainCount.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.ObjCProperty.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.SecKeychainAPI.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.AtSync.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.AutoreleaseWrite.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.ClassRelease.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.Dealloc.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.IncompatibleMethodTypes.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.Loops.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.MissingSuperCall.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NSAutoreleasePool.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NSError.rst
  clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NilArg.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.NonNilReturnValue.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.ObjCGenerics.rst
  
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer-osx.cocoa.RetainCount.rst
  

[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.

2019-07-12 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D63753



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


[PATCH] D64656: Ensure placeholder instruction for cleanup is created

2019-07-12 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656



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


[PATCH] D64676: Support __seg_fs and __seg_gs on x86

2019-07-12 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
Herald added subscribers: cfe-commits, dexonsmith, jkorous.
Herald added a project: clang.

GCC supports named address spaces macros:

  https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html

clang does as well with address spaces:

  
https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments

Add the __seg_fs and __seg_gs macros for compatibility with GCC.

rdar://problem/52944935


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64676

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/Preprocessor/x86_seg_fs_gs.c


Index: clang/test/Preprocessor/x86_seg_fs_gs.c
===
--- /dev/null
+++ clang/test/Preprocessor/x86_seg_fs_gs.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - %s | FileCheck 
-match-full-lines %s
+// RUN: %clang -target x86_64-unknown-unknown -x c -E -dM -o - %s | FileCheck 
-match-full-lines %s
+
+// CHECK: #define __SEG_GS 1
+// CHECK: #define __SEG_FS 1
+// CHECK: #define __seg_gs __attribute__((address_space(256)))
+// CHECK: #define __seg_fs __attribute__((address_space(257)))
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -917,6 +917,11 @@
 DefineStd(Builder, "i386", Opts);
   }
 
+  Builder.defineMacro("__SEG_GS");
+  Builder.defineMacro("__SEG_FS");
+  Builder.defineMacro("__seg_gs", "__attribute__((address_space(256)))");
+  Builder.defineMacro("__seg_fs", "__attribute__((address_space(257)))");
+
   // Subtarget options.
   // FIXME: We are hard-coding the tune parameters based on the CPU, but they
   // truly should be based on -mtune options.
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2467,6 +2467,10 @@
   movl%gs:(%eax), %eax
   ret
 
+You can also use the GCC compatibility macros ``__seg_fs`` and ``__seg_gs`` for
+the same purpose. The preprocessor symbols ``__SEG_FS`` and ``__SEG_GS``
+indicate their support.
+
 PowerPC Language Extensions
 --
 


Index: clang/test/Preprocessor/x86_seg_fs_gs.c
===
--- /dev/null
+++ clang/test/Preprocessor/x86_seg_fs_gs.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - %s | FileCheck -match-full-lines %s
+// RUN: %clang -target x86_64-unknown-unknown -x c -E -dM -o - %s | FileCheck -match-full-lines %s
+
+// CHECK: #define __SEG_GS 1
+// CHECK: #define __SEG_FS 1
+// CHECK: #define __seg_gs __attribute__((address_space(256)))
+// CHECK: #define __seg_fs __attribute__((address_space(257)))
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -917,6 +917,11 @@
 DefineStd(Builder, "i386", Opts);
   }
 
+  Builder.defineMacro("__SEG_GS");
+  Builder.defineMacro("__SEG_FS");
+  Builder.defineMacro("__seg_gs", "__attribute__((address_space(256)))");
+  Builder.defineMacro("__seg_fs", "__attribute__((address_space(257)))");
+
   // Subtarget options.
   // FIXME: We are hard-coding the tune parameters based on the CPU, but they
   // truly should be based on -mtune options.
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2467,6 +2467,10 @@
   movl%gs:(%eax), %eax
   ret
 
+You can also use the GCC compatibility macros ``__seg_fs`` and ``__seg_gs`` for
+the same purpose. The preprocessor symbols ``__SEG_FS`` and ``__SEG_GS``
+indicate their support.
+
 PowerPC Language Extensions
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64656: Ensure placeholder instruction for cleanup is created

2019-07-12 Thread Øystein Dale via Phabricator via cfe-commits
oydale updated this revision to Diff 209627.
oydale added a comment.

Minimized test case further, removed misleading CHECK from comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp


Index: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions %s
+// PR40771: check that this input does not crash or assert
+
+struct Q { Q(); };
+struct R { R(Q); ~R(); };
+struct S { S(Q); ~S(); };
+struct T : R, S {};
+
+Q q;
+T t { R{q}, S{q} };
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -1495,6 +1495,13 @@
   // initializers throws an exception.
   SmallVector cleanups;
   llvm::Instruction *cleanupDominator = nullptr;
+  auto addCleanup = [&](const EHScopeStack::stable_iterator ) {
+cleanups.push_back(cleanup);
+if (!cleanupDominator) // create placeholder once needed
+  cleanupDominator = CGF.Builder.CreateAlignedLoad(
+  CGF.Int8Ty, llvm::Constant::getNullValue(CGF.Int8PtrTy),
+  CharUnits::One());
+  };
 
   unsigned curInitIndex = 0;
 
@@ -1519,7 +1526,7 @@
   if (QualType::DestructionKind dtorKind =
   Base.getType().isDestructedType()) {
 CGF.pushDestroy(dtorKind, V, Base.getType());
-cleanups.push_back(CGF.EHStack.stable_begin());
+addCleanup(CGF.EHStack.stable_begin());
   }
 }
   }
@@ -1596,15 +1603,9 @@
   = field->getType().isDestructedType()) {
   assert(LV.isSimple());
   if (CGF.needsEHCleanup(dtorKind)) {
-if (!cleanupDominator)
-  cleanupDominator = CGF.Builder.CreateAlignedLoad(
-  CGF.Int8Ty,
-  llvm::Constant::getNullValue(CGF.Int8PtrTy),
-  CharUnits::One()); // placeholder
-
 CGF.pushDestroy(EHCleanup, LV.getAddress(), field->getType(),
 CGF.getDestroyer(dtorKind), false);
-cleanups.push_back(CGF.EHStack.stable_begin());
+addCleanup(CGF.EHStack.stable_begin());
 pushedCleanup = true;
   }
 }
@@ -1620,6 +1621,8 @@
 
   // Deactivate all the partial cleanups in reverse order, which
   // generally means popping them.
+  assert((cleanupDominator || cleanups.empty()) &&
+ "Missing cleanupDominator before deactivating cleanup blocks");
   for (unsigned i = cleanups.size(); i != 0; --i)
 CGF.DeactivateCleanupBlock(cleanups[i-1], cleanupDominator);
 


Index: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions %s
+// PR40771: check that this input does not crash or assert
+
+struct Q { Q(); };
+struct R { R(Q); ~R(); };
+struct S { S(Q); ~S(); };
+struct T : R, S {};
+
+Q q;
+T t { R{q}, S{q} };
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -1495,6 +1495,13 @@
   // initializers throws an exception.
   SmallVector cleanups;
   llvm::Instruction *cleanupDominator = nullptr;
+  auto addCleanup = [&](const EHScopeStack::stable_iterator ) {
+cleanups.push_back(cleanup);
+if (!cleanupDominator) // create placeholder once needed
+  cleanupDominator = CGF.Builder.CreateAlignedLoad(
+  CGF.Int8Ty, llvm::Constant::getNullValue(CGF.Int8PtrTy),
+  CharUnits::One());
+  };
 
   unsigned curInitIndex = 0;
 
@@ -1519,7 +1526,7 @@
   if (QualType::DestructionKind dtorKind =
   Base.getType().isDestructedType()) {
 CGF.pushDestroy(dtorKind, V, Base.getType());
-cleanups.push_back(CGF.EHStack.stable_begin());
+addCleanup(CGF.EHStack.stable_begin());
   }
 }
   }
@@ -1596,15 +1603,9 @@
   = field->getType().isDestructedType()) {
   assert(LV.isSimple());
   if (CGF.needsEHCleanup(dtorKind)) {
-if (!cleanupDominator)
-  cleanupDominator = CGF.Builder.CreateAlignedLoad(
-  CGF.Int8Ty,
-  llvm::Constant::getNullValue(CGF.Int8PtrTy),
-  CharUnits::One()); // placeholder
-
 CGF.pushDestroy(EHCleanup, LV.getAddress(), field->getType(),
 CGF.getDestroyer(dtorKind), false);
-cleanups.push_back(CGF.EHStack.stable_begin());
+addCleanup(CGF.EHStack.stable_begin());
   

[PATCH] D64675: WIP: Disable optimization in emitStoresForConstant

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

Not rely a review, but removing this code I see slight improvements in
binary size on CTMark. Looks like with "ptr" patches MemCpyOptPass is
capable to handle this.

WDYT?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64675

Files:
  clang/lib/CodeGen/CGDecl.cpp

Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1162,62 +1162,62 @@
 
   auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize);
 
-  // If the initializer is all or mostly the same, codegen with bzero / memset
-  // then do a few stores afterward.
-  if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal,
- isVolatile);
-
-bool valueAlreadyCorrect =
-constant->isNullValue() || isa(constant);
-if (!valueAlreadyCorrect) {
-  Loc = Builder.CreateBitCast(Loc, Ty->getPointerTo(Loc.getAddressSpace()));
-  emitStoresForInitAfterBZero(CGM, constant, Loc, isVolatile, Builder);
-}
-return;
-  }
-
-  // If the initializer is a repeated byte pattern, use memset.
-  llvm::Value *Pattern =
-  shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
-  if (Pattern) {
-uint64_t Value = 0x00;
-if (!isa(Pattern)) {
-  const llvm::APInt  = cast(Pattern)->getValue();
-  assert(AP.getBitWidth() <= 8);
-  Value = AP.getLimitedValue();
-}
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), SizeVal,
- isVolatile);
-return;
-  }
+  // // If the initializer is all or mostly the same, codegen with bzero / memset
+  // // then do a few stores afterward.
+  // if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
+  //   Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal,
+  //isVolatile);
+
+  //   bool valueAlreadyCorrect =
+  //   constant->isNullValue() || isa(constant);
+  //   if (!valueAlreadyCorrect) {
+  // Loc = Builder.CreateBitCast(Loc, Ty->getPointerTo(Loc.getAddressSpace()));
+  // emitStoresForInitAfterBZero(CGM, constant, Loc, isVolatile, Builder);
+  //   }
+  //   return;
+  // }
+
+  // // If the initializer is a repeated byte pattern, use memset.
+  // llvm::Value *Pattern =
+  // shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
+  // if (Pattern) {
+  //   uint64_t Value = 0x00;
+  //   if (!isa(Pattern)) {
+  // const llvm::APInt  = cast(Pattern)->getValue();
+  // assert(AP.getBitWidth() <= 8);
+  // Value = AP.getLimitedValue();
+  //   }
+  //   Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), SizeVal,
+  //isVolatile);
+  //   return;
+  // }
 
   // If the initializer is small, use a handful of stores.
-  if (shouldSplitConstantStore(CGM, ConstantSize)) {
-if (auto *STy = dyn_cast(Ty)) {
-  // FIXME: handle the case when STy != Loc.getElementType().
-  if (STy == Loc.getElementType()) {
-for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-  Address EltPtr = Builder.CreateStructGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)));
-}
-return;
-  }
-} else if (auto *ATy = dyn_cast(Ty)) {
-  // FIXME: handle the case when ATy != Loc.getElementType().
-  if (ATy == Loc.getElementType()) {
-for (unsigned i = 0; i != ATy->getNumElements(); i++) {
-  Address EltPtr = Builder.CreateConstArrayGEP(Loc, i);
-  emitStoresForConstant(
-  CGM, D, EltPtr, isVolatile, Builder,
-  cast(Builder.CreateExtractValue(constant, i)));
-}
-return;
-  }
-}
-  }
+  // if (shouldSplitConstantStore(CGM, ConstantSize)) {
+  //   if (auto *STy = dyn_cast(Ty)) {
+  // // FIXME: handle the case when STy != Loc.getElementType().
+  // if (STy == Loc.getElementType()) {
+  //   for (unsigned i = 0; i != constant->getNumOperands(); i++) {
+  // Address EltPtr = Builder.CreateStructGEP(Loc, i);
+  // emitStoresForConstant(
+  // CGM, D, EltPtr, isVolatile, Builder,
+  // cast(Builder.CreateExtractValue(constant, i)));
+  //   }
+  //   return;
+  // }
+  //   } else if (auto *ATy = dyn_cast(Ty)) {
+  // // FIXME: handle the case when ATy != Loc.getElementType().
+  // if (ATy == Loc.getElementType()) {
+  //   for (unsigned i = 0; i != ATy->getNumElements(); i++) {
+  // Address EltPtr = Builder.CreateConstArrayGEP(Loc, i);
+  // 

[PATCH] D64646: [OPENMP]Add support for analysis of if clauses.

2019-07-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great! Thank you for improving the tests even further.




Comment at: test/Analysis/cfg-openmp.cpp:58-67
 #pragma omp distribute simd
   for (int i = 0; i < 10; ++i)
 argc = x;
-// CHECK-NEXT:  27: x
-// CHECK-NEXT:  28: [B1.27] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  29: argc
-// CHECK-NEXT:  30: [B1.29] = [B1.28]
-// CHECK-NEXT:  31: #pragma omp for
+// CHECK-NEXT:  [[#FOR:]]: x
+// CHECK-NEXT:  [[#FOR+1]]: [B1.[[#FOR]]] (ImplicitCastExpr, LValueToRValue, 
int)
+// CHECK-NEXT:  [[#FOR+2]]: argc
+// CHECK-NEXT:  [[#FOR+3]]: [B1.[[#FOR+2]]] = [B1.[[#FOR+1]]]

I'm slowly updating my mental model of these CFGs. Just to confirm my 
understanding - tried the following example:

```lang=c++
int main(int argc, char **argv) {
  int x = 0;
#pragma omp for
  for (int i = 0; i < 10; ++i)
x += argv[i];
}
```

The CFG was as follows:

```
   1: 0
   2: int x = 0;
   3: x
   4: argv
   5: [B1.4] (ImplicitCastExpr, LValueToRValue, char **)
   6: i
   7: [B1.6] (ImplicitCastExpr, LValueToRValue, int)
   8: [B1.5][[B1.7]]
   9: [B1.8] (ImplicitCastExpr, LValueToRValue, char *)
  10: [B1.3] += [B1.9]
  11: #pragma omp for
for (int i = 0; i < 10; ++i)
[B1.10];
```

Do i understand correctly that `[B1.10]` aka `argv[0]` is going to act like an 
"argument" to the "outlined function" and then it's going to be re-used (as if 
it was a "local" "variable") on subsequent iterations of the loop (i.e., 
assigned values `argv[1]`, ..., `argv[9]`)? I.e., the "function" is going to be 
responsible for computing `argv[1]` and storing it in the "parameter variable" 
(`OMPCapturedExprDecl` which is a sub-class of `VarDecl`) that previously 
contained `argv[0]`, but it's not responsible for computing `argv[0]` itself, 
right?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64646



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


[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.

2019-07-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 209626.
ahatanak added a comment.

In Type.h, move method declarations down and mention that the predicates imply 
the associated basic non-triviality predicates.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63753

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Type.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenObjC/Inputs/strong_in_union.h
  test/CodeGenObjC/strong-in-c-struct.m
  test/PCH/non-trivial-c-union.m
  test/SemaObjC/arc-decls.m
  test/SemaObjC/non-trivial-c-union.m

Index: test/SemaObjC/non-trivial-c-union.m
===
--- /dev/null
+++ test/SemaObjC/non-trivial-c-union.m
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -fobjc-runtime-has-weak -verify %s
+
+typedef union { // expected-note 12 {{'U0' has subobjects that are non-trivial to default-initialize}} expected-note 36 {{'U0' has subobjects that are non-trivial to destruct}} expected-note 28 {{'U0' has subobjects that are non-trivial to copy}}
+  id f0; // expected-note 12 {{f0 has type '__strong id' that is non-trivial to default-initialize}} expected-note 36 {{f0 has type '__strong id' that is non-trivial to destruct}} expected-note 28 {{f0 has type '__strong id' that is non-trivial to copy}}
+  __weak id f1; // expected-note 12 {{f1 has type '__weak id' that is non-trivial to default-initialize}} expected-note 36 {{f1 has type '__weak id' that is non-trivial to destruct}} expected-note 28 {{f1 has type '__weak id' that is non-trivial to copy}}
+} U0;
+
+typedef struct {
+  U0 f0;
+  id f1;
+} S0;
+
+id g0;
+U0 ug0; // expected-error {{cannot default-initialize an object of type 'U0' since it is a union that is non-trivial to default-initialize}}
+U0 ug1 = { .f0 = 0 };
+S0 sg0; // expected-error {{cannot default-initialize an object of type 'S0' since it contains a union that is non-trivial to default-initialize}}
+S0 sg1 = { .f0 = {0}, .f1 = 0 };
+S0 sg2 = { .f1 = 0 }; // expected-error {{cannot default-initialize an object of type 'U0' since it is a union that is non-trivial to default-initialize}}
+
+U0 foo0(U0); // expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to copy}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to copy}}
+S0 foo1(S0); // expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to copy}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to copy}}
+
+@interface C
+-(U0)m0:(U0)arg; // expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to copy}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to copy}}
+-(S0)m1:(S0)arg; // expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to copy}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to copy}}
+@end
+
+void testBlockFunction(void) {
+  (void)^(U0 a){ return ug0; }; // expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to copy}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for 

[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.

2019-07-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 209622.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Improve comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63753

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Type.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenObjC/Inputs/strong_in_union.h
  test/CodeGenObjC/strong-in-c-struct.m
  test/PCH/non-trivial-c-union.m
  test/SemaObjC/arc-decls.m
  test/SemaObjC/non-trivial-c-union.m

Index: test/SemaObjC/non-trivial-c-union.m
===
--- /dev/null
+++ test/SemaObjC/non-trivial-c-union.m
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -fobjc-runtime-has-weak -verify %s
+
+typedef union { // expected-note 12 {{'U0' has subobjects that are non-trivial to default-initialize}} expected-note 36 {{'U0' has subobjects that are non-trivial to destruct}} expected-note 28 {{'U0' has subobjects that are non-trivial to copy}}
+  id f0; // expected-note 12 {{f0 has type '__strong id' that is non-trivial to default-initialize}} expected-note 36 {{f0 has type '__strong id' that is non-trivial to destruct}} expected-note 28 {{f0 has type '__strong id' that is non-trivial to copy}}
+  __weak id f1; // expected-note 12 {{f1 has type '__weak id' that is non-trivial to default-initialize}} expected-note 36 {{f1 has type '__weak id' that is non-trivial to destruct}} expected-note 28 {{f1 has type '__weak id' that is non-trivial to copy}}
+} U0;
+
+typedef struct {
+  U0 f0;
+  id f1;
+} S0;
+
+id g0;
+U0 ug0; // expected-error {{cannot default-initialize an object of type 'U0' since it is a union that is non-trivial to default-initialize}}
+U0 ug1 = { .f0 = 0 };
+S0 sg0; // expected-error {{cannot default-initialize an object of type 'S0' since it contains a union that is non-trivial to default-initialize}}
+S0 sg1 = { .f0 = {0}, .f1 = 0 };
+S0 sg2 = { .f1 = 0 }; // expected-error {{cannot default-initialize an object of type 'U0' since it is a union that is non-trivial to default-initialize}}
+
+U0 foo0(U0); // expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to copy}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to copy}}
+S0 foo1(S0); // expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to copy}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to copy}}
+
+@interface C
+-(U0)m0:(U0)arg; // expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to copy}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to copy}}
+-(S0)m1:(S0)arg; // expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for a function/method parameter since it contains a union that is non-trivial to copy}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to destruct}} expected-error {{cannot use type 'S0' for function/method return since it contains a union that is non-trivial to copy}}
+@end
+
+void testBlockFunction(void) {
+  (void)^(U0 a){ return ug0; }; // expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for a function/method parameter since it is a union that is non-trivial to copy}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to destruct}} expected-error {{cannot use type 'U0' for function/method return since it is a union that is non-trivial to 

r365969 - NFC: utils/perf-training: Python 3 compatibility for lit.cfg

2019-07-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jul 12 15:29:44 2019
New Revision: 365969

URL: http://llvm.org/viewvc/llvm-project?rev=365969=rev
Log:
NFC: utils/perf-training: Python 3 compatibility for lit.cfg

The output of subprocess.check_output is now bytes. We need to decode it.

Modified:
cfe/trunk/utils/perf-training/lit.cfg

Modified: cfe/trunk/utils/perf-training/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/lit.cfg?rev=365969=365968=365969=diff
==
--- cfe/trunk/utils/perf-training/lit.cfg (original)
+++ cfe/trunk/utils/perf-training/lit.cfg Fri Jul 12 15:29:44 2019
@@ -10,7 +10,7 @@ def getSysrootFlagsOnDarwin(config, lit_
 # default system root path.
 if 'darwin' in config.target_triple:
 try:
-out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
+out = subprocess.check_output(['xcrun', 
'--show-sdk-path']).strip().decode()
 res = 0
 except OSError:
 res = -1


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


r365968 - [DirectoryWatcher][NFC] Silence warnings in release build

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 15:25:17 2019
New Revision: 365968

URL: http://llvm.org/viewvc/llvm-project?rev=365968=rev
Log:
[DirectoryWatcher][NFC] Silence warnings in release build

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=365968=365967=365968=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Fri Jul 12 
15:25:17 2019
@@ -55,7 +55,10 @@ struct SemaphorePipe {
   };
 
   void signal() {
-ssize_t Result = llvm::sys::RetryAfterSignal(-1, write, FDWrite, "A", 1);
+#ifndef NDEBUG
+ssize_t Result =
+#endif
+llvm::sys::RetryAfterSignal(-1, write, FDWrite, "A", 1);
 assert(Result != -1);
   }
   ~SemaphorePipe() {

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=365968=365967=365968=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Fri Jul 12 
15:25:17 2019
@@ -38,12 +38,18 @@ struct DirectoryWatcherTestFixture {
 
   DirectoryWatcherTestFixture() {
 SmallString<128> pathBuf;
-std::error_code UniqDirRes = createUniqueDirectory("dirwatcher", pathBuf);
+#ifndef NDEBUG
+std::error_code UniqDirRes =
+#endif
+createUniqueDirectory("dirwatcher", pathBuf);
 assert(!UniqDirRes);
 TestRootDir = pathBuf.str();
 path::append(pathBuf, "watch");
 TestWatchedDir = pathBuf.str();
-std::error_code CreateDirRes = create_directory(TestWatchedDir, false);
+#ifndef NDEBUG
+std::error_code CreateDirRes =
+#endif
+create_directory(TestWatchedDir, false);
 assert(!CreateDirRes);
   }
 
@@ -415,8 +421,9 @@ TEST(DirectoryWatcherTest, ChangeMetadat
 const int FD = HopefullyTheFD.get();
 const TimePoint<> NewTimePt =
 std::chrono::system_clock::now() - std::chrono::minutes(1);
-
+#ifndef NDEBUG
 std::error_code setTimeRes =
+#endif
 llvm::sys::fs::setLastAccessAndModificationTime(FD, NewTimePt,
 NewTimePt);
 assert(!setTimeRes);


___
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-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3279
+def ObjCClampingBool : TypeAttr {
+  let Spellings = [Clang<"objc_clamping_bool">];
+  let Subjects = SubjectList<[TypedefName]>;

erik.pilkington wrote:
> aaron.ballman wrote:
> > Is there a desire for similar functionality for C's `_Bool` datatype, or 
> > other, custom datatypes (perhaps `BOOL` from the Win32 APIs)? It seems like 
> > this attribute could be generalized to apply to any typedef to an integral 
> > type.
> Sure, I guess there isn't anything Objective-C specific about this. The new 
> patches renames it to `clamping_integral_bool` (and permits it on any 
> integral type).
Given that "clamping" isn't exactly what's going on -- since `-1` becomes `1`, 
not `0` -- is there another word we can use here?


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

https://reviews.llvm.org/D64600



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


[PATCH] D64669: [clang-doc] Fix failing tests on Windows

2019-07-12 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365967: [clang-doc] Fix failing tests on Windows (authored 
by juliehockett, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64669?vs=209601=209617#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64669

Files:
  clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp


Index: clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -79,10 +79,11 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
   I.Members.emplace_back("int", "X/Y", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
- llvm::SmallString<128>("path/to"));
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -97,6 +98,10 @@
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToF;
+  llvm::sys::path::native("../../../path/to/F.html", PathToF);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("../int.html", PathToInt);
   std::string Expected = R"raw(
 
 class r
@@ -107,12 +112,14 @@
   
   
 Inherits from 
-F
+F
 , G
   
   Members
   
-private int X
+private int X
   
   Records
   
@@ -143,8 +150,10 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, "path/to");
-  I.Params.emplace_back("int", "path/to", "P");
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
+  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo);
+  I.Params.emplace_back("int", PathTo, "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
 
@@ -154,15 +163,21 @@
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToFloat;
+  llvm::sys::path::native("path/to/float.html", PathToFloat);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("path/to/int.html", PathToInt);
   std::string Expected = R"raw(
 
 
 
   f
   
-float
+float
  f(
-int
+int
  P)
   
   


Index: clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -79,10 +79,11 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
   I.Members.emplace_back("int", "X/Y", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
- llvm::SmallString<128>("path/to"));
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -97,6 +98,10 @@
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToF;
+  llvm::sys::path::native("../../../path/to/F.html", PathToF);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("../int.html", PathToInt);
   std::string Expected = R"raw(
 
 class r
@@ -107,12 +112,14 @@
   
   
 Inherits from 
-F
+F
 , G
   
   Members
   
-private int X
+private int X
   
   Records
   
@@ -143,8 +150,10 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, "path/to");
-  I.Params.emplace_back("int", "path/to", "P");
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
+  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo);
+  I.Params.emplace_back("int", PathTo, "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", 

[PATCH] D64671: New clang-tidy check: misc-init-local-variables

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

This certainly needs more tests: macros, `-x C`, ???




Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:26-29
+  if(!MatchedDecl->isLocalVarDecl())
+return;
+  if(MatchedDecl->hasInit())
+return;

Can make these proper `AST_MATCHER` and do this in `registerMatchers()`.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:32-35
+  if(varName.empty() || varName.front() == '_') {
+// Some standard library methods such as "be64toh" are implemented
+// as macros that internally use variable names
+// like __v. Do not touch those.

This feels brittle.




Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:41-48
+replacement = "=0";
+  } else if(typePtr->isFloatingType()) {
+replacement = "=(0.0/0.0)"; // NaN without needing #includes
+  } else if(typePtr->isPointerType()) {
+if(getLangOpts().CPlusPlus) {
+  replacement = "=nullptr";
+} else {

should be `var = ;`



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:43
+  } else if(typePtr->isFloatingType()) {
+replacement = "=(0.0/0.0)"; // NaN without needing #includes
+  } else if(typePtr->isPointerType()) {

I'm pretty sure there's simple utility function that can insert include.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D64671



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


[clang-tools-extra] r365967 - [clang-doc] Fix failing tests on Windows

2019-07-12 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri Jul 12 15:19:02 2019
New Revision: 365967

URL: http://llvm.org/viewvc/llvm-project?rev=365967=rev
Log:
[clang-doc] Fix failing tests on Windows

Tests on Windows were failing due to path separator differences.
'/' was being used as separator in the expected output, paths in expected
output are now changed to their native form before comparing them to the
actual output.

Committed on behalf of Diego Astiazarán (diegoaa...@gmail.com).

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

Modified:
clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp

Modified: clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp?rev=365967=365966=365967=diff
==
--- clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp Fri Jul 
12 15:19:02 2019
@@ -79,10 +79,11 @@ TEST(HTMLGeneratorTest, emitRecordHTML)
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
   I.Members.emplace_back("int", "X/Y", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
- llvm::SmallString<128>("path/to"));
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -97,6 +98,10 @@ TEST(HTMLGeneratorTest, emitRecordHTML)
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToF;
+  llvm::sys::path::native("../../../path/to/F.html", PathToF);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("../int.html", PathToInt);
   std::string Expected = R"raw(
 
 class r
@@ -107,12 +112,14 @@ TEST(HTMLGeneratorTest, emitRecordHTML)
   
   
 Inherits from 
-F
+F
 , G
   
   Members
   
-private int X
+private int X
   
   Records
   
@@ -143,8 +150,10 @@ TEST(HTMLGeneratorTest, emitFunctionHTML
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, "path/to");
-  I.Params.emplace_back("int", "path/to", "P");
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
+  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo);
+  I.Params.emplace_back("int", PathTo, "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
 
@@ -154,15 +163,21 @@ TEST(HTMLGeneratorTest, emitFunctionHTML
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToFloat;
+  llvm::sys::path::native("path/to/float.html", PathToFloat);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("path/to/int.html", PathToInt);
   std::string Expected = R"raw(
 
 
 
   f
   
-float
+float
  f(
-int
+int
  P)
   
   


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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3245
+def warn_impcast_integer_float_precision : Warning<
+  "implicit conversion from %0 to %1 may loses integer precision">,
+  InGroup, DefaultIgnore;

ziangwan wrote:
> nickdesaulniers wrote:
> > `may lose` or just `loses`.
> "may lose". Whether the precision loss really happens depends on the value of 
> i (how many precision bits i has).
> 
> For example, `float e = i` where i is an integer. If i is 15 then there isn't 
> precision loss. If i is 2, then there is precision loss.
This isn't done yet (reopening comment until `may loses` is respelled `may 
lose`).



Comment at: clang/lib/Sema/SemaChecking.cpp:11416
+  S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)));
+llvm::APFloat TargetFloatValue(
+  S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)));

You don't need `TargetFloatValue` until later? Maybe sink it's definition below 
closer to where it's used.  That way we don't have to calculate this if the 
below condition is false.



Comment at: clang/lib/Sema/SemaChecking.cpp:11430
+SmallString<32> PrettyTargetValue;
+TargetFloatValue.toString(PrettyTargetValue,
+  TargetPrecision);

xbolva00 wrote:
> Can you check my older patch + tests + discussion? 
> 
> I had to use other way to get this string..
> 
> 
And I don't think there's a test for this case? Or at least one that checks the 
printed value?


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

https://reviews.llvm.org/D64666



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


[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.

2019-07-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks, just a few minor comment requests now.




Comment at: include/clang/AST/DeclBase.h:1453
+/// copy.
+uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
+

Please include in these comments that these imply the associated basic 
non-triviality predicates.



Comment at: include/clang/AST/Type.h:1133
+  /// Check if this is or contains a non-trivial C struct/union type.
+  bool hasNonTrivialPrimitiveCStruct() const;
 

rjmccall wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > You only want these checks to trigger on unions with non-trivial 
> > > > members (or structs containing them), right?  How about something like 
> > > > `hasNonTrivialPrimitiveCUnionMember()`?  Or maybe make it more 
> > > > descriptive for the use sites, like `isPrimitiveCRestrictedType()`?
> > > > 
> > > > Also, it would be nice if the fast path of this could be inlined so 
> > > > that clients usually didn't had to make a call at all.  You can write 
> > > > the `getBaseElementTypeUnsafe()->getAs()` part in an 
> > > > `inline` implementation at the bottom this file.
> > > Since we don't keep track of whether a struct or union is or contains 
> > > unions with non-trivial members, we'll have to use the visitors to detect 
> > > such structs or unions or, to do it faster, add a bit to `RecordDeclBits` 
> > > that indicates the presence of non-trivial unions. I guess it's okay to 
> > > add another bit to `RecordDeclBits`?
> > It looks like there's plenty of space in `RecordDeclBits`, yeah.
> This comment seems like the right place to explain what makes a union 
> non-trivial in C (that it contains a member which is non-trivial for *any* of 
> the reasons that a type might be non-trivial).
Okay, if we're tracking these separately, please put separate comments on each. 
 Also, please mention in each comment that this implies the associated basic 
non-triviality predicate.



Comment at: lib/Sema/SemaDecl.cpp:12053
+NTCUC_UninitAutoVar);
 }
+

ahatanak wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > Please add a comment explaining why this is specific to local variables.
> > > I was trying to explain why this should be specific to local variables 
> > > and realized that it's not clear to me whether it should be.
> > > 
> > > Suppose there is a union with two fields that are both non-trivial:
> > > 
> > > ```
> > > union U {
> > >   Type A a;
> > >   Type B a;
> > > };
> > > 
> > > U global;
> > > ```
> > > 
> > > In this case, is value-initialization (which is essentially 
> > > default-initialization plus a bunch of zero-initialization as per our 
> > > previous discussion) used to initialize `global`? If so, should we reject 
> > > the code since it requires default-initialization? It should be fine if 
> > > we can assume default-initialization means zero-initialization for 
> > > non-trivial types in C, but what if `TypeA` or `TypeB` requires 
> > > initializing to a non-zero value?
> > Yeah, the default-initialization dimension of this problem is interesting.  
> > The C++ rule makes sense for C++ because default initialization of a C++ 
> > class requires an actual, arbitrary-side-effects constructor call, which of 
> > course you can't reasonably do implicitly for a union member.  As discussed 
> > previously, non-trivial C types can presumably always be 
> > default-initialized with a constant bit pattern.  That means that, as long 
> > as we can do any initialization work at all, then it's in principle not a 
> > problem as long as the bit pattern is the same for all the union members 
> > requiring non-trivial initialization (and in particular if there's only one 
> > such member).  So it's just like you say, we *could* just initialize such 
> > unions conservatively as long as two different members don't require 
> > inconsistent patterns, which in practice they currently never do.  That's 
> > all true independent of storage duration — if we can write that pattern 
> > into a global, we can write into a local.  The only caveat is that a 
> > semantic need for non-trivial default initialization almost certainly means 
> > that there's a semantic need for non-trivial destruction as well, which of 
> > course can't be done on a local union (but isn't a problem for a global 
> > because we just don't destroy them).
> > 
> > On the other hand, on a language level it's much simpler to just say that 
> > we can't default-initialize a union of any storage duration if it has a 
> > non-trivial member, and then the language rule doesn't depend on bit-level 
> > representations.  If there's interest, we can look into weakening that rule 
> > later by saying that e.g. it's possible to default-initialize a union with 
> > at most one non-trivial member.
> > 
> > Apropos, do we consider unions with non-trivial members 

[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:11430
+SmallString<32> PrettyTargetValue;
+TargetFloatValue.toString(PrettyTargetValue,
+  TargetPrecision);

Can you check my older patch + tests + discussion? 

I had to use other way to get this string..





Comment at: clang/test/Sema/implicit-float-conversion.c:13
+  
+  float ff = L; // expected-warning {{implicit conversion from 
'long' to 'float' changes value}}
+  

Can you show the whole warning message?


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

https://reviews.llvm.org/D64666



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


r365966 - [DirectoryWatcher][linux] Fix use of uninitialized value

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 15:11:43 2019
New Revision: 365966

URL: http://llvm.org/viewvc/llvm-project?rev=365966=rev
Log:
[DirectoryWatcher][linux] Fix use of uninitialized value

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=365966=365965=365966=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Fri Jul 12 
15:11:43 2019
@@ -220,8 +220,8 @@ void DirectoryWatcherLinux::InotifyPolli
 
 // Multiple epoll_events can be received for a single file descriptor per
 // epoll_wait call.
-for (const auto  : EpollEventBuffer) {
-  if (EpollEvent.data.fd == InotifyPollingStopSignal.FDRead) {
+for (int i = 0; i < EpollWaitResult; ++i) {
+  if (EpollEventBuffer[i].data.fd == InotifyPollingStopSignal.FDRead) {
 StopWork();
 return;
   }


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


[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-07-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: eli.friedman, RKSimon, spatel, rnk.

As far as I can tell, gcc passes 256/512 bit vectors __int128 in memory. And 
passes a vector of 1 _int128 in an xmm register. The backend considers  as an illegal type and will scalarize any arguments with that type. So we 
need to coerce the argument types in the frontend to match to avoid the illegal 
type.

Are there other element types to consider? Do we need to keep the old behavior 
on platforms where clang is the de facto compiler?

This issue was identified in PR42607. Though even with the types changed, we 
still seem to be doing some unnecessary stack realignment.

I'll add test cases later today or over the weekend.


https://reviews.llvm.org/D64672

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2657,6 +2657,14 @@
 Hi = Lo;
 } else if (Size == 128 ||
(isNamedArg && Size <= getNativeVectorSizeForAVXABI(AVXLevel))) 
{
+  QualType ElementType = VT->getElementType();
+
+  // gcc passes 256 and 512 bit  vectors in memory. :(
+  if (Size != 128 &&
+  (ElementType->isSpecificBuiltinType(BuiltinType::Int128) ||
+   ElementType->isSpecificBuiltinType(BuiltinType::UInt128)))
+return;
+
   // Arguments of 256-bits are split into four eightbyte chunks. The
   // least significant one belongs to class SSE and all the others to class
   // SSEUP. The original Lo and Hi design considers that types can't be
@@ -2899,6 +2907,10 @@
 unsigned LargestVector = getNativeVectorSizeForAVXABI(AVXLevel);
 if (Size <= 64 || Size > LargestVector)
   return true;
+QualType EltTy = VecTy->getElementType();
+if (EltTy->isSpecificBuiltinType(BuiltinType::Int128) ||
+EltTy->isSpecificBuiltinType(BuiltinType::UInt128))
+  return true;
   }
 
   return false;
@@ -2972,8 +2984,11 @@
   if (const Type *InnerTy = isSingleElementStruct(Ty, getContext()))
 Ty = QualType(InnerTy, 0);
 
+  // Don't pass vXi128 vectors in their native type, the backend can't
+  // legalize them.
   llvm::Type *IRType = CGT.ConvertType(Ty);
-  if (isa(IRType) ||
+  if ((isa(IRType) &&
+   !IRType->getVectorElementType()->isIntegerTy(128)) ||
   IRType->getTypeID() == llvm::Type::FP128TyID)
 return IRType;
 


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2657,6 +2657,14 @@
 Hi = Lo;
 } else if (Size == 128 ||
(isNamedArg && Size <= getNativeVectorSizeForAVXABI(AVXLevel))) {
+  QualType ElementType = VT->getElementType();
+
+  // gcc passes 256 and 512 bit  vectors in memory. :(
+  if (Size != 128 &&
+  (ElementType->isSpecificBuiltinType(BuiltinType::Int128) ||
+   ElementType->isSpecificBuiltinType(BuiltinType::UInt128)))
+return;
+
   // Arguments of 256-bits are split into four eightbyte chunks. The
   // least significant one belongs to class SSE and all the others to class
   // SSEUP. The original Lo and Hi design considers that types can't be
@@ -2899,6 +2907,10 @@
 unsigned LargestVector = getNativeVectorSizeForAVXABI(AVXLevel);
 if (Size <= 64 || Size > LargestVector)
   return true;
+QualType EltTy = VecTy->getElementType();
+if (EltTy->isSpecificBuiltinType(BuiltinType::Int128) ||
+EltTy->isSpecificBuiltinType(BuiltinType::UInt128))
+  return true;
   }
 
   return false;
@@ -2972,8 +2984,11 @@
   if (const Type *InnerTy = isSingleElementStruct(Ty, getContext()))
 Ty = QualType(InnerTy, 0);
 
+  // Don't pass vXi128 vectors in their native type, the backend can't
+  // legalize them.
   llvm::Type *IRType = CGT.ConvertType(Ty);
-  if (isa(IRType) ||
+  if ((isa(IRType) &&
+   !IRType->getVectorElementType()->isIntegerTy(128)) ||
   IRType->getTypeID() == llvm::Type::FP128TyID)
 return IRType;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D64666#1583667 , @ziangwan wrote:

> In D64666#1583633 , @xbolva00 wrote:
>
> > You can check also https://reviews.llvm.org/D52835. I hit there issue which 
> > I didn't know how to solve.
>
>
> Hi David,
>
> Can you elaborate what issues you encountered? Thank you.


I had duplicated warning for C++11+ - my new warning and C++11’s narrowing 
warning.

Did you run ‘ninja check-clang’?


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

https://reviews.llvm.org/D64666



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


[PATCH] D64656: Ensure placeholder instruction for cleanup is created

2019-07-12 Thread Øystein Dale via Phabricator via cfe-commits
oydale marked an inline comment as done.
oydale added inline comments.



Comment at: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:2
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions -O1 %s
+// CHECK no crash
+

rjmccall wrote:
> oydale wrote:
> > lebedev.ri wrote:
> > > Either add missing `:` or please write better comment :)
> > I'm not sure what else that comment would contain. I want the test to 
> > verify that clang does not crash given the provided input. 
> We have a testing tool called FileCheck which is used to pattern-match 
> compiler output, and it uses a lot of lines that look like `CHECK: blah`, so 
> the all-caps CHECK makes people think that it's supposed to be a FileCheck 
> line.  Please just write the comment normally, like "PR4771: check that this 
> doesn't crash."
> 
> Was this crash specific to optimization being enabled?
I'll change it to a normal-looking comment.

Yes, for a release build the crash does not happen unless -O1 or greater is 
specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan marked 2 inline comments as done.
ziangwan added inline comments.



Comment at: clang/test/Sema/implicit-float-conversion.c:29
+  double e = 0.0;
+  double f = i + e;
+}

etalvala wrote:
> should this also test the case of:
> `
> long g = L;
> long h = g + a;
> `
> or is that unlikely to fail if the assignment-to-float variant succeeds?
> 
I feel like your case is covered in the testReturn() function.


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

https://reviews.llvm.org/D64666



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


[PATCH] D64671: New clang-tidy check: misc-init-local-variables

2019-07-12 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane created this revision.
jpakkane added a reviewer: alexfh.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

This checks finds all primitive type local variables (integers, doubles, 
pointers) that are declared without an initial value. Includes fixit 
functionality to initialize said variables with a default value. This is zero 
for most types and NaN for floating point types. The use of NaNs is copied from 
the D programming language.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D64671

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp
  clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst
  clang-tools-extra/test/clang-tidy/misc-init-local-variables.cpp

Index: clang-tools-extra/test/clang-tidy/misc-init-local-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-init-local-variables.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-init-local-variables %t
+
+#define DO_NOTHING(x) ((void)x)
+
+// Ensure that function declarations are not changed.
+void some_func(int x, double d, bool b, const char *p);
+
+int do_not_modify_me;
+
+typedef struct {
+  int unaltered1;
+  int unaltered2;
+} UnusedStruct;
+
+
+void init_unit_tests() {
+  int x;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'x' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  int x=0;{{$}}
+  int x0=1, x1, x2=2;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'x1' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  int x0=1, x1=0, x2=2;{{$}}
+  int y0, y1=1, y2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'y0' is not initialized [misc-init-local-variables]
+// CHECK-MESSAGES: :[[@LINE-2]]:17: warning: variable 'y2' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  int y0=0, y1=1, y2=0;{{$}}
+  int hasval = 42;
+
+  float f;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'f' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  float f=(0.0/0.0);{{$}}
+  float fval = 85.0;
+  double d;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: variable 'd' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  double d=(0.0/0.0);{{$}}
+  double dval = 99.0;
+
+  bool b;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  bool b=0;{{$}}
+  bool bval = true;
+
+  const char *ptr;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'ptr' is not initialized [misc-init-local-variables]
+// CHECK-FIXES: {{^}}  const char *ptr=nullptr;{{$}}
+  const char *ptrval = "a string";
+
+  UnusedStruct u;
+
+  DO_NOTHING(x);
+  DO_NOTHING(x0);
+  DO_NOTHING(x1);
+  DO_NOTHING(x2);
+  DO_NOTHING(y0);
+  DO_NOTHING(y1);
+  DO_NOTHING(y2);
+  DO_NOTHING(hasval);
+  DO_NOTHING(f);
+  DO_NOTHING(fval);
+  DO_NOTHING(d);
+  DO_NOTHING(dval);
+  DO_NOTHING(b);
+  DO_NOTHING(bval);
+  DO_NOTHING(ptr);
+  DO_NOTHING(ptrval);
+  DO_NOTHING(u);
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - misc-init-local-variables
+
+misc-init-local-variables
+=
+
+Finds local variables that are declared without an initial
+value. These may lead to unexpected behaviour if there is a code path
+that reads the variable before assigning to it.
+
+Only integers, booleans, floats, doubles and pointers are checked. The
+fix option initializes all detected values with the value of zero. An
+exception is float and double types, which are initialized to NaN.
+
+As an example a function that looks like this:
+
+.. code-block:: c++
+
+   void function() {
+ int x;
+ char *txt;
+ double d;
+
+ // Rest of the function.
+   }
+
+Would be rewritten to look like this:
+
+.. code-block:: c++
+
+   void function() {
+ int x=0;
+ char *txt=nullptr;
+ double d=(0.0/0.0);
+
+ // Rest of the function.
+   }
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -189,6 +189,7 @@
llvm-prefer-isa-or-dyn-cast-in-conditionals
llvm-twine-local
misc-definitions-in-headers
+   misc-init-local-variables
misc-misplaced-const
misc-new-delete-overloads
misc-non-copyable-objects
Index: 

[PATCH] D64656: Ensure placeholder instruction for cleanup is created

2019-07-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh, I see you've already answered that.  I think it's fine to just leave this 
testing debug output if generated optimized output doesn't affect it; the bulk 
of our regression testing is with assertions-enabled compilers anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan marked 6 inline comments as done.
ziangwan added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3245
+def warn_impcast_integer_float_precision : Warning<
+  "implicit conversion from %0 to %1 may loses integer precision">,
+  InGroup, DefaultIgnore;

nickdesaulniers wrote:
> `may lose` or just `loses`.
"may lose". Whether the precision loss really happens depends on the value of i 
(how many precision bits i has).

For example, `float e = i` where i is an integer. If i is 15 then there isn't 
precision loss. If i is 2, then there is precision loss.



Comment at: clang/lib/Sema/SemaChecking.cpp:11417
+llvm::APFloat SourceToFloatValue(
+  S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)));
+

nickdesaulniers wrote:
> should this use `SourceBT` rather than `TargetBT`?
Should be `TargetBT`. I've updated the naming convention to make it more clear.


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

https://reviews.llvm.org/D64666



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


[PATCH] D64669: [clang-doc] Fix failing tests on Windows

2019-07-12 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett accepted this revision.
juliehockett added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D64669



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


[PATCH] D64656: Ensure placeholder instruction for cleanup is created

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



Comment at: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:2
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions -O1 %s
+// CHECK no crash
+

oydale wrote:
> lebedev.ri wrote:
> > Either add missing `:` or please write better comment :)
> I'm not sure what else that comment would contain. I want the test to verify 
> that clang does not crash given the provided input. 
We have a testing tool called FileCheck which is used to pattern-match compiler 
output, and it uses a lot of lines that look like `CHECK: blah`, so the 
all-caps CHECK makes people think that it's supposed to be a FileCheck line.  
Please just write the comment normally, like "PR4771: check that this doesn't 
crash."

Was this crash specific to optimization being enabled?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-12 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan updated this revision to Diff 209611.
ziangwan added a comment.

Fix spelling / comment / naming issues.


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

https://reviews.llvm.org/D64666

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conversion.c
  clang/test/Sema/ext_vector_casts.c
  clang/test/Sema/implicit-float-conversion.c

Index: clang/test/Sema/implicit-float-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-float-conversion.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion
+
+
+long testReturn(long a, float b) {
+  return a + b; // expected-warning {{implicit conversion from 'long' to 'float' may loses integer precision}}
+}
+
+
+void testAssignment() {
+  float f = 22;
+  double b = L;
+  
+  float ff = L; // expected-warning {{implicit conversion from 'long' to 'float' changes value}}
+  
+  long l = L;
+  float fff = l; // expected-warning {{implicit conversion from 'long' to 'float' may loses integer precision}}
+}
+
+
+void testExpression() {
+  float a = 0.0f;
+  float b = L + a; // expected-warning {{implicit conversion from 'long' to 'float' changes value}}
+  float c =  + 2223; // expected-warning {{implicit conversion from 'int' to 'float' changes value}}
+
+  int i = 0;
+  float d = i + a; // expected-warning {{implicit conversion from 'int' to 'float' may loses integer precision}}
+  
+  double e = 0.0;
+  double f = i + e;
+}
Index: clang/test/Sema/ext_vector_casts.c
===
--- clang/test/Sema/ext_vector_casts.c
+++ clang/test/Sema/ext_vector_casts.c
@@ -115,12 +115,12 @@
   vl = vl + t; // expected-warning {{implicit conversion loses integer precision}}
   
   vf = 1 + vf;
-  vf = l + vf;
+  vf = l + vf; // expected-warning {{implicit conversion from 'long' to 'float2' (vector of 2 'float' values) may loses integer precision}}
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
-  vd = l + vd;
-  vd = vd + t;
+  vd = l + vd; // expected-warning {{implicit conversion from 'long' to 'double2' (vector of 2 'double' values) may loses integer precision}}
+  vd = vd + t; // expected-warning {{implicit conversion from '__uint128_t' (aka 'unsigned __int128') to 'double2' (vector of 2 'double' values) may loses integer precision}}
 }
Index: clang/test/Sema/conversion.c
===
--- clang/test/Sema/conversion.c
+++ clang/test/Sema/conversion.c
@@ -233,7 +233,7 @@
   takes_int(v);
   takes_long(v);
   takes_longlong(v);
-  takes_float(v);
+  takes_float(v); // expected-warning {{implicit conversion from 'int' to 'float' may loses integer precision}}
   takes_double(v);
   takes_longdouble(v);
 }
@@ -244,8 +244,8 @@
   takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
   takes_long(v);
   takes_longlong(v);
-  takes_float(v);
-  takes_double(v);
+  takes_float(v); // expected-warning {{implicit conversion from 'long' to 'float' may loses integer precision}}
+  takes_double(v); // expected-warning {{implicit conversion from 'long' to 'double' may loses integer precision}}
   takes_longdouble(v);
 }
 
@@ -255,8 +255,8 @@
   takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
   takes_long(v);
   takes_longlong(v);
-  takes_float(v);
-  takes_double(v);
+  takes_float(v); // expected-warning {{implicit conversion from 'long long' to 'float' may loses integer precision}}
+  takes_double(v); // expected-warning {{implicit conversion from 'long long' to 'double' may loses integer precision}}
   takes_longdouble(v);
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11400,6 +11400,49 @@
 }
   }
 
+  // If we are casting an integer type to a floating point type, we might
+  // lose accuracy if the floating point type has a narrower significand
+  // than the floating point type. Issue warnings for that accuracy loss. 
+  if (SourceBT && TargetBT &&
+  SourceBT->isIntegerType() && TargetBT->isFloatingType()) {
+// Determine the number of precision bits in the source integer type.
+IntRange SourceRange = GetExprRange(S.Context, E, S.isConstantEvaluated());
+unsigned int SourcePrecision = SourceRange.Width;
+
+// Determine the number of 

[PATCH] D64062: Remove __VERSION__

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

Thanks @rnk :)


Repository:
  rL LLVM

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] D64669: [clang-doc] Fix failing tests on Windows

2019-07-12 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added reviewers: juliehockett, jakehehrlich, lebedev.ri.
DiegoAstiazaran added a project: clang-tools-extra.

Tests on Windows were failing due to path separator differences.
 '/' was being used as separator in the expected output, paths in expected 
output are now changed to their native form before comparing them to the actual 
output.


https://reviews.llvm.org/D64669

Files:
  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
@@ -79,10 +79,11 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
   I.Members.emplace_back("int", "X/Y", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
- llvm::SmallString<128>("path/to"));
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -97,6 +98,10 @@
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToF;
+  llvm::sys::path::native("../../../path/to/F.html", PathToF);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("../int.html", PathToInt);
   std::string Expected = R"raw(
 
 class r
@@ -107,12 +112,14 @@
   
   
 Inherits from 
-F
+F
 , G
   
   Members
   
-private int X
+private int X
   
   Records
   
@@ -143,8 +150,10 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, "path/to");
-  I.Params.emplace_back("int", "path/to", "P");
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
+  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo);
+  I.Params.emplace_back("int", PathTo, "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
 
@@ -154,15 +163,21 @@
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToFloat;
+  llvm::sys::path::native("path/to/float.html", PathToFloat);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("path/to/int.html", PathToInt);
   std::string Expected = R"raw(
 
 
 
   f
   
-float
+float
  f(
-int
+int
  P)
   
   


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
@@ -79,10 +79,11 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
   I.Members.emplace_back("int", "X/Y", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
- llvm::SmallString<128>("path/to"));
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, PathTo);
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -97,6 +98,10 @@
   llvm::raw_string_ostream Actual(Buffer);
   auto Err = G->generateDocForInfo(, Actual);
   assert(!Err);
+  SmallString<16> PathToF;
+  llvm::sys::path::native("../../../path/to/F.html", PathToF);
+  SmallString<16> PathToInt;
+  llvm::sys::path::native("../int.html", PathToInt);
   std::string Expected = R"raw(
 
 class r
@@ -107,12 +112,14 @@
   
   
 Inherits from 
-F
+F
 , G
   
   Members
   
-private int X
+private int X
   
   Records
   
@@ -143,8 +150,10 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, "path/to");
-  I.Params.emplace_back("int", "path/to", "P");
+  SmallString<16> PathTo;
+  llvm::sys::path::native("path/to", PathTo);
+  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, PathTo);
+  I.Params.emplace_back("int", PathTo, "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
 
@@ -154,15 +163,21 @@
   llvm::raw_string_ostream 

[PATCH] D64656: Ensure placeholder instruction for cleanup is created

2019-07-12 Thread Øystein Dale via Phabricator via cfe-commits
oydale marked 2 inline comments as done.
oydale added inline comments.



Comment at: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:1
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions -O1 %s
+// CHECK no crash

lebedev.ri wrote:
> lebedev.ri wrote:
> > Why do you need `-O1`?
> > 
> Also, you only check $? Don't you want to check the actual IR?
> 
> 

I wanted the test case to cover both a debug build and a release build of 
clang, hence the use of -O1.

For a release build without asserts, the issue is only visible when building 
with -O1 or higher. For a debug build the optimization level doesn't matter 
because it hits an assert (the one mentioned in the commit message) earlier in 
the compile process.

Using clang++ as provided by my distro and on godbolt the following works fine:
```
clang++ --std=c++17 -c crash.cpp
```

The following crashes:
```
clang++ --std=c++17 -c -O1 crash.cpp
```

I do not have sufficient knowledge of what the IR is expected to look like in 
this case to write a test for it. Further, all I have done is to ensure that a 
placeholder instruction is created when it's needed. This placeholder 
instruction is erased at the end of the function where it was created, so the 
generated IR should already be covered by other tests.



Comment at: clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:2
+// RUN: %clang_cc1 -emit-obj --std=c++17 -fcxx-exceptions -fexceptions -O1 %s
+// CHECK no crash
+

lebedev.ri wrote:
> Either add missing `:` or please write better comment :)
I'm not sure what else that comment would contain. I want the test to verify 
that clang does not crash given the provided input. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64656



___
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-12 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3279
+def ObjCClampingBool : TypeAttr {
+  let Spellings = [Clang<"objc_clamping_bool">];
+  let Subjects = SubjectList<[TypedefName]>;

aaron.ballman wrote:
> Is there a desire for similar functionality for C's `_Bool` datatype, or 
> other, custom datatypes (perhaps `BOOL` from the Win32 APIs)? It seems like 
> this attribute could be generalized to apply to any typedef to an integral 
> type.
Sure, I guess there isn't anything Objective-C specific about this. The new 
patches renames it to `clamping_integral_bool` (and permits it on any integral 
type).


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

https://reviews.llvm.org/D64600



___
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-12 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 209603.
erik.pilkington marked 2 inline comments as done.
erik.pilkington added a comment.

Address review comments.


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

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/CodeGen/clamping-integral-bool.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/clamping-integral-bool.m

Index: clang/test/Sema/clamping-integral-bool.m
===
--- /dev/null
+++ clang/test/Sema/clamping-integral-bool.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+typedef __attribute__((clamping_integral_bool)) signed char BOOL;
+typedef __attribute__((clamping_integral_bool)) unsigned char BOOL2;
+typedef __attribute__((clamping_integral_bool)) int BOOL3;
+
+// expected-error@+1 {{clamping_integral_bool attribute must appertain to an integral type}}
+typedef __attribute__((clamping_integral_bool)) float BOOL4;
+
+// expected-error@+1 {{'clamping_integral_bool' attribute takes no arguments}}
+typedef __attribute__((clamping_integral_bool(1))) signed char BOOL5;
+
+// expected-warning@+1 {{'clamping_integral_bool' attribute only applies to typedefs}}
+__attribute__((clamping_integral_bool)) signed char x;
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
@@ -35,6 +35,7 @@
 // CHECK-NEXT: Callback (SubjectMatchRule_function)
 // CHECK-NEXT: Capability (SubjectMatchRule_record, SubjectMatchRule_type_alias)
 // CHECK-NEXT: CarriesDependency (SubjectMatchRule_variable_is_parameter, SubjectMatchRule_objc_method, SubjectMatchRule_function)
+// CHECK-NEXT: ClampingIntegralBool (SubjectMatchRule_type_alias)
 // CHECK-NEXT: Cold (SubjectMatchRule_function)
 // CHECK-NEXT: Common (SubjectMatchRule_variable)
 // CHECK-NEXT: Constructor (SubjectMatchRule_function)
Index: clang/test/CodeGen/clamping-integral-bool.m
===
--- /dev/null
+++ clang/test/CodeGen/clamping-integral-bool.m
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.14 -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef __attribute__((clamping_integral_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)bf.b;
+  // CHECK: shl i8 %{{.*}}, 7
+  // CHECK-NEXT: [[LOAD:%.*]] = ashr i8 %{{.*}}, 7
+  // CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[LOAD]], 0
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+  // CHECK-NOT: icmp
+
+  (BOOL)bf.b;
+  // CHECK: shl i8 %{{.*}}, 7
+  

[PATCH] D64062: Remove __VERSION__

2019-07-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365962: Remove __VERSION__ (authored by sylvestre, committed 
by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64062?vs=209474=209604#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64062

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/lib/Basic/Version.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Index/complete-exprs.c
  cfe/trunk/test/Preprocessor/init.c
  cfe/trunk/utils/builtin-defines.c

Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -101,7 +101,6 @@
 // COMMON:#define __ORDER_PDP_ENDIAN__ 3412
 // COMMON:#define __STDC_HOSTED__ 1
 // COMMON:#define __STDC__ 1
-// COMMON:#define __VERSION__ {{.*}}
 // COMMON:#define __clang__ 1
 // COMMON:#define __clang_major__ {{[0-9]+}}
 // COMMON:#define __clang_minor__ {{[0-9]+}}
@@ -8169,7 +8168,6 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "4.2.1 Compatible{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
@@ -9041,7 +9039,6 @@
 // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255
 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__
-// X86_64-CLOUDABI:#define __VERSION__ "4.2.1 Compatible{{.*}}
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32
@@ -10043,7 +10040,6 @@
 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_MAX__ 255
 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_TYPE__ unsigned char
 // WEBASSEMBLY-NEXT:#define __USER_LABEL_PREFIX__
-// WEBASSEMBLY-NEXT:#define __VERSION__ "{{.*}}"
 // WEBASSEMBLY-NEXT:#define __WCHAR_MAX__ 2147483647
 // WEBASSEMBLY-NEXT:#define __WCHAR_TYPE__ int
 // WEBASSEMBLY-NOT:#define __WCHAR_UNSIGNED__
Index: cfe/trunk/test/Index/complete-exprs.c
===
--- cfe/trunk/test/Index/complete-exprs.c
+++ cfe/trunk/test/Index/complete-exprs.c
@@ -27,7 +27,6 @@
 // RUN: c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
-// CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
 // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
 // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
@@ -39,7 +38,6 @@
 // RUN: c-index-test -code-completion-at=%s:7:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:22 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
 // CHECK-CC2: NotImplemented:{TypedText float} (50)
 // CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (34)
Index: cfe/trunk/lib/Basic/Version.cpp
===
--- cfe/trunk/lib/Basic/Version.cpp
+++ cfe/trunk/lib/Basic/Version.cpp
@@ -136,8 +136,6 @@
 }
 
 std::string getClangFullCPPVersion() {
-  // The version string we report in __VERSION__ is just a compacted version of
-  // the one we report on the command line.
   std::string buf;
   llvm::raw_string_ostream OS(buf);
 #ifdef CLANG_VENDOR
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -604,12 +604,6 @@
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
-  // As sad as it is, enough software depends on the __VERSION__ for version
-  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
-  // compatibility with) first.
-  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " +
-  Twine(getClangFullCPPVersion()) + "\"");
-

r365962 - Remove __VERSION__

2019-07-12 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Jul 12 14:45:08 2019
New Revision: 365962

URL: http://llvm.org/viewvc/llvm-project?rev=365962=rev
Log:
Remove __VERSION__

Summary:
It has been introduced in 2011 for gcc compat:
https://github.com/llvm-mirror/clang/commit/ad1a4c6e89594e704775ddb6b036ac982fd68cad
it is probably time to remove it


Reviewers: rnk, dexonsmith

Reviewed By: rnk

Subscribers: dschuff, aheejin, fedor.sergeev, arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Basic/Version.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Index/complete-exprs.c
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/utils/builtin-defines.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=365962=365961=365962=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Fri Jul 12 14:45:08 2019
@@ -324,6 +324,8 @@ option for a warning and returns true if
   ...
   #endif
 
+.. _languageextensions-builtin-macros:
+
 Builtin Macros
 ==
 

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=365962=365961=365962=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Jul 12 14:45:08 2019
@@ -56,6 +56,11 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -
 
+- The ``__VERSION__`` macro has been removed.
+  Previously this macro was set to a string aiming to achieve compatibility 
with 
+  GCC 4.2.1, but that should no longer be necessary. To get Clang's version,
+  use the :ref:`clang namespaced version macros 
`.
+
 - ...
 
 
@@ -79,6 +84,11 @@ Modified Compiler Flags
 
 - ...
 
+Removed Compiler Options
+
+
+- ...
+
 New Pragmas in Clang
 
 

Modified: cfe/trunk/lib/Basic/Version.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=365962=365961=365962=diff
==
--- cfe/trunk/lib/Basic/Version.cpp (original)
+++ cfe/trunk/lib/Basic/Version.cpp Fri Jul 12 14:45:08 2019
@@ -136,8 +136,6 @@ std::string getClangToolFullVersion(Stri
 }
 
 std::string getClangFullCPPVersion() {
-  // The version string we report in __VERSION__ is just a compacted version of
-  // the one we report on the command line.
   std::string buf;
   llvm::raw_string_ostream OS(buf);
 #ifdef CLANG_VENDOR

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=365962=365961=365962=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri Jul 12 14:45:08 2019
@@ -604,12 +604,6 @@ static void InitializePredefinedMacros(c
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
-  // As sad as it is, enough software depends on the __VERSION__ for version
-  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
-  // compatibility with) first.
-  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " +
-  Twine(getClangFullCPPVersion()) + "\"");
-
   // Initialize language-specific preprocessor defines.
 
   // Standard conforming mode?

Modified: cfe/trunk/test/Index/complete-exprs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-exprs.c?rev=365962=365961=365962=diff
==
--- cfe/trunk/test/Index/complete-exprs.c (original)
+++ cfe/trunk/test/Index/complete-exprs.c Fri Jul 12 14:45:08 2019
@@ -27,7 +27,6 @@ void f5(float f) {
 // RUN: c-index-test -code-completion-at=%s:7:10 -Xclang 
-code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck 
-check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
-// CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen 
(}{Placeholder int}{RightParen )} (12) (unavailable)
 // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
 // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
@@ -39,7 +38,6 @@ void f5(float f) {
 // RUN: 

[PATCH] D64666: Allow Clang -Wconversion, -Wimplicit-float-conversion warns about integer type -> floating point type implicit conversion precision loss.

2019-07-12 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan added a comment.

In D64666#1583633 , @xbolva00 wrote:

> You can check also https://reviews.llvm.org/D52835. I hit there issue which I 
> didn't know how to solve.


Hi David,

I have read your patch. I think that integer-to-floating-point conversion does 
not necessarily leads to precision loss. We need to have extra condition about 
whether to issue warnings.

For example,

1. Convert L to float leads to precision loss. The reason is that 
L needs 48 bits of precision where float only has 24 bits of 
precision.
2. Convert 22 to float does not lead to precision loss. 22 needs 18 
bits of precision only.


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

https://reviews.llvm.org/D64666



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


[PATCH] D64666: Allow Clang -Wconversion, -Wimplicit-float-conversion warns about integer type -> floating point type implicit conversion precision loss.

2019-07-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I also recommend re-titling the commit to something like:

  [Sema] Enable -Wimplicit-float-conversion for integral to floating point 
precision loss


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

https://reviews.llvm.org/D64666



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


[PATCH] D64666: Allow Clang -Wconversion, -Wimplicit-float-conversion warns about integer type -> floating point type implicit conversion precision loss.

2019-07-12 Thread Eino-Ville Talvala via Phabricator via cfe-commits
etalvala added inline comments.



Comment at: clang/test/Sema/implicit-float-conversion.c:29
+  double e = 0.0;
+  double f = i + e;
+}

should this also test the case of:
`
long g = L;
long h = g + a;
`
or is that unlikely to fail if the assignment-to-float variant succeeds?



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

https://reviews.llvm.org/D64666



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


[PATCH] D64666: Allow Clang -Wconversion, -Wimplicit-float-conversion warns about integer type -> floating point type implicit conversion precision loss.

2019-07-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for the patch @ziangwan !




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3245
+def warn_impcast_integer_float_precision : Warning<
+  "implicit conversion from %0 to %1 may loses integer precision">,
+  InGroup, DefaultIgnore;

`may lose` or just `loses`.



Comment at: clang/lib/Sema/SemaChecking.cpp:11404
+  // If we are casting an integer type to a floating point type, we might
+  // lose accuracy if the floating point type has a narrower signicand
+  // than the floating point type. Issue warnings for that accuracy loss. 

`significand`



Comment at: clang/lib/Sema/SemaChecking.cpp:11412
+
+// Determine the number of precision bits in the target floating point type
+// Also create the APFloat object to represent the converted value.

End the sentence w/ punctuation.



Comment at: clang/lib/Sema/SemaChecking.cpp:11417
+llvm::APFloat SourceToFloatValue(
+  S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)));
+

should this use `SourceBT` rather than `TargetBT`?



Comment at: clang/lib/Sema/SemaChecking.cpp:11420
+// If we manage to find out the precisions for both types, perform
+// acccuracy loss check and issue warning if necessary.
+if (SourcePrecision > 0 && TargetPrecision > 0 &&

`accuracy`

`:set spell` if you're using vim



Comment at: clang/lib/Sema/SemaChecking.cpp:11421
+// acccuracy loss check and issue warning if necessary.
+if (SourcePrecision > 0 && TargetPrecision > 0 &&
+SourcePrecision > TargetPrecision) {

Maybe negate this conditional and return early?



Comment at: clang/lib/Sema/SemaChecking.cpp:11437
+// Issue constant integer to float precision loss warning.
+S.DiagRuntimeBehavior(
+  E->getExprLoc(), E,

Should this just be a generic `Diag` rather than a `DiagRuntimeBehavior`?


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

https://reviews.llvm.org/D64666



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


  1   2   3   >