[PATCH] D47643: Rewrite JSON dispatcher loop using C IO (FILE*) instead of std::istream.

2018-06-04 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D47643#1120913, @ilya-biryukov wrote:

> PS I've checked it on my Mac and lldb seems to attach just fine.


Working fine in my setup too!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47643



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


[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device

2018-06-04 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D47694



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


[PATCH] D47759: [Format] Do not use a global static value for EOF within ScopedMacroState.

2018-06-04 Thread David L. Jones via Phabricator via cfe-commits
dlj created this revision.
dlj added a reviewer: djasper.
dlj added a project: clang.
Herald added a subscriber: klimek.

ScopedMacroState injects its own EOF token under certain conditions, and the
returned token may be modified in several different locations. If multiple
reformat operations are started in different threads, then they will both see
the same fake EOF token, and may both try to modify it. This is a data race.

This bug was caught with tsan.


Repository:
  rC Clang

https://reviews.llvm.org/D47759

Files:
  lib/Format/UnwrappedLineParser.cpp


Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -83,6 +83,8 @@
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
 Token(nullptr), PreviousToken(nullptr) {
+FakeEOF.Tok.startToken();
+FakeEOF.Tok.setKind(tok::eof);
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -102,7 +104,7 @@
 PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
-  return getFakeEOF();
+  return 
 return Token;
   }
 
@@ -121,17 +123,7 @@
  /*MinColumnToken=*/PreviousToken);
   }
 
-  FormatToken *getFakeEOF() {
-static bool EOFInitialized = false;
-static FormatToken FormatTok;
-if (!EOFInitialized) {
-  FormatTok.Tok.startToken();
-  FormatTok.Tok.setKind(tok::eof);
-  EOFInitialized = true;
-}
-return 
-  }
-
+  FormatToken FakeEOF;
   UnwrappedLine 
   FormatTokenSource *
   FormatToken *


Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -83,6 +83,8 @@
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
 Token(nullptr), PreviousToken(nullptr) {
+FakeEOF.Tok.startToken();
+FakeEOF.Tok.setKind(tok::eof);
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -102,7 +104,7 @@
 PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
-  return getFakeEOF();
+  return 
 return Token;
   }
 
@@ -121,17 +123,7 @@
  /*MinColumnToken=*/PreviousToken);
   }
 
-  FormatToken *getFakeEOF() {
-static bool EOFInitialized = false;
-static FormatToken FormatTok;
-if (!EOFInitialized) {
-  FormatTok.Tok.startToken();
-  FormatTok.Tok.setKind(tok::eof);
-  EOFInitialized = true;
-}
-return 
-  }
-
+  FormatToken FakeEOF;
   UnwrappedLine 
   FormatTokenSource *
   FormatToken *
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333980 - [X86] Mark all the builtins and intrinsics that require MMX and an SSE feature as requiring both mmx and the sse feature.

2018-06-04 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Jun  4 20:12:14 2018
New Revision: 333980

URL: http://llvm.org/viewvc/llvm-project?rev=333980=rev
Log:
[X86] Mark all the builtins and intrinsics that require MMX and an SSE feature 
as requiring both mmx and the sse feature.

Previously we only checked the sse feature, but this means that if you passed 
-mno-mmx, the builtins/intrinsics wouldn't be disabled in the frontend and 
would instead fail backend isel.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/tmmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=333980=333979=333980=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jun  4 20:12:14 2018
@@ -145,47 +145,47 @@ TARGET_BUILTIN(__builtin_ia32_vec_init_v
 TARGET_BUILTIN(__builtin_ia32_vec_ext_v2si, "iV2ii", "nc", "mmx")
 
 // MMX2 (MMX+SSE) intrinsics
-TARGET_BUILTIN(__builtin_ia32_cvtpi2ps, "V4fV4fV2i", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_cvtps2pi, "V2iV4f", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_cvttps2pi, "V2iV4f", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pavgb, "V8cV8cV8c", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pavgw, "V4sV4sV4s", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pmaxsw, "V4sV4sV4s", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pmaxub, "V8cV8cV8c", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pminsw, "V4sV4sV4s", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pminub, "V8cV8cV8c", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pmovmskb, "iV8c", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pmulhuw, "V4sV4sV4s", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_psadbw, "V4sV8cV8c", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_pshufw, "V4sV4sIc", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_vec_ext_v4hi, "iV4sIi", "nc", "sse")
-TARGET_BUILTIN(__builtin_ia32_vec_set_v4hi, "V4sV4siIi", "nc", "sse")
+TARGET_BUILTIN(__builtin_ia32_cvtpi2ps, "V4fV4fV2i", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_cvtps2pi, "V2iV4f", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_cvttps2pi, "V2iV4f", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pavgb, "V8cV8cV8c", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pavgw, "V4sV4sV4s", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pmaxsw, "V4sV4sV4s", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pmaxub, "V8cV8cV8c", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pminsw, "V4sV4sV4s", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pminub, "V8cV8cV8c", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pmovmskb, "iV8c", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pmulhuw, "V4sV4sV4s", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_psadbw, "V4sV8cV8c", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_pshufw, "V4sV4sIc", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_vec_ext_v4hi, "iV4sIi", "nc", "mmx,sse")
+TARGET_BUILTIN(__builtin_ia32_vec_set_v4hi, "V4sV4siIi", "nc", "mmx,sse")
 
 // MMX+SSE2
-TARGET_BUILTIN(__builtin_ia32_cvtpd2pi, "V2iV2d", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cvtpi2pd, "V2dV2i", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cvttpd2pi, "V2iV2d", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_paddq, "V1LLiV1LLiV1LLi", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_pmuludq, "V1LLiV2iV2i", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_psubq, "V1LLiV1LLiV1LLi", "nc", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvtpd2pi, "V2iV2d", "nc", "mmx,sse2")
+TARGET_BUILTIN(__builtin_ia32_cvtpi2pd, "V2dV2i", "nc", "mmx,sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttpd2pi, "V2iV2d", "nc", "mmx,sse2")
+TARGET_BUILTIN(__builtin_ia32_paddq, "V1LLiV1LLiV1LLi", "nc", "mmx,sse2")
+TARGET_BUILTIN(__builtin_ia32_pmuludq, "V1LLiV2iV2i", "nc", "mmx,sse2")
+TARGET_BUILTIN(__builtin_ia32_psubq, "V1LLiV1LLiV1LLi", "nc", "mmx,sse2")
 
 // MMX+SSSE3
-TARGET_BUILTIN(__builtin_ia32_pabsb, "V8cV8c", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_pabsd, "V2iV2i", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_pabsw, "V4sV4s", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_palignr, "V8cV8cV8cIc", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_phaddd, "V2iV2iV2i", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_phaddsw, "V4sV4sV4s", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_phaddw, "V4sV4sV4s", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_phsubd, "V2iV2iV2i", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_phsubsw, "V4sV4sV4s", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_phsubw, "V4sV4sV4s", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_pmaddubsw, "V8cV8cV8c", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_pmulhrsw, "V4sV4sV4s", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_pshufb, "V8cV8cV8c", "nc", "ssse3")
-TARGET_BUILTIN(__builtin_ia32_psignw, "V4sV4sV4s", "nc", "ssse3")

[PATCH] D47758: [Fuchsia] Include install-distribution-stripped in bootstrap targets

2018-06-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, juliehockett.
Herald added subscribers: cfe-commits, mgorny.

This enables the use of install-distribution-stripped target in the
2-stage builds.


Repository:
  rC Clang

https://reviews.llvm.org/D47758

Files:
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -38,6 +38,7 @@
   clang-test-depends
   distribution
   install-distribution
+  install-distribution-stripped
   clang CACHE STRING "")
 
 get_cmake_property(variableNames VARIABLES)


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -38,6 +38,7 @@
   clang-test-depends
   distribution
   install-distribution
+  install-distribution-stripped
   clang CACHE STRING "")
 
 get_cmake_property(variableNames VARIABLES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47757: [Sema] Diagnose unavailable aligned deallocation functions called from deleting destructors.

2018-06-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, vsapsai, EricWF, erik.pilkington.

Deallocation functions are called from deleting destructors that are declared 
virtual. Issue an error if an aligned deallocation function is selected but is 
not available.


Repository:
  rC Clang

https://reviews.llvm.org/D47757

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/unavailable_aligned_allocation.cpp

Index: test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- test/SemaCXX/unavailable_aligned_allocation.cpp
+++ test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -124,6 +124,33 @@
 // expected-note@-20 2 {{if you supply your own aligned allocation functions}}
 #endif
 
+// Test that diagnostics are produced when an unavailable aligned deallocation
+// function is called from a deleting destructor.
+struct alignas(256) OveralignedS2 {
+  int a[4];
+  virtual ~OveralignedS2();
+};
+
+OveralignedS2::~OveralignedS2() {}
+
+#ifdef NO_ERRORS
+// expected-no-diagnostics
+#else
+#if defined(IOS)
+// expected-error@-6 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on iOS 11 or newer}}}
+// expected-note@-7 {{if you supply your own aligned allocation functions}}
+#elif defined(TVOS)
+// expected-error@-9 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on tvOS 11 or newer}}}
+// expected-note@-10 {{if you supply your own aligned allocation functions}}
+#elif defined(WATCHOS)
+// expected-error@-12 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
+// expected-note@-13 {{if you supply your own aligned allocation functions}}
+#else
+// expected-error@-15 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
+// expected-note@-16 {{if you supply your own aligned allocation functions}}
+#endif
+#endif
+
 // No errors if user-defined aligned allocation functions are available.
 void *operator new(std::size_t __sz, std::align_val_t) {
   static char array[256];
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1681,26 +1681,26 @@
 
 // Emit a diagnostic if an aligned allocation/deallocation function that is not
 // implemented in the standard library is selected.
-static void diagnoseUnavailableAlignedAllocation(const FunctionDecl ,
- SourceLocation Loc, bool IsDelete,
- Sema ) {
-  if (!S.getLangOpts().AlignedAllocationUnavailable)
+void Sema::diagnoseUnavailableAlignedAllocation(const FunctionDecl ,
+SourceLocation Loc,
+bool IsDelete) {
+  if (!getLangOpts().AlignedAllocationUnavailable)
 return;
 
   // Return if there is a definition.
   if (FD.isDefined())
 return;
 
   bool IsAligned = false;
   if (FD.isReplaceableGlobalAllocationFunction() && IsAligned) {
-const llvm::Triple  = S.getASTContext().getTargetInfo().getTriple();
+const llvm::Triple  = getASTContext().getTargetInfo().getTriple();
 StringRef OSName = AvailabilityAttr::getPlatformNameSourceSpelling(
-S.getASTContext().getTargetInfo().getPlatformName());
+getASTContext().getTargetInfo().getPlatformName());
 
-S.Diag(Loc, diag::warn_aligned_allocation_unavailable)
+Diag(Loc, diag::warn_aligned_allocation_unavailable)
  << IsDelete << FD.getType().getAsString() << OSName
  << alignedAllocMinVersion(T.getOS()).getAsString();
-S.Diag(Loc, diag::note_silence_unligned_allocation_unavailable);
+Diag(Loc, diag::note_silence_unligned_allocation_unavailable);
   }
 }
 
@@ -2091,13 +2091,13 @@
 if (DiagnoseUseOfDecl(OperatorNew, StartLoc))
   return ExprError();
 MarkFunctionReferenced(StartLoc, OperatorNew);
-diagnoseUnavailableAlignedAllocation(*OperatorNew, StartLoc, false, *this);
+diagnoseUnavailableAlignedAllocation(*OperatorNew, StartLoc, false);
   }
   if (OperatorDelete) {
 if (DiagnoseUseOfDecl(OperatorDelete, StartLoc))
   return ExprError();
 MarkFunctionReferenced(StartLoc, OperatorDelete);
-diagnoseUnavailableAlignedAllocation(*OperatorDelete, StartLoc, true, *this);
+diagnoseUnavailableAlignedAllocation(*OperatorDelete, StartLoc, true);
   }
 
   // C++0x [expr.new]p17:
@@ -3329,8 +3329,7 @@
   }
 }
 
-diagnoseUnavailableAlignedAllocation(*OperatorDelete, StartLoc, true,
- *this);
+diagnoseUnavailableAlignedAllocation(*OperatorDelete, StartLoc, true);
 
 // Convert the operand to the 

[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-06-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I see, thank you.

clang front-end currently fails to issue a warning or error when an aligned 
allocation/deallocation functions are required but not available in a few cases 
(e.g., delete called from a deleting destructor, calls to operator or builtin 
operator new/delete). I suppose those bugs should be fixed in separate patches.


https://reviews.llvm.org/D45015



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


[PATCH] D47668: [Driver][Fuchsia] Pass LTO flags to linker

2018-06-04 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333979: [Driver][Fuchsia] Pass LTO flags to linker (authored 
by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47668?vs=149590=149893#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47668

Files:
  cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
  cfe/trunk/test/Driver/fuchsia.c


Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -114,3 +114,16 @@
 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-SHARED: "{{.*[/\\]}}libclang_rt.scudo-x86_64.so"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: "-plugin-opt=mcpu=cortex-a53"
+// CHECK-LTO: "-plugin-opt=O3"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -flto=thin -flto-jobs=8 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO
+// CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
+// CHECK-THINLTO: "-plugin-opt=thinlto"
+// CHECK-THINLTO: "-plugin-opt=jobs=8"
Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
@@ -100,6 +100,12 @@
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+  }
+
   addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);


Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -114,3 +114,16 @@
 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-SHARED: "{{.*[/\\]}}libclang_rt.scudo-x86_64.so"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: "-plugin-opt=mcpu=cortex-a53"
+// CHECK-LTO: "-plugin-opt=O3"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -flto=thin -flto-jobs=8 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO
+// CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
+// CHECK-THINLTO: "-plugin-opt=thinlto"
+// CHECK-THINLTO: "-plugin-opt=jobs=8"
Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
@@ -100,6 +100,12 @@
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+  }
+
   addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333979 - [Driver][Fuchsia] Pass LTO flags to linker

2018-06-04 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Jun  4 18:50:59 2018
New Revision: 333979

URL: http://llvm.org/viewvc/llvm-project?rev=333979=rev
Log:
[Driver][Fuchsia] Pass LTO flags to linker

Even though we use lld by default for Fuchsia, we use Gold plugin
arguments like all other drivers as lld supports Gold plugin options.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=333979=333978=333979=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Mon Jun  4 18:50:59 2018
@@ -100,6 +100,12 @@ void fuchsia::Linker::ConstructJob(Compi
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+  }
+
   addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=333979=333978=333979=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Mon Jun  4 18:50:59 2018
@@ -114,3 +114,16 @@
 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-SHARED: "{{.*[/\\]}}libclang_rt.scudo-x86_64.so"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: "-plugin-opt=mcpu=cortex-a53"
+// CHECK-LTO: "-plugin-opt=O3"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -flto=thin -flto-jobs=8 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO
+// CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
+// CHECK-THINLTO: "-plugin-opt=thinlto"
+// CHECK-THINLTO: "-plugin-opt=jobs=8"


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


[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device

2018-06-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 149892.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D47694

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/device-vtable.cu


Index: test/CodeGenCUDA/device-vtable.cu
===
--- test/CodeGenCUDA/device-vtable.cu
+++ test/CodeGenCUDA/device-vtable.cu
@@ -19,15 +19,19 @@
 //CHECK-HOST: @_ZTV1H =
 //CHECK-HOST-SAME: @_ZN1H6methodEv
 //CHECK-DEVICE-NOT: @_ZTV1H =
-
+//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE
+//CHECK-DEVICE-NOT: @_ZTS1H
+//CHECK-DEVICE-NOT: @_ZTI1H
 struct D  {
__device__ virtual void method();
 };
 
 //CHECK-DEVICE: @_ZTV1D
 //CHECK-DEVICE-SAME: @_ZN1D6methodEv
 //CHECK-HOST-NOT: @_ZTV1D
-
+//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE
+//CHECK-DEVICE-NOT: @_ZTS1D
+//CHECK-DEVICE-NOT: @_ZTI1D
 // This is the case with mixed host and device virtual methods.  It's
 // impossible to emit a valid vtable in that case because only host or
 // only device methods would be available during host or device
@@ -45,6 +49,9 @@
 // CHECK-HOST-NOT: @_ZN2HD8d_methodEv
 // CHECK-HOST-SAME: null
 // CHECK-BOTH-SAME: ]
+// CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE
+// CHECK-DEVICE-NOT: @_ZTS2HD
+// CHECK-DEVICE-NOT: @_ZTI2HD
 
 void H::method() {}
 //CHECK-HOST: define void @_ZN1H6methodEv
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4899,7 +4899,7 @@
   // Return a bogus pointer if RTTI is disabled, unless it's for EH.
   // FIXME: should we even be calling this method if RTTI is disabled
   // and it's not for EH?
-  if (!ForEH && !getLangOpts().RTTI)
+  if ((!ForEH && !getLangOpts().RTTI) || getLangOpts().CUDAIsDevice)
 return llvm::Constant::getNullValue(Int8PtrTy);
 
   if (ForEH && Ty->isObjCObjectPointerType() &&


Index: test/CodeGenCUDA/device-vtable.cu
===
--- test/CodeGenCUDA/device-vtable.cu
+++ test/CodeGenCUDA/device-vtable.cu
@@ -19,15 +19,19 @@
 //CHECK-HOST: @_ZTV1H =
 //CHECK-HOST-SAME: @_ZN1H6methodEv
 //CHECK-DEVICE-NOT: @_ZTV1H =
-
+//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE
+//CHECK-DEVICE-NOT: @_ZTS1H
+//CHECK-DEVICE-NOT: @_ZTI1H
 struct D  {
__device__ virtual void method();
 };
 
 //CHECK-DEVICE: @_ZTV1D
 //CHECK-DEVICE-SAME: @_ZN1D6methodEv
 //CHECK-HOST-NOT: @_ZTV1D
-
+//CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE
+//CHECK-DEVICE-NOT: @_ZTS1D
+//CHECK-DEVICE-NOT: @_ZTI1D
 // This is the case with mixed host and device virtual methods.  It's
 // impossible to emit a valid vtable in that case because only host or
 // only device methods would be available during host or device
@@ -45,6 +49,9 @@
 // CHECK-HOST-NOT: @_ZN2HD8d_methodEv
 // CHECK-HOST-SAME: null
 // CHECK-BOTH-SAME: ]
+// CHECK-DEVICE-NOT: @_ZTVN10__cxxabiv117__class_type_infoE
+// CHECK-DEVICE-NOT: @_ZTS2HD
+// CHECK-DEVICE-NOT: @_ZTI2HD
 
 void H::method() {}
 //CHECK-HOST: define void @_ZN1H6methodEv
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4899,7 +4899,7 @@
   // Return a bogus pointer if RTTI is disabled, unless it's for EH.
   // FIXME: should we even be calling this method if RTTI is disabled
   // and it's not for EH?
-  if (!ForEH && !getLangOpts().RTTI)
+  if ((!ForEH && !getLangOpts().RTTI) || getLangOpts().CUDAIsDevice)
 return llvm::Constant::getNullValue(Int8PtrTy);
 
   if (ForEH && Ty->isObjCObjectPointerType() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333978 - Reimplement the bittest intrinsic family as builtins with inline asm

2018-06-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Jun  4 18:33:40 2018
New Revision: 333978

URL: http://llvm.org/viewvc/llvm-project?rev=333978=rev
Log:
Reimplement the bittest intrinsic family as builtins with inline asm

We need to implement _interlockedbittestandset as a builtin for
windows.h, so we might as well do the whole family. It reduces code
duplication anyway.

Fixes PR33188, a long standing bug in our bittest implementation
encountered by Chakra.

Added:
cfe/trunk/test/CodeGen/bittest-intrin.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/ms-intrinsics-other.c
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=333978=333977=333978=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jun  4 18:33:40 2018
@@ -744,6 +744,14 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn"
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__assume, "vb",  "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittest,"UcNiC*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittestandcomplement,   "UcNi*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittestandreset,"UcNi*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittestandset,  "UcNi*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittest64,  "UcWiC*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittestandcomplement64, "UcWi*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittestandreset64,  "UcWi*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_bittestandset64,"UcWi*Wi", "n", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_ulong,  "UNiUNi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
@@ -783,7 +791,10 @@ LANGBUILTIN(_InterlockedOr,   "NiNiD*Ni"
 LANGBUILTIN(_InterlockedXor8,  "ccD*c",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor16, "ssD*s",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor,   "NiNiD*Ni","n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__noop,   "i.",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt,   "UiUi", "nc", ALL_MS_LANGUAGES)

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333978=333977=333978=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun  4 18:33:40 2018
@@ -484,6 +484,37 @@ CodeGenFunction::emitBuiltinObjectSize(c
   return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown});
 }
 
+static RValue EmitBitTestIntrinsic(CodeGenFunction , const CallExpr *E,
+   char TestAnd, char Size,
+   bool Locked = false) {
+  Value *BitBase = CGF.EmitScalarExpr(E->getArg(0));
+  Value *BitPos = CGF.EmitScalarExpr(E->getArg(1));
+
+  // Build the assembly.
+  SmallString<64> Asm;
+  raw_svector_ostream AsmOS(Asm);
+  if (Locked)
+AsmOS << "lock ";
+  AsmOS << "bt";
+  if (TestAnd)
+AsmOS << TestAnd;
+  AsmOS << Size << " $2, ($1)\n\tsetc ${0:b}";
+
+  // Build the constraints. FIXME: We should support immediates when possible.
+  std::string Constraints = "=r,r,r,~{cc},~{flags},~{memory},~{fpsr}";
+  llvm::IntegerType *IntType = llvm::IntegerType::get(
+  CGF.getLLVMContext(),
+  CGF.getContext().getTypeSize(E->getArg(1)->getType()));
+  llvm::Type *IntPtrType = IntType->getPointerTo();
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(CGF.Int8Ty, {IntPtrType, IntType}, false);
+
+  llvm::InlineAsm *IA =
+  llvm::InlineAsm::get(FTy, Asm, Constraints, /*SideEffects=*/true);
+  CallSite CS = CGF.Builder.CreateCall(IA, {BitBase, BitPos});
+  return RValue::get(CS.getInstruction());
+}
+
 // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we
 // handle them here.
 enum class CodeGenFunction::MSVCIntrin {
@@ -497,7 +528,6 @@ enum class CodeGenFunction::MSVCIntrin {
   _InterlockedIncrement,
   _InterlockedOr,
   _InterlockedXor,
-  _interlockedbittestandset,
   __fastfail,
 };
 
@@ 

[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> I agree, though a number of these are limitations in CSA, and not 
> specifically the backend.

Yeah, so for instance we always assume that for a given state we know whether 
it's feasible or not,
and IMO for efficient SMT solver support we would need to operate over "lazy" 
states which may or may not be feasible.


Repository:
  rC Clang

https://reviews.llvm.org/D47726



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


[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

> @ddcc  To be completely honest, I see a few design issues with the current 
> implementation of Z3 backend,
>  the main one being that it checks satisfiability after every single exploded 
> node.
>  To the best of my knowledge, reasonable scalability would not be achieved 
> with such an approach,
>  and I'm not sure how feasible would it be to change it without rewriting 
> most of the checkers.

I agree, though a number of these are limitations in CSA, and not specifically 
the backend.

> Thus we currently do not plan to set up a Z3 bot, but if you wish to maintain 
> we certainly can provide pointers on how this can be done.

I don't plan to set one up either. Just compiling clang/llvm is already very 
resource intensive.

> What do you think if we introduce `ninja check-clang-analyzer` to run the 
> analyzer tests, and `ninja check-clang-analyzer-z3` to run all the analyzer 
> tests with Z3?
>  [there might be another ninja target for running all analyzer tests, I just 
> don't remember which one. But at the end of the day there should be away to 
> run analyzer tests without Z3 even when Z3 is linked in]

Sounds good.


Repository:
  rC Clang

https://reviews.llvm.org/D47726



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


[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a subscriber: mikhail.ramalho.
george.karpenkov added a comment.

@ddcc  To be completely honest, I see a few design issues with the current 
implementation of Z3 backend,
the main one being that it checks satisfiability after every single exploded 
node.
To the best of my knowledge, reasonable scalability would not be achieved with 
such an approach,
and I'm not sure how feasible would it be to change it without rewriting most 
of the checkers.

Thus we currently do not plan to set up a Z3 bot, but if you wish to maintain 
we certainly can provide pointers on how this can be done.

> The test approach is what @dcoughlin suggested in 
> https://reviews.llvm.org/D28952, where the tests are run using each 
> constraint manager that is available

Apologies for conflicting instruction. Now that @mikhail.ramalho is working on 
refutation with Z3 it might not make sense to force the user to run all tests 
with Z3 at all times.
What do you think if we introduce `ninja check-clang-analyzer` to run the 
analyzer tests, and `ninja check-clang-analyzer-z3` to run all the analyzer 
tests with Z3?
[there might be another ninja target for running all analyzer tests, I just 
don't remember which one. But at the end of the day there should be away to run 
analyzer tests without Z3 even when Z3 is linked in]


Repository:
  rC Clang

https://reviews.llvm.org/D47726



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333969: [clang-proto-fuzzer] Refactored LLVMFuzzerInitialize 
into its own file. (authored by morehouse, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47666?vs=149872=149876#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47666

Files:
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
  cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h

Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -40,6 +40,9 @@
   # Build the protobuf->C++ translation library and driver.
   add_clang_subdirectory(proto-to-cxx)
 
+  # Build the fuzzer initialization library.
+  add_clang_subdirectory(fuzzer-initialize)
+
   # Build the protobuf fuzzer
   add_clang_executable(clang-proto-fuzzer
 ${DUMMY_MAIN}
@@ -52,6 +55,7 @@
 ${PROTOBUF_LIBRARIES}
 ${LLVM_LIB_FUZZING_ENGINE}
 clangCXXProto
+clangFuzzerInitialize
 clangHandleCXX
 clangProtoToCXX
 )
Index: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -17,28 +17,12 @@
 #include "cxx_proto.pb.h"
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
-
+#include "fuzzer-initialize/fuzzer_initialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
-#include 
-
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }
Index: cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
===
--- cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
+++ cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
@@ -0,0 +1,19 @@
+//==-- fuzzer_initialize.h - Fuzz Clang ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a function that returns the command line arguments for a specific
+// call to the fuzz target.
+//
+//===--===//
+
+#include 
+
+namespace clang_fuzzer {
+const std::vector& GetCLArgs();
+}
Index: cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
===
--- cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
+++ cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
@@ -0,0 +1,43 @@
+//===-- fuzzer_initialize.cpp - Fuzz Clang ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file implements two functions: one that returns the command line
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments.
+///
+//===--===//
+
+#include "fuzzer_initialize.h"
+#include 
+
+using namespace clang_fuzzer;
+
+
+namespace clang_fuzzer {
+
+static std::vector CLArgs;
+
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  break;
+}
+  }
+  return 0;
+}
Index: cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
+++ 

r333969 - [clang-proto-fuzzer] Refactored LLVMFuzzerInitialize into its own file.

2018-06-04 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Mon Jun  4 17:11:41 2018
New Revision: 333969

URL: http://llvm.org/viewvc/llvm-project?rev=333969=rev
Log:
[clang-proto-fuzzer] Refactored LLVMFuzzerInitialize into its own file.

Copied and renamed some files in preparation for new loop-proto-fuzzer.

Patch By: emmettneyman

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

Added:
cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/
cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=333969=333968=333969=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Mon Jun  4 17:11:41 2018
@@ -40,6 +40,9 @@ if(CLANG_ENABLE_PROTO_FUZZER)
   # Build the protobuf->C++ translation library and driver.
   add_clang_subdirectory(proto-to-cxx)
 
+  # Build the fuzzer initialization library.
+  add_clang_subdirectory(fuzzer-initialize)
+
   # Build the protobuf fuzzer
   add_clang_executable(clang-proto-fuzzer
 ${DUMMY_MAIN}
@@ -52,6 +55,7 @@ if(CLANG_ENABLE_PROTO_FUZZER)
 ${PROTOBUF_LIBRARIES}
 ${LLVM_LIB_FUZZING_ENGINE}
 clangCXXProto
+clangFuzzerInitialize
 clangHandleCXX
 clangProtoToCXX
 )

Modified: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp?rev=333969=333968=333969=diff
==
--- cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp Mon Jun  4 
17:11:41 2018
@@ -17,28 +17,12 @@
 #include "cxx_proto.pb.h"
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
-
+#include "fuzzer-initialize/fuzzer_initialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
-#include 
-
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }

Added: cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt?rev=333969=auto
==
--- cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt (added)
+++ cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt Mon Jun  4 
17:11:41 2018
@@ -0,0 +1,3 @@
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
+
+add_clang_library(clangFuzzerInitialize fuzzer_initialize.cpp)

Added: cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp?rev=333969=auto
==
--- cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp (added)
+++ cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp Mon 
Jun  4 17:11:41 2018
@@ -0,0 +1,43 @@
+//===-- fuzzer_initialize.cpp - Fuzz Clang 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file implements two functions: one that returns the command line
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments.
+///
+//===--===//
+
+#include "fuzzer_initialize.h"
+#include 
+
+using namespace clang_fuzzer;
+
+
+namespace clang_fuzzer {
+
+static std::vector CLArgs;
+
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; 

[PATCH] D36918: [Sema] Take into account the current context when checking the accessibility of a member function pointer

2018-06-04 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.

LGTM.

Thank you for the explanation!


Repository:
  rC Clang

https://reviews.llvm.org/D36918



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D47666



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 149872.
emmettneyman added a comment.

- Removed unecessary includes and renamed library.


Repository:
  rC Clang

https://reviews.llvm.org/D47666

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h

Index: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
===
--- /dev/null
+++ tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
@@ -0,0 +1,20 @@
+//==-- fuzzer_initialize.h - Fuzz Clang ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a function that returns the command line arguments for a specific
+// call to the fuzz target.
+//
+//===--===//
+
+#include 
+
+namespace clang_fuzzer {
+const std::vector& GetCLArgs();
+}
+
Index: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
===
--- tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
+++ tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
@@ -1,4 +1,4 @@
-//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --===//
+//===-- fuzzer_initialize.cpp - Fuzz Clang ===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,24 +8,28 @@
 //===--===//
 ///
 /// \file
-/// This file implements a function that runs Clang on a single
-///  input and uses libprotobuf-mutator to find new inputs. This function is
-///  then linked into the Fuzzer library.
+/// This file implements two functions: one that returns the command line 
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments. 
 ///
 //===--===//
 
-#include "cxx_proto.pb.h"
-#include "handle-cxx/handle_cxx.h"
-#include "proto-to-cxx/proto_to_cxx.h"
-
-#include "src/libfuzzer/libfuzzer_macro.h"
-
+#include "fuzzer_initialize.h"
 #include 
 
 using namespace clang_fuzzer;
 
+
+namespace clang_fuzzer {
+
 static std::vector CLArgs;
 
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
   CLArgs.push_back("-O2");
   for (int I = 1; I < *argc; I++) {
@@ -38,7 +42,3 @@
   return 0;
 }
 
-DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
-  auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
-}
Index: tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
+
+add_clang_library(clangFuzzerInitialize fuzzer_initialize.cpp)
Index: tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -17,28 +17,12 @@
 #include "cxx_proto.pb.h"
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
-
+#include "fuzzer-initialize/fuzzer_initialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
-#include 
-
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -39,6 +39,9 @@
 
   # Build the protobuf->C++ translation library and driver.
   add_clang_subdirectory(proto-to-cxx)
+  
+  # Build the fuzzer initialization library.
+  add_clang_subdirectory(fuzzer-initialize)
 
   # Build the protobuf fuzzer
   add_clang_executable(clang-proto-fuzzer
@@ -52,6 +55,7 @@
 ${PROTOBUF_LIBRARIES}
 ${LLVM_LIB_FUZZING_ENGINE}
 clangCXXProto
+clangFuzzerInitialize
 clangHandleCXX
 

[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-06-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D45015#1121581, @ahatanak wrote:

> Could you elaborate on what kind of changes you are planning to make in 
> libc++ after committing this patch?


Libc++ shouldn't actually need any changes if this current patch lands. 
Currently libc++ is in a "incorrect" state where
it generates calls to `__builtin_operator_new(size_t, align_val_t)` when 
`__cpp_aligned_new` is defined but when aligned new/delete
are actually unavailable.

If we change `__cpp_aligned_new` to no longer be defined when aligned new is 
unavailable, then libc++ will start doing the right thing.
See r328180 

 for the relevent commits which made these libc++ changes.


https://reviews.llvm.org/D45015



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


[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-06-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

By the way, I went ahead and reverted this in r333958.


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:23
 
 #include 
 

I think `cstring` is no longer used after this change.  So we can probably 
remove this include.



Comment at: tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt:3
+
+add_clang_library(clangFuzzerInit fuzzer_initialize.cpp)

Nit:  `clangFuzzerInitialize` would better follow the naming convention of the 
other libraries.



Comment at: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h:15
+
+#include "src/libfuzzer/libfuzzer_macro.h"
+

I don't think this include is used in this file either.  Can we remove it?


Repository:
  rC Clang

https://reviews.llvm.org/D47666



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


[PATCH] D46700: [ThinLTO] Add testing of new summary index format to a couple CFI tests

2018-06-04 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333966: [ThinLTO] Add testing of new summary index format to 
a couple CFI tests (authored by tejohnson, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46700

Files:
  cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll


Index: cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
===
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
@@ -20,6 +20,11 @@
 ; CHECK: blob data = '_ZTS1A'
 ; CHECK-LABEL: Index: cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
===
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
@@ -20,6 +20,11 @@
 ; CHECK: blob data = '_ZTS1A'
 ; CHECK-LABEL: ___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333966 - [ThinLTO] Add testing of new summary index format to a couple CFI tests

2018-06-04 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Mon Jun  4 16:05:24 2018
New Revision: 333966

URL: http://llvm.org/viewvc/llvm-project?rev=333966=rev
Log:
[ThinLTO] Add testing of new summary index format to a couple CFI tests

Summary:
Adds testing of combined index summary entries in disassembly format
to CFI tests that were already testing the bitcode format.

Depends on D46699.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

Modified:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=333966=333965=333966=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Mon Jun  4 
16:05:24 2018
@@ -29,6 +29,11 @@
 ; CHECK: blob data = '_ZTS1A_ZN1A1nEi'
 ; CHECK-LABEL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll?rev=333966=333965=333966=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll Mon Jun  4 16:05:24 2018
@@ -20,6 +20,11 @@
 ; CHECK: blob data = '_ZTS1A'
 ; CHECK-LABEL: http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47554: [analyzer] Check for dead/impossible status checks

2018-06-04 Thread Tom Rix via Phabricator via cfe-commits
trixirt updated this revision to Diff 149868.
trixirt added a comment.
Herald added a subscriber: klimek.

Convert to AST Visitor

Remove Ctx parameter from shouldNullCheckAllocation

Add a shouldNullCheckAllocation ASTMatcher


Repository:
  rC Clang

https://reviews.llvm.org/D47554

Files:
  include/clang/AST/ExprCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/AST/ExprCXX.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/DeadStatusChecker.cpp
  test/Analysis/dead-status-new-nullptr.cpp

Index: test/Analysis/dead-status-new-nullptr.cpp
===
--- /dev/null
+++ test/Analysis/dead-status-new-nullptr.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=deadcode.DeadStatus -verify %s
+
+void *t1(unsigned n, bool *fail);
+void *t1(unsigned n, bool *fail) {
+  char *m = new char[n];
+  if (nullptr == m) // expected-warning{{This variable can never be a nullptr}}
+*fail = true;
+  else
+*fail = false;
+  return m;
+}
+
+void *t2(unsigned n, bool *fail);
+void *t2(unsigned n, bool *fail) {
+  char *m = new char[n];
+  if (m == nullptr) // expected-warning{{This variable can never be a nullptr}}
+*fail = true;
+  else
+*fail = false;
+  return m;
+}
+
+// a variant of nullptr
+void *t3(unsigned n, bool *fail);
+void *t3(unsigned n, bool *fail) {
+  char *m = new char[n];
+  if (m == 0) // expected-warning{{This variable can never be a nullptr}}
+*fail = true;
+  else
+*fail = false;
+  return m;
+}
+
+// a variant of nullptr
+#define NULL __null
+void *t4(unsigned n, bool *fail);
+void *t4(unsigned n, bool *fail) {
+  char *m = new char[n];
+  if (m == NULL) // expected-warning{{This variable can never be a nullptr}}
+*fail = true;
+  else
+*fail = false;
+  return m;
+}
Index: lib/StaticAnalyzer/Checkers/DeadStatusChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/DeadStatusChecker.cpp
@@ -0,0 +1,145 @@
+//==- DeadStatusChecker.cpp - Check for impossible status -*- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines a DeadStatus, a checker that looks for impossible
+//  status checks.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class DeadStatusChecker : public Checker {
+  class Walker : public RecursiveASTVisitor {
+BugReporter 
+const DeadStatusChecker *Checker;
+AnalysisDeclContext *AC;
+llvm::SmallPtrSet throwingNews;
+
+const Expr *hasNullptr(const BinaryOperator *BO) const {
+  const Expr *ret = nullptr;
+  const Expr *E[2] = {BO->getLHS()->IgnoreParenCasts(),
+  BO->getRHS()->IgnoreParenCasts()};
+  const Expr *EO[2] = {E[1], E[0]};
+  for (int i = 0; i < 2; i++) {
+bool ok = false;
+if (isa(E[i]) || isa(E[i]) ||
+(isa(E[i]) &&
+ dyn_cast(E[i])->getValue() == 0)) {
+  ok = true;
+}
+if (ok) {
+  ret = EO[i];
+  break;
+}
+  }
+  return ret;
+}
+
+const Expr *hasThrowingNew(const BinaryOperator *BO) const {
+  const Expr *ret = nullptr;
+  const Expr *rhs = BO->getRHS()->IgnoreParenCasts();
+  if (isa(rhs)) {
+auto NE = static_cast(rhs);
+if (!NE->shouldNullCheckAllocation()) {
+  ret = BO->getLHS()->IgnoreParenCasts();
+}
+  }
+  return ret;
+}
+
+bool hasThrowingNew(const VarDecl *VD) const {
+  bool ret = false;
+  const Expr *E = VD->getInit();
+  if (E != nullptr) {
+E = E->IgnoreParenCasts();
+if (isa(E)) {
+  auto NE = static_cast(E);
+  if (!NE->shouldNullCheckAllocation()) {
+ret = true;
+  }
+}
+  }
+  return ret;
+}
+
+  public:
+explicit Walker(BugReporter , const DeadStatusChecker *C,
+AnalysisDeclContext *AC)
+: BR(BR), Checker(C), AC(AC) {}
+bool VisitBinaryOperator(const BinaryOperator *BO) {
+  const Expr *E = nullptr;
+  BinaryOperator::Opcode Op = BO->getOpcode();
+  foo();
+  if (BinaryOperator::isEqualityOp(Op)) {
+E = hasNullptr(BO);
+

[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-06-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D46042#1121674, @rjmccall wrote:

> > I think we should revert this for now. Adding the alignment attribute to 
> > all Intel vector typedefs is a bigger change than it seems.
>
> Ugh.  That is just an awful language rule.   Would it be reasonable to 
> restrict it to only attributes spelled with `__declspec(align(N))` rather 
> than `__attribute__((aligned(N)))`, or is that too invasive in the alignment 
> computation?


When we were working on the record layout code, I didn't want to do that 
because users often structure their portability headers to check for 
`__clang__` first because clang also defines `_MSC_VER` and `__GNUC__`. I felt 
it would be best if the alignment attributes were as interchangeable as 
possible. They are very common.

Maybe checking the spelling of the packing attribute would work better. The GCC 
`__attribute__` spelling would ignore what we called "required alignment", 
meaning alignment required by explicit attributes and not the normal `alignof`.


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 149867.
emmettneyman added a comment.

- Refactored FuzzerInitialize into library


Repository:
  rC Clang

https://reviews.llvm.org/D47666

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
  tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h

Index: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
===
--- /dev/null
+++ tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.h
@@ -0,0 +1,20 @@
+//==-- fuzzer_initialize.h - Fuzz Clang ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a function that returns the command line arguments for a specific
+// call to the fuzz target.
+//
+//===--===//
+
+#include "src/libfuzzer/libfuzzer_macro.h"
+
+namespace clang_fuzzer {
+const std::vector& GetCLArgs();
+}
+
Index: tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
===
--- tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
+++ tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp
@@ -1,4 +1,4 @@
-//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --===//
+//===-- fuzzer_initialize.cpp - Fuzz Clang ===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,24 +8,27 @@
 //===--===//
 ///
 /// \file
-/// This file implements a function that runs Clang on a single
-///  input and uses libprotobuf-mutator to find new inputs. This function is
-///  then linked into the Fuzzer library.
+/// This file implements two functions: one that returns the command line 
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments. 
 ///
 //===--===//
 
-#include "cxx_proto.pb.h"
-#include "handle-cxx/handle_cxx.h"
-#include "proto-to-cxx/proto_to_cxx.h"
+#include "fuzzer_initialize.h"
 
-#include "src/libfuzzer/libfuzzer_macro.h"
+using namespace clang_fuzzer;
 
-#include 
 
-using namespace clang_fuzzer;
+namespace clang_fuzzer {
 
 static std::vector CLArgs;
 
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
   CLArgs.push_back("-O2");
   for (int I = 1; I < *argc; I++) {
@@ -38,7 +41,3 @@
   return 0;
 }
 
-DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
-  auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
-}
Index: tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-fuzzer/fuzzer-initialize/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
+
+add_clang_library(clangFuzzerInit fuzzer_initialize.cpp)
Index: tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -17,28 +17,14 @@
 #include "cxx_proto.pb.h"
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
-
+#include "fuzzer-initialize/fuzzer_initialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
 #include 
 
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -39,6 +39,9 @@
 
   # Build the protobuf->C++ translation library and driver.
   add_clang_subdirectory(proto-to-cxx)
+  
+  # Build the fuzzer initialization library.
+  add_clang_subdirectory(fuzzer-initialize)
 
   # Build the protobuf fuzzer
   add_clang_executable(clang-proto-fuzzer
@@ -52,6 +55,7 @@
 ${PROTOBUF_LIBRARIES}
 ${LLVM_LIB_FUZZING_ENGINE}
 clangCXXProto
+

[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device

2018-06-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh, I see, because you're worried that the host code might contain 
`dynamic_cast` or similar features which would complain if RTTI were disabled.

`getLangOpts().CUDAIsDevice` implies `getLangOpts().CUDA`, so I think you can 
just check the former.  Otherwise LGTM.


https://reviews.llvm.org/D47694



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-06-04 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.

Okay,  We can try this, then.


Repository:
  rC Clang

https://reviews.llvm.org/D47564



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


[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-06-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D46042#1121648, @rnk wrote:

> It's the typedef alignment changes that are causing problems for us, not the 
> MaxVectorAlign changes. That makes more sense. The new alignment attribute 
> breaks our implementation of `_mm256_loadu_ps`, because the packed struct 
> ends up with a 32-byte alignment. Here's the implementation:
>
>   static __inline __m256 __DEFAULT_FN_ATTRS
>   _mm256_loadu_ps(float const *__p)
>   {
> struct __loadu_ps {
>   __m256 __v;
> } __attribute__((__packed__, __may_alias__));
> return ((struct __loadu_ps*)__p)->__v;
>   }
>
>
> And clang's -fdump-record-layouts says:
>
>   *** Dumping AST Record Layout
>0 | struct __loadu_ps
>0 |   __m256 __v
>  | [sizeof=32, align=32]
>
>
> I think the problem is that `__attribute__((aligned(N)))` beats 
> `__attribute__((packed))` on Windows to match MSVC's behavior with 
> `__declspec(align(N))`.
>
> I think we should revert this for now. Adding the alignment attribute to all 
> Intel vector typedefs is a bigger change than it seems.


Ugh.  That is just an awful language rule.   Would it be reasonable to restrict 
it to only attributes spelled with `__declspec(align(N))` rather than 
`__attribute__((aligned(N)))`, or is that too invasive in the alignment 
computation?


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/CMakeLists.txt:48
 ExampleClangProtoFuzzer.cpp
+FuzzerInitialize.cpp
 )

Rather than compiling `FuzzerInitialize.cpp` into the binary, can we make it a 
library like `handle-cxx` or `proto-to-cxx`?



Comment at: tools/clang-fuzzer/FuzzerInitialize.cpp:17
 
 #include "cxx_proto.pb.h"
 

Do we need this include?



Comment at: tools/clang-fuzzer/FuzzerInitialize.h:20
+
+#include 
+

Why do we need these includes in the header?  Doesn't look like they're used 
here.


Repository:
  rC Clang

https://reviews.llvm.org/D47666



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


[PATCH] D47291: Proposal to make rtti errors more generic.

2018-06-04 Thread Warren Ristow via Phabricator via cfe-commits
wristow added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6729
 def err_no_dynamic_cast_with_fno_rtti : Error<
-  "cannot use dynamic_cast with -fno-rtti">;
+  "use of dynamic_cast requires enabling RTTI">;
 

Sunil_Srivastava wrote:
> probinson wrote:
> > filcab wrote:
> > > I'd prefer to have the way to enable RTTI mentioned in the message. Could 
> > > we have something like `ToolChain::getRTTIMode()` and have a "RTTI was 
> > > on/of" or "RTTI defaulted to on/off"? That way we'd be able to have a 
> > > message similar to the current one (mentioning "you passed -fno-rtti") on 
> > > platforms that default to RTTI=on, and have your updated message 
> > > (possibly with a mention of "use -frtti") on platforms that default to 
> > > RTTI=off.
> > > 
> > > (This is a minor usability comment about this patch, I don't consider it 
> > > a blocker or anything)
> > If the options are spelled differently for clang-cl and we had a way to 
> > retrieve the appropriate spellings, providing the option to use in the 
> > diagnostic does seem like a nice touch.
> The idea of suggestion as to how-to-turn-on-rtti is appealing, but it is not 
> trivial.
> 
> First, clang-cl does not give this warning at all, so the issue is moot for 
> clang-cl.
> 
> For unix-line command-line, if the default RTTI mode in ENABLED (the 
> unknown-linux)
> then this warning appears only if the user gives -fno-rtti options, so again 
> we do
> not need to say anything more.
> 
> The only cases left are compilers a where the default RTTI mode is DISABLED. 
> Here an addendum like '[-frtti]' may make sense. AFAIK, PS4 is the only 
> compiler
> with this default, but there may be other such private compilers.
> 
> So should we append '[-frtti]' if Target.getTriple().isPS4() is true?
> So should we append '[-frtti]' if Target.getTriple().isPS4() is true?

Personally, I'd be OK with producing a suggestion of how to enable RTTI based 
on the PS4 triple.  But I'd also be OK with not enhancing this diagnostic to 
suggest how to turn on RTTI (that is, going with the patch as originally 
proposed here).

If clang-cl produced a warning when a dynamic_cast or typeid construct was 
encountered in `/GR-` mode, then I'd feel it's worth complicating the code to 
provide a target-sensitive way for advising the user how to turn RTTI on.  But 
clang-cl doesn't produce a warning in that case, so the effort to add the 
framework for producing a target-sensitive warning doesn't seem worth it to me.

Improving clang-cl to produce a diagnostic in this `/GR-` situation seems like 
a good idea, but separate from this proposed patch.  If that work gets done at 
some point, then it would be natural to revisit this diagnostic at that time.


Repository:
  rC Clang

https://reviews.llvm.org/D47291



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


r333958 - Revert r333791 "Cap "voluntary" vector alignment at 16 for all Darwin platforms."

2018-06-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Jun  4 14:39:20 2018
New Revision: 333958

URL: http://llvm.org/viewvc/llvm-project?rev=333958=rev
Log:
Revert r333791 "Cap "voluntary" vector alignment at 16 for all Darwin 
platforms."

Adding __attribute__((aligned(32))) to __m256 breaks the implementation
of _mm256_loadu_ps on Windows. On Windows, alignment attributes have
higher precedence than packing attributes.

We also might want to carefully consider the consequences of changing
our vector typedefs, since many users copy them and invent their own
new, non-Intel specific vector type names.

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/test/CodeGen/arm-swiftcall.c
cfe/trunk/test/CodeGen/vector-alignment.c
cfe/trunk/test/CodeGenCXX/align-avx-complete-objects.cpp

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=333958=333957=333958=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Mon Jun  4 14:39:20 2018
@@ -113,9 +113,6 @@ public:
 }
 
 this->MCountName = "\01mcount";
-
-// Cap vector alignment at 16 bytes for all Darwin platforms.
-this->MaxVectorAlign = 128;
   }
 
   std::string isValidSectionSpecifier(StringRef SR) const override {

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=333958=333957=333958=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Mon Jun  4 14:39:20 2018
@@ -421,6 +421,7 @@ public:
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 SuitableAlign = 128;
+MaxVectorAlign = 256;
 // The watchOS simulator uses the builtin bool type for Objective-C.
 llvm::Triple T = llvm::Triple(Triple);
 if (T.isWatchOS())
@@ -436,6 +437,9 @@ public:
 if (!DarwinTargetInfo::handleTargetFeatures(Features,
   Diags))
   return false;
+// We now know the features we have: we can decide how to align vectors.
+MaxVectorAlign =
+hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
 return true;
   }
 };
@@ -798,6 +802,9 @@ public:
 if (!DarwinTargetInfo::handleTargetFeatures(Features,
   Diags))
   return false;
+// We now know the features we have: we can decide how to align vectors.
+MaxVectorAlign =
+hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
 return true;
   }
 };

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333958=333957=333958=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun  4 14:39:20 2018
@@ -8885,20 +8885,18 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_movdqa64store128_mask:
   case X86::BI__builtin_ia32_storeaps128_mask:
   case X86::BI__builtin_ia32_storeapd128_mask:
-return EmitX86MaskedStore(*this, Ops, 16);
-
   case X86::BI__builtin_ia32_movdqa32store256_mask:
   case X86::BI__builtin_ia32_movdqa64store256_mask:
   case X86::BI__builtin_ia32_storeaps256_mask:
   case X86::BI__builtin_ia32_storeapd256_mask:
-return EmitX86MaskedStore(*this, Ops, 32);
-
   case X86::BI__builtin_ia32_movdqa32store512_mask:
   case X86::BI__builtin_ia32_movdqa64store512_mask:
   case X86::BI__builtin_ia32_storeaps512_mask:
-  case X86::BI__builtin_ia32_storeapd512_mask:
-return EmitX86MaskedStore(*this, Ops, 64);
-
+  case X86::BI__builtin_ia32_storeapd512_mask: {
+unsigned Align =
+  getContext().getTypeAlignInChars(E->getArg(1)->getType()).getQuantity();
+return EmitX86MaskedStore(*this, Ops, Align);
+  }
   case X86::BI__builtin_ia32_loadups128_mask:
   case X86::BI__builtin_ia32_loadups256_mask:
   case X86::BI__builtin_ia32_loadups512_mask:
@@ -8919,25 +8917,26 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_loaddqudi512_mask:
 return EmitX86MaskedLoad(*this, Ops, 1);
 
-  case X86::BI__builtin_ia32_loadaps128_mask:
-  case X86::BI__builtin_ia32_loadapd128_mask:
   case X86::BI__builtin_ia32_loadss128_mask:
   case X86::BI__builtin_ia32_loadsd128_mask:
-  case X86::BI__builtin_ia32_movdqa32load128_mask:
-  case X86::BI__builtin_ia32_movdqa64load128_mask:
-return EmitX86MaskedLoad(*this, Ops, 16);
+return EmitX86MaskedLoad(*this, Ops, 1);
 
+  case 

[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added a comment.

In https://reviews.llvm.org/D47666#1121608, @emmettneyman wrote:

> - Updated and added header comments to two new files. Deleted loop fuzzer 
> files.


I will commit the loop fuzzer files in a future patch.


Repository:
  rC Clang

https://reviews.llvm.org/D47666



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


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-04 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 149856.
juliehockett marked 4 inline comments as done.
juliehockett added a comment.

Addressing comments


https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Generators.cpp
  clang-doc/Generators.h
  clang-doc/Representation.h
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,250 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/A.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Bc.yaml | FileCheck %s --check-prefix=CHECK-BC
+// RUN: cat %t/docs/B.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/C.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/D.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/E.yaml | FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/E/ProtectedMethod.yaml | FileCheck %s --check-prefix=CHECK-EPM
+// RUN: cat %t/docs/E/E.yaml | FileCheck %s --check-prefix=CHECK-ECON
+// RUN: cat %t/docs/E/'~E.yaml' | FileCheck %s --check-prefix=CHECK-EDES
+// RUN: cat %t/docs/F.yaml | FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/X.yaml | FileCheck %s --check-prefix=CHECK-X
+// RUN: cat %t/docs/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
+// RUN: cat %t/docs/H.yaml | FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/H/I.yaml | FileCheck %s --check-prefix=CHECK-I
+
+union A { int X; int Y; };
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-A-NEXT: Name:'A'
+// CHECK-A-NEXT: DefLocation: 
+// CHECK-A-NEXT:   LineNumber:  21
+// CHECK-A-NEXT:   Filename:'{{.*}}'
+// CHECK-A-NEXT: TagType: Union
+// CHECK-A-NEXT: Members: 
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'X'
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'Y'
+// CHECK-A-NEXT: ...
+
+
+enum B { X, Y };
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: 'FC07BD34D5E77782C263FA97929EA8753740'
+// CHECK-B-NEXT: Name:'B'
+// CHECK-B-NEXT: DefLocation: 
+// CHECK-B-NEXT:   LineNumber:  40
+// CHECK-B-NEXT:   Filename:'{{.*}}'
+// CHECK-B-NEXT: Members: 
+// CHECK-B-NEXT:   - 'X'
+// CHECK-B-NEXT:   - 'Y'
+// CHECK-B-NEXT: ...
+
+enum class Bc { A, B };
+
+// CHECK-BC: ---
+// CHECK-BC-NEXT: USR: '1E3438A08BA22025C0B46289FF0686F92C8924C5'
+// CHECK-BC-NEXT: Name:'Bc'
+// CHECK-BC-NEXT: DefLocation: 
+// CHECK-BC-NEXT:   LineNumber:  53
+// CHECK-BC-NEXT:   Filename:'{{.*}}'
+// CHECK-BC-NEXT: Scoped:  true
+// CHECK-BC-NEXT: Members: 
+// CHECK-BC-NEXT:   - 'A'
+// CHECK-BC-NEXT:   - 'B'
+// CHECK-BC-NEXT: ...
+
+struct C { int i; };
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-C-NEXT: Name:'C'
+// CHECK-C-NEXT: DefLocation: 
+// CHECK-C-NEXT:   LineNumber:  67
+// CHECK-C-NEXT:   Filename:'{{.*}}'
+// CHECK-C-NEXT: Members: 
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'i'
+// CHECK-C-NEXT: ...
+
+class D {};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-D-NEXT: Name:'D'
+// CHECK-D-NEXT: DefLocation: 
+// CHECK-D-NEXT:   LineNumber:  81
+// CHECK-D-NEXT:   Filename:'{{.*}}'
+// CHECK-D-NEXT: TagType: Class
+// CHECK-D-NEXT: ...
+
+class E {
+public:
+  E() {}
+
+// CHECK-ECON: ---
+// CHECK-ECON-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: Namespace:   
+// CHECK-ECON-NEXT:   - Type:Record
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: DefLocation:
+// CHECK-ECON-NEXT:   LineNumber:  94
+// CHECK-ECON-NEXT:   Filename:'{{.*}}'
+// CHECK-ECON-NEXT: IsMethod:true
+// CHECK-ECON-NEXT: Parent:  
+// CHECK-ECON-NEXT:   Type:Record
+// CHECK-ECON-NEXT:   Name:'E'
+// CHECK-ECON-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: ReturnType:  
+// CHECK-ECON-NEXT:   Type:
+// CHECK-ECON-NEXT: Name:'void'
+// CHECK-ECON-NEXT: ...
+  

[PATCH] D46700: [ThinLTO] Add testing of new summary index format to a couple CFI tests

2018-06-04 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D46700



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 149854.
emmettneyman added a comment.

- Another edit to the file header comments.


Repository:
  rC Clang

https://reviews.llvm.org/D47666

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/FuzzerInitialize.cpp
  tools/clang-fuzzer/FuzzerInitialize.h

Index: tools/clang-fuzzer/FuzzerInitialize.h
===
--- /dev/null
+++ tools/clang-fuzzer/FuzzerInitialize.h
@@ -0,0 +1,25 @@
+//==-- FuzzerInitialize.h - Fuzz Clang -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a function that returns the command line arguments for a specific
+// call to the fuzz target.
+//
+//===--===//
+
+#include "handle-cxx/handle_cxx.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+
+#include "src/libfuzzer/libfuzzer_macro.h"
+
+#include 
+
+namespace clang_fuzzer {
+const std::vector& GetCLArgs();
+}
+
Index: tools/clang-fuzzer/FuzzerInitialize.cpp
===
--- tools/clang-fuzzer/FuzzerInitialize.cpp
+++ tools/clang-fuzzer/FuzzerInitialize.cpp
@@ -1,4 +1,4 @@
-//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --===//
+//===-- FuzzerInitialize.cpp - Fuzz Clang -===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,24 +8,29 @@
 //===--===//
 ///
 /// \file
-/// This file implements a function that runs Clang on a single
-///  input and uses libprotobuf-mutator to find new inputs. This function is
-///  then linked into the Fuzzer library.
+/// This file implements two functions: one that returns the command line 
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments. 
 ///
 //===--===//
 
 #include "cxx_proto.pb.h"
-#include "handle-cxx/handle_cxx.h"
-#include "proto-to-cxx/proto_to_cxx.h"
 
-#include "src/libfuzzer/libfuzzer_macro.h"
-
-#include 
+#include "FuzzerInitialize.h"
 
 using namespace clang_fuzzer;
 
+
+namespace clang_fuzzer {
+
 static std::vector CLArgs;
 
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
   CLArgs.push_back("-O2");
   for (int I = 1; I < *argc; I++) {
@@ -38,7 +43,3 @@
   return 0;
 }
 
-DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
-  auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
-}
Index: tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -18,27 +18,14 @@
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
 
+#include "FuzzerInitialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
 #include 
 
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -14,6 +14,7 @@
   ClangFuzzer.cpp
   DummyClangFuzzer.cpp
   ExampleClangProtoFuzzer.cpp
+  FuzzerInitialize.cpp
   )
 
 if(CLANG_ENABLE_PROTO_FUZZER)
@@ -44,6 +45,7 @@
   add_clang_executable(clang-proto-fuzzer
 ${DUMMY_MAIN}
 ExampleClangProtoFuzzer.cpp
+FuzzerInitialize.cpp
 )
 
   target_link_libraries(clang-proto-fuzzer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-06-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

It's the typedef alignment changes that are causing problems for us, not the 
MaxVectorAlign changes. That makes more sense. The new alignment attribute 
breaks our implementation of `_mm256_loadu_ps`, because the packed struct ends 
up with a 32-byte alignment. Here's the implementation:

  static __inline __m256 __DEFAULT_FN_ATTRS
  _mm256_loadu_ps(float const *__p)
  {
struct __loadu_ps {
  __m256 __v;
} __attribute__((__packed__, __may_alias__));
return ((struct __loadu_ps*)__p)->__v;
  }

And clang's -fdump-record-layouts says:

  *** Dumping AST Record Layout
   0 | struct __loadu_ps
   0 |   __m256 __v
 | [sizeof=32, align=32]

I think the problem is that `__attribute__((aligned(N)))` beats 
`__attribute__((packed))` on Windows to match MSVC's behavior with 
`__declspec(align(N))`.

I think we should revert this for now. Adding the alignment attribute to all 
Intel vector typedefs is a bigger change than it seems.


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


r333955 - Update for an LLVM header file move

2018-06-04 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Jun  4 14:23:29 2018
New Revision: 333955

URL: http://llvm.org/viewvc/llvm-project?rev=333955=rev
Log:
Update for an LLVM header file move

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=333955=333954=333955=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jun  4 14:23:29 2018
@@ -29,7 +29,7 @@
 #include "clang/CodeGen/SwiftCallingConv.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/Analysis/Utils/Local.h"
+#include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/CallSite.h"


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


[PATCH] D47291: Proposal to make rtti errors more generic.

2018-06-04 Thread Sunil Srivastava via Phabricator via cfe-commits
Sunil_Srivastava added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6729
 def err_no_dynamic_cast_with_fno_rtti : Error<
-  "cannot use dynamic_cast with -fno-rtti">;
+  "use of dynamic_cast requires enabling RTTI">;
 

probinson wrote:
> filcab wrote:
> > I'd prefer to have the way to enable RTTI mentioned in the message. Could 
> > we have something like `ToolChain::getRTTIMode()` and have a "RTTI was 
> > on/of" or "RTTI defaulted to on/off"? That way we'd be able to have a 
> > message similar to the current one (mentioning "you passed -fno-rtti") on 
> > platforms that default to RTTI=on, and have your updated message (possibly 
> > with a mention of "use -frtti") on platforms that default to RTTI=off.
> > 
> > (This is a minor usability comment about this patch, I don't consider it a 
> > blocker or anything)
> If the options are spelled differently for clang-cl and we had a way to 
> retrieve the appropriate spellings, providing the option to use in the 
> diagnostic does seem like a nice touch.
The idea of suggestion as to how-to-turn-on-rtti is appealing, but it is not 
trivial.

First, clang-cl does not give this warning at all, so the issue is moot for 
clang-cl.

For unix-line command-line, if the default RTTI mode in ENABLED (the 
unknown-linux)
then this warning appears only if the user gives -fno-rtti options, so again we 
do
not need to say anything more.

The only cases left are compilers a where the default RTTI mode is DISABLED. 
Here an addendum like '[-frtti]' may make sense. AFAIK, PS4 is the only compiler
with this default, but there may be other such private compilers.

So should we append '[-frtti]' if Target.getTriple().isPS4() is true?


Repository:
  rC Clang

https://reviews.llvm.org/D47291



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


[PATCH] D46700: [ThinLTO] Add testing of new summary index format to a couple CFI tests

2018-06-04 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.
Herald added a subscriber: steven_wu.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D46700



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


[PATCH] D46042: Cap vector alignment at 16 for all Darwin platforms

2018-06-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This change appears to have caused some blink vector math unit tests to fail on 
Windows. We are tracking it at https://crbug.com/849251.

It has a pretty small reproducer:

  #include 
  __m256 loadit(__m256 *p) { return _mm256_loadu_ps((const float *)p); }

Compile for x86_64-windows-msvc with -mavx, and before this change we got this 
IR: `%0 = load <8 x float>, <8 x float>* %p, align 1`
After we get this IR: `%0 = load <8 x float>, <8 x float>* %p, align 32`

This is surprising. I'll keep debugging.


Repository:
  rC Clang

https://reviews.llvm.org/D46042



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 149851.
emmettneyman added a comment.

- Fixed file header comment


Repository:
  rC Clang

https://reviews.llvm.org/D47666

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/FuzzerInitialize.cpp
  tools/clang-fuzzer/FuzzerInitialize.h

Index: tools/clang-fuzzer/FuzzerInitialize.h
===
--- /dev/null
+++ tools/clang-fuzzer/FuzzerInitialize.h
@@ -0,0 +1,25 @@
+//==-- FuzzerInitialize.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a function that returns the command line arguments for a specific
+// call to the fuzz target.
+//
+//===--===//
+
+#include "handle-cxx/handle_cxx.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+
+#include "src/libfuzzer/libfuzzer_macro.h"
+
+#include 
+
+namespace clang_fuzzer {
+const std::vector& GetCLArgs();
+}
+
Index: tools/clang-fuzzer/FuzzerInitialize.cpp
===
--- tools/clang-fuzzer/FuzzerInitialize.cpp
+++ tools/clang-fuzzer/FuzzerInitialize.cpp
@@ -1,4 +1,4 @@
-//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --===//
+//===-- FuzzerInitialize.cpp - Fuzz Clang -===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,24 +8,29 @@
 //===--===//
 ///
 /// \file
-/// This file implements a function that runs Clang on a single
-///  input and uses libprotobuf-mutator to find new inputs. This function is
-///  then linked into the Fuzzer library.
+/// This file implements two functions: one that returns the command line 
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments. 
 ///
 //===--===//
 
 #include "cxx_proto.pb.h"
-#include "handle-cxx/handle_cxx.h"
-#include "proto-to-cxx/proto_to_cxx.h"
 
-#include "src/libfuzzer/libfuzzer_macro.h"
-
-#include 
+#include "FuzzerInitialize.h"
 
 using namespace clang_fuzzer;
 
+
+namespace clang_fuzzer {
+
 static std::vector CLArgs;
 
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
   CLArgs.push_back("-O2");
   for (int I = 1; I < *argc; I++) {
@@ -38,7 +43,3 @@
   return 0;
 }
 
-DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
-  auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
-}
Index: tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -18,27 +18,14 @@
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
 
+#include "FuzzerInitialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
 #include 
 
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -14,6 +14,7 @@
   ClangFuzzer.cpp
   DummyClangFuzzer.cpp
   ExampleClangProtoFuzzer.cpp
+  FuzzerInitialize.cpp
   )
 
 if(CLANG_ENABLE_PROTO_FUZZER)
@@ -44,6 +45,7 @@
   add_clang_executable(clang-proto-fuzzer
 ${DUMMY_MAIN}
 ExampleClangProtoFuzzer.cpp
+FuzzerInitialize.cpp
 )
 
   target_link_libraries(clang-proto-fuzzer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 149850.
emmettneyman added a comment.

- Updated and added header comments to two new files. Deleted loop fuzzer files.


Repository:
  rC Clang

https://reviews.llvm.org/D47666

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/FuzzerInitialize.cpp
  tools/clang-fuzzer/FuzzerInitialize.h

Index: tools/clang-fuzzer/FuzzerInitialize.h
===
--- /dev/null
+++ tools/clang-fuzzer/FuzzerInitialize.h
@@ -0,0 +1,25 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a function that returns the command line arguments for a specific
+// call to the fuzz target.
+//
+//===--===//
+
+#include "handle-cxx/handle_cxx.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+
+#include "src/libfuzzer/libfuzzer_macro.h"
+
+#include 
+
+namespace clang_fuzzer {
+const std::vector& GetCLArgs();
+}
+
Index: tools/clang-fuzzer/FuzzerInitialize.cpp
===
--- tools/clang-fuzzer/FuzzerInitialize.cpp
+++ tools/clang-fuzzer/FuzzerInitialize.cpp
@@ -1,4 +1,4 @@
-//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --===//
+//===-- FuzzerInitialize.cpp - Fuzz Clang -===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,24 +8,29 @@
 //===--===//
 ///
 /// \file
-/// This file implements a function that runs Clang on a single
-///  input and uses libprotobuf-mutator to find new inputs. This function is
-///  then linked into the Fuzzer library.
+/// This file implements two functions: one that returns the command line 
+/// arguments for a given call to the fuzz target and one that initializes
+/// the fuzzer with the correct command line arguments. 
 ///
 //===--===//
 
 #include "cxx_proto.pb.h"
-#include "handle-cxx/handle_cxx.h"
-#include "proto-to-cxx/proto_to_cxx.h"
 
-#include "src/libfuzzer/libfuzzer_macro.h"
-
-#include 
+#include "FuzzerInitialize.h"
 
 using namespace clang_fuzzer;
 
+
+namespace clang_fuzzer {
+
 static std::vector CLArgs;
 
+const std::vector& GetCLArgs() {
+  return CLArgs;
+}
+
+}
+
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
   CLArgs.push_back("-O2");
   for (int I = 1; I < *argc; I++) {
@@ -38,7 +43,3 @@
   return 0;
 }
 
-DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
-  auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
-}
Index: tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -18,27 +18,14 @@
 #include "handle-cxx/handle_cxx.h"
 #include "proto-to-cxx/proto_to_cxx.h"
 
+#include "FuzzerInitialize.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
 #include 
 
 using namespace clang_fuzzer;
 
-static std::vector CLArgs;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
-  CLArgs.push_back("-O2");
-  for (int I = 1; I < *argc; I++) {
-if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
-  for (I++; I < *argc; I++)
-CLArgs.push_back((*argv)[I]);
-  break;
-}
-  }
-  return 0;
-}
-
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, CLArgs);
+  HandleCXX(S, GetCLArgs());
 }
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -14,6 +14,7 @@
   ClangFuzzer.cpp
   DummyClangFuzzer.cpp
   ExampleClangProtoFuzzer.cpp
+  FuzzerInitialize.cpp
   )
 
 if(CLANG_ENABLE_PROTO_FUZZER)
@@ -44,6 +45,7 @@
   add_clang_executable(clang-proto-fuzzer
 ${DUMMY_MAIN}
 ExampleClangProtoFuzzer.cpp
+FuzzerInitialize.cpp
 )
 
   target_link_libraries(clang-proto-fuzzer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47607: [libcxx] Almost fix some UB in and

2018-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333948: Fix a strict aliasing violation in map and 
unordered_map. (authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47607?vs=149449=149847#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47607

Files:
  libcxx/trunk/include/__hash_table
  libcxx/trunk/include/__tree
  libcxx/trunk/include/map
  libcxx/trunk/include/unordered_map

Index: libcxx/trunk/include/__tree
===
--- libcxx/trunk/include/__tree
+++ libcxx/trunk/include/__tree
@@ -37,13 +37,8 @@
 template  class __tree_node_base;
 template  class __tree_node;
 
-#ifndef _LIBCPP_CXX03_LANG
-template 
-union __value_type;
-#else
 template 
 struct __value_type;
-#endif
 
 template ::value && !__libcpp_is_final<_Compare>::value>
@@ -569,10 +564,9 @@
   static __container_value_type* __get_ptr(__node_value_type& __n) {
 return _VSTD::addressof(__n);
   }
-
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __container_value_type&& __move(__node_value_type& __v) {
+  static __container_value_type&& __move(__node_value_type& __v) {
 return _VSTD::move(__v);
   }
 #endif
@@ -584,14 +578,13 @@
   typedef _Tp  mapped_type;
   typedef __value_type<_Key, _Tp>  __node_value_type;
   typedef pair__container_value_type;
-  typedef pair<_Key, _Tp>  __nc_value_type;
   typedef __container_value_type   __map_value_type;
   static const bool __is_map = true;
 
   _LIBCPP_INLINE_VISIBILITY
   static key_type const&
   __get_key(__node_value_type const& __t) {
-return __t.__cc.first;
+return __t.__get_value().first;
   }
 
   template 
@@ -605,7 +598,7 @@
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type const&
   __get_value(__node_value_type const& __t) {
-return __t.__cc;
+return __t.__get_value();
   }
 
   template 
@@ -618,13 +611,13 @@
 
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type* __get_ptr(__node_value_type& __n) {
-return _VSTD::addressof(__n.__cc);
+return _VSTD::addressof(__n.__get_value());
   }
 
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __nc_value_type&& __move(__node_value_type& __v) {
-return _VSTD::move(__v.__nc);
+  static pair __move(__node_value_type& __v) {
+return __v.__move();
   }
 #endif
 };
Index: libcxx/trunk/include/map
===
--- libcxx/trunk/include/map
+++ libcxx/trunk/include/map
@@ -470,13 +470,13 @@
 const _Compare& key_comp() const _NOEXCEPT {return *this;}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _CP& __x, const _CP& __y) const
-{return static_cast(*this)(__x.__cc.first, __y.__cc.first);}
+{return static_cast(*this)(__x.__get_value().first, __y.__get_value().first);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _CP& __x, const _Key& __y) const
-{return static_cast(*this)(__x.__cc.first, __y);}
+{return static_cast(*this)(__x.__get_value().first, __y);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Key& __x, const _CP& __y) const
-{return static_cast(*this)(__x, __y.__cc.first);}
+{return static_cast(*this)(__x, __y.__get_value().first);}
 void swap(__map_value_compare&__y)
 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
 {
@@ -489,13 +489,13 @@
 _LIBCPP_INLINE_VISIBILITY
 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
 operator () ( const _K2& __x, const _CP& __y ) const
-{return static_cast(*this) (__x, __y.__cc.first);}
+{return static_cast(*this) (__x, __y.__get_value().first);}
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
 operator () (const _CP& __x, const _K2& __y) const
-{return static_cast(*this) (__x.__cc.first, __y);}
+{return static_cast(*this) (__x.__get_value().first, __y);}
 #endif
 };
 
@@ -518,13 +518,13 @@
 
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _CP& __x, const _CP& __y) const
-{return comp(__x.__cc.first, __y.__cc.first);}
+{return comp(__x.__get_value().first, __y.__get_value().first);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _CP& __x, const _Key& __y) const
-{return comp(__x.__cc.first, __y);}
+{return comp(__x.__get_value().first, __y);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Key& __x, const _CP& __y) const
-{return comp(__x, __y.__cc.first);}
+{return comp(__x, __y.__get_value().first);}
 void 

[libcxx] r333948 - Fix a strict aliasing violation in map and unordered_map.

2018-06-04 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Jun  4 13:38:23 2018
New Revision: 333948

URL: http://llvm.org/viewvc/llvm-project?rev=333948=rev
Log:
Fix a strict aliasing violation in map and unordered_map.

These containers type-punned between pair and pair as an
optimization. This commit instead provides access to the pair via a pair of
references that assign through to the underlying object. It's still undefined to
mutate a const object, but clang doesn't optimize on this for data members, so
this should be safe.

Differential revision: https://reviews.llvm.org/D47607

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__tree
libcxx/trunk/include/map
libcxx/trunk/include/unordered_map

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=333948=333947=333948=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Mon Jun  4 13:38:23 2018
@@ -32,13 +32,8 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_CXX03_LANG
-template 
-union __hash_value_type;
-#else
 template 
 struct __hash_value_type;
-#endif
 
 template ::value && !__libcpp_is_final<_Hash>::value>
@@ -172,7 +167,7 @@ struct __hash_key_value_types {
   }
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __container_value_type&& __move(__node_value_type& __v) {
+  static __container_value_type&& __move(__node_value_type& __v) {
 return _VSTD::move(__v);
   }
 #endif
@@ -184,7 +179,6 @@ struct __hash_key_value_types<__hash_val
   typedef _Tp  mapped_type;
   typedef __hash_value_type<_Key, _Tp> __node_value_type;
   typedef pair__container_value_type;
-  typedef pair<_Key, _Tp>  __nc_value_type;
   typedef __container_value_type   __map_value_type;
   static const bool __is_map = true;
 
@@ -198,7 +192,7 @@ struct __hash_key_value_types<__hash_val
   static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
   __container_value_type const&>::type
   __get_value(_Up& __t) {
-return __t.__cc;
+return __t.__get_value();
   }
 
   template 
@@ -211,12 +205,12 @@ struct __hash_key_value_types<__hash_val
 
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type* __get_ptr(__node_value_type& __n) {
-return _VSTD::addressof(__n.__cc);
+return _VSTD::addressof(__n.__get_value());
   }
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static __nc_value_type&& __move(__node_value_type& __v) {
-return _VSTD::move(__v.__nc);
+  static pair __move(__node_value_type& __v) {
+return __v.__move();
   }
 #endif
 

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=333948=333947=333948=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Mon Jun  4 13:38:23 2018
@@ -37,13 +37,8 @@ template  class __tree_e
 template  class __tree_node_base;
 template  class __tree_node;
 
-#ifndef _LIBCPP_CXX03_LANG
-template 
-union __value_type;
-#else
 template 
 struct __value_type;
-#endif
 
 template ::value && !__libcpp_is_final<_Compare>::value>
@@ -569,10 +564,9 @@ struct __tree_key_value_types {
   static __container_value_type* __get_ptr(__node_value_type& __n) {
 return _VSTD::addressof(__n);
   }
-
 #ifndef _LIBCPP_CXX03_LANG
   _LIBCPP_INLINE_VISIBILITY
-  static  __container_value_type&& __move(__node_value_type& __v) {
+  static __container_value_type&& __move(__node_value_type& __v) {
 return _VSTD::move(__v);
   }
 #endif
@@ -584,14 +578,13 @@ struct __tree_key_value_types<__value_ty
   typedef _Tp  mapped_type;
   typedef __value_type<_Key, _Tp>  __node_value_type;
   typedef pair__container_value_type;
-  typedef pair<_Key, _Tp>  __nc_value_type;
   typedef __container_value_type   __map_value_type;
   static const bool __is_map = true;
 
   _LIBCPP_INLINE_VISIBILITY
   static key_type const&
   __get_key(__node_value_type const& __t) {
-return __t.__cc.first;
+return __t.__get_value().first;
   }
 
   template 
@@ -605,7 +598,7 @@ struct __tree_key_value_types<__value_ty
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type const&
   __get_value(__node_value_type const& __t) {
-return __t.__cc;
+return __t.__get_value();
   }
 
   template 
@@ -618,13 +611,13 @@ struct __tree_key_value_types<__value_ty
 
   _LIBCPP_INLINE_VISIBILITY
   static __container_value_type* __get_ptr(__node_value_type& __n) {
-return _VSTD::addressof(__n.__cc);
+return _VSTD::addressof(__n.__get_value());
   }
 
 #ifndef 

[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-06-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Could you elaborate on what kind of changes you are planning to make in libc++ 
after committing this patch?


https://reviews.llvm.org/D45015



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


[PATCH] D47671: [analyzer] Implement copy elision.

2018-06-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

So having an analyzer-config option would be useful for those codebases that 
are expected to be compiled with less advanced compilers that do not elide 
copies or not doing it aggressively enough. Maybe it is worth to ask on the 
mailing list of the community wants to have an option for this? I am not sure 
though how often the end users end up fine tuning the analyzer. It might be 
nice to have a guide how to do that (and in what circumstances does each of the 
config values make sense).


Repository:
  rC Clang

https://reviews.llvm.org/D47671



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


[PATCH] D47668: [Driver][Fuchsia] Pass LTO flags to linker

2018-06-04 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D47668



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


[PATCH] D44239: [analyzer] Re-enable constructor inlining when lifetime extension through fields occurs.

2018-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333946: [analyzer] Re-enable constructors when lifetime 
extension through fields occurs. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D44239

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/lifetime-extension.cpp

Index: test/Analysis/lifetime-extension.cpp
===
--- test/Analysis/lifetime-extension.cpp
+++ test/Analysis/lifetime-extension.cpp
@@ -46,10 +46,18 @@
   const int  = A().j[1]; // no-crash
   const int  = (A().j[1], A().j[0]); // no-crash
 
-  // FIXME: All of these should be TRUE, but constructors aren't inlined.
-  clang_analyzer_eval(x == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(y == 3); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(z == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x == 1);
+  clang_analyzer_eval(y == 3);
+  clang_analyzer_eval(z == 2);
+#ifdef TEMPORARIES
+  // expected-warning@-4{{TRUE}}
+  // expected-warning@-4{{TRUE}}
+  // expected-warning@-4{{TRUE}}
+#else
+  // expected-warning@-8{{UNKNOWN}}
+  // expected-warning@-8{{UNKNOWN}}
+  // expected-warning@-8{{UNKNOWN}}
+#endif
 }
 } // end namespace pr19539_crash_on_destroying_an_integer
 
@@ -144,8 +152,12 @@
   {
 const bool  = C(true, , ).x; // no-crash
   }
-  // FIXME: Should be TRUE. Should not warn about garbage value.
-  clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(after == before);
+#ifdef TEMPORARIES
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
 }
 
 struct A { // A is an aggregate.
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -181,22 +181,13 @@
   const auto *TOCC = cast(CC);
   if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) {
 if (const ValueDecl *VD = MTE->getExtendingDecl()) {
-  // Pattern-match various forms of lifetime extension that aren't
-  // currently supported by the CFG.
-  // FIXME: Is there a better way to retrieve this information from
-  // the MaterializeTemporaryExpr?
   assert(MTE->getStorageDuration() != SD_FullExpression);
-  if (VD->getType()->isReferenceType()) {
-assert(VD->getType()->isReferenceType());
-if (VD->getType()->getPointeeType().getCanonicalType() !=
-MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
-  // We're lifetime-extended via our field. Automatic destructors
-  // aren't quite working in this case.
-  CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
-}
-  } else {
+  if (!VD->getType()->isReferenceType()) {
 // We're lifetime-extended by a surrounding aggregate.
-// Automatic destructors aren't quite working in this case.
+// Automatic destructors aren't quite working in this case
+// on the CFG side. We should warn the caller about that.
+// FIXME: Is there a better way to retrieve this information from
+// the MaterializeTemporaryExpr?
 CallOpts.IsTemporaryLifetimeExtendedViaAggregate = true;
   }
 }
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -696,12 +696,7 @@
   if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
 return CIP_DisallowedOnce;
 
-  // If the temporary is lifetime-extended by binding a smaller object
-  // within it to a reference, automatic destructors don't work properly.
-  if (CallOpts.IsTemporaryLifetimeExtendedViaSubobject)
-return CIP_DisallowedOnce;
-
-  // If the temporary is lifetime-extended by binding it to a reference-typ
+  // If the temporary is lifetime-extended by binding it to a reference-type
   // field within an aggregate, automatic destructors don't work properly.
   if (CallOpts.IsTemporaryLifetimeExtendedViaAggregate)
 return CIP_DisallowedOnce;
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -106,11 +106,6 @@
 bool IsTemporaryCtorOrDtor = false;
 
 /// This call is a constructor for a temporary that is lifetime-extended
-/// by 

r333946 - [analyzer] Re-enable constructors when lifetime extension through fields occurs.

2018-06-04 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Jun  4 13:18:37 2018
New Revision: 333946

URL: http://llvm.org/viewvc/llvm-project?rev=333946=rev
Log:
[analyzer] Re-enable constructors when lifetime extension through fields occurs.

Temporary object constructor inlining was disabled in r326240 for code like

const int  = A().x;

because automatic destructor for the lifetime-extended object A() was not
working correctly in CFG.

CFG was fixed in r333941, so inlining can be re-enabled. CFG for lifetime
extension through aggregates still needs to be fixed.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/lifetime-extension.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=333946=333945=333946=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Mon 
Jun  4 13:18:37 2018
@@ -106,11 +106,6 @@ public:
 bool IsTemporaryCtorOrDtor = false;
 
 /// This call is a constructor for a temporary that is lifetime-extended
-/// by binding a smaller object within it to a reference, for example
-/// 'const int  = C().x;'.
-bool IsTemporaryLifetimeExtendedViaSubobject = false;
-
-/// This call is a constructor for a temporary that is lifetime-extended
 /// by binding it to a reference-type field within an aggregate,
 /// for example 'A { const C  }; A a = { C() };'
 bool IsTemporaryLifetimeExtendedViaAggregate = false;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=333946=333945=333946=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Mon Jun  4 13:18:37 2018
@@ -181,22 +181,13 @@ SVal ExprEngine::getLocationForConstruct
   const auto *TOCC = cast(CC);
   if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) {
 if (const ValueDecl *VD = MTE->getExtendingDecl()) {
-  // Pattern-match various forms of lifetime extension that aren't
-  // currently supported by the CFG.
-  // FIXME: Is there a better way to retrieve this information from
-  // the MaterializeTemporaryExpr?
   assert(MTE->getStorageDuration() != SD_FullExpression);
-  if (VD->getType()->isReferenceType()) {
-assert(VD->getType()->isReferenceType());
-if (VD->getType()->getPointeeType().getCanonicalType() !=
-MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
-  // We're lifetime-extended via our field. Automatic destructors
-  // aren't quite working in this case.
-  CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
-}
-  } else {
+  if (!VD->getType()->isReferenceType()) {
 // We're lifetime-extended by a surrounding aggregate.
-// Automatic destructors aren't quite working in this case.
+// Automatic destructors aren't quite working in this case
+// on the CFG side. We should warn the caller about that.
+// FIXME: Is there a better way to retrieve this information from
+// the MaterializeTemporaryExpr?
 CallOpts.IsTemporaryLifetimeExtendedViaAggregate = true;
   }
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=333946=333945=333946=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Mon Jun  4 
13:18:37 2018
@@ -696,12 +696,7 @@ ExprEngine::mayInlineCallKind(const Call
   if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
 return CIP_DisallowedOnce;
 
-  // If the temporary is lifetime-extended by binding a smaller object
-  // within it to a reference, automatic destructors don't work properly.
-  if (CallOpts.IsTemporaryLifetimeExtendedViaSubobject)
-return CIP_DisallowedOnce;
-
-  // If the temporary is lifetime-extended by binding it to a reference-typ
+  // If the temporary is lifetime-extended by binding it to a 
reference-type
   // field within an 

[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka requested changes to this revision.
vitalybuka added inline comments.
This revision now requires changes to proceed.



Comment at: tools/clang-fuzzer/FuzzerInitialize.cpp:11
 /// \file
 /// This file implements a function that runs Clang on a single
 ///  input and uses libprotobuf-mutator to find new inputs. This function is

Could you please update this description?



Comment at: tools/clang-fuzzer/experimental/ExampleClangLoopProtoFuzzer.cpp:22
+
+#include "FuzzerInitialize.h"
 

Please move ExampleClangLoopProtoFuzzer into a separate patch


Repository:
  rC Clang

https://reviews.llvm.org/D47666



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


[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a subscriber: dcoughlin.
ddcc added a comment.

In https://reviews.llvm.org/D47726#1121395, @george.karpenkov wrote:

> - Do all tests for Z3 run when LLVM is configured to use Z3? I'm not sure if 
> that's the right thing: do all tests start to take 10x time to run once Z3 is 
> enabled?


The test approach is what @dcoughlin suggested in 
https://reviews.llvm.org/D28952, where the tests are run using each constraint 
manager that is available. At that time, he measured an increase in test time 
from 25s to 90s (see https://reviews.llvm.org/D28952#686284).

> - Is anyone interested in running a buildbot running those?

@dcoughlin mentioned that he (Apple?) would set up a buildbot for this, but I 
don't know if that happened.


Repository:
  rC Clang

https://reviews.llvm.org/D47726



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-06-04 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D47564#1119925, @rjmccall wrote:

> In https://reviews.llvm.org/D47564#1119874, @smeenai wrote:
>
> > In https://reviews.llvm.org/D47564#1118424, @rjmccall wrote:
> >
> > > No, it was just a general question.  Have you gotten this to a point 
> > > where it's testable?
> >
> >
> > Yup, it's been working fine in my local testing. There's one more patch 
> > that I need to put up, which actually handles doing proper codegen for 
> > @try/@catch/@finally; I'm working on cleaning that up right now.
>
>
> Okay.  And simple tests with throwing exceptions out of the `@finally` block 
> seem to work?


Yup, it works fine. It's essentially the same as calling a function inside a 
catch block which throws (since the finally is modeled as a catch-all, and the 
finally body is outlined into a function which gets called by that catch-all).


Repository:
  rC Clang

https://reviews.llvm.org/D47564



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


[PATCH] D47737: [clangd] Remove unused variables

2018-06-04 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle created this revision.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov, 
klimek.

Signed-off-by: Marc-Andre Laperle 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47737

Files:
  clangd/ClangdServer.cpp


Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -298,9 +298,8 @@
 
 void ClangdServer::findDefinitions(PathRef File, Position Pos,
Callback> CB) {
-  auto FS = FSProvider.getFileSystem();
-  auto Action = [Pos, FS, this](Callback> CB,
-llvm::Expected InpAST) {
+  auto Action = [Pos, this](Callback> CB,
+llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::findDefinitions(InpAST->AST, Pos, this->FileIdx.get()));
@@ -391,10 +390,8 @@
 
 void ClangdServer::findDocumentHighlights(
 PathRef File, Position Pos, Callback> CB) {
-
-  auto FS = FSProvider.getFileSystem();
-  auto Action = [FS, Pos](Callback> CB,
-  llvm::Expected InpAST) {
+  auto Action = [Pos](Callback> CB,
+  llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::findDocumentHighlights(InpAST->AST, Pos));
@@ -405,9 +402,8 @@
 
 void ClangdServer::findHover(PathRef File, Position Pos,
  Callback> CB) {
-  auto FS = FSProvider.getFileSystem();
-  auto Action = [Pos, FS](Callback> CB,
-  llvm::Expected InpAST) {
+  auto Action = [Pos](Callback> CB,
+  llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::getHover(InpAST->AST, Pos));


Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -298,9 +298,8 @@
 
 void ClangdServer::findDefinitions(PathRef File, Position Pos,
Callback> CB) {
-  auto FS = FSProvider.getFileSystem();
-  auto Action = [Pos, FS, this](Callback> CB,
-llvm::Expected InpAST) {
+  auto Action = [Pos, this](Callback> CB,
+llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::findDefinitions(InpAST->AST, Pos, this->FileIdx.get()));
@@ -391,10 +390,8 @@
 
 void ClangdServer::findDocumentHighlights(
 PathRef File, Position Pos, Callback> CB) {
-
-  auto FS = FSProvider.getFileSystem();
-  auto Action = [FS, Pos](Callback> CB,
-  llvm::Expected InpAST) {
+  auto Action = [Pos](Callback> CB,
+  llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::findDocumentHighlights(InpAST->AST, Pos));
@@ -405,9 +402,8 @@
 
 void ClangdServer::findHover(PathRef File, Position Pos,
  Callback> CB) {
-  auto FS = FSProvider.getFileSystem();
-  auto Action = [Pos, FS](Callback> CB,
-  llvm::Expected InpAST) {
+  auto Action = [Pos](Callback> CB,
+  llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::getHover(InpAST->AST, Pos));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333944 - [X86] Avoid passing _mm_undefined* to builtin_shufflevector if we are able to pass the first input a second time.

2018-06-04 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Jun  4 12:28:09 2018
New Revision: 333944

URL: http://llvm.org/viewvc/llvm-project?rev=333944=rev
Log:
[X86] Avoid passing _mm_undefined* to builtin_shufflevector if we are able to 
pass the first input a second time.

This is more consistent with other usages of builtin_shufflevector. Later 
optimization passes or codegen will detect the duplicate vector and replace it 
with undef. Using _mm_undefined just puts a zeroinitializer that still needs to 
be optimized out later.

Modified:
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=333944=333943=333944=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Mon Jun  4 12:28:09 2018
@@ -1889,8 +1889,7 @@ _mm512_movm_epi16 (__mmask32 __A)
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcastb_epi8 (__m128i __A)
 {
-  return (__m512i)__builtin_shufflevector((__v16qi) __A,
-  (__v16qi)_mm_undefined_si128(),
+  return (__m512i)__builtin_shufflevector((__v16qi) __A, (__v16qi) __A,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0,
@@ -1932,8 +1931,7 @@ _mm512_maskz_set1_epi16 (__mmask32 __M,
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcastw_epi16 (__m128i __A)
 {
-  return (__m512i)__builtin_shufflevector((__v8hi) __A,
-  (__v8hi)_mm_undefined_si128(),
+  return (__m512i)__builtin_shufflevector((__v8hi) __A, (__v8hi) __A,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0);
 }

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=333944=333943=333944=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Mon Jun  4 12:28:09 2018
@@ -963,8 +963,7 @@ _mm512_movepi64_mask (__m512i __A)
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_broadcast_f32x2 (__m128 __A)
 {
-  return (__m512)__builtin_shufflevector((__v4sf)__A,
- (__v4sf)_mm_undefined_ps(),
+  return (__m512)__builtin_shufflevector((__v4sf)__A, (__v4sf)__A,
  0, 1, 0, 1, 0, 1, 0, 1,
  0, 1, 0, 1, 0, 1, 0, 1);
 }
@@ -1035,8 +1034,7 @@ _mm512_maskz_broadcast_f64x2(__mmask8 __
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcast_i32x2 (__m128i __A)
 {
-  return (__m512i)__builtin_shufflevector((__v4si)__A,
-  (__v4si)_mm_undefined_si128(),
+  return (__m512i)__builtin_shufflevector((__v4si)__A, (__v4si)__A,
   0, 1, 0, 1, 0, 1, 0, 1,
   0, 1, 0, 1, 0, 1, 0, 1);
 }

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=333944=333943=333944=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Jun  4 12:28:09 2018
@@ -212,8 +212,7 @@ _mm512_undefined_epi32(void)
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcastd_epi32 (__m128i __A)
 {
-  return (__m512i)__builtin_shufflevector((__v4si) __A,
-  (__v4si)_mm_undefined_si128(),
+  return (__m512i)__builtin_shufflevector((__v4si) __A, (__v4si) __A,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0);
 }
 
@@ -236,8 +235,7 @@ _mm512_maskz_broadcastd_epi32 (__mmask16
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcastq_epi64 (__m128i __A)
 {
-  return (__m512i)__builtin_shufflevector((__v2di) __A,
-  (__v2di) _mm_undefined_si128(),
+  return (__m512i)__builtin_shufflevector((__v2di) __A, (__v2di) __A,
   0, 0, 0, 0, 0, 0, 0, 0);
 }
 
@@ -344,8 +342,7 @@ _mm512_maskz_set1_epi64(__mmask8 

[PATCH] D44865: [libc++] Implement P0608R2 - A sane variant converting constructor

2018-06-04 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 149825.
lichray added a comment.

Refine coding style


Repository:
  rCXX libc++

https://reviews.llvm.org/D44865

Files:
  include/variant
  test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp

Index: test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test_convertible.hpp"
 #include "test_macros.h"
@@ -39,6 +40,8 @@
 
 struct AnyConstructible { template  AnyConstructible(T&&) {} };
 struct NoConstructible { NoConstructible() = delete; };
+template 
+struct RValueConvertibleFrom { RValueConvertibleFrom(T&&) {} };
 
 void test_T_ctor_noexcept() {
   {
@@ -53,7 +56,7 @@
 
 void test_T_ctor_sfinae() {
   {
-using V = std::variant;
+using V = std::variant;
 static_assert(!std::is_constructible::value, "ambiguous");
   }
   {
@@ -66,6 +69,16 @@
   "no matching constructor");
   }
   {
+using V = std::variant;
+static_assert(!std::is_constructible::value,
+  "no matching constructor");
+  }
+  {
+using V = std::variant, bool>;
+static_assert(!std::is_constructible>::value,
+  "no explicit bool in constructor");
+  }
+  {
 using V = std::variant;
 static_assert(
 !std::is_constructible>::value,
@@ -99,6 +112,34 @@
 static_assert(v.index() == 1, "");
 static_assert(std::get<1>(v) == 42, "");
   }
+  {
+constexpr std::variant v(42);
+static_assert(v.index() == 1, "");
+static_assert(std::get<1>(v) == 42, "");
+  }
+  {
+std::variant v = "foo";
+assert(v.index() == 0);
+assert(std::get<0>(v) == "foo");
+  }
+  {
+std::variant> v = nullptr;
+assert(v.index() == 1);
+assert(std::get<1>(v) == nullptr);
+  }
+  {
+std::variant v = true;
+assert(v.index() == 0);
+assert(std::get<0>(v));
+  }
+  {
+std::variant> v1 = 42;
+assert(v1.index() == 0);
+
+int x = 42;
+std::variant, AnyConstructible> v2 = x;
+assert(v2.index() == 1);
+  }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
 using V = std::variant;
Index: test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "variant_test_helpers.hpp"
@@ -128,7 +129,7 @@
 
 void test_T_assignment_sfinae() {
   {
-using V = std::variant;
+using V = std::variant;
 static_assert(!std::is_assignable::value, "ambiguous");
   }
   {
@@ -139,6 +140,15 @@
 using V = std::variant;
 static_assert(!std::is_assignable::value, "no matching operator=");
   }
+  {
+using V = std::variant;
+static_assert(!std::is_assignable::value, "no matching operator=");
+  }
+  {
+using V = std::variant, bool>;
+static_assert(!std::is_assignable>::value,
+  "no explicit bool in operator=");
+  }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
 using V = std::variant;
@@ -167,6 +177,44 @@
 assert(v.index() == 1);
 assert(std::get<1>(v) == 43);
   }
+  {
+std::variant v;
+v = 42;
+assert(v.index() == 1);
+assert(std::get<1>(v) == 42);
+v = 43u;
+assert(v.index() == 0);
+assert(std::get<0>(v) == 43);
+  }
+  {
+std::variant v = true;
+v = std::false_type();
+assert(v.index() == 1);
+assert(std::get<1>(v) == false);
+v = "bar";
+assert(v.index() == 0);
+assert(std::get<0>(v) == "bar");
+  }
+  {
+std::variant> v;
+v = nullptr;
+assert(v.index() == 1);
+assert(std::get<1>(v) == nullptr);
+v = std::true_type();
+assert(v.index() == 0);
+assert(std::get<0>(v));
+  }
+  {
+std::variant v = 42;
+assert(v.index() == 1);
+assert(std::get<1>(v) == 42);
+v = std::false_type();
+assert(v.index() == 0);
+assert(!std::get<0>(v));
+v = true;
+assert(v.index() == 0);
+assert(std::get<0>(v));
+  }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
 using V = std::variant;
Index: include/variant
===
--- include/variant
+++ include/variant
@@ -1097,11 +1097,40 @@
 template 
 struct __overload<_Tp, _Types...> : __overload<_Types...> {
   using __overload<_Types...>::operator();
-  __identity<_Tp> operator()(_Tp) const;
+
+  template 
+  auto operator()(_Tp, _Up&& __t) const
+  -> decltype(_Tp{_VSTD::forward<_Up>(__t)}, __identity<_Tp>());
+};
+
+template 
+struct 

[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Seems to be good to merge regardless.


Repository:
  rC Clang

https://reviews.llvm.org/D47726



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


[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Impressive, really. So almost all tests still pass.
However, a few questions should be resolved before we can merge:

- Do all tests for Z3 run when LLVM is configured to use Z3? I'm not sure if 
that's the right thing: do all tests start to take 10x time to run once Z3 is 
enabled?

Should we create a separate ninja target for those?

- Is anyone interested in running a buildbot running those?


Repository:
  rC Clang

https://reviews.llvm.org/D47726



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


[PATCH] D47617: [Analyzer] Fix Z3ConstraintManager crash (PR37646)

2018-06-04 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47617



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


[PATCH] D44865: [libc++] Implement P0608R2 - A sane variant converting constructor

2018-06-04 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 149824.
lichray added a comment.

Preserve value category in narrowing test.


Repository:
  rCXX libc++

https://reviews.llvm.org/D44865

Files:
  include/variant
  test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp

Index: test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test_convertible.hpp"
 #include "test_macros.h"
@@ -40,6 +41,11 @@
 struct AnyConstructible { template  AnyConstructible(T&&) {} };
 struct NoConstructible { NoConstructible() = delete; };
 
+template 
+struct RValueConvertibleFrom {
+RValueConvertibleFrom(T&&) {}
+};
+
 void test_T_ctor_noexcept() {
   {
 using V = std::variant;
@@ -53,7 +59,7 @@
 
 void test_T_ctor_sfinae() {
   {
-using V = std::variant;
+using V = std::variant;
 static_assert(!std::is_constructible::value, "ambiguous");
   }
   {
@@ -66,6 +72,16 @@
   "no matching constructor");
   }
   {
+using V = std::variant;
+static_assert(!std::is_constructible::value,
+  "no matching constructor");
+  }
+  {
+using V = std::variant, bool>;
+static_assert(!std::is_constructible>::value,
+  "no explicit bool in constructor");
+  }
+  {
 using V = std::variant;
 static_assert(
 !std::is_constructible>::value,
@@ -99,6 +115,34 @@
 static_assert(v.index() == 1, "");
 static_assert(std::get<1>(v) == 42, "");
   }
+  {
+constexpr std::variant v(42);
+static_assert(v.index() == 1, "");
+static_assert(std::get<1>(v) == 42, "");
+  }
+  {
+std::variant v = "foo";
+assert(v.index() == 0);
+assert(std::get<0>(v) == "foo");
+  }
+  {
+std::variant> v = nullptr;
+assert(v.index() == 1);
+assert(std::get<1>(v) == nullptr);
+  }
+  {
+std::variant v = true;
+assert(v.index() == 0);
+assert(std::get<0>(v));
+  }
+  {
+std::variant> v1 = 42;
+assert(v1.index() == 0);
+
+int x = 42;
+std::variant, AnyConstructible> v2 = x;
+assert(v2.index() == 1);
+  }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
 using V = std::variant;
Index: test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 #include "variant_test_helpers.hpp"
@@ -128,7 +129,7 @@
 
 void test_T_assignment_sfinae() {
   {
-using V = std::variant;
+using V = std::variant;
 static_assert(!std::is_assignable::value, "ambiguous");
   }
   {
@@ -139,6 +140,15 @@
 using V = std::variant;
 static_assert(!std::is_assignable::value, "no matching operator=");
   }
+  {
+using V = std::variant;
+static_assert(!std::is_assignable::value, "no matching operator=");
+  }
+  {
+using V = std::variant, bool>;
+static_assert(!std::is_assignable>::value,
+  "no explicit bool in operator=");
+  }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
 using V = std::variant;
@@ -167,6 +177,44 @@
 assert(v.index() == 1);
 assert(std::get<1>(v) == 43);
   }
+  {
+std::variant v;
+v = 42;
+assert(v.index() == 1);
+assert(std::get<1>(v) == 42);
+v = 43u;
+assert(v.index() == 0);
+assert(std::get<0>(v) == 43);
+  }
+  {
+std::variant v = true;
+v = std::false_type();
+assert(v.index() == 1);
+assert(std::get<1>(v) == false);
+v = "bar";
+assert(v.index() == 0);
+assert(std::get<0>(v) == "bar");
+  }
+  {
+std::variant> v;
+v = nullptr;
+assert(v.index() == 1);
+assert(std::get<1>(v) == nullptr);
+v = std::true_type();
+assert(v.index() == 0);
+assert(std::get<0>(v));
+  }
+  {
+std::variant v = 42;
+assert(v.index() == 1);
+assert(std::get<1>(v) == 42);
+v = std::false_type();
+assert(v.index() == 0);
+assert(!std::get<0>(v));
+v = true;
+assert(v.index() == 0);
+assert(std::get<0>(v));
+  }
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {
 using V = std::variant;
Index: include/variant
===
--- include/variant
+++ include/variant
@@ -1097,11 +1097,40 @@
 template 
 struct __overload<_Tp, _Types...> : __overload<_Types...> {
   using __overload<_Types...>::operator();
-  __identity<_Tp> operator()(_Tp) const;
+
+  template 
+  auto operator()(_Tp, _Up&& __t) const
+  -> 

r333941 - [CFG] Fix automatic destructors when a member is bound to a reference.

2018-06-04 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Jun  4 11:56:25 2018
New Revision: 333941

URL: http://llvm.org/viewvc/llvm-project?rev=333941=rev
Log:
[CFG] Fix automatic destructors when a member is bound to a reference.

In code like

const int  = A().x;

automatic destructor for the object A() lifetime-extended by reference 'x' was
not present in the clang CFG due to ad-hoc pattern-matching in
getReferenceInitTemporaryType().

Re-use skipRValueSubobjectAdjustments() again to find the lifetime-extended
object in the AST and emit the correct destructor.

Lifetime extension through aggregates with references still needs to be covered.

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

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=333941=333940=333941=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Mon Jun  4 11:56:25 2018
@@ -1493,19 +1493,18 @@ CFGBlock *CFGBuilder::addInitializer(CXX
 
 /// Retrieve the type of the temporary object whose lifetime was 
 /// extended by a local reference with the given initializer.
-static QualType getReferenceInitTemporaryType(ASTContext ,
-  const Expr *Init,
+static QualType getReferenceInitTemporaryType(const Expr *Init,
   bool *FoundMTE = nullptr) {
   while (true) {
 // Skip parentheses.
 Init = Init->IgnoreParens();
-
+
 // Skip through cleanups.
 if (const ExprWithCleanups *EWC = dyn_cast(Init)) {
   Init = EWC->getSubExpr();
   continue;
 }
-
+
 // Skip through the temporary-materialization expression.
 if (const MaterializeTemporaryExpr *MTE
   = dyn_cast(Init)) {
@@ -1514,26 +1513,17 @@ static QualType getReferenceInitTemporar
 *FoundMTE = true;
   continue;
 }
-
-// Skip derived-to-base and no-op casts.
-if (const CastExpr *CE = dyn_cast(Init)) {
-  if ((CE->getCastKind() == CK_DerivedToBase ||
-   CE->getCastKind() == CK_UncheckedDerivedToBase ||
-   CE->getCastKind() == CK_NoOp) &&
-  Init->getType()->isRecordType()) {
-Init = CE->getSubExpr();
-continue;
-  }
-}
-
-// Skip member accesses into rvalues.
-if (const MemberExpr *ME = dyn_cast(Init)) {
-  if (!ME->isArrow() && ME->getBase()->isRValue()) {
-Init = ME->getBase();
-continue;
-  }
+
+// Skip sub-object accesses into rvalues.
+SmallVector CommaLHSs;
+SmallVector Adjustments;
+const Expr *SkippedInit =
+Init->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
+if (SkippedInit != Init) {
+  Init = SkippedInit;
+  continue;
 }
-
+
 break;
   }
 
@@ -1682,7 +1672,7 @@ void CFGBuilder::addAutomaticObjDtors(Lo
 // anything built thus far: control won't flow out of this block.
 QualType Ty = (*I)->getType();
 if (Ty->isReferenceType()) {
-  Ty = getReferenceInitTemporaryType(*Context, (*I)->getInit());
+  Ty = getReferenceInitTemporaryType((*I)->getInit());
 }
 Ty = Context->getBaseElementType(Ty);
 
@@ -1795,7 +1785,7 @@ LocalScope* CFGBuilder::addLocalScopeFor
 bool CFGBuilder::hasTrivialDestructor(VarDecl *VD) {
   // Check for const references bound to temporary. Set type to pointee.
   QualType QT = VD->getType();
-  if (QT.getTypePtr()->isReferenceType()) {
+  if (QT->isReferenceType()) {
 // Attempt to determine whether this declaration lifetime-extends a
 // temporary.
 //
@@ -1805,12 +1795,16 @@ bool CFGBuilder::hasTrivialDestructor(Va
 // MaterializeTemporaryExpr instead.
 
 const Expr *Init = VD->getInit();
-if (!Init)
+if (!Init) {
+  // Probably an exception catch-by-reference variable.
+  // FIXME: It doesn't really mean that the object has a trivial 
destructor.
+  // Also are there other cases?
   return true;
+}
 
-// Lifetime-extending a temporary.
+// Lifetime-extending a temporary?
 bool FoundMTE = false;
-QT = getReferenceInitTemporaryType(*Context, Init, );
+QT = getReferenceInitTemporaryType(Init, );
 if (!FoundMTE)
   return true;
   }
@@ -4596,7 +4590,7 @@ CFGImplicitDtor::getDestructorDecl(ASTCo
   // temporary in an initializer expression.
   if (ty->isReferenceType()) {
 if (const Expr *Init = var->getInit()) {
-  ty = getReferenceInitTemporaryType(astContext, Init);
+  ty = getReferenceInitTemporaryType(Init);
 }
   }
 
@@ -5061,10 +5055,12 @@ static void print_elem(raw_ostream ,
 const VarDecl *VD = DE->getVarDecl();
 Helper.handleDecl(VD, OS);
 
-const Type* T = VD->getType().getTypePtr();
-if (const ReferenceType* RT = T->getAs())
- 

[PATCH] D44238: [CFG] Fix automatic destructors when a member is bound to a reference.

2018-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333941: [CFG] Fix automatic destructors when a member is 
bound to a reference. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D44238

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/auto-obj-dtors-cfg-output.cpp

Index: test/Analysis/auto-obj-dtors-cfg-output.cpp
===
--- test/Analysis/auto-obj-dtors-cfg-output.cpp
+++ test/Analysis/auto-obj-dtors-cfg-output.cpp
@@ -1,7 +1,11 @@
-// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
-// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,WARNINGS %s
-// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
-// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,ANALYZER %s
+// RUN: %clang_analyze_cc1 -std=c++98 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,CXX98,WARNINGS,CXX98-WARNINGS %s
+// RUN: %clang_analyze_cc1 -std=c++98 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,CXX98,ANALYZER,CXX98-ANALYZER %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,CXX11,WARNINGS,CXX11-WARNINGS %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,CXX11,ANALYZER,CXX11-ANALYZER %s
 
 // This file tests how we construct two different flavors of the Clang CFG -
 // the CFG used by the Sema analysis-based warnings and the CFG used by the
@@ -14,6 +18,8 @@
 
 class A {
 public:
+  int x;
+
 // CHECK:  [B1 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B0
 // CHECK:  [B0 (EXIT)]
@@ -70,6 +76,287 @@
 // CHECK:  [B2 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B1
 // CHECK:  [B1]
+// WARNINGS-NEXT:   1: A() (CXXConstructExpr, class A)
+// CXX98-ANALYZER-NEXT:   1: A() (CXXConstructExpr, [B1.2], class A)
+// CXX11-ANALYZER-NEXT:   1: A() (CXXConstructExpr, [B1.2], [B1.3], class A)
+// CHECK-NEXT:   2: [B1.1] (BindTemporary)
+// CXX98-NEXT:   3: [B1.2].x
+// CXX98-NEXT:   4: [B1.3]
+// CXX98-NEXT:   5: const int  = A().x;
+// CXX98-NEXT:   6: [B1.5].~A() (Implicit destructor)
+// CXX11-NEXT:   3: [B1.2]
+// CXX11-NEXT:   4: [B1.3].x
+// CXX11-NEXT:   5: [B1.4] (ImplicitCastExpr, NoOp, const int)
+// CXX11-NEXT:   6: const int  = A().x;
+// CXX11-NEXT:   7: [B1.6].~A() (Implicit destructor)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_const_ref_to_field() {
+  const int  = A().x;
+}
+
+// CHECK:[B2 (ENTRY)]
+// CHECK-NEXT: Succs (1): B1
+// CHECK:[B1]
+// WARNINGS-NEXT: 1: A() (CXXConstructExpr, class A)
+// CXX98-ANALYZER-NEXT: 1: A() (CXXConstructExpr, [B1.2], class A)
+// CXX11-ANALYZER-NEXT: 1: A() (CXXConstructExpr, [B1.2], [B1.3], class A)
+// CHECK-NEXT: 2: [B1.1] (BindTemporary)
+// CXX98-NEXT: 3: A::x
+// CXX98-NEXT: 4: &[B1.3]
+// CXX98-NEXT: 5: [B1.2] .* [B1.4]
+// CXX98-NEXT: 6: [B1.5]
+// CXX98-NEXT: 7: const int  = A() .* ::x;
+// CXX98-NEXT: 8: [B1.7].~A() (Implicit destructor)
+// CXX11-NEXT: 3: [B1.2]
+// CXX11-NEXT: 4: A::x
+// CXX11-NEXT: 5: &[B1.4]
+// CXX11-NEXT: 6: [B1.3] .* [B1.5]
+// CXX11-NEXT: 7: [B1.6] (ImplicitCastExpr, NoOp, const int)
+// CXX11-NEXT: 8: const int  = A() .* ::x;
+// CXX11-NEXT: 9: [B1.8].~A() (Implicit destructor)
+// CHECK-NEXT: Preds (1): B2
+// CHECK-NEXT: Succs (1): B0
+// CHECK:[B0 (EXIT)]
+// CHECK-NEXT: Preds (1): B1
+void test_pointer_to_member() {
+  const int  = A().*::x;
+}
+
+// FIXME: There should be automatic destructors at the end of scope.
+// CHECK:[B2 (ENTRY)]
+// CHECK-NEXT: Succs (1): B1
+// CHECK:[B1]
+// WARNINGS-NEXT: 1: A() (CXXConstructExpr, class A)
+// ANALYZER-NEXT: 1: A() (CXXConstructExpr, [B1.2], [B1.4], class A)
+// CHECK-NEXT: 2: [B1.1] (BindTemporary)
+// CHECK-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT: 4: [B1.3]
+// CHECK-NEXT: 5: {[B1.4]}
+// CHECK-NEXT: 6: B b = {A()};
+// WARNINGS-NEXT: 7: A() (CXXConstructExpr, class A)
+// ANALYZER-NEXT: 7: A() (CXXConstructExpr, [B1.8], [B1.10], class A)
+// CHECK-NEXT: 8: [B1.7] (BindTemporary)
+// CHECK-NEXT: 9: 

[PATCH] D47620: Remove llvm::Triple argument from get***Personality() functions. NFC.

2018-06-04 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333938: Remove llvm::Triple argument from 
get***Personality() functions. NFC. (authored by aheejin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47620?vs=149406=149814#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47620

Files:
  lib/CodeGen/CGException.cpp

Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -114,8 +114,9 @@
 const EHPersonality
 EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr };
 
-static const EHPersonality (const llvm::Triple ,
+static const EHPersonality (const TargetInfo ,
 const LangOptions ) {
+  const llvm::Triple  = Target.getTriple();
   if (L.SjLjExceptions)
 return EHPersonality::GNU_C_SJLJ;
   if (L.DWARFExceptions)
@@ -127,11 +128,12 @@
   return EHPersonality::GNU_C;
 }
 
-static const EHPersonality (const llvm::Triple ,
+static const EHPersonality (const TargetInfo ,
const LangOptions ) {
+  const llvm::Triple  = Target.getTriple();
   switch (L.ObjCRuntime.getKind()) {
   case ObjCRuntime::FragileMacOSX:
-return getCPersonality(T, L);
+return getCPersonality(Target, L);
   case ObjCRuntime::MacOSX:
   case ObjCRuntime::iOS:
   case ObjCRuntime::WatchOS:
@@ -153,9 +155,9 @@
   llvm_unreachable("bad runtime kind");
 }
 
-static const EHPersonality (const llvm::Triple ,
-  const LangOptions ,
-  const TargetInfo ) {
+static const EHPersonality (const TargetInfo ,
+  const LangOptions ) {
+  const llvm::Triple  = Target.getTriple();
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
@@ -174,31 +176,30 @@
 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
-static const EHPersonality (const llvm::Triple ,
- const LangOptions ,
- const TargetInfo ) {
+static const EHPersonality (const TargetInfo ,
+ const LangOptions ) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-return getCXXPersonality(T, L, Target);
+return getCXXPersonality(Target, L);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
   // function on targets using (backend-driven) SJLJ EH.
   case ObjCRuntime::MacOSX:
   case ObjCRuntime::iOS:
   case ObjCRuntime::WatchOS:
-return getObjCPersonality(T, L);
+return getObjCPersonality(Target, L);
 
   case ObjCRuntime::GNUstep:
 return EHPersonality::GNU_ObjCXX;
 
   // The GCC runtime's personality function inherently doesn't support
   // mixed EH.  Use the ObjC personality just to avoid returning null.
   case ObjCRuntime::GCC:
   case ObjCRuntime::ObjFW:
-return getObjCPersonality(T, L);
+return getObjCPersonality(Target, L);
   }
   llvm_unreachable("bad runtime kind");
 }
@@ -220,9 +221,10 @@
 return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
-   : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
+return L.CPlusPlus ? getObjCXXPersonality(Target, L)
+   : getObjCPersonality(Target, L);
+  return L.CPlusPlus ? getCXXPersonality(Target, L)
+ : getCPersonality(Target, L);
 }
 
 const EHPersonality ::get(CodeGenFunction ) {
@@ -318,8 +320,7 @@
 return;
 
   const EHPersonality  = EHPersonality::get(*this, /*FD=*/nullptr);
-  const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
+  const EHPersonality  = getCXXPersonality(getTarget(), LangOpts);
   if ( == )
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333938 - Remove llvm::Triple argument from get***Personality() functions. NFC.

2018-06-04 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Mon Jun  4 11:23:00 2018
New Revision: 333938

URL: http://llvm.org/viewvc/llvm-project?rev=333938=rev
Log:
Remove llvm::Triple argument from get***Personality() functions. NFC.

Summary:
Because `llvm::Triple` can be derived from `TargetInfo`, it is simpler
to take only `TargetInfo` argument.

Reviewers: sbc100

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=333938=333937=333938=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Mon Jun  4 11:23:00 2018
@@ -114,8 +114,9 @@ EHPersonality::MSVC_CxxFrameHandler3 = {
 const EHPersonality
 EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr };
 
-static const EHPersonality (const llvm::Triple ,
+static const EHPersonality (const TargetInfo ,
 const LangOptions ) {
+  const llvm::Triple  = Target.getTriple();
   if (L.SjLjExceptions)
 return EHPersonality::GNU_C_SJLJ;
   if (L.DWARFExceptions)
@@ -127,11 +128,12 @@ static const EHPersonality 
   return EHPersonality::GNU_C;
 }
 
-static const EHPersonality (const llvm::Triple ,
+static const EHPersonality (const TargetInfo ,
const LangOptions ) {
+  const llvm::Triple  = Target.getTriple();
   switch (L.ObjCRuntime.getKind()) {
   case ObjCRuntime::FragileMacOSX:
-return getCPersonality(T, L);
+return getCPersonality(Target, L);
   case ObjCRuntime::MacOSX:
   case ObjCRuntime::iOS:
   case ObjCRuntime::WatchOS:
@@ -153,9 +155,9 @@ static const EHPersonality 
   llvm_unreachable("bad runtime kind");
 }
 
-static const EHPersonality (const llvm::Triple ,
-  const LangOptions ,
-  const TargetInfo ) {
+static const EHPersonality (const TargetInfo ,
+  const LangOptions ) {
+  const llvm::Triple  = Target.getTriple();
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
@@ -174,14 +176,13 @@ static const EHPersonality 
 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
-static const EHPersonality (const llvm::Triple ,
- const LangOptions ,
- const TargetInfo ) {
+static const EHPersonality (const TargetInfo ,
+ const LangOptions ) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-return getCXXPersonality(T, L, Target);
+return getCXXPersonality(Target, L);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
@@ -189,7 +190,7 @@ static const EHPersonality 
   case ObjCRuntime::MacOSX:
   case ObjCRuntime::iOS:
   case ObjCRuntime::WatchOS:
-return getObjCPersonality(T, L);
+return getObjCPersonality(Target, L);
 
   case ObjCRuntime::GNUstep:
 return EHPersonality::GNU_ObjCXX;
@@ -198,7 +199,7 @@ static const EHPersonality 
   // mixed EH.  Use the ObjC personality just to avoid returning null.
   case ObjCRuntime::GCC:
   case ObjCRuntime::ObjFW:
-return getObjCPersonality(T, L);
+return getObjCPersonality(Target, L);
   }
   llvm_unreachable("bad runtime kind");
 }
@@ -220,9 +221,10 @@ const EHPersonality ::get(
 return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
-   : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
+return L.CPlusPlus ? getObjCXXPersonality(Target, L)
+   : getObjCPersonality(Target, L);
+  return L.CPlusPlus ? getCXXPersonality(Target, L)
+ : getCPersonality(Target, L);
 }
 
 const EHPersonality ::get(CodeGenFunction ) {
@@ -318,8 +320,7 @@ void CodeGenModule::SimplifyPersonality(
 return;
 
   const EHPersonality  = EHPersonality::get(*this, /*FD=*/nullptr);
-  const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
+  const EHPersonality  = getCXXPersonality(getTarget(), LangOpts);
   if ( == )
 return;
 


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


[PATCH] D47732: [clang-doc] Add BitReader to LLVM_LINK_COMPONENTS

2018-06-04 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin abandoned this revision.
aheejin added a comment.

Oh I see, thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47732



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


[PATCH] D47733: [CUDA][HIP] Set kernel calling convention before arrange function

2018-06-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, tra.

Currently clang set kernel calling convention for CUDA/HIP after
arranging function, which causes incorrect kernel function type since
it depends on calling convention.

This patch moves setting kernel convention before arranging
function.


https://reviews.llvm.org/D47733

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenCUDA/kernel-args-amdgcn.cu

Index: test/CodeGenCUDA/kernel-args-amdgcn.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args-amdgcn.cu
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
+#include "Inputs/cuda.h"
+
+struct A {
+  int a[32];
+};
+
+// CHECK: define amdgpu_kernel void @_Z6kernel1A(%struct.A %x.coerce)
+__global__ void kernel(A x) {
+}
+
+class Kernel {
+public:
+  // CHECK: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A %x.coerce)
+  static __global__ void memberKernel(A x){}
+  template static __global__ void templateMemberKernel(T x) {}
+};
+
+
+template 
+__global__ void templateKernel(T x) {}
+
+void launch(void*);
+
+void test() {
+  Kernel K;
+  // CHECK: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A %x.coerce)
+  launch((void*)templateKernel);
+
+  // CHECK: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A %x.coerce)
+  launch((void*)Kernel::templateMemberKernel);
+}
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -302,7 +302,7 @@
   /// as 'used', and having internal linkage.
   virtual bool shouldEmitStaticExternCAliases() const { return true; }
 
-  virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {}
+  virtual void setCUDAKernelCallingConvention(const FunctionType *) const {}
 };
 
 } // namespace CodeGen
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7646,7 +7646,7 @@
 llvm::Function *BlockInvokeFunc,
 llvm::Value *BlockLiteral) const override;
   bool shouldEmitStaticExternCAliases() const override;
-  void setCUDAKernelCallingConvention(llvm::Function *F) const override;
+  void setCUDAKernelCallingConvention(const FunctionType *) const override;
 };
 }
 
@@ -7783,8 +7783,9 @@
 }
 
 void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention(
-llvm::Function *F) const {
-  F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+const FunctionType *) const {
+  FT = getABIInfo().getContext().adjustFunctionType(
+  FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
 }
 
 //===--===//
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3671,8 +3671,6 @@
 
   MaybeHandleStaticInExternC(D, Fn);
 
-  if (D->hasAttr())
-getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn);
 
   maybeSetTrivialComdat(*D, *Fn);
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -255,6 +255,16 @@
   FTP->getCanonicalTypeUnqualified().getAs(), MD);
 }
 
+/// Set calling convention for CUDA/HIP kernel.
+static void setCUDAKernelCallingConvention(CanQualType , CodeGenModule ,
+   const FunctionDecl *FD) {
+  if (FD->hasAttr()) {
+const FunctionType *FT = FTy->getAs();
+CGM.getTargetCodeGenInfo().setCUDAKernelCallingConvention(FT);
+FTy = FT->getCanonicalTypeUnqualified();
+  }
+}
+
 /// Arrange the argument and result information for a declaration or
 /// definition of the given C++ non-static member function.  The
 /// member function must be an ordinary function, i.e. not a
@@ -264,7 +274,9 @@
   assert(!isa(MD) && "wrong method for constructors!");
   assert(!isa(MD) && "wrong method for destructors!");
 
-  CanQual prototype = GetFormalType(MD);
+  CanQualType FT = GetFormalType(MD).getAs();
+  setCUDAKernelCallingConvention(FT, CGM, MD);
+  auto prototype = FT.getAs();
 
   if (MD->isInstance()) {
 // The abstract case is perfectly fine.
@@ -424,6 +436,7 @@
   CanQualType FTy = FD->getType()->getCanonicalTypeUnqualified();
 
   assert(isa(FTy));
+  setCUDAKernelCallingConvention(FTy, CGM, FD);
 
   // When declaring a function without a prototype, always use a
   // non-variadic type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47732: [clang-doc] Add BitReader to LLVM_LINK_COMPONENTS

2018-06-04 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

Already fixed in https://reviews.llvm.org/rL333936, sorry!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47732



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


[clang-tools-extra] r333936 - [clang-doc] Adding missing dependencies to fix linker error on bot

2018-06-04 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Mon Jun  4 11:18:00 2018
New Revision: 333936

URL: http://llvm.org/viewvc/llvm-project?rev=333936=rev
Log:
[clang-doc] Adding missing dependencies to fix linker error on bot

Modified:
clang-tools-extra/trunk/clang-doc/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-doc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/CMakeLists.txt?rev=333936=333935=333936=diff
==
--- clang-tools-extra/trunk/clang-doc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-doc/CMakeLists.txt Mon Jun  4 11:18:00 2018
@@ -1,5 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   support
+  BitReader
+  BitWriter
   )
 
 add_clang_library(clangDoc


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


[PATCH] D47732: [clang-doc] Add BitReader to LLVM_LINK_COMPONENTS

2018-06-04 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: juliehockett.
Herald added subscribers: cfe-commits, mgorny, klimek.

Without this, build with `-DSHARED_LIB=ON` fails.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47732

Files:
  clang-doc/CMakeLists.txt


Index: clang-doc/CMakeLists.txt
===
--- clang-doc/CMakeLists.txt
+++ clang-doc/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  BitReader
   support
   )
 


Index: clang-doc/CMakeLists.txt
===
--- clang-doc/CMakeLists.txt
+++ clang-doc/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  BitReader
   support
   )
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47532: [ASTImporter] Import the whole redecl chain of functions

2018-06-04 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Gabor,

This patch is really cool. Unfortunately, right now I don't have enough time 
for reviewing large patches in a single review. Are you OK with incremental 
review?




Comment at: lib/AST/ASTImporter.cpp:75
+  template 
+  llvm::SmallVector
+  getCanonicalForwardRedeclChain(Redeclarable* D) {

We can drop `llvm::` prefix for SmallVectors.



Comment at: lib/AST/ASTImporter.cpp:78
+llvm::SmallVector Redecls;
+for (auto R : D->getFirstDecl()->redecls()) {
+  if (R != D->getFirstDecl())

Please keep `*` where possible.



Comment at: lib/AST/ASTImporter.cpp:79
+for (auto R : D->getFirstDecl()->redecls()) {
+  if (R != D->getFirstDecl())
+Redecls.push_back(R);

Does this code mean that we can get R == getFirstDecl() in the middle of the 
import chain?



Comment at: lib/AST/ASTImporter.cpp:2340
+ FunctionDecl::TK_FunctionTemplateSpecialization);
+  auto *FTSInfo = FromFD->getTemplateSpecializationInfo();
+  auto *Template = cast_or_null(

This code should be unified with `ImportTemplateInformation()` to avoid 
duplication.



Comment at: lib/AST/ASTImporter.cpp:2363
+  // declarations starting from the canonical decl.
+  for (;RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt)
+Importer.Import(*RedeclIt);

Can we just import `getPreviousDecl()`?



Comment at: lib/AST/ASTImporter.cpp:2364
+  for (;RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt)
+Importer.Import(*RedeclIt);
+  assert(*RedeclIt == D);

Unchecked import result, is it intentional?



Comment at: lib/AST/ASTImporter.cpp:2380
+  // If this is a function template specialization, then try to find the same
+  // existing specialization in the "to" context.  The localUncachedLookup
+  // below will not find any specialization, but would find the primary

Double space.



Comment at: lib/AST/ASTImporter.cpp:2409
 FoundFunction->getType())) {
-// FIXME: Actually try to merge the body and other attributes.
-const FunctionDecl *FromBodyDecl = nullptr;
-D->hasBody(FromBodyDecl);
-if (D == FromBodyDecl && !FoundFunction->hasBody()) {
-  // This function is needed to merge completely.
-  FoundWithoutBody = FoundFunction;
+  if (D->doesThisDeclarationHaveABody() &&
+  FoundFunction->hasBody())

Has removed comment become irrelevant? (Same below)



Comment at: lib/AST/ASTImporter.cpp:2609
 
+  // Friend declarations lexical context is the befriending class, but the
+  // semantic context is the enclosing scope of the befriending class.

declaration's



Comment at: lib/AST/ASTImporter.cpp:2612
+  // We want the friend functions to be found in the semantic context by 
lookup.
+  // FIXME should we handle this genrically in VisitFriendDecl?
+  // In Other cases when LexicalDC != DC we don't want it to be added,

generically?



Comment at: lib/AST/ASTImporter.cpp:2619
+
+  // Import the rest of the chain. I.e. import all subsequent declarations.
+  for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt)

So, we're importing a redeclaration. It imports its own redeclarations during 
import. This means that after the first redecl is imported, all other redecls 
should be imported too. So, do we need to have a loop here?



Comment at: test/ASTMerge/class/test.cpp:20
 
+// CHECK: class1.cpp:36:8: warning: type 'F2' has incompatible definitions in 
different translation units
+// CHECK: class1.cpp:39:3: note: friend declared here

Why did the order change?



Comment at: unittests/AST/ASTImporterTest.cpp:1745
+TEST_P(ImportFunctions, ImportDefinitions) {
+  auto Pattern = functionDecl(hasName("f"));
+

martong wrote:
> balazske wrote:
> > This test imports the definition two times, the second should result in 
> > error. The import does not check the function body for similarness. 
> > Probably a check can be made for the result of the second import.
> I don't think this should result an error, because the second definition has 
> the very same type as the first. And also the body is structurally equivalent 
> too, but we do not check that. Perhaps, on a long term we should check the 
> body too (?).
> 
> I think the importer should work in this way: if there is already a 
> definition then just simply use that and omit any subsequent definitions if 
> they are the same definitions (or report error if the body is different).
> The key principle I followed is this: we can have arbitrary number of 
> prototypes but 

Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread Nico Weber via cfe-commits
(Cost as in "shared library buildsof clang are ~35% slower than regular
clang" last we checked.)

On Mon, Jun 4, 2018 at 2:14 PM, Nico Weber  wrote:

> Sure, the bots could do that, the more general point was that many
> (probably most) people who want to enable asserts don't want to use shared
> libs. I believe that only a few people use that config, so turning things
> around why should everyone building with asserts have to pay the cost of
> supporting the shared build config?
>
> On Mon, Jun 4, 2018 at 12:51 PM, David Zarzycki  wrote:
>
>> Hi Roman – I agree that people shouldn’t need to manually fix this every
>> time it happens.
>>
>> Hi Nico – What is stopping the Chromium buildbots from setting
>> BUILD_SHARED_LIBS to false? That way the default BUILD_SHARED_LIBS policy
>> of llvm and/or clang doesn’t matter, right?
>>
>> Dave
>>
>>
>> > On Jun 4, 2018, at 12:40 PM, Roman Lebedev 
>> wrote:
>> >
>> > This is n-th time i do this kind of fix.
>> > Sure this does resolve the issue, but it would be much better to use
>> > proper means,
>> > and tell people to fix their code, in an automatic way :)
>> >
>> > On Mon, Jun 4, 2018 at 7:36 PM, Nico Weber  wrote:
>> >> All chromium bots build with asserts on and we definitely don't want
>> shared
>> >> libs :-) Having the people who care about this build config make sure
>> it
>> >> keeps working seems like a good approach to me.
>> >>
>> >> On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits
>> >>  wrote:
>> >>>
>> >>> What’s stopping the project from automatically setting
>> BUILD_SHARED_LIBS
>> >>> to TRUE if asserts are enabled? That’d automatically “force” active
>> >>> developers to test the scenario on their local machines, but not
>> change the
>> >>> way release builds work.
>> >>>
>> >>>
>>  On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits
>>   wrote:
>> 
>>  This broke building as shared libraries.
>> 
>>  I've committed the fix, but the bot coverage is clearly severely
>>  missing,
>>  given that such breakages are very often.
>> 
>>  Roman.
>> 
>>  On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
>>   wrote:
>> > Author: ioeric
>> > Date: Mon Jun  4 02:04:12 2018
>> > New Revision: 333874
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=333874=rev
>> > Log:
>> > Reland "Move #include manipulation code to new
>> lib/Tooling/Inclusions."
>> >
>> > This reverts commit r333534 (i.e. reland r332720) after fixing
>> module
>> > build.
>> >
>> > Differential Revision: https://reviews.llvm.org/D47068
>> >
>> > Added:
>> >   cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
>> > - copied, changed from r333865,
>> > cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >   cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
>> > - copied, changed from r333865,
>> > cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >   cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
>> > - copied, changed from r333865,
>> > cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >   cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
>> > - copied, changed from r333865,
>> > cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >   cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
>> > - copied, changed from r333865,
>> > cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> > Removed:
>> >   cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >   cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >   cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >   cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> > Modified:
>> >   cfe/trunk/include/clang/Format/Format.h
>> >   cfe/trunk/include/clang/module.modulemap
>> >   cfe/trunk/lib/Format/CMakeLists.txt
>> >   cfe/trunk/lib/Format/Format.cpp
>> >   cfe/trunk/lib/Tooling/CMakeLists.txt
>> >   cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >   cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Format/Format.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Format/Format.h?rev=333874=333873=333874=diff
>> >
>> > 
>> ==
>> > --- cfe/trunk/include/clang/Format/Format.h (original)
>> > +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12
>> 2018
>> > @@ -16,8 +16,8 @@
>> > #define LLVM_CLANG_FORMAT_FORMAT_H
>> >
>> > #include "clang/Basic/LangOptions.h"
>> > -#include "clang/Tooling/Core/IncludeStyle.h"
>> > #include "clang/Tooling/Core/Replacement.h"
>> > +#include "clang/Tooling/Inclusions/IncludeStyle.h"
>> > #include "llvm/ADT/ArrayRef.h"
>> > #include "llvm/Support/Regex.h"
>> > #include 
>> >
>> > Removed: 

Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread Nico Weber via cfe-commits
Sure, the bots could do that, the more general point was that many
(probably most) people who want to enable asserts don't want to use shared
libs. I believe that only a few people use that config, so turning things
around why should everyone building with asserts have to pay the cost of
supporting the shared build config?

On Mon, Jun 4, 2018 at 12:51 PM, David Zarzycki  wrote:

> Hi Roman – I agree that people shouldn’t need to manually fix this every
> time it happens.
>
> Hi Nico – What is stopping the Chromium buildbots from setting
> BUILD_SHARED_LIBS to false? That way the default BUILD_SHARED_LIBS policy
> of llvm and/or clang doesn’t matter, right?
>
> Dave
>
>
> > On Jun 4, 2018, at 12:40 PM, Roman Lebedev  wrote:
> >
> > This is n-th time i do this kind of fix.
> > Sure this does resolve the issue, but it would be much better to use
> > proper means,
> > and tell people to fix their code, in an automatic way :)
> >
> > On Mon, Jun 4, 2018 at 7:36 PM, Nico Weber  wrote:
> >> All chromium bots build with asserts on and we definitely don't want
> shared
> >> libs :-) Having the people who care about this build config make sure it
> >> keeps working seems like a good approach to me.
> >>
> >> On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits
> >>  wrote:
> >>>
> >>> What’s stopping the project from automatically setting
> BUILD_SHARED_LIBS
> >>> to TRUE if asserts are enabled? That’d automatically “force” active
> >>> developers to test the scenario on their local machines, but not
> change the
> >>> way release builds work.
> >>>
> >>>
>  On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits
>   wrote:
> 
>  This broke building as shared libraries.
> 
>  I've committed the fix, but the bot coverage is clearly severely
>  missing,
>  given that such breakages are very often.
> 
>  Roman.
> 
>  On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
>   wrote:
> > Author: ioeric
> > Date: Mon Jun  4 02:04:12 2018
> > New Revision: 333874
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=333874=rev
> > Log:
> > Reland "Move #include manipulation code to new
> lib/Tooling/Inclusions."
> >
> > This reverts commit r333534 (i.e. reland r332720) after fixing module
> > build.
> >
> > Differential Revision: https://reviews.llvm.org/D47068
> >
> > Added:
> >   cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
> > - copied, changed from r333865,
> > cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >   cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
> > - copied, changed from r333865,
> > cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >   cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
> > - copied, changed from r333865,
> > cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >   cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
> > - copied, changed from r333865,
> > cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >   cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
> > - copied, changed from r333865,
> > cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Removed:
> >   cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >   cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >   cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >   cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Modified:
> >   cfe/trunk/include/clang/Format/Format.h
> >   cfe/trunk/include/clang/module.modulemap
> >   cfe/trunk/lib/Format/CMakeLists.txt
> >   cfe/trunk/lib/Format/Format.cpp
> >   cfe/trunk/lib/Tooling/CMakeLists.txt
> >   cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >   cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
> >
> > Modified: cfe/trunk/include/clang/Format/Format.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Format/Format.h?rev=333874=333873=333874=diff
> >
> > 
> ==
> > --- cfe/trunk/include/clang/Format/Format.h (original)
> > +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12 2018
> > @@ -16,8 +16,8 @@
> > #define LLVM_CLANG_FORMAT_FORMAT_H
> >
> > #include "clang/Basic/LangOptions.h"
> > -#include "clang/Tooling/Core/IncludeStyle.h"
> > #include "clang/Tooling/Core/Replacement.h"
> > +#include "clang/Tooling/Inclusions/IncludeStyle.h"
> > #include "llvm/ADT/ArrayRef.h"
> > #include "llvm/Support/Regex.h"
> > #include 
> >
> > Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Tooling/Core/HeaderIncludes.h?rev=333873=auto
> >
> > 
> ==
> > --- 

[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-06-04 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D46024#1121242, @rkirsling wrote:

> FWIW, please note that this space-before-brace style is not specific to 
> WebKit; CppCoreGuidelines exhibits it as well:
>  
> http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es23-prefer-the--initializer-syntax


The main point of clang-format, for me , is to not argue about style. Can we... 
not argue about WebKit's and others' choice? :)


Repository:
  rC Clang

https://reviews.llvm.org/D46024



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-04 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 149807.
emmettneyman added a comment.

- Changed CLArgs into getter and deleted commented code

1. Updating https://reviews.llvm.org/D47666: Refactored clang-fuzzer and added 
new (copy) files #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment.

Made changes in response to comments
Removed commented out code
Changed CLArgs to be a getter method
Removed LLVMFuzzerInitialize decl from header file


Repository:
  rC Clang

https://reviews.llvm.org/D47666

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  tools/clang-fuzzer/FuzzerInitialize.cpp
  tools/clang-fuzzer/FuzzerInitialize.h
  tools/clang-fuzzer/experimental/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/experimental/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx.h
  tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx_main.cpp

Index: tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,34 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "loop_proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+// std::cout << clang_fuzzer::ProtoStringToCxx(str);
+  }
+}
+
Index: tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx.h
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx.h
@@ -0,0 +1,24 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/experimental/loop_proto_to_cxx.cpp
@@ -0,0 +1,115 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include "loop_proto_to_cxx.h"
+#include "cxx_loop_proto.pb.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   

[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-06-04 Thread Ross Kirsling via Phabricator via cfe-commits
rkirsling added a comment.

FWIW, please note that this space-before-brace style is not specific to WebKit; 
CppCoreGuidelines exhibits it as well:
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es23-prefer-the--initializer-syntax


Repository:
  rC Clang

https://reviews.llvm.org/D46024



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


[PATCH] D47628: Detect an incompatible VLA pointer assignment

2018-06-04 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D47628



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-06-04 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333932: [clang-doc] Implement reducer portion of the 
frontend framework (authored by juliehockett, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43341?vs=149500=149804#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43341

Files:
  clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp
  clang-tools-extra/trunk/clang-doc/BitcodeReader.h
  clang-tools-extra/trunk/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/trunk/clang-doc/BitcodeWriter.h
  clang-tools-extra/trunk/clang-doc/CMakeLists.txt
  clang-tools-extra/trunk/clang-doc/Representation.cpp
  clang-tools-extra/trunk/clang-doc/Representation.h
  clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/trunk/test/clang-doc/bc-comment.cpp
  clang-tools-extra/trunk/test/clang-doc/bc-namespace.cpp
  clang-tools-extra/trunk/test/clang-doc/bc-record.cpp

Index: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
@@ -18,7 +18,10 @@
 //
 //===--===//
 
+#include "BitcodeReader.h"
+#include "BitcodeWriter.h"
 #include "ClangDoc.h"
+#include "Representation.h"
 #include "clang/AST/AST.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -30,6 +33,7 @@
 #include "clang/Tooling/StandaloneExecution.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/APFloat.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
@@ -54,14 +58,66 @@
  llvm::cl::desc("Dump mapper results to bitcode file."),
  llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
 
+static llvm::cl::opt DumpIntermediateResult(
+"dump-intermediate",
+llvm::cl::desc("Dump intermediate results to bitcode file."),
+llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
+
+enum OutputFormatTy {
+  yaml,
+};
+
+static llvm::cl::opt
+Format("format", llvm::cl::desc("Format for outputted docs."),
+   llvm::cl::values(clEnumVal(yaml, "Documentation in YAML format.")),
+   llvm::cl::init(yaml), llvm::cl::cat(ClangDocCategory));
+
 static llvm::cl::opt DoxygenOnly(
 "doxygen",
 llvm::cl::desc("Use only doxygen-style comments to generate docs."),
 llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
 
+bool CreateDirectory(const Twine , bool ClearDirectory = false) {
+  std::error_code OK;
+  llvm::SmallString<128> DocsRootPath;
+  if (ClearDirectory) {
+std::error_code RemoveStatus = llvm::sys::fs::remove_directories(DirName);
+if (RemoveStatus != OK) {
+  llvm::errs() << "Unable to remove existing documentation directory for "
+   << DirName << ".\n";
+  return true;
+}
+  }
+  std::error_code DirectoryStatus = llvm::sys::fs::create_directories(DirName);
+  if (DirectoryStatus != OK) {
+llvm::errs() << "Unable to create documentation directories.\n";
+return true;
+  }
+  return false;
+}
+
+bool DumpResultToFile(const Twine , const Twine ,
+  StringRef Buffer, bool ClearDirectory = false) {
+  std::error_code OK;
+  llvm::SmallString<128> IRRootPath;
+  llvm::sys::path::native(OutDirectory, IRRootPath);
+  llvm::sys::path::append(IRRootPath, DirName);
+  if (CreateDirectory(IRRootPath, ClearDirectory))
+return true;
+  llvm::sys::path::append(IRRootPath, FileName);
+  std::error_code OutErrorInfo;
+  llvm::raw_fd_ostream OS(IRRootPath, OutErrorInfo, llvm::sys::fs::F_None);
+  if (OutErrorInfo != OK) {
+llvm::errs() << "Error opening documentation file.\n";
+return true;
+  }
+  OS << Buffer;
+  OS.close();
+  return false;
+}
+
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-  std::error_code OK;
 
   auto Exec = clang::tooling::createExecutorFromCommandLineArgs(
   argc, argv, ClangDocCategory);
@@ -80,34 +136,66 @@
 
   // Mapping phase
   llvm::outs() << "Mapping decls...\n";
-  auto Err = Exec->get()->execute(doc::newMapperActionFactory(
-  Exec->get()->getExecutionContext()),
-  ArgAdjuster);
-  if (Err)
+  auto Err = Exec->get()->execute(
+  doc::newMapperActionFactory(Exec->get()->getExecutionContext()),
+  ArgAdjuster);
+  if (Err) {
 llvm::errs() << toString(std::move(Err)) << "\n";
+return 1;
+  }
 
   if (DumpMapperResult) {
-Exec->get()->getToolResults()->forEachResult([&](StringRef Key,
- StringRef Value) {
-  SmallString<128> IRRootPath;
-  llvm::sys::path::native(OutDirectory, 

[clang-tools-extra] r333932 - [clang-doc] Implement reducer portion of the frontend framework

2018-06-04 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Mon Jun  4 10:22:20 2018
New Revision: 333932

URL: http://llvm.org/viewvc/llvm-project?rev=333932=rev
Log:
[clang-doc] Implement reducer portion of the frontend framework

Implements a simple, in-memory reducer for the mapped output of the
initial tool. This creates a collection object for storing the
deduplicated infos on each declaration, and populates that from the
mapper output. The collection object is serialized to LLVM
bitstream. On reading each serialized output, it checks to see if a
merge is necessary and if so, merges the new info with the existing
info (prefering the existing one if conflicts exist).

For a more detailed overview of the tool, see the design document
on the mailing list:
http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html

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

Added:
clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp
clang-tools-extra/trunk/clang-doc/BitcodeReader.h
clang-tools-extra/trunk/clang-doc/Representation.cpp
clang-tools-extra/trunk/test/clang-doc/bc-comment.cpp
clang-tools-extra/trunk/test/clang-doc/bc-namespace.cpp
clang-tools-extra/trunk/test/clang-doc/bc-record.cpp
Modified:
clang-tools-extra/trunk/clang-doc/BitcodeWriter.cpp
clang-tools-extra/trunk/clang-doc/BitcodeWriter.h
clang-tools-extra/trunk/clang-doc/CMakeLists.txt
clang-tools-extra/trunk/clang-doc/Representation.h
clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp

Added: clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp?rev=333932=auto
==
--- clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp (added)
+++ clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp Mon Jun  4 10:22:20 2018
@@ -0,0 +1,622 @@
+//===--  BitcodeReader.cpp - ClangDoc Bitcode Reader *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "BitcodeReader.h"
+#include "llvm/ADT/IndexedMap.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace doc {
+
+using Record = llvm::SmallVector;
+
+bool decodeRecord(Record R, llvm::SmallVectorImpl ,
+  llvm::StringRef Blob) {
+  Field.assign(Blob.begin(), Blob.end());
+  return true;
+}
+
+bool decodeRecord(Record R, SymbolID , llvm::StringRef Blob) {
+  if (R[0] != BitCodeConstants::USRHashSize)
+return false;
+
+  // First position in the record is the length of the following array, so we
+  // copy the following elements to the field.
+  for (int I = 0, E = R[0]; I < E; ++I)
+Field[I] = R[I + 1];
+  return true;
+}
+
+bool decodeRecord(Record R, bool , llvm::StringRef Blob) {
+  Field = R[0] != 0;
+  return true;
+}
+
+bool decodeRecord(Record R, int , llvm::StringRef Blob) {
+  if (R[0] > INT_MAX)
+return false;
+  Field = (int)R[0];
+  return true;
+}
+
+bool decodeRecord(Record R, AccessSpecifier , llvm::StringRef Blob) {
+  switch (R[0]) {
+  case AS_public:
+  case AS_private:
+  case AS_protected:
+  case AS_none:
+Field = (AccessSpecifier)R[0];
+return true;
+  default:
+return false;
+  }
+}
+
+bool decodeRecord(Record R, TagTypeKind , llvm::StringRef Blob) {
+  switch (R[0]) {
+  case TTK_Struct:
+  case TTK_Interface:
+  case TTK_Union:
+  case TTK_Class:
+  case TTK_Enum:
+Field = (TagTypeKind)R[0];
+return true;
+  default:
+return false;
+  }
+}
+
+bool decodeRecord(Record R, llvm::Optional ,
+  llvm::StringRef Blob) {
+  if (R[0] > INT_MAX)
+return false;
+  Field.emplace((int)R[0], Blob);
+  return true;
+}
+
+bool decodeRecord(Record R, InfoType , llvm::StringRef Blob) {
+  switch (auto IT = static_cast(R[0])) {
+  case InfoType::IT_namespace:
+  case InfoType::IT_record:
+  case InfoType::IT_function:
+  case InfoType::IT_default:
+  case InfoType::IT_enum:
+Field = IT;
+return true;
+  }
+  return false;
+}
+
+bool decodeRecord(Record R, FieldId , llvm::StringRef Blob) {
+  switch (auto F = static_cast(R[0])) {
+  case FieldId::F_namespace:
+  case FieldId::F_parent:
+  case FieldId::F_vparent:
+  case FieldId::F_type:
+  case FieldId::F_default:
+Field = F;
+return true;
+  }
+  return false;
+}
+
+bool decodeRecord(Record R, llvm::SmallVectorImpl> 
,
+  llvm::StringRef Blob) {
+  Field.push_back(Blob);
+  return true;
+}
+
+bool decodeRecord(Record R, llvm::SmallVectorImpl ,
+  llvm::StringRef Blob) {
+  if (R[0] > INT_MAX)
+return false;
+  Field.emplace_back((int)R[0], Blob);
+  return true;
+}
+
+bool parseRecord(Record R, unsigned ID, llvm::StringRef Blob,
+ 

[PATCH] D47401: [X86] Rewrite the max and min reduction intrinsics to make better use of other functions and to reduce width to 256 and 128 bits were possible.

2018-06-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D47401



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


[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: craig.topper, chandlerc.
rnk added a comment.

I read up a little bit on TSX and HLE:
https://software.intel.com/en-us/node/524022
https://en.wikipedia.org/wiki/Transactional_Synchronization_Extensions

These HLE variants of the usual atomic exchange intrinsics add the `xacquire` 
and `xrelease` prefixes. They use the same encoding as the `repe` and `repne` 
prefixes, which previously didn't do anything on Intel (and presumably) AMD 
hardware.

They are a hint to the processor that this is a short critical section, and it 
is likely that the entire critical section can be entered, run, and committed 
to memory before another thread needs to use the memory used by the critical 
section. Your implementation doesn't add these prefixes, but the code will 
execute correctly. This functionality relies on TSX, which it looks like Intel 
added some time in 2014, so it's probably widely available.

Personally, I don't want to implement these intrinsics this way. We've already 
implemented intrinsics "our way" instead of doing whatever Visual C does, and 
it just leads to developer confusion when they discover that the compiler 
didn't emit the instruction they want. For example, the rotate intrinsics often 
don't work (https://llvm.org/pr37387) and the bittestandset (bts) intrinsics 
are just broken (http://llvm.org/pr33188).

@chandlerc @craig.topper are there any plans for representing HLE hints on 
atomic instructions in LLVM IR? Alternatively, do you know who would be most 
interested in adding them? This seems like a reasonable place to use metadata 
or SubclassOptionalData on regular `atomicrmw` instructions, since it's a hint 
that could be dropped. As far as mid-level passes are concerned, these are 
vanilla acquire and release instructions.


Repository:
  rC Clang

https://reviews.llvm.org/D47672



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


[PATCH] D47617: [Analyzer] Fix Z3ConstraintManager crash (PR37646)

2018-06-04 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 149796.
vlad.tsyrklevich added a comment.

- Merge test with apsint.c and move to z3/apsint.c


Repository:
  rC Clang

https://reviews.llvm.org/D47617

Files:
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/apsint.c
  test/Analysis/z3/apsint.c


Index: test/Analysis/z3/apsint.c
===
--- /dev/null
+++ test/Analysis/z3/apsint.c
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu 
-analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+// https://bugs.llvm.org/show_bug.cgi?id=37622
+_Bool a() {
+  return !({ a(); });
+}
+
+// https://bugs.llvm.org/show_bug.cgi?id=37646
+_Bool b;
+void c() {
+  _Bool a = b | 0;
+  for (;;)
+if (a)
+  ;
+}
Index: test/Analysis/apsint.c
===
--- test/Analysis/apsint.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// REQUIRES: z3
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu 
-analyzer-checker=core -verify %s
-// expected-no-diagnostics
-
-_Bool a() {
-  return !({ a(); });
-}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -1231,8 +1231,10 @@
 if (!LHS || !RHS)
   return nullptr;
 
-llvm::APSInt ConvertedLHS = *LHS, ConvertedRHS = *RHS;
-QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
+llvm::APSInt ConvertedLHS, ConvertedRHS;
+QualType LTy, RTy;
+std::tie(ConvertedLHS, LTy) = fixAPSInt(*LHS);
+std::tie(ConvertedRHS, RTy) = fixAPSInt(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
 return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);


Index: test/Analysis/z3/apsint.c
===
--- /dev/null
+++ test/Analysis/z3/apsint.c
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+// https://bugs.llvm.org/show_bug.cgi?id=37622
+_Bool a() {
+  return !({ a(); });
+}
+
+// https://bugs.llvm.org/show_bug.cgi?id=37646
+_Bool b;
+void c() {
+  _Bool a = b | 0;
+  for (;;)
+if (a)
+  ;
+}
Index: test/Analysis/apsint.c
===
--- test/Analysis/apsint.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// REQUIRES: z3
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu -analyzer-checker=core -verify %s
-// expected-no-diagnostics
-
-_Bool a() {
-  return !({ a(); });
-}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -1231,8 +1231,10 @@
 if (!LHS || !RHS)
   return nullptr;
 
-llvm::APSInt ConvertedLHS = *LHS, ConvertedRHS = *RHS;
-QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
+llvm::APSInt ConvertedLHS, ConvertedRHS;
+QualType LTy, RTy;
+std::tie(ConvertedLHS, LTy) = fixAPSInt(*LHS);
+std::tie(ConvertedRHS, RTy) = fixAPSInt(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
 return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47620: Remove llvm::Triple argument from get***Personality() functions. NFC.

2018-06-04 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

@sbc100 ping :)


Repository:
  rC Clang

https://reviews.llvm.org/D47620



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


Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread David Zarzycki via cfe-commits
Hi Roman – I agree that people shouldn’t need to manually fix this every time 
it happens.

Hi Nico – What is stopping the Chromium buildbots from setting 
BUILD_SHARED_LIBS to false? That way the default BUILD_SHARED_LIBS policy of 
llvm and/or clang doesn’t matter, right?

Dave


> On Jun 4, 2018, at 12:40 PM, Roman Lebedev  wrote:
> 
> This is n-th time i do this kind of fix.
> Sure this does resolve the issue, but it would be much better to use
> proper means,
> and tell people to fix their code, in an automatic way :)
> 
> On Mon, Jun 4, 2018 at 7:36 PM, Nico Weber  wrote:
>> All chromium bots build with asserts on and we definitely don't want shared
>> libs :-) Having the people who care about this build config make sure it
>> keeps working seems like a good approach to me.
>> 
>> On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits
>>  wrote:
>>> 
>>> What’s stopping the project from automatically setting BUILD_SHARED_LIBS
>>> to TRUE if asserts are enabled? That’d automatically “force” active
>>> developers to test the scenario on their local machines, but not change the
>>> way release builds work.
>>> 
>>> 
 On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits
  wrote:
 
 This broke building as shared libraries.
 
 I've committed the fix, but the bot coverage is clearly severely
 missing,
 given that such breakages are very often.
 
 Roman.
 
 On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
  wrote:
> Author: ioeric
> Date: Mon Jun  4 02:04:12 2018
> New Revision: 333874
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=333874=rev
> Log:
> Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
> 
> This reverts commit r333534 (i.e. reland r332720) after fixing module
> build.
> 
> Differential Revision: https://reviews.llvm.org/D47068
> 
> Added:
>   cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
> - copied, changed from r333865,
> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>   cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
> - copied, changed from r333865,
> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>   cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
> - copied, changed from r333865,
> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>   cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
> - copied, changed from r333865,
> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>   cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
> - copied, changed from r333865,
> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> Removed:
>   cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>   cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>   cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>   cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> Modified:
>   cfe/trunk/include/clang/Format/Format.h
>   cfe/trunk/include/clang/module.modulemap
>   cfe/trunk/lib/Format/CMakeLists.txt
>   cfe/trunk/lib/Format/Format.cpp
>   cfe/trunk/lib/Tooling/CMakeLists.txt
>   cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>   cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
> 
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333874=333873=333874=diff
> 
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12 2018
> @@ -16,8 +16,8 @@
> #define LLVM_CLANG_FORMAT_FORMAT_H
> 
> #include "clang/Basic/LangOptions.h"
> -#include "clang/Tooling/Core/IncludeStyle.h"
> #include "clang/Tooling/Core/Replacement.h"
> +#include "clang/Tooling/Inclusions/IncludeStyle.h"
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/Support/Regex.h"
> #include 
> 
> Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=333873=auto
> 
> ==
> --- cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (removed)
> @@ -1,137 +0,0 @@
> -//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*-
> C++-*-===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open
> Source
> -// License. See LICENSE.TXT for details.
> -//
> 
> -//===--===//
> -
> 

Re: r333923 - This diff includes changes for supporting the following types.

2018-06-04 Thread Leonard Chan via cfe-commits
Sorry. I did not notice this. I will be sure to add the title from the
phabricator review as the first line next time.
On Mon, Jun 4, 2018 at 9:44 AM Roman Lebedev  wrote:
>
> Did you use `arc patch` to get the commit description?
> Please make sure that the first line of the commit is reasonable.
> In this case it is not reasonable.
>
> On Mon, Jun 4, 2018 at 7:07 PM, Leonard Chan via cfe-commits
>  wrote:
> > Author: leonardchan
> > Date: Mon Jun  4 09:07:52 2018
> > New Revision: 333923
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=333923=rev
> > Log:
> > This diff includes changes for supporting the following types.
> >
> > // Primary fixed point types
> > signed short _Accum s_short_accum;
> > signed _Accum s_accum;
> > signed long _Accum s_long_accum;
> > unsigned short _Accum u_short_accum;
> > unsigned _Accum u_accum;
> > unsigned long _Accum u_long_accum;
> >
> > // Aliased fixed point types
> > short _Accum short_accum;
> > _Accum accum;
> > long _Accum long_accum;
> > This diff only allows for declaration of the fixed point types. Assignment 
> > and other operations done on fixed point types according to 
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
> > future patches. The saturated versions of these types and the equivalent 
> > _Fract types will also be added in future patches.
> >
> > The tests included are for asserting that we can declare these types.
> >
> > Fixed the test that was failing by not checking for dso_local on some
> > targets.
> >
> > Differential Revision: https://reviews.llvm.org/D46084
> >
> > Added:
> > cfe/trunk/test/Frontend/fixed_point.c
> > cfe/trunk/test/Frontend/fixed_point_bit_widths.c
> > cfe/trunk/test/Frontend/fixed_point_errors.c
> > cfe/trunk/test/Frontend/fixed_point_errors.cpp
> > cfe/trunk/test/Frontend/fixed_point_not_enabled.c
> > Modified:
> > cfe/trunk/include/clang-c/Index.h
> > cfe/trunk/include/clang/AST/ASTContext.h
> > cfe/trunk/include/clang/AST/BuiltinTypes.def
> > cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
> > cfe/trunk/include/clang/Basic/LangOptions.def
> > cfe/trunk/include/clang/Basic/Specifiers.h
> > cfe/trunk/include/clang/Basic/TargetInfo.h
> > cfe/trunk/include/clang/Basic/TokenKinds.def
> > cfe/trunk/include/clang/Driver/Options.td
> > cfe/trunk/include/clang/Sema/DeclSpec.h
> > cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> > cfe/trunk/lib/AST/ASTContext.cpp
> > cfe/trunk/lib/AST/ExprConstant.cpp
> > cfe/trunk/lib/AST/ItaniumMangle.cpp
> > cfe/trunk/lib/AST/MicrosoftMangle.cpp
> > cfe/trunk/lib/AST/NSAPI.cpp
> > cfe/trunk/lib/AST/Type.cpp
> > cfe/trunk/lib/AST/TypeLoc.cpp
> > cfe/trunk/lib/Analysis/PrintfFormatString.cpp
> > cfe/trunk/lib/Basic/TargetInfo.cpp
> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> > cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> > cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> > cfe/trunk/lib/Index/USRGeneration.cpp
> > cfe/trunk/lib/Parse/ParseDecl.cpp
> > cfe/trunk/lib/Sema/DeclSpec.cpp
> > cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> > cfe/trunk/lib/Sema/SemaType.cpp
> > cfe/trunk/lib/Serialization/ASTCommon.cpp
> > cfe/trunk/lib/Serialization/ASTReader.cpp
> > cfe/trunk/tools/libclang/CXType.cpp
> >
> > Modified: cfe/trunk/include/clang-c/Index.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333923=333922=333923=diff
> > ==
> > --- cfe/trunk/include/clang-c/Index.h (original)
> > +++ cfe/trunk/include/clang-c/Index.h Mon Jun  4 09:07:52 2018
> > @@ -3182,8 +3182,14 @@ enum CXTypeKind {
> >CXType_Float128 = 30,
> >CXType_Half = 31,
> >CXType_Float16 = 32,
> > +  CXType_ShortAccum = 33,
> > +  CXType_Accum = 34,
> > +  CXType_LongAccum = 35,
> > +  CXType_UShortAccum = 36,
> > +  CXType_UAccum = 37,
> > +  CXType_ULongAccum = 38,
> >CXType_FirstBuiltin = CXType_Void,
> > -  CXType_LastBuiltin  = CXType_Float16,
> > +  CXType_LastBuiltin = CXType_ULongAccum,
> >
> >CXType_Complex = 100,
> >CXType_Pointer = 101,
> >
> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333923=333922=333923=diff
> > ==
> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> > +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jun  4 09:07:52 2018
> > @@ -1007,6 +1007,9 @@ public:
> >CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, 
> > UnsignedLongTy;
> >CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
> >CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
> > +  CanQualType ShortAccumTy, AccumTy,

Re: r333923 - This diff includes changes for supporting the following types.

2018-06-04 Thread Roman Lebedev via cfe-commits
Did you use `arc patch` to get the commit description?
Please make sure that the first line of the commit is reasonable.
In this case it is not reasonable.

On Mon, Jun 4, 2018 at 7:07 PM, Leonard Chan via cfe-commits
 wrote:
> Author: leonardchan
> Date: Mon Jun  4 09:07:52 2018
> New Revision: 333923
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333923=rev
> Log:
> This diff includes changes for supporting the following types.
>
> // Primary fixed point types
> signed short _Accum s_short_accum;
> signed _Accum s_accum;
> signed long _Accum s_long_accum;
> unsigned short _Accum u_short_accum;
> unsigned _Accum u_accum;
> unsigned long _Accum u_long_accum;
>
> // Aliased fixed point types
> short _Accum short_accum;
> _Accum accum;
> long _Accum long_accum;
> This diff only allows for declaration of the fixed point types. Assignment 
> and other operations done on fixed point types according to 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
> future patches. The saturated versions of these types and the equivalent 
> _Fract types will also be added in future patches.
>
> The tests included are for asserting that we can declare these types.
>
> Fixed the test that was failing by not checking for dso_local on some
> targets.
>
> Differential Revision: https://reviews.llvm.org/D46084
>
> Added:
> cfe/trunk/test/Frontend/fixed_point.c
> cfe/trunk/test/Frontend/fixed_point_bit_widths.c
> cfe/trunk/test/Frontend/fixed_point_errors.c
> cfe/trunk/test/Frontend/fixed_point_errors.cpp
> cfe/trunk/test/Frontend/fixed_point_not_enabled.c
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/BuiltinTypes.def
> cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Basic/Specifiers.h
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Sema/DeclSpec.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/AST/NSAPI.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/AST/TypeLoc.cpp
> cfe/trunk/lib/Analysis/PrintfFormatString.cpp
> cfe/trunk/lib/Basic/TargetInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Index/USRGeneration.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/DeclSpec.cpp
> cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Serialization/ASTCommon.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/tools/libclang/CXType.cpp
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333923=333922=333923=diff
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Mon Jun  4 09:07:52 2018
> @@ -3182,8 +3182,14 @@ enum CXTypeKind {
>CXType_Float128 = 30,
>CXType_Half = 31,
>CXType_Float16 = 32,
> +  CXType_ShortAccum = 33,
> +  CXType_Accum = 34,
> +  CXType_LongAccum = 35,
> +  CXType_UShortAccum = 36,
> +  CXType_UAccum = 37,
> +  CXType_ULongAccum = 38,
>CXType_FirstBuiltin = CXType_Void,
> -  CXType_LastBuiltin  = CXType_Float16,
> +  CXType_LastBuiltin = CXType_ULongAccum,
>
>CXType_Complex = 100,
>CXType_Pointer = 101,
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333923=333922=333923=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jun  4 09:07:52 2018
> @@ -1007,6 +1007,9 @@ public:
>CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
>CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
>CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
> +  CanQualType ShortAccumTy, AccumTy,
> +  LongAccumTy;  // ISO/IEC JTC1 SC22 WG14 N1169 Extension
> +  CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy;
>CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
>CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
>CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
>
> Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
> URL: 
> 

[PATCH] D47726: [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-04 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich created this revision.
vlad.tsyrklevich added reviewers: george.karpenkov, NoQ, ddcc.
Herald added subscribers: cfe-commits, a.sidorin, zzheng, szepet, xazax.hun.

Since Z3 tests have been not been running [1] some tests needed to be
updated. I also added a regression test for [1].

[1] https://reviews.llvm.org/D47722


Repository:
  rC Clang

https://reviews.llvm.org/D47726

Files:
  test/Analysis/PR24184.cpp
  test/Analysis/constant-folding.c
  test/Analysis/loop-unrolling.cpp
  test/Analysis/z3/enabled.c


Index: test/Analysis/z3/enabled.c
===
--- /dev/null
+++ test/Analysis/z3/enabled.c
@@ -0,0 +1,3 @@
+// REQUIRES: z3
+// RUN: echo %clang_analyze_cc1 | FileCheck %s
+// CHECK: -analyzer-constraints=z3
Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -368,7 +368,11 @@
 int nested_inlined_no_unroll1() {
   int k;
   for (int i = 0; i < 9; i++) {
+#ifdef ANALYZER_CM_Z3
+clang_analyzer_numTimesReached(); // expected-warning {{13}}
+#else
 clang_analyzer_numTimesReached(); // expected-warning {{15}}
+#endif
 k = simple_unknown_bound_loop();  // reevaluation without inlining, splits 
the state as well
   }
   int a = 22 / k; // no-warning
Index: test/Analysis/constant-folding.c
===
--- test/Analysis/constant-folding.c
+++ test/Analysis/constant-folding.c
@@ -108,7 +108,11 @@
   clang_analyzer_eval((b | -2) == 0); // expected-warning{{FALSE}}
   clang_analyzer_eval((b | 10) == 0); // expected-warning{{FALSE}}
   clang_analyzer_eval((b | 0) == 0); // expected-warning{{UNKNOWN}}
+#ifdef ANALYZER_CM_Z3
+  clang_analyzer_eval((b | -2) >= 0); // expected-warning{{FALSE}}
+#else
   clang_analyzer_eval((b | -2) >= 0); // expected-warning{{UNKNOWN}}
+#endif
 
   // Check that dynamically computed constants also work.
   int constant = 1 << 3;
Index: test/Analysis/PR24184.cpp
===
--- test/Analysis/PR24184.cpp
+++ test/Analysis/PR24184.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: z3
 // RUN: %clang_analyze_cc1 -w -analyzer-eagerly-assume -fcxx-exceptions 
-analyzer-checker=core 
-analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct 
-analyzer-max-loop 64 -verify %s
 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core 
-analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker 
alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify 
%s
 


Index: test/Analysis/z3/enabled.c
===
--- /dev/null
+++ test/Analysis/z3/enabled.c
@@ -0,0 +1,3 @@
+// REQUIRES: z3
+// RUN: echo %clang_analyze_cc1 | FileCheck %s
+// CHECK: -analyzer-constraints=z3
Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -368,7 +368,11 @@
 int nested_inlined_no_unroll1() {
   int k;
   for (int i = 0; i < 9; i++) {
+#ifdef ANALYZER_CM_Z3
+clang_analyzer_numTimesReached(); // expected-warning {{13}}
+#else
 clang_analyzer_numTimesReached(); // expected-warning {{15}}
+#endif
 k = simple_unknown_bound_loop();  // reevaluation without inlining, splits the state as well
   }
   int a = 22 / k; // no-warning
Index: test/Analysis/constant-folding.c
===
--- test/Analysis/constant-folding.c
+++ test/Analysis/constant-folding.c
@@ -108,7 +108,11 @@
   clang_analyzer_eval((b | -2) == 0); // expected-warning{{FALSE}}
   clang_analyzer_eval((b | 10) == 0); // expected-warning{{FALSE}}
   clang_analyzer_eval((b | 0) == 0); // expected-warning{{UNKNOWN}}
+#ifdef ANALYZER_CM_Z3
+  clang_analyzer_eval((b | -2) >= 0); // expected-warning{{FALSE}}
+#else
   clang_analyzer_eval((b | -2) >= 0); // expected-warning{{UNKNOWN}}
+#endif
 
   // Check that dynamically computed constants also work.
   int constant = 1 << 3;
Index: test/Analysis/PR24184.cpp
===
--- test/Analysis/PR24184.cpp
+++ test/Analysis/PR24184.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: z3
 // RUN: %clang_analyze_cc1 -w -analyzer-eagerly-assume -fcxx-exceptions -analyzer-checker=core -analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 64 -verify %s
 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread Roman Lebedev via cfe-commits
This is n-th time i do this kind of fix.
Sure this does resolve the issue, but it would be much better to use
proper means,
and tell people to fix their code, in an automatic way :)

On Mon, Jun 4, 2018 at 7:36 PM, Nico Weber  wrote:
> All chromium bots build with asserts on and we definitely don't want shared
> libs :-) Having the people who care about this build config make sure it
> keeps working seems like a good approach to me.
>
> On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits
>  wrote:
>>
>> What’s stopping the project from automatically setting BUILD_SHARED_LIBS
>> to TRUE if asserts are enabled? That’d automatically “force” active
>> developers to test the scenario on their local machines, but not change the
>> way release builds work.
>>
>>
>> > On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits
>> >  wrote:
>> >
>> > This broke building as shared libraries.
>> >
>> > I've committed the fix, but the bot coverage is clearly severely
>> > missing,
>> > given that such breakages are very often.
>> >
>> > Roman.
>> >
>> > On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
>> >  wrote:
>> >> Author: ioeric
>> >> Date: Mon Jun  4 02:04:12 2018
>> >> New Revision: 333874
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=333874=rev
>> >> Log:
>> >> Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
>> >>
>> >> This reverts commit r333534 (i.e. reland r332720) after fixing module
>> >> build.
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D47068
>> >>
>> >> Added:
>> >>cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >>cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >>cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >>cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >>cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> >> Removed:
>> >>cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >>cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >>cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >>cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> >> Modified:
>> >>cfe/trunk/include/clang/Format/Format.h
>> >>cfe/trunk/include/clang/module.modulemap
>> >>cfe/trunk/lib/Format/CMakeLists.txt
>> >>cfe/trunk/lib/Format/Format.cpp
>> >>cfe/trunk/lib/Tooling/CMakeLists.txt
>> >>cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >>cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
>> >>
>> >> Modified: cfe/trunk/include/clang/Format/Format.h
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333874=333873=333874=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/include/clang/Format/Format.h (original)
>> >> +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12 2018
>> >> @@ -16,8 +16,8 @@
>> >> #define LLVM_CLANG_FORMAT_FORMAT_H
>> >>
>> >> #include "clang/Basic/LangOptions.h"
>> >> -#include "clang/Tooling/Core/IncludeStyle.h"
>> >> #include "clang/Tooling/Core/Replacement.h"
>> >> +#include "clang/Tooling/Inclusions/IncludeStyle.h"
>> >> #include "llvm/ADT/ArrayRef.h"
>> >> #include "llvm/Support/Regex.h"
>> >> #include 
>> >>
>> >> Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=333873=auto
>> >>
>> >> ==
>> >> --- cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (original)
>> >> +++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (removed)
>> >> @@ -1,137 +0,0 @@
>> >> -//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*-
>> >> C++-*-===//
>> >> -//
>> >> -// The LLVM Compiler Infrastructure
>> >> -//
>> >> -// This file is distributed under the University of Illinois Open
>> >> Source
>> >> -// License. See LICENSE.TXT for details.
>> >> -//
>> >>
>> >> -//===--===//
>> >> -
>> >> -#ifndef LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
>> >> -#define LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
>> >> -
>> >> -#include "clang/Basic/SourceManager.h"
>> >> -#include "clang/Tooling/Core/Replacement.h"
>> >> -#include "clang/Tooling/Core/IncludeStyle.h"
>> >> -#include "llvm/Support/Path.h"
>> >> -#include "llvm/Support/Regex.h"
>> >> -#include 
>> >> -
>> 

Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread Nico Weber via cfe-commits
All chromium bots build with asserts on and we definitely don't want shared
libs :-) Having the people who care about this build config make sure it
keeps working seems like a good approach to me.

On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> What’s stopping the project from automatically setting BUILD_SHARED_LIBS
> to TRUE if asserts are enabled? That’d automatically “force” active
> developers to test the scenario on their local machines, but not change the
> way release builds work.
>
>
> > On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > This broke building as shared libraries.
> >
> > I've committed the fix, but the bot coverage is clearly severely missing,
> > given that such breakages are very often.
> >
> > Roman.
> >
> > On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
> >  wrote:
> >> Author: ioeric
> >> Date: Mon Jun  4 02:04:12 2018
> >> New Revision: 333874
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=333874=rev
> >> Log:
> >> Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
> >>
> >> This reverts commit r333534 (i.e. reland r332720) after fixing module
> build.
> >>
> >> Differential Revision: https://reviews.llvm.org/D47068
> >>
> >> Added:
> >>cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
> >>  - copied, changed from r333865, cfe/trunk/include/clang/
> Tooling/Core/HeaderIncludes.h
> >>cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
> >>  - copied, changed from r333865, cfe/trunk/include/clang/
> Tooling/Core/IncludeStyle.h
> >>cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
> >>  - copied, changed from r333865, cfe/trunk/lib/Tooling/Core/
> CMakeLists.txt
> >>cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
> >>  - copied, changed from r333865, cfe/trunk/lib/Tooling/Core/
> HeaderIncludes.cpp
> >>cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
> >>  - copied, changed from r333865, cfe/trunk/lib/Tooling/Core/
> IncludeStyle.cpp
> >> Removed:
> >>cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >>cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >>cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >>cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> >> Modified:
> >>cfe/trunk/include/clang/Format/Format.h
> >>cfe/trunk/include/clang/module.modulemap
> >>cfe/trunk/lib/Format/CMakeLists.txt
> >>cfe/trunk/lib/Format/Format.cpp
> >>cfe/trunk/lib/Tooling/CMakeLists.txt
> >>cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >>cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Format/Format.h
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Format/Format.h?rev=333874=333873=333874=diff
> >> 
> ==
> >> --- cfe/trunk/include/clang/Format/Format.h (original)
> >> +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12 2018
> >> @@ -16,8 +16,8 @@
> >> #define LLVM_CLANG_FORMAT_FORMAT_H
> >>
> >> #include "clang/Basic/LangOptions.h"
> >> -#include "clang/Tooling/Core/IncludeStyle.h"
> >> #include "clang/Tooling/Core/Replacement.h"
> >> +#include "clang/Tooling/Inclusions/IncludeStyle.h"
> >> #include "llvm/ADT/ArrayRef.h"
> >> #include "llvm/Support/Regex.h"
> >> #include 
> >>
> >> Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Tooling/Core/HeaderIncludes.h?rev=333873=auto
> >> 
> ==
> >> --- cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (original)
> >> +++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (removed)
> >> @@ -1,137 +0,0 @@
> >> -//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*-
> C++-*-===//
> >> -//
> >> -// The LLVM Compiler Infrastructure
> >> -//
> >> -// This file is distributed under the University of Illinois Open
> Source
> >> -// License. See LICENSE.TXT for details.
> >> -//
> >> -//===--
> ===//
> >> -
> >> -#ifndef LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
> >> -#define LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
> >> -
> >> -#include "clang/Basic/SourceManager.h"
> >> -#include "clang/Tooling/Core/Replacement.h"
> >> -#include "clang/Tooling/Core/IncludeStyle.h"
> >> -#include "llvm/Support/Path.h"
> >> -#include "llvm/Support/Regex.h"
> >> -#include 
> >> -
> >> -namespace clang {
> >> -namespace tooling {
> >> -
> >> -/// This class manages priorities of C++ #include categories and
> calculates
> >> -/// priorities for headers.
> >> -/// FIXME(ioeric): move this class into implementation file when
> clang-format's
> >> -/// include sorting functions are also moved here.
> >> -class 

[PATCH] D47694: [CUDA][HIP] Do not emit type info when compiling for device

2018-06-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D47694#1121037, @rjmccall wrote:

> In https://reviews.llvm.org/D47694#1120375, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D47694#1120367, @rjmccall wrote:
> >
> > > Why not just have the driver disable RTTI in the frontend invocation?
> >
> >
> > CUDA/HIP uses single source for device and host. The host code may depend 
> > on RTTI,
> >  e.g., an application may include some boost headers which will fail if 
> > RTTI is disabled,
> >  therefore RTTI cannot be disabled when compiling device code.
>
>
> It's a single source file, yes, but behind the scenes you do a separate 
> invocation of the compiler to re-parse that file for device code-generation, 
> right?


That's true. However, when compiling for device, the source file is still the 
original source code which are for both host and device. When compiling
for device, the compiler still needs to parse the source code for host, and 
there is no way to disable RTTI only for the device code.


https://reviews.llvm.org/D47694



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


[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning

2018-06-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I'm in favor of this direction. The `var || var && truth_constant` pattern 
match seems much more robust than the macro pattern match. It's also consistent 
with what we do outside of macros, so it's less special and surprising.


https://reviews.llvm.org/D47687



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


r333923 - This diff includes changes for supporting the following types.

2018-06-04 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Jun  4 09:07:52 2018
New Revision: 333923

URL: http://llvm.org/viewvc/llvm-project?rev=333923=rev
Log:
This diff includes changes for supporting the following types.

// Primary fixed point types
signed short _Accum s_short_accum;
signed _Accum s_accum;
signed long _Accum s_long_accum;
unsigned short _Accum u_short_accum;
unsigned _Accum u_accum;
unsigned long _Accum u_long_accum;

// Aliased fixed point types
short _Accum short_accum;
_Accum accum;
long _Accum long_accum;
This diff only allows for declaration of the fixed point types. Assignment and 
other operations done on fixed point types according to 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
future patches. The saturated versions of these types and the equivalent _Fract 
types will also be added in future patches.

The tests included are for asserting that we can declare these types.

Fixed the test that was failing by not checking for dso_local on some
targets.

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

Added:
cfe/trunk/test/Frontend/fixed_point.c
cfe/trunk/test/Frontend/fixed_point_bit_widths.c
cfe/trunk/test/Frontend/fixed_point_errors.c
cfe/trunk/test/Frontend/fixed_point_errors.cpp
cfe/trunk/test/Frontend/fixed_point_not_enabled.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333923=333922=333923=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Jun  4 09:07:52 2018
@@ -3182,8 +3182,14 @@ enum CXTypeKind {
   CXType_Float128 = 30,
   CXType_Half = 31,
   CXType_Float16 = 32,
+  CXType_ShortAccum = 33,
+  CXType_Accum = 34,
+  CXType_LongAccum = 35,
+  CXType_UShortAccum = 36,
+  CXType_UAccum = 37,
+  CXType_ULongAccum = 38,
   CXType_FirstBuiltin = CXType_Void,
-  CXType_LastBuiltin  = CXType_Float16,
+  CXType_LastBuiltin = CXType_ULongAccum,
 
   CXType_Complex = 100,
   CXType_Pointer = 101,

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333923=333922=333923=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jun  4 09:07:52 2018
@@ -1007,6 +1007,9 @@ public:
   CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
   CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
   CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
+  CanQualType ShortAccumTy, AccumTy,
+  LongAccumTy;  // ISO/IEC JTC1 SC22 WG14 N1169 Extension
+  CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
   CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;

Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=333923=333922=333923=diff
==
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Mon Jun  4 09:07:52 2018
@@ -122,6 +122,26 @@ SIGNED_TYPE(LongLong, LongLongTy)
 // '__int128_t'
 SIGNED_TYPE(Int128, Int128Ty)
 
+//===- Fixed point 

[PATCH] D47592: [AArch64] Corrected FP16 Intrinsic range checks in Clang + added Sema tests

2018-06-04 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

I think this looks ok now, just some nits inline.

Can you please upload your diffs with more context next time?




Comment at: utils/TableGen/NeonEmitter.cpp:2166
+void NeonEmitter::genIntrinsicRangeCheckCode(raw_ostream ,
 SmallVectorImpl ) {
   OS << "#ifdef GET_NEON_IMMEDIATE_CHECK\n";

Nit: can you realign this?



Comment at: utils/TableGen/NeonEmitter.cpp:2193
+ if (Def->getBaseType().getElementSizeInBits() == 16 ||
+ Def->getName().find('h') != std::string::npos)
+   // VCVTh operating on FP16 intrinsics in range [1, 16)

Nit: for a moment I thought this could match more cases than intended, but we 
have already checked for isVCVT_N, so should be fine?



Comment at: utils/TableGen/NeonEmitter.cpp:2194
+ Def->getName().find('h') != std::string::npos)
+   // VCVTh operating on FP16 intrinsics in range [1, 16)
+   UpperBound = "15";

Nit: think you're (almost) repeating the comment above, so you can omit this 
one?


https://reviews.llvm.org/D47592



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


[PATCH] D46421: [analyzer][CrossTU] Extend CTU to VarDecls with initializer

2018-06-04 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added a comment.

In https://reviews.llvm.org/D46421#1119098, @xazax.hun wrote:

> Sorry for the limited activity. Unfortunately, I have very little time 
> reviewing patches lately.


Thanks for getting around to it!

> I think we need to answer the following questions:
> 
> - Does this change affect the analysis of the constructors of global objects? 
> If so, how?

The intention was to only allow the analyzer to resolve constants of arrays, 
structs and integral values. It seems to me that construction would have to be 
symbolically executed at the correct point in time and cannot be retroactively 
looked up - as is done with the constants here.

> - Do we want to import non-const object's initializer expressions? The 
> analyzer might not end up using the value anyways.

It seems like a good idea to not do that, since non-const values are not used. 
It might become useful if we ever do some kind of straight line execution from 
static initialization to main.
However for structs it is enough if one of their fields is declared const.

> - How big can the index get with this modification for large projects?

That depends a lot on global usage of course. In LLVM for example there is 
little impact, but I don't have any numbers, it's taking too long. Taking care 
of the previous point helps here as well.

> Overall the direction looks good to me, this will be a very useful addition, 
> thanks for working on this.

I will prepare something to not store unnecessary entries in the index. I also 
noticed the AnalysisConsumer change has gone missing with my latest diff - will 
be fixed.


https://reviews.llvm.org/D46421



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


[PATCH] D47724: [X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmaddsub/fmsubadd builtins.

2018-06-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: tkrupa, RKSimon, spatel, GBuella.

We recently switch to using a selects in the intrinsics header files for FMA 
instructions. But the 512-bit versions support flavors with rounding mode which 
must be an Integer Constant Expression. This has forced those intrinsics to be 
implemented as macros. As it stands now the mask and mask3 intrinsics evaluate 
one of their macro arguments twice. If that argument itself is another 
intrinsic macro, we can end up over expanding macros. Or if its something we 
can CSE later it would show up multiple times when it shouldn't.

I tried adding __extension__ around the macro and making it an expression 
statement and declaring a local variable. But whatever name you choose for the 
local variable can never be used as the name of an input to the macro in user 
code. If that happens you would end up with the same name on the LHS and RHS of 
an assignment after expansion. We might be safe if we use __ in front of the 
variable names because those names are reserved and user code shouldn't use 
that, but I wasn't sure I wanted to make that claim.

The other option which I've chosen here, is to add back _mask, _maskz, and 
_mask3 flavors of the builtin which we will expand in CGBuiltin.cpp to 
replicate the argument as needed and insert any fneg needed on the third 
operand to make a subtract. The _maskz isn't truly necessary if we have an 
unmasked version or if we use the masked version with a -1 mask and wrap a 
select around it. But I've chosen to make things more uniform.

I separated out the scalar builtin handling to avoid too many things going on 
in EmitX86FMAExpr. It was different enough due to the extract and insert that 
the minor duplication of the CreateCall was probably worth it.


Repository:
  rC Clang

https://reviews.llvm.org/D47724

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/avx512fintrin.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -461,7 +461,7 @@
   // CHECK-LABEL: @test_mm512_maskz_fmadd_round_pd
   // CHECK: @llvm.x86.avx512.vfmadd.pd.512
   // CHECK: bitcast i8 %{{.*}} to <8 x i1>
-  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> zeroinitializer
   return _mm512_maskz_fmadd_round_pd(__U, __A, __B, __C, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 __m512d test_mm512_fmsub_round_pd(__m512d __A, __m512d __B, __m512d __C) {
@@ -483,7 +483,7 @@
   // CHECK: fsub <8 x double> 
   // CHECK: @llvm.x86.avx512.vfmadd.pd.512
   // CHECK: bitcast i8 %{{.*}} to <8 x i1>
-  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> zeroinitializer
   return _mm512_maskz_fmsub_round_pd(__U, __A, __B, __C, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 __m512d test_mm512_fnmadd_round_pd(__m512d __A, __m512d __B, __m512d __C) {
@@ -505,7 +505,7 @@
   // CHECK: fsub <8 x double> 
   // CHECK: @llvm.x86.avx512.vfmadd.pd.512
   // CHECK: bitcast i8 %{{.*}} to <8 x i1>
-  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> zeroinitializer
   return _mm512_maskz_fnmadd_round_pd(__U, __A, __B, __C, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 __m512d test_mm512_fnmsub_round_pd(__m512d __A, __m512d __B, __m512d __C) {
@@ -521,7 +521,7 @@
   // CHECK: fsub <8 x double> 
   // CHECK: @llvm.x86.avx512.vfmadd.pd.512
   // CHECK: bitcast i8 %{{.*}} to <8 x i1>
-  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> zeroinitializer
   return _mm512_maskz_fnmsub_round_pd(__U, __A, __B, __C, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 __m512d test_mm512_fmadd_pd(__m512d __A, __m512d __B, __m512d __C) {
@@ -547,7 +547,7 @@
   // CHECK-LABEL: @test_mm512_maskz_fmadd_pd
   // CHECK: call <8 x double> @llvm.fma.v8f64(<8 x double> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}})
   // CHECK: bitcast i8 %{{.*}} to <8 x i1>
-  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> zeroinitializer
   return _mm512_maskz_fmadd_pd(__U, __A, __B, __C);
 }
 __m512d test_mm512_fmsub_pd(__m512d __A, __m512d __B, __m512d __C) {
@@ -569,7 +569,7 @@
   // CHECK: fsub <8 x double> , %{{.*}}
   // CHECK: call <8 x double> @llvm.fma.v8f64(<8 x double> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}})
   // CHECK: bitcast i8 %{{.*}} to <8 x i1>
-  // CHECK: select <8 x i1> %{{.*}}, <8 

[libcxxabi] r333916 - Creating release candidate rc2 from release_601 branch

2018-06-04 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Mon Jun  4 08:53:32 2018
New Revision: 333916

URL: http://llvm.org/viewvc/llvm-project?rev=333916=rev
Log:
Creating release candidate rc2 from release_601 branch

Added:
libcxxabi/tags/RELEASE_601/rc2/
  - copied from r333915, libcxxabi/branches/release_60/

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


[libunwind] r333922 - Creating release candidate rc2 from release_601 branch

2018-06-04 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Mon Jun  4 08:54:00 2018
New Revision: 333922

URL: http://llvm.org/viewvc/llvm-project?rev=333922=rev
Log:
Creating release candidate rc2 from release_601 branch

Added:
libunwind/tags/RELEASE_601/rc2/
  - copied from r333921, libunwind/branches/release_60/

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


[libcxx] r333915 - Creating release candidate rc2 from release_601 branch

2018-06-04 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Mon Jun  4 08:53:28 2018
New Revision: 333915

URL: http://llvm.org/viewvc/llvm-project?rev=333915=rev
Log:
Creating release candidate rc2 from release_601 branch

Added:
libcxx/tags/RELEASE_601/rc2/   (props changed)
  - copied from r333914, libcxx/branches/release_60/

Propchange: libcxx/tags/RELEASE_601/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Mon Jun  4 08:53:28 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:321963,324153,324855,325147


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


[PATCH] D47720: [DebugInfo] Inline for without DebugLocation

2018-06-04 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: test/CodeGen/debug-info-inline-for.c:2
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+int func(int n) {

Please add a comment explaining what is being tested here.


Repository:
  rC Clang

https://reviews.llvm.org/D47720



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


[PATCH] D47617: [Analyzer] Fix Z3ConstraintManager crash (PR37646)

2018-06-04 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added a comment.

In https://reviews.llvm.org/D47617#1119268, @NoQ wrote:

> Also does this test need to be z3-specific? We would also not like to crash 
> here without z3.


I originally did that so I could specify enabling and testing the z3 backend; 
however, looking at the testing infra more I realize that z3 is supposed to be 
run on the analyzer tests but it seems like z3 tests have been broken since 
October when r315627 landed. I submitted a fix in 
https://reviews.llvm.org/D47722


Repository:
  rC Clang

https://reviews.llvm.org/D47617



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


  1   2   >