Re: r338899 - [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-06 Thread Vlad Tsyrklevich via cfe-commits
Have you tried setting detect_stack_use_after_return in ASAN_OPTIONS? The
ASan buildbot sets the following ASAN_OPTIONS prior to running tests:
export
ASAN_OPTIONS="check_initialization_order=true:detect_stack_use_after_return=1:detect_leaks=1"

On Mon, Aug 6, 2018 at 7:34 AM  wrote:

> I can't seem to reproduce the ASan failure locally, even after building
> a clang with the latest compiler-rt, and then rebuilding my patch with
> LLVM_USE_SANITIZER=Address
>
> I am pretty confident the problem should be fixed with a one-line change
> to my patch:
>
> -auto CreateArrayForSizeVar = [=](unsigned First) {
> +auto CreateArrayForSizeVar = [=](unsigned First)
> +-> std::tuple {
>
> I don't want to commit something and then immediately have to revert,
> though. Can you think of anything I might be missing locally to
> reproduce the ASan failure?
>
> Thanks,
> Scott
>
> On 2018-08-03 13:48, Vlad Tsyrklevich wrote:
> > This change is causing ASan failures on the sanitizer bots:
> >
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/21898/steps/check-clang%20asan/logs/stdio
> > [9]
> >
> > I've reverted it in r338904.
> >
> > On Fri, Aug 3, 2018 at 8:51 AM Scott Linder via cfe-commits
> >  wrote:
> >
> >> Author: scott.linder
> >> Date: Fri Aug 3 08:50:52 2018
> >> New Revision: 338899
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=338899&view=rev [1]
> >> Log:
> >> [OpenCL] Always emit alloca in entry block for enqueue_kernel
> >> builtin
> >>
> >> Ensures the statically sized alloca is not converted to
> >> DYNAMIC_STACKALLOC
> >> later because it is not in the entry block.
> >>
> >> Differential Revision: https://reviews.llvm.org/D50104 [2]
> >>
> >> Added:
> >> cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
> >> [3]
> >> Modified:
> >> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl [4]
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL:
> >>
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=338899&r1=338898&r2=338899&view=diff
> >> [5]
> >>
> >
> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug 3 08:50:52 2018
> >> @@ -3338,23 +3338,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >> // Create a temporary array to hold the sizes of local pointer
> >> arguments
> >> // for the block. \p First is the position of the first size
> >> argument.
> >> auto CreateArrayForSizeVar = [=](unsigned First) {
> >> - auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
> >> - auto *Arr = Builder.CreateAlloca(AT);
> >> - llvm::Value *Ptr;
> >> + llvm::APInt ArraySize(32, NumArgs - First);
> >> + QualType SizeArrayTy = getContext().getConstantArrayType(
> >> + getContext().getSizeType(), ArraySize, ArrayType::Normal,
> >> + /*IndexTypeQuals=*/0);
> >> + auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
> >> + llvm::Value *TmpPtr = Tmp.getPointer();
> >> + llvm::Value *TmpSize = EmitLifetimeStart(
> >> +
> >> CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
> >> + llvm::Value *ElemPtr;
> >> // Each of the following arguments specifies the size of the
> >> corresponding
> >> // argument passed to the enqueued block.
> >> auto *Zero = llvm::ConstantInt::get(IntTy, 0);
> >> for (unsigned I = First; I < NumArgs; ++I) {
> >> auto *Index = llvm::ConstantInt::get(IntTy, I - First);
> >> - auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
> >> + auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
> >> if (I == First)
> >> - Ptr = GEP;
> >> + ElemPtr = GEP;
> >> auto *V =
> >> Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)),
> >> SizeTy);
> >> Builder.CreateAlignedStore(
> >> V, GEP,
> >> CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
> >> }
> >> - return Ptr;
> >> + return std::tie(ElemPtr, TmpSize, TmpPtr);
> >> };
> >>
> >> // Could have events and/or varargs.
> >> @@ -3366,24 +3372,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >> llvm::Value *Kernel =
> >> Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
> >> auto *Block = Builder.CreatePointerCast(Info.BlockArg,
> >> GenericVoidPtrTy);
> >> - auto *PtrToSizeArray = CreateArrayForSizeVar(4);
> >> + llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
> >> + std::tie(ElemPtr, TmpSize, TmpPtr) =
> >> CreateArrayForSizeVar(4);
> >>
> >> // Create a vector of the arguments, as well as a constant
> >> value to
> >> // express to the runtime the number of variadic arguments.
> >> std::vector Args = {
> >> Queue, Flags, Range,
> >> Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
> >> - PtrToSizeArray};
> >> + ElemPtr};
> >> std::vector ArgTys = {
> >> - QueueTy, IntTy, RangeTy,
> >> - GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
> >> - PtrToSizeArray->getType()};
> >> + QueueTy, IntTy, RangeTy,
> >> GenericVoidPtrTy,
> >> + GenericVoidPtrTy, IntTy, ElemPtr-

r339720 - SafeStack: Disable Darwin support

2018-08-14 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Aug 14 12:50:41 2018
New Revision: 339720

URL: http://llvm.org/viewvc/llvm-project?rev=339720&view=rev
Log:
SafeStack: Disable Darwin support

Summary:
Darwin support does not appear to be used as evidenced by the fact that
the runtime has never supported non-trivial programs.

Reviewers: pcc, kubamracek

Reviewed By: pcc

Subscribers: cfe-commits, kcc

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=339720&r1=339719&r2=339720&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Aug 14 12:50:41 2018
@@ -509,15 +509,6 @@ void darwin::Linker::ConstructJob(Compil
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
 
-  // SafeStack requires its own runtime libraries
-  // These libraries should be linked first, to make sure the
-  // __safestack_init constructor executes before everything else
-  if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
-getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
-  "libclang_rt.safestack_osx.a",
-  toolchains::Darwin::RLO_AlwaysLink);
-  }
-
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -2297,7 +2288,6 @@ SanitizerMask Darwin::getSupportedSaniti
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
-Res |= SanitizerKind::SafeStack;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {


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


r314171 - Allow specifying sanitizers in blacklists

2017-09-25 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Sep 25 15:11:12 2017
New Revision: 314171

URL: http://llvm.org/viewvc/llvm-project?rev=314171&view=rev
Log:
Allow specifying sanitizers in blacklists

Summary:
This is the follow-up patch to D37924.

This change refactors clang to use the the newly added section headers
in SpecialCaseList to specify which sanitizers blacklists entries
should apply to, like so:

  [cfi-vcall]
  fun:*bad_vcall*
  [cfi-derived-cast|cfi-unrelated-cast]
  fun:*bad_cast*

The SanitizerSpecialCaseList class has been added to allow querying by
SanitizerMask, and SanitizerBlacklist and its downstream users have been
updated to provide that information. Old blacklists not using sections
will continue to function identically since the blacklist entries will
be placed into a '[*]' section by default matching against all
sanitizers.

Reviewers: pcc, kcc, eugenis, vsk

Reviewed By: eugenis

Subscribers: dberris, cfe-commits, mgorny

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

Added:
cfe/trunk/include/clang/Basic/SanitizerSpecialCaseList.h
cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.sanitized.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized1.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized2.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
cfe/trunk/test/CodeGen/sanitizer-special-case-list.c
Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst
cfe/trunk/docs/SanitizerSpecialCaseList.rst
cfe/trunk/include/clang/Basic/SanitizerBlacklist.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/SanitizerBlacklist.cpp
cfe/trunk/lib/Basic/XRayLists.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=314171&r1=314170&r2=314171&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Mon Sep 25 15:11:12 2017
@@ -243,17 +243,25 @@ Blacklist
 
 A :doc:`SanitizerSpecialCaseList` can be used to relax CFI checks for certain
 source files, functions and types using the ``src``, ``fun`` and ``type``
-entity types.
+entity types. Specific CFI modes can be be specified using ``[section]``
+headers.
 
 .. code-block:: bash
 
-# Suppress checking for code in a file.
+# Suppress all CFI checking for code in a file.
 src:bad_file.cpp
 src:bad_header.h
 # Ignore all functions with names containing MyFooBar.
 fun:*MyFooBar*
 # Ignore all types in the standard library.
 type:std::*
+# Disable only unrelated cast checks for this function
+[cfi-unrelated-cast]
+fun:*UnrelatedCast*
+# Disable CFI call checks for this function without affecting cast checks
+[cfi-vcall|cfi-nvcall|cfi-icall]
+fun:*BadCall*
+
 
 .. _cfi-cross-dso:
 

Modified: cfe/trunk/docs/SanitizerSpecialCaseList.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerSpecialCaseList.rst?rev=314171&r1=314170&r2=314171&view=diff
==
--- cfe/trunk/docs/SanitizerSpecialCaseList.rst (original)
+++ cfe/trunk/docs/SanitizerSpecialCaseList.rst Mon Sep 25 15:11:12 2017
@@ -51,14 +51,23 @@ Example
 Format
 ==
 
-Each line contains an entity type, followed by a colon and a regular
-expression, specifying the names of the entities, optionally followed by
-an equals sign and a tool-specific category. Empty lines and lines starting
-with "#" are ignored. The meanining of ``*`` in regular expression for entity
-names is different - it is treated as in shell wildcarding. Two generic
-entity types are ``src`` and ``fun``, which allow user to add, respectively,
-source files and functions to special case list. Some sanitizer tools may
-introduce custom entity types - refer to tool-specific docs.
+Blacklists consist of entries, optionally grouped into sections. Empty lines 
and
+lines starting with "#" are ignored.
+
+Section names are regular expressions written in square brackets that denote
+which sanitizer the following entries apply to. For example, ``[address]``
+specifies AddressSanitizer while ``[cfi-vcall|cfi-icall]`` specifies Control
+Flow Integrity virtual and indirect call checking. Entries without a section
+will be placed under the ``[*]`` section applying to all enabled sanitizers.
+
+Entries contain an ent

r338648 - [AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl

2018-08-01 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Wed Aug  1 15:41:03 2018
New Revision: 338648

URL: http://llvm.org/viewvc/llvm-project?rev=338648&view=rev
Log:
[AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl

Summary:
This check was introduced by r338641
but this broke some builds. For now remove it.

Subscribers: cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=338648&r1=338647&r2=338648&view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Wed Aug  1 15:41:03 2018
@@ -787,13 +787,6 @@ ObjCMethodDecl::ObjCMethodDecl(SourceLoc
 : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
   DeclContext(ObjCMethod), MethodDeclType(T), ReturnTInfo(ReturnTInfo),
   DeclEndLoc(endLoc) {
-  // See the comment in ObjCMethodFamilyBitfields about
-  // ObjCMethodFamilyBitWidth for why we check this.
-  static_assert(
-  static_cast(ObjCMethodDeclBits.ObjCMethodFamilyBitWidth) ==
-  static_cast(ObjCMethodFamilyBitWidth),
-  "ObjCMethodDeclBitfields::ObjCMethodFamilyBitWidth and "
-  "ObjCMethodFamilyBitWidth do not match!");
 
   // Initialized the bits stored in DeclContext.
   ObjCMethodDeclBits.Family =


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


r338904 - Revert "[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin"

2018-08-03 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  3 10:47:58 2018
New Revision: 338904

URL: http://llvm.org/viewvc/llvm-project?rev=338904&view=rev
Log:
Revert "[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin"

This reverts commit r338899, it was causing ASan test failures on 
sanitizer-x86_64-linux-fast.

Removed:
cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=338904&r1=338903&r2=338904&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug  3 10:47:58 2018
@@ -3338,29 +3338,23 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 // Create a temporary array to hold the sizes of local pointer arguments
 // for the block. \p First is the position of the first size argument.
 auto CreateArrayForSizeVar = [=](unsigned First) {
-  llvm::APInt ArraySize(32, NumArgs - First);
-  QualType SizeArrayTy = getContext().getConstantArrayType(
-  getContext().getSizeType(), ArraySize, ArrayType::Normal,
-  /*IndexTypeQuals=*/0);
-  auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
-  llvm::Value *TmpPtr = Tmp.getPointer();
-  llvm::Value *TmpSize = EmitLifetimeStart(
-  CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
-  llvm::Value *ElemPtr;
+  auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
+  auto *Arr = Builder.CreateAlloca(AT);
+  llvm::Value *Ptr;
   // Each of the following arguments specifies the size of the 
corresponding
   // argument passed to the enqueued block.
   auto *Zero = llvm::ConstantInt::get(IntTy, 0);
   for (unsigned I = First; I < NumArgs; ++I) {
 auto *Index = llvm::ConstantInt::get(IntTy, I - First);
-auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
+auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
 if (I == First)
-  ElemPtr = GEP;
+  Ptr = GEP;
 auto *V =
 Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)), SizeTy);
 Builder.CreateAlignedStore(
 V, GEP, CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
   }
-  return std::tie(ElemPtr, TmpSize, TmpPtr);
+  return Ptr;
 };
 
 // Could have events and/or varargs.
@@ -3372,27 +3366,24 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   llvm::Value *Kernel =
   Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
   auto *Block = Builder.CreatePointerCast(Info.BlockArg, GenericVoidPtrTy);
-  llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
-  std::tie(ElemPtr, TmpSize, TmpPtr) = CreateArrayForSizeVar(4);
+  auto *PtrToSizeArray = CreateArrayForSizeVar(4);
 
   // Create a vector of the arguments, as well as a constant value to
   // express to the runtime the number of variadic arguments.
   std::vector Args = {
   Queue,  Flags, Range,
   Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
-  ElemPtr};
+  PtrToSizeArray};
   std::vector ArgTys = {
-  QueueTy,  IntTy, RangeTy,   GenericVoidPtrTy,
-  GenericVoidPtrTy, IntTy, ElemPtr->getType()};
+  QueueTy,  IntTy,RangeTy,
+  GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
+  PtrToSizeArray->getType()};
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(
   Int32Ty, llvm::ArrayRef(ArgTys), false);
-  auto Call =
-  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
-  if (TmpSize)
-EmitLifetimeEnd(TmpSize, TmpPtr);
-  return Call;
+  return RValue::get(
+  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ llvm::ArrayRef(Args)));
 }
 // Any calls now have event arguments passed.
 if (NumArgs >= 7) {
@@ -3439,19 +3430,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   ArgTys.push_back(Int32Ty);
   Name = "__enqueue_kernel_events_varargs";
 
-  llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
-  std::tie(ElemPtr, TmpSize, TmpPtr) = CreateArrayForSizeVar(7);
-  Args.push_back(ElemPtr);
-  ArgTys.push_back(ElemPtr->getType());
+  auto *PtrToSizeArray = CreateArrayForSizeVar(7);
+  Args.push_back(PtrToSizeArray);
+  ArgTys.push_back(PtrToSizeArray->getType());
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(
   Int32Ty, llvm::ArrayRef(ArgTys), false);
-  auto Call =
-  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Arg

Re: r338899 - [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-03 Thread Vlad Tsyrklevich via cfe-commits
This change is causing ASan failures on the sanitizer bots:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/21898/steps/check-clang%20asan/logs/stdio

I've reverted it in r338904.

On Fri, Aug 3, 2018 at 8:51 AM Scott Linder via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: scott.linder
> Date: Fri Aug  3 08:50:52 2018
> New Revision: 338899
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338899&view=rev
> Log:
> [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin
>
> Ensures the statically sized alloca is not converted to DYNAMIC_STACKALLOC
> later because it is not in the entry block.
>
> Differential Revision: https://reviews.llvm.org/D50104
>
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=338899&r1=338898&r2=338899&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug  3 08:50:52 2018
> @@ -3338,23 +3338,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>  // Create a temporary array to hold the sizes of local pointer
> arguments
>  // for the block. \p First is the position of the first size argument.
>  auto CreateArrayForSizeVar = [=](unsigned First) {
> -  auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
> -  auto *Arr = Builder.CreateAlloca(AT);
> -  llvm::Value *Ptr;
> +  llvm::APInt ArraySize(32, NumArgs - First);
> +  QualType SizeArrayTy = getContext().getConstantArrayType(
> +  getContext().getSizeType(), ArraySize, ArrayType::Normal,
> +  /*IndexTypeQuals=*/0);
> +  auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
> +  llvm::Value *TmpPtr = Tmp.getPointer();
> +  llvm::Value *TmpSize = EmitLifetimeStart(
> +  CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()),
> TmpPtr);
> +  llvm::Value *ElemPtr;
>// Each of the following arguments specifies the size of the
> corresponding
>// argument passed to the enqueued block.
>auto *Zero = llvm::ConstantInt::get(IntTy, 0);
>for (unsigned I = First; I < NumArgs; ++I) {
>  auto *Index = llvm::ConstantInt::get(IntTy, I - First);
> -auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
> +auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
>  if (I == First)
> -  Ptr = GEP;
> +  ElemPtr = GEP;
>  auto *V =
>  Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)),
> SizeTy);
>  Builder.CreateAlignedStore(
>  V, GEP, CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
>}
> -  return Ptr;
> +  return std::tie(ElemPtr, TmpSize, TmpPtr);
>  };
>
>  // Could have events and/or varargs.
> @@ -3366,24 +3372,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>llvm::Value *Kernel =
>Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
>auto *Block = Builder.CreatePointerCast(Info.BlockArg,
> GenericVoidPtrTy);
> -  auto *PtrToSizeArray = CreateArrayForSizeVar(4);
> +  llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
> +  std::tie(ElemPtr, TmpSize, TmpPtr) = CreateArrayForSizeVar(4);
>
>// Create a vector of the arguments, as well as a constant value to
>// express to the runtime the number of variadic arguments.
>std::vector Args = {
>Queue,  Flags, Range,
>Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
> -  PtrToSizeArray};
> +  ElemPtr};
>std::vector ArgTys = {
> -  QueueTy,  IntTy,RangeTy,
> -  GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
> -  PtrToSizeArray->getType()};
> +  QueueTy,  IntTy, RangeTy,   GenericVoidPtrTy,
> +  GenericVoidPtrTy, IntTy, ElemPtr->getType()};
>
>llvm::FunctionType *FTy = llvm::FunctionType::get(
>Int32Ty, llvm::ArrayRef(ArgTys), false);
> -  return RValue::get(
> -  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
> - llvm::ArrayRef(Args)));
> +  auto Call =
> +  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy,
> Name),
> + llvm::ArrayRef *>(Args)));
> +  if (TmpSize)
> +EmitLifetimeEnd(TmpSize, TmpPtr);
> +  return Call;
>  }
>  // Any calls now have event arguments passed.
>  if (NumArgs >= 7) {
> @@ -3430,15 +3439,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>ArgTys.push_back(Int32Ty);
>Name = "__enqueue_kernel_events_varargs";
>
> -  auto *PtrToSizeArray = CreateArray

Re: r327547 - Attempt to fix failure of deep-ast-tree.cpp on atom and s390

2018-03-14 Thread Vlad Tsyrklevich via cfe-commits
Hi Yaxun, the test continues to be broken on the sanitizer buildbots:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/4639
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/3298
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/15327

On Wed, Mar 14, 2018 at 11:27 AM Yaxun Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yaxunl
> Date: Wed Mar 14 11:24:38 2018
> New Revision: 327547
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327547&view=rev
> Log:
> Attempt to fix failure of deep-ast-tree.cpp on atom and s390
>
> Modified:
> cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp
>
> Modified: cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp?rev=327547&r1=327546&r2=327547&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp Wed Mar 14 11:24:38 2018
> @@ -131,7 +131,7 @@ void f() {
>
>  
> 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
>
>  
> 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
>/* some archs have smaller stack size */
> -#if !defined(__ppc__) && !defined(__arm__)
> +#if !defined(__ppc__) && !defined(__atom__) && !defined(__s390__)
>
>  
> 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
>
>  
> 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
>
>  
> 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334065 - [Analyzer] Fix Z3ConstraintManager crash (PR37646)

2018-06-05 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Jun  5 23:09:02 2018
New Revision: 334065

URL: http://llvm.org/viewvc/llvm-project?rev=334065&view=rev
Log:
[Analyzer] Fix Z3ConstraintManager crash (PR37646)

Summary:
Fix another Z3ConstraintManager crash, use fixAPSInt() to extend a
boolean APSInt.

Reviewers: george.karpenkov, NoQ, ddcc

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits

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

Added:
cfe/trunk/test/Analysis/z3/
cfe/trunk/test/Analysis/z3/apsint.c
Removed:
cfe/trunk/test/Analysis/apsint.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp?rev=334065&r1=334064&r2=334065&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Tue Jun  5 
23:09:02 2018
@@ -1231,8 +1231,10 @@ const llvm::APSInt *Z3ConstraintManager:
 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);

Removed: cfe/trunk/test/Analysis/apsint.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/apsint.c?rev=334064&view=auto
==
--- cfe/trunk/test/Analysis/apsint.c (original)
+++ cfe/trunk/test/Analysis/apsint.c (removed)
@@ -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(); });
-}

Added: cfe/trunk/test/Analysis/z3/apsint.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/z3/apsint.c?rev=334065&view=auto
==
--- cfe/trunk/test/Analysis/z3/apsint.c (added)
+++ cfe/trunk/test/Analysis/z3/apsint.c Tue Jun  5 23:09:02 2018
@@ -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)
+  ;
+}


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


r334067 - [Analyzer][Z3] Test fixes for Z3 constraint manager

2018-06-05 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Jun  5 23:25:51 2018
New Revision: 334067

URL: http://llvm.org/viewvc/llvm-project?rev=334067&view=rev
Log:
[Analyzer][Z3] Test fixes for Z3 constraint manager

Summary:
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

Reviewers: george.karpenkov, NoQ, ddcc

Reviewed By: george.karpenkov

Subscribers: mikhail.ramalho, dcoughlin, xazax.hun, szepet, zzheng, a.sidorin, 
cfe-commits

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

Added:
cfe/trunk/test/Analysis/z3/enabled.c
Modified:
cfe/trunk/test/Analysis/PR24184.cpp
cfe/trunk/test/Analysis/constant-folding.c
cfe/trunk/test/Analysis/loop-unrolling.cpp

Modified: cfe/trunk/test/Analysis/PR24184.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR24184.cpp?rev=334067&r1=334066&r2=334067&view=diff
==
--- cfe/trunk/test/Analysis/PR24184.cpp (original)
+++ cfe/trunk/test/Analysis/PR24184.cpp Tue Jun  5 23:25:51 2018
@@ -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
 

Modified: cfe/trunk/test/Analysis/constant-folding.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/constant-folding.c?rev=334067&r1=334066&r2=334067&view=diff
==
--- cfe/trunk/test/Analysis/constant-folding.c (original)
+++ cfe/trunk/test/Analysis/constant-folding.c Tue Jun  5 23:25:51 2018
@@ -108,7 +108,11 @@ void testBitwiseRules(unsigned int a, in
   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;

Modified: cfe/trunk/test/Analysis/loop-unrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/loop-unrolling.cpp?rev=334067&r1=334066&r2=334067&view=diff
==
--- cfe/trunk/test/Analysis/loop-unrolling.cpp (original)
+++ cfe/trunk/test/Analysis/loop-unrolling.cpp Tue Jun  5 23:25:51 2018
@@ -368,7 +368,11 @@ int nested_inlined_unroll1() {
 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

Added: cfe/trunk/test/Analysis/z3/enabled.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/z3/enabled.c?rev=334067&view=auto
==
--- cfe/trunk/test/Analysis/z3/enabled.c (added)
+++ cfe/trunk/test/Analysis/z3/enabled.c Tue Jun  5 23:25:51 2018
@@ -0,0 +1,3 @@
+// REQUIRES: z3
+// RUN: echo %clang_analyze_cc1 | FileCheck %s
+// CHECK: -analyzer-constraints=z3


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


r344961 - Revert "Ensure sanitizer check function calls have a !dbg location"

2018-10-22 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Oct 22 14:51:58 2018
New Revision: 344961

URL: http://llvm.org/viewvc/llvm-project?rev=344961&view=rev
Log:
Revert "Ensure sanitizer check function calls have a !dbg location"

This reverts commit r344915. It was causing exceptions on the
x86_64-linux-ubsan bot.

Removed:
cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=344961&r1=344960&r2=344961&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 22 14:51:58 2018
@@ -2867,9 +2867,6 @@ static void emitCheckHandlerCall(CodeGen
  CheckRecoverableKind RecoverKind, bool 
IsFatal,
  llvm::BasicBlock *ContBB) {
   assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
-  auto *DI = CGF.getDebugInfo();
-  SourceLocation Loc = DI ? DI->getLocation() : SourceLocation();
-  auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
   bool NeedsAbortSuffix =
   IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;
   bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime;

Removed: cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp?rev=344960&view=auto
==
--- cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited \
-// RUN:   -fsanitize=null %s -o - | FileCheck %s
-
-// Check that santizer check calls have a !dbg location.
-// CHECK: define {{.*}}acquire{{.*}} !dbg
-// CHECK-NOT: define
-// CHECK: call void {{.*}}@__ubsan_handle_type_mismatch_v1
-// CHECK-SAME: !dbg
-
-struct SourceLocation {
-  SourceLocation acquire() {};
-};
-extern "C" void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc);
-static void handleTypeMismatchImpl(SourceLocation *Loc) { Loc->acquire(); }
-void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc) {
-  handleTypeMismatchImpl(Loc);
-}


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


Re: r344915 - Ensure sanitizer check function calls have a !dbg location

2018-10-22 Thread Vlad Tsyrklevich via cfe-commits
This change causes build failures on the UBSan bot, like so

:

3.  
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/include/llvm/Support/Allocator.h:98:40:
Generating code for declaration 'llvm::MallocAllocator::Allocate'

#0 0x55c1695ee77a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x265677a)
#1 0x55c1695ecc55 llvm::sys::RunSignalHandlers()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2654c55)
#2 0x55c1695ecd6c SignalHandler(int)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2654d6c)
#3 0x7f1e75f880c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#4 0x55c169018c69 llvm::DebugLoc::get(unsigned int, unsigned int,
llvm::MDNode const*, llvm::MDNode const*, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2080c69)
#5 0x55c1697ddb31
clang::CodeGen::CGDebugInfo::EmitLocation(clang::CodeGen::CGBuilderTy&,
clang::SourceLocation)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2845b31)
#6 0x55c1697ddcd6
clang::CodeGen::ApplyDebugLocation::init(clang::SourceLocation, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2845cd6)
#7 0x55c1699defa6
emitCheckHandlerCall(clang::CodeGen::CodeGenFunction&,
llvm::FunctionType*, llvm::ArrayRef,
clang::CodeGen::SanitizerHandler, (anonymous
namespace)::CheckRecoverableKind, bool, llvm::BasicBlock*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a46fa6)
#8 0x55c1699e155a
clang::CodeGen::CodeGenFunction::EmitCheck(llvm::ArrayRef >, clang::CodeGen::SanitizerHandler,
llvm::ArrayRef, llvm::ArrayRef)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a4955a)
#9 0x55c169991463
clang::CodeGen::CodeGenFunction::EmitReturnValueCheck(llvm::Value*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29f9463)
#10 0x55c16999f536
clang::CodeGen::CodeGenFunction::EmitFunctionEpilog(clang::CodeGen::CGFunctionInfo
const&, bool, clang::SourceLocation)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a07536)
#11 0x55c16985070a
clang::CodeGen::CodeGenFunction::FinishFunction(clang::SourceLocation)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28b870a)
#12 0x55c16985959f
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28c159f)
#13 0x55c169895ac5
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28fdac5)
#14 0x55c169892c39
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28fac39)
#15 0x55c169898992 clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2900992)
#16 0x55c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#17 0x55c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#18 0x55c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#19 0x55c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#20 0x55c169898af3 clang::CodeGen::CodeGenModule::Release()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2900af3)
#21 0x55c169fae527 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3016527)
#22 0x55c169fad156
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3015156)
#23 0x55c16a7b9569 clang::ParseAST(clang::Sema&, bool, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3821569)
#24 0x55c169fac339 clang::CodeGenAction::ExecuteAction()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3014339)
#25 0x55c169c2d25e clang::FrontendAction::Execute()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2c9525e)
#26 0x55c169bf7b0e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/b/sanitizer-x86_64-

r351159 - Revert alignment assumptions changes

2019-01-14 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Jan 14 19:38:02 2019
New Revision: 351159

URL: http://llvm.org/viewvc/llvm-project?rev=351159&view=rev
Log:
Revert alignment assumptions changes

Revert r351104-6, r351109, r351110, r351119, r351134, and r351153. These
changes fail on the sanitizer bots.

Removed:

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
cfe/trunk/test/CodeGen/catch-alignment-assumption-blacklist.c

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
cfe/trunk/test/CodeGen/catch-alignment-assumption-openmp.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351159&r1=351158&r2=351159&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jan 14 19:38:02 2019
@@ -321,49 +321,6 @@ Undefined Behavior Sanitizer (UBSan)
 * The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
   learned to sanitize compound assignment operators.
 
-* ``alignment`` check has learned to sanitize the assume_aligned-like 
attributes:
-
-  .. code-block:: c++
-
-  typedef char **__attribute__((align_value(1024))) aligned_char;
-  struct ac_struct {
-aligned_char a;
-  };
-  char **load_from_ac_struct(struct ac_struct *x) {
-return x->a; // <- check that loaded 'a' is aligned
-  }
-
-  char **passthrough(__attribute__((align_value(1024))) char **x) {
-return x; // <- check the pointer passed as function argument
-  }
-
-  char **__attribute__((alloc_align(2)))
-  alloc_align(int size, unsigned long alignment);
-
-  char **caller(int size) {
-return alloc_align(size, 1024); // <- check returned pointer
-  }
-
-  char **__attribute__((assume_aligned(1024))) get_ptr();
-
-  char **caller2() {
-return get_ptr(); // <- check returned pointer
-  }
-
-  void *caller3(char **x) {
-return __builtin_assume_aligned(x, 1024);  // <- check returned pointer
-  }
-
-  void *caller4(char **x, unsigned long offset) {
-return __builtin_assume_aligned(x, 1024, offset);  // <- check 
returned pointer accounting for the offest
-  }
-
-  void process(char *data, int width) {
-  #pragma omp for simd aligned(data : 1024) // <- aligned clause will 
be checked.
-  for (int x = 0; x < width; x++)
-  data[x] *= data[x];
-  }
-
 Core Analysis Improvements
 ==
 

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=351159&r1=351158&r2=351159&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Jan 14 19:38:02 2019
@@ -72,7 +72,7 @@ Available checks
 Available checks are:
 
   -  ``-fsanitize=alignment``: Use of a misaligned pointer or creation
- of a misaligned reference. Also sanitizes assume_aligned-like attributes.
+ of a misaligned reference.
   -  ``-fsanitize=bool``: Load of a ``bool`` value which is neither
  ``true`` nor ``false``.
   -  ``-fsanitize=builtin``: Passing invalid values to compiler builtins.

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351159&r1=351158&r2=351159&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jan 14 19:38:02 2019
@@ -1904,17 +1904,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(Result);
   }
   case Builtin::BI__builtin_assum

r351282 - Revert "[Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database."

2019-01-15 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Jan 15 16:37:39 2019
New Revision: 351282

URL: http://llvm.org/viewvc/llvm-project?rev=351282&view=rev
Log:
Revert "[Tooling] Make clang-tool find libc++ dir on mac when running on a file 
without compilation database."

This reverts commits r351222 and r351229, they were causing ASan/MSan failures
on the sanitizer bots.

Removed:
cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
Modified:
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=351282&r1=351281&r2=351282&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Tue Jan 15 16:37:39 2019
@@ -227,16 +227,6 @@ struct FilterUnusedFlags {
   }
 };
 
-std::string GetClangToolCommand() {
-  static int Dummy;
-  std::string ClangExecutable =
-  llvm::sys::fs::getMainExecutable("clang", (void *)&Dummy);
-  SmallString<128> ClangToolPath;
-  ClangToolPath = llvm::sys::path::parent_path(ClangExecutable);
-  llvm::sys::path::append(ClangToolPath, "clang-tool");
-  return ClangToolPath.str();
-}
-
 } // namespace
 
 /// Strips any positional args and possible argv[0] from a command-line
@@ -276,9 +266,9 @@ static bool stripPositionalArgs(std::vec
   Diagnostics));
   NewDriver->setCheckInputsExist(false);
 
-  // This becomes the new argv[0]. The value is used to detect libc++ include
-  // dirs on Mac, it isn't used for other platforms.
-  Args.insert(Args.begin(), GetClangToolCommand().c_str());
+  // This becomes the new argv[0]. The value is actually not important as it
+  // isn't used for invoking Tools.
+  Args.insert(Args.begin(), "clang-tool");
 
   // By adding -c, we force the driver to treat compilation as the last phase.
   // It will then issue warnings via Diagnostics about un-used options that
@@ -376,7 +366,7 @@ FixedCompilationDatabase::loadFromFile(S
 
 FixedCompilationDatabase::
 FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine) {
-  std::vector ToolCommandLine(1, GetClangToolCommand());
+  std::vector ToolCommandLine(1, "clang-tool");
   ToolCommandLine.insert(ToolCommandLine.end(),
  CommandLine.begin(), CommandLine.end());
   CompileCommands.emplace_back(Directory, StringRef(),

Removed: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351281&view=auto
==
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(original)
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(removed)
@@ -1,16 +0,0 @@
-// Clang on MacOS can find libc++ living beside the installed compiler.
-// This test makes sure our libTooling-based tools emulate this properly with
-// fixed compilation database.
-//
-// RUN: rm -rf %t
-// RUN: mkdir %t
-//
-// Install the mock libc++ (simulates the libc++ directory structure).
-// RUN: cp -r %S/Inputs/mock-libcxx %t/
-//
-// RUN: cp clang-check %t/mock-libcxx/bin/
-// RUN: cp "%s" "%t/test.cpp"
-// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- -stdlib=libc++
-
-#include 
-vector v;

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=351282&r1=351281&r2=351282&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Tue Jan 15 16:37:39 
2019
@@ -14,15 +14,11 @@
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 
-using testing::ElementsAre;
-using testing::EndsWith;
-
 static void expectFailure(StringRef JSONDatabase, StringRef Explanation) {
   std::string ErrorMessage;
   EXPECT_EQ(nullptr,
@@ -471,15 +467,21 @@ TEST(unescapeJsonCommandLine, ParsesSing
 }
 
 TEST(FixedCompilationDatabase, ReturnsFixedCommandLine) {
-  FixedCompilationDatabase Database(".", /*CommandLine*/ {"one", "two"});
+  std::vector CommandLine;
+  CommandLine.push_back("one");
+  CommandLine.push_back("two");
+  FixedCompilationDatabase Database(".", CommandLine);
   StringRef FileName("source");
   std::vector Result =
 Database.getCompileCommands(FileName);
   ASSERT_EQ(1ul, Result.size());
+  std::vector ExpectedCommandLine(1, "clang-tool");
+  ExpectedCommandLine.insert(ExpectedCommandL

Re: r351222 - [Tooling] Make clang-tool find libc++ dir on mac when running on a file without compilation database.

2019-01-15 Thread Vlad Tsyrklevich via cfe-commits
This change was causing MSan/ASan failures on the sanitizer bots:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/28272

I reverted it in r351282.

On Tue, Jan 15, 2019 at 11:09 AM Haojian Wu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hokein
> Date: Tue Jan 15 11:05:50 2019
> New Revision: 351222
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351222&view=rev
> Log:
> [Tooling] Make clang-tool find libc++ dir on mac when running on a file
> without compilation database.
>
> Summary:
> This is a regression of r348365.
>
> When clang-tools run on a file without a complation database (`clang-check
> /tmp/t.cc`),
> we will use fixed compilation database as a fallback. However the actual
> compiler
> path in the fallback complation command is just `clang-tool` which is
> insufficient to detect the libc++ dir.
>
> Reviewers: ilya-biryukov, EricWF
>
> Reviewed By: ilya-biryukov
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D56680
>
> Added:
> cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
> Modified:
> cfe/trunk/lib/Tooling/CompilationDatabase.cpp
>
> Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=351222&r1=351221&r2=351222&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
> +++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Tue Jan 15 11:05:50 2019
> @@ -227,6 +227,16 @@ struct FilterUnusedFlags {
>}
>  };
>
> +std::string GetClangToolCommand() {
> +  static int Dummy;
> +  std::string ClangExecutable =
> +  llvm::sys::fs::getMainExecutable("clang", (void *)&Dummy);
> +  SmallString<128> ClangToolPath;
> +  ClangToolPath = llvm::sys::path::parent_path(ClangExecutable);
> +  llvm::sys::path::append(ClangToolPath, "clang-tool");
> +  return ClangToolPath.str();
> +}
> +
>  } // namespace
>
>  /// Strips any positional args and possible argv[0] from a command-line
> @@ -266,9 +276,9 @@ static bool stripPositionalArgs(std::vec
>Diagnostics));
>NewDriver->setCheckInputsExist(false);
>
> -  // This becomes the new argv[0]. The value is actually not important as
> it
> -  // isn't used for invoking Tools.
> -  Args.insert(Args.begin(), "clang-tool");
> +  // This becomes the new argv[0]. The value is used to detect libc++
> include
> +  // dirs on Mac, it isn't used for other platforms.
> +  Args.insert(Args.begin(), GetClangToolCommand().c_str());
>
>// By adding -c, we force the driver to treat compilation as the last
> phase.
>// It will then issue warnings via Diagnostics about un-used options
> that
> @@ -366,7 +376,7 @@ FixedCompilationDatabase::loadFromFile(S
>
>  FixedCompilationDatabase::
>  FixedCompilationDatabase(Twine Directory, ArrayRef
> CommandLine) {
> -  std::vector ToolCommandLine(1, "clang-tool");
> +  std::vector ToolCommandLine(1, GetClangToolCommand());
>ToolCommandLine.insert(ToolCommandLine.end(),
>   CommandLine.begin(), CommandLine.end());
>CompileCommands.emplace_back(Directory, StringRef(),
>
> Added:
> cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351222&view=auto
>
> ==
> --- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
> (added)
> +++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
> Tue Jan 15 11:05:50 2019
> @@ -0,0 +1,16 @@
> +// Clang on MacOS can find libc++ living beside the installed compiler.
> +// This test makes sure our libTooling-based tools emulate this properly
> with
> +// fixed compilation database.
> +//
> +// RUN: rm -rf %t
> +// RUN: mkdir %t
> +//
> +// Install the mock libc++ (simulates the libc++ directory structure).
> +// RUN: cp -r %S/Inputs/mock-libcxx %t/
> +//
> +// RUN: cp clang-check %t/mock-libcxx/bin/
> +// RUN: cp "%s" "%t/test.cpp"
> +// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" --
> -stdlib=libc++
> +
> +#include 
> +vector v;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351457 - TLS: Respect visibility for thread_local variables on Darwin (PR40327)

2019-01-17 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Thu Jan 17 09:53:45 2019
New Revision: 351457

URL: http://llvm.org/viewvc/llvm-project?rev=351457&view=rev
Log:
TLS: Respect visibility for thread_local variables on Darwin (PR40327)

Summary:
Teach clang to mark thread wrappers for thread_local variables with
hidden visibility when the original variable is marked with hidden
visibility. This is necessary on Darwin which exposes the thread wrapper
instead of the thread variable. The thread wrapper would previously
always be created with default visibility unless it had
linkonce*/weak_odr linkage.

Reviewers: rjmccall

Reviewed By: rjmccall

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

Added:
cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=351457&r1=351456&r2=351457&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Jan 17 09:53:45 2019
@@ -2463,10 +2463,12 @@ ItaniumCXXABI::getOrCreateThreadLocalWra
 CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Wrapper);
 
   // Always resolve references to the wrapper at link time.
-  if (!Wrapper->hasLocalLinkage() && !(isThreadWrapperReplaceable(VD, CGM) &&
-  !llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) &&
-  !llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage(
-Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility);
+  if (!Wrapper->hasLocalLinkage())
+if (!isThreadWrapperReplaceable(VD, CGM) ||
+llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) ||
+llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage()) ||
+VD->getVisibility() == HiddenVisibility)
+  Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   if (isThreadWrapperReplaceable(VD, CGM)) {
 Wrapper->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);

Added: cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp?rev=351457&view=auto
==
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local-visibility.cpp Thu Jan 17 
09:53:45 2019
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck --check-prefix=LINUX %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 
| FileCheck --check-prefix=DARWIN %s
+
+// Regression test for PR40327
+
+// LINUX: @default_tls = thread_local global i32
+// LINUX: @hidden_tls = hidden thread_local global i32
+// LINUX: define weak_odr hidden i32* @_ZTW11default_tls()
+// LINUX: define weak_odr hidden i32* @_ZTW10hidden_tls()
+//
+// DARWIN: @default_tls = internal thread_local global i32
+// DARWIN: @hidden_tls = internal thread_local global i32
+// DARWIN: define cxx_fast_tlscc i32* @_ZTW11default_tls()
+// DARWIN: define hidden cxx_fast_tlscc i32* @_ZTW10hidden_tls()
+
+__attribute__((visibility("default"))) thread_local int default_tls;
+__attribute__((visibility("hidden"))) thread_local int hidden_tls;

Modified: cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp?rev=351457&r1=351456&r2=351457&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp Thu Jan 17 09:53:45 2019
@@ -318,7 +318,7 @@ void set_anon_i() {
 // CHECK-NOT: call void @[[V_M_INIT]]()
 
 
-// LIUNX: define weak_odr hidden i32* @_ZTW1a() {
+// LINUX: define weak_odr hidden i32* @_ZTW1a()
 // DARWIN: define cxx_fast_tlscc i32* @_ZTW1a()
 // LINUX:   call void @_ZTH1a()
 // DARWIN: call cxx_fast_tlscc void @_ZTH1a()


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


r351528 - Fix failing MSan bots

2019-01-18 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Jan 18 00:43:22 2019
New Revision: 351528

URL: http://llvm.org/viewvc/llvm-project?rev=351528&view=rev
Log:
Fix failing MSan bots

Revert r351508-351514, this block of changes introduced a consistent
MSan failure on the sanitizer bots.

Removed:
cfe/trunk/test/Analysis/os_object_base.h
cfe/trunk/test/Analysis/os_smart_ptr.h
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
cfe/trunk/test/Analysis/test-separate-retaincount.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=351528&r1=351527&r2=351528&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Fri 
Jan 18 00:43:22 2019
@@ -95,7 +95,7 @@ protected:
   friend class BugReportEquivClass;
   friend class BugReporter;
 
-  const BugType& BT;
+  BugType& BT;
   const Decl *DeclWithIssue = nullptr;
   std::string ShortDescription;
   std::string Description;
@@ -164,15 +164,15 @@ private:
   void popInterestingSymbolsAndRegions();
 
 public:
-  BugReport(const BugType& bt, StringRef desc, const ExplodedNode *errornode)
+  BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode)
   : BT(bt), Description(desc), ErrorNode(errornode) {}
 
-  BugReport(const BugType& bt, StringRef shortDesc, StringRef desc,
+  BugReport(BugType& bt, StringRef shortDesc, StringRef desc,
 const ExplodedNode *errornode)
   : BT(bt), ShortDescription(shortDesc), Description(desc),
 ErrorNode(errornode) {}
 
-  BugReport(const BugType &bt, StringRef desc, PathDiagnosticLocation l)
+  BugReport(BugType &bt, StringRef desc, PathDiagnosticLocation l)
   : BT(bt), Description(desc), Location(l) {}
 
   /// Create a BugReport with a custom uniqueing location.
@@ -190,7 +190,7 @@ public:
   virtual ~BugReport();
 
   const BugType& getBugType() const { return BT; }
-  //BugType& getBugType() { return BT; }
+  BugType& getBugType() { return BT; }
 
   /// True when the report has an execution path associated with it.
   ///
@@ -481,7 +481,7 @@ public:
 return {};
   }
 
-  void Register(const BugType *BT);
+  void Register(BugType *BT);
 
   /// Add the given report to the set of reports tracked by BugReporter.
   ///

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h?rev=351528&r1=351527&r2=351528&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h Fri Jan 
18 00:43:22 2019
@@ -38,14 +38,12 @@ private:
   virtual void anchor();
 
 public:
-  BugType(CheckName Check, StringRef Name, StringRef Cat,
-  bool SuppressOnSink=false)
+  BugType(CheckName Check, StringRef Name, StringRef Cat)
   : Check(Check), Name(Name), Category(Cat), Checker(nullptr),
-SuppressOnSink(SuppressOnSink) {}
-  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat,
-  bool SuppressOnSink=false)
+SuppressOnSink(false) {}
+  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
   : Check(Checker->getCheckName()), Name(Name), Category(Cat),
-Checker(Checker), SuppressOnSink(SuppressOnSink) {}
+Checker(Checker), SuppressOnSink(false) {}
   virtual ~BugType() = default;
 
   StringRef getName() const { return Name; }
@@ -66,6 +64,7 @@ public:
   ///  type should be suppressed if the end node of the report is 
post-dominated
   ///  by a sink node.
   bo

Re: r351514 - [analyzer] Introduce proper diagnostic for freeing unowned object

2019-01-18 Thread Vlad Tsyrklevich via cfe-commits
Hi, I've reverted r351508-351514 as they were causing MSan failures on the
sanitizer bots. It looks like isLeak is not initialized by one of the
RefCountReport constructors and it is not immediately obvious to me what an
appropriate value for it is. You can observe the failures here
,
they look like the following:

FAIL: Clang :: Analysis/inlining/path-notes.m (525 of 13800)
 TEST 'Clang :: Analysis/inlining/path-notes.m'
FAILED 
Script:
--
: 'RUN: at line 1';
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang
-cc1 -internal-isystem
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
-nostdsysteminc -analyze -analyzer-constraints=range
-analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount
-analyzer-output=text -analyzer-config
suppress-null-return-paths=false -fblocks -verify
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/path-notes.m
: 'RUN: at line 2';
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang
-cc1 -internal-isystem
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
-nostdsysteminc -analyze -analyzer-constraints=range
-analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount
-analyzer-output=plist-multi-file -analyzer-config
suppress-null-return-paths=false -fblocks
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/path-notes.m
-o 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Analysis/inlining/Output/path-notes.m.tmp.plist
: 'RUN: at line 3';   cat
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Analysis/inlining/Output/path-notes.m.tmp.plist
| diff -u -w -I "/" -I ".:" -I "version"
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.m.plist
-
--
Exit Code: 77

Command Output (stderr):
--
==93612==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0xa0635a8 in
clang::ento::retaincountchecker::RefCountReport::getRanges()
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h:65:9
#1 0xa18bb67 in
clang::ento::BugReporterVisitor::getDefaultEndPath(clang::ento::BugReporterContext&,
clang::ento::ExplodedNode const*, clang::ento::BugReport&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:176:27
#2 0xa05cf02 in
clang::ento::retaincountchecker::RefCountReportVisitor::getEndPath(clang::ento::BugReporterContext&,
clang::ento::ExplodedNode const*, clang::ento::BugReport&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:681:10
#3 0xa15b9aa in
generateVisitorsDiagnostics(clang::ento::BugReport*,
clang::ento::ExplodedNode const*, clang::ento::BugReporterContext&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2564:29
#4 0xa1429dc in findValidReport
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2621:9
#5 0xa1429dc in
clang::ento::GRBugReporter::generatePathDiagnostics(llvm::ArrayRef,
llvm::ArrayRef&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2670
#6 0xa14f991 in
clang::ento::BugReporter::generateDiagnosticForConsumerMap(clang::ento::BugReport*,
llvm::ArrayRef,
llvm::ArrayRef)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3092:5
#7 0xa13cbc1 in
clang::ento::BugReporter::FlushReport(clang::ento::BugReportEquivClass&)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2948:7
#8 0xa13a171 in clang::ento::BugReporter::FlushReports()
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2254:5
#9 0x99e9463 in RunPathSensitiveChecks
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:752:24
#10 0x99e9463 in (anonymous
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*)
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:716
#11 0x99ca7d6 in HandleDeclsCallGraph
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:507:5
#12 0x99ca7d6 in runAnalysisOnTranslationUnit
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Vlad Tsyrklevich via cfe-commits
This change appears to have broken a number of compiler-rt coverage tests,
e.g. in this run
.
The source of the error appears to be that llvm-cov is now trying to use a
relative path that's not relative to the directory it's in, though I'm not
familiar enough with debuginfo/coverage to understand what an appropriate
fix is. I've not yet reverted these changes to give you a chance to take a
look.

On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348154&view=rev
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata
> entries.
>
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
>
>   .file  1 "/Volumes/Data/llvm"
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
>
> After this patch the above entry is (assuming a compilation dir of
> "/Volumes/Data/llvm/_build"):
>
>   .file 1 "/Volumes/Data/llvm"
> "tools/clang/test/CodeGen/debug-info-abspath.c"
>
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
>
> Differential Revision: https://reviews.llvm.org/D55085
>
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager &SM = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
>
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager &SM = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
>
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
>
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
>
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()),
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc)));
> +  StringRef Dir;
> +  StringRef File;
> +  std::string RemappedFile = remapDIPath(FileName);
> +  std::string CurDir = remapDIPath(getCurrentDirname());
> +  SmallString<128> DirBuf;
> +  SmallString<128> FileBuf;
> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
> +// Strip the common prefix (if it is more than just "/") from current
> +// directory and FileName for a more space-efficient encoding.
> +auto FileIt = llvm::sys::path::begin(RemappedFile);
> +auto FileE = llvm::sys::path::end(RemappedFile);
> +auto CurDirIt = llvm::sys::path::begin(CurDir);
> +auto CurDirE = llvm::sys::path::end(CurDir);
> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt,
> ++FileIt)
> +  llvm::sys::path::append(DirBuf, *CurDirIt);
> +if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
> +  // The common prefix only the root; stripping it would cause
> +  // LLVM diagnostic locations to be more confusing.
> +  Dir = {};
> +  File = RemappedFile;
> +} else {
> +  for (; FileIt != FileE; ++FileIt)
> +llvm::sys::path::append(FileBuf, *FileIt);
> +  Dir = DirBuf;
> +  File = FileBuf;
> +}
> +  } else {
> +Dir = CurDir;
> +File = Rema

r355624 - Delete x86_64 ShadowCallStack support

2019-03-07 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Thu Mar  7 10:56:36 2019
New Revision: 355624

URL: http://llvm.org/viewvc/llvm-project?rev=355624&view=rev
Log:
Delete x86_64 ShadowCallStack support

Summary:
ShadowCallStack on x86_64 suffered from the same racy security issues as
Return Flow Guard and had performance overhead as high as 13% depending
on the benchmark. x86_64 ShadowCallStack was always an experimental
feature and never shipped a runtime required to support it, as such
there are no expected downstream users.

Reviewers: pcc

Reviewed By: pcc

Subscribers: mgorny, javed.absar, hiraditya, jdoerfert, cfe-commits, 
#sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

Modified:
cfe/trunk/docs/ShadowCallStack.rst

Modified: cfe/trunk/docs/ShadowCallStack.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ShadowCallStack.rst?rev=355624&r1=355623&r2=355624&view=diff
==
--- cfe/trunk/docs/ShadowCallStack.rst (original)
+++ cfe/trunk/docs/ShadowCallStack.rst Thu Mar  7 10:56:36 2019
@@ -9,7 +9,7 @@ Introduction
 
 
 ShadowCallStack is an instrumentation pass, currently only implemented for
-aarch64 and x86_64, that protects programs against return address overwrites
+aarch64, that protects programs against return address overwrites
 (e.g. stack buffer overflows.) It works by saving a function's return address
 to a separately allocated 'shadow call stack' in the function prolog in
 non-leaf functions and loading the return address from the shadow call stack
@@ -18,11 +18,10 @@ for compatibility with unwinders, but is
 
 The aarch64 implementation is considered production ready, and
 an `implementation of the runtime`_ has been added to Android's libc
-(bionic). The x86_64 implementation was evaluated using Chromium and was
-found to have critical performance and security deficiencies, and may be
-removed in a future release of the compiler. This document only describes
-the aarch64 implementation; details on the x86_64 implementation are found
-in the `Clang 7.0.1 documentation`_.
+(bionic). An x86_64 implementation was evaluated using Chromium and was found
+to have critical performance and security deficiencies--it was removed in
+LLVM 9.0. Details on the x86_64 implementation can be found in the
+`Clang 7.0.1 documentation`_.
 
 .. _`implementation of the runtime`: 
https://android.googlesource.com/platform/bionic/+/808d176e7e0dd727c7f929622ec017f6e065c582/libc/bionic/pthread_create.cpp#128
 .. _`Clang 7.0.1 documentation`: 
https://releases.llvm.org/7.0.1/tools/clang/docs/ShadowCallStack.html
@@ -37,10 +36,9 @@ consuming more memory for shorter functi
 memory accesses.
 
 `Return Flow Guard`_ is a pure software implementation of shadow call stacks
-on x86_64. It is similar to the ShadowCallStack x86_64 implementation but
-trades off higher memory usage for a shorter prologue and epilogue. Like
-x86_64 ShadowCallStack, it is inherently racy due to the architecture's use
-of the stack for calls and returns.
+on x86_64. Like the previous implementation of ShadowCallStack on x86_64, it is
+inherently racy due to the architecture's use of the stack for calls and
+returns.
 
 Intel `Control-flow Enforcement Technology`_ (CET) is a proposed hardware
 extension that would add native support to use a shadow stack to store/check


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


r354812 - Revert "Make static counters in ASTContext non-static."

2019-02-25 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Feb 25 11:53:13 2019
New Revision: 354812

URL: http://llvm.org/viewvc/llvm-project?rev=354812&view=rev
Log:
Revert "Make static counters in ASTContext non-static."

This reverts commit r354795, I suspect it is causing test failures
on MSan sanitizer bots.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354812&r1=354811&r2=354812&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 11:53:13 2019
@@ -2809,46 +2809,46 @@ public:
   
//======//
 
   /// The number of implicitly-declared default constructors.
-  unsigned NumImplicitDefaultConstructors;
+  static unsigned NumImplicitDefaultConstructors;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  unsigned NumImplicitDefaultConstructorsDeclared;
+  static unsigned NumImplicitDefaultConstructorsDeclared;
 
   /// The number of implicitly-declared copy constructors.
-  unsigned NumImplicitCopyConstructors;
+  static unsigned NumImplicitCopyConstructors;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  unsigned NumImplicitCopyConstructorsDeclared;
+  static unsigned NumImplicitCopyConstructorsDeclared;
 
   /// The number of implicitly-declared move constructors.
-  unsigned NumImplicitMoveConstructors;
+  static unsigned NumImplicitMoveConstructors;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  unsigned NumImplicitMoveConstructorsDeclared;
+  static unsigned NumImplicitMoveConstructorsDeclared;
 
   /// The number of implicitly-declared copy assignment operators.
-  unsigned NumImplicitCopyAssignmentOperators;
+  static unsigned NumImplicitCopyAssignmentOperators;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared move assignment operators.
-  unsigned NumImplicitMoveAssignmentOperators;
+  static unsigned NumImplicitMoveAssignmentOperators;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared destructors.
-  unsigned NumImplicitDestructors;
+  static unsigned NumImplicitDestructors;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  unsigned NumImplicitDestructorsDeclared;
+  static unsigned NumImplicitDestructorsDeclared;
 
 public:
   /// Initialize built-in types.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354812&r1=354811&r2=354812&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 11:53:13 2019
@@ -94,6 +94,19 @@
 
 using namespace clang;
 
+unsigned ASTContext::NumImplicitDefaultConstructors;
+unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
+unsigned ASTContext::NumImplicitCopyConstructors;
+unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
+unsigned ASTContext::NumImplicitMoveConstructors;
+unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
+unsigned ASTContext::NumImplicitCopyAssignmentOperators;
+unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
+unsigned ASTContext::NumImplicitMoveAssignmentOperators;
+unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
+unsigned ASTContext::NumImplicitDestructors;
+unsigned ASTContext::NumImplicitDestructorsDeclared;
+
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
 };

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354812&r1=354811&r2=354812&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Feb 25 11:53:13 2019
@@ -7971,14 +7971,14 @@ void Sema::ActOnFinishCXXMemberSpecifica
 /// definition of the class is complete.
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
   if (ClassDecl->needsImplicitDefaultConstructor()) {
-++getASTContext().Num

Re: r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Vlad Tsyrklevich via cfe-commits
I've reverted this commit in r354812, it was causing MSan failures like
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio
Though
these error reports don't clearly implicate this change, from your change
it seems like the failure is occurring because you changed static
(zero-initialized) variables to member (uninitialized) variables that were
then never initialized before being used. The build recovered after the
revert landed in
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894

On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Mon Feb 25 08:08:46 2019
> New Revision: 354795
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354795&view=rev
> Log:
> Make static counters in ASTContext non-static.
>
> Summary:
> Fixes a data race and makes it possible to run clang-based tools in
> multithreaded environment with TSan.
>
> Reviewers: ilya-biryukov, riccibruno
>
> Reviewed By: riccibruno
>
> Subscribers: riccibruno, jfb, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D58612
>
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795&r1=354794&r2=354795&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
> @@ -2809,46 +2809,46 @@ public:
>
>  
> //======//
>
>/// The number of implicitly-declared default constructors.
> -  static unsigned NumImplicitDefaultConstructors;
> +  unsigned NumImplicitDefaultConstructors;
>
>/// The number of implicitly-declared default constructors for
>/// which declarations were built.
> -  static unsigned NumImplicitDefaultConstructorsDeclared;
> +  unsigned NumImplicitDefaultConstructorsDeclared;
>
>/// The number of implicitly-declared copy constructors.
> -  static unsigned NumImplicitCopyConstructors;
> +  unsigned NumImplicitCopyConstructors;
>
>/// The number of implicitly-declared copy constructors for
>/// which declarations were built.
> -  static unsigned NumImplicitCopyConstructorsDeclared;
> +  unsigned NumImplicitCopyConstructorsDeclared;
>
>/// The number of implicitly-declared move constructors.
> -  static unsigned NumImplicitMoveConstructors;
> +  unsigned NumImplicitMoveConstructors;
>
>/// The number of implicitly-declared move constructors for
>/// which declarations were built.
> -  static unsigned NumImplicitMoveConstructorsDeclared;
> +  unsigned NumImplicitMoveConstructorsDeclared;
>
>/// The number of implicitly-declared copy assignment operators.
> -  static unsigned NumImplicitCopyAssignmentOperators;
> +  unsigned NumImplicitCopyAssignmentOperators;
>
>/// The number of implicitly-declared copy assignment operators for
>/// which declarations were built.
> -  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
> +  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>
>/// The number of implicitly-declared move assignment operators.
> -  static unsigned NumImplicitMoveAssignmentOperators;
> +  unsigned NumImplicitMoveAssignmentOperators;
>
>/// The number of implicitly-declared move assignment operators for
>/// which declarations were built.
> -  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
> +  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>
>/// The number of implicitly-declared destructors.
> -  static unsigned NumImplicitDestructors;
> +  unsigned NumImplicitDestructors;
>
>/// The number of implicitly-declared destructors for which
>/// declarations were built.
> -  static unsigned NumImplicitDestructorsDeclared;
> +  unsigned NumImplicitDestructorsDeclared;
>
>  public:
>/// Initialize built-in types.
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795&r1=354794&r2=354795&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 08:08:46 2019
> @@ -94,19 +94,6 @@
>
>  using namespace clang;
>
> -unsigned ASTContext::NumImplicitDefaultConstructors;
> -unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
> -unsigned ASTContext::NumImplicitCopyConstructors;
> -unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
> -unsigned ASTContext::NumImplicitMoveConstructors;
> -unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
> -unsigned ASTContext::NumImplicitC

r312986 - Fix broken links to the Itanium CXX ABI

2017-09-11 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Sep 11 17:21:17 2017
New Revision: 312986

URL: http://llvm.org/viewvc/llvm-project?rev=312986&view=rev
Log:
Fix broken links to the Itanium CXX ABI

Modified:
cfe/trunk/docs/ControlFlowIntegrityDesign.rst
cfe/trunk/docs/Toolchain.rst
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/docs/ControlFlowIntegrityDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrityDesign.rst?rev=312986&r1=312985&r2=312986&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrityDesign.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrityDesign.rst Mon Sep 11 17:21:17 2017
@@ -92,7 +92,7 @@ The compiler relies on co-operation from
 the bit vectors for the whole program. It currently does this using LLVM's
 `type metadata`_ mechanism together with link-time optimization.
 
-.. _address point: 
https://mentorembedded.github.io/cxx-abi/abi.html#vtable-general
+.. _address point: 
http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-general
 .. _type metadata: http://llvm.org/docs/TypeMetadata.html
 .. _ByteArrayBuilder: 
http://llvm.org/docs/doxygen/html/structllvm_1_1ByteArrayBuilder.html
 

Modified: cfe/trunk/docs/Toolchain.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Toolchain.rst?rev=312986&r1=312985&r2=312986&view=diff
==
--- cfe/trunk/docs/Toolchain.rst (original)
+++ cfe/trunk/docs/Toolchain.rst Mon Sep 11 17:21:17 2017
@@ -222,7 +222,7 @@ Unwind library
 
 The unwind library provides a family of ``_Unwind_*`` functions implementing
 the language-neutral stack unwinding portion of the Itanium C++ ABI
-(`Level I `_).
+(`Level I `_).
 It is a dependency of the C++ ABI library, and sometimes is a dependency
 of other runtimes.
 
@@ -288,9 +288,9 @@ C++ ABI library
 The C++ ABI library provides an implementation of the library portion of
 the Itanium C++ ABI, covering both the
 `support functionality in the main Itanium C++ ABI document
-`_ and
+`_ and
 `Level II of the exception handling support
-`_.
+`_.
 References to the functions and objects in this library are implicitly
 generated by Clang when compiling C++ code.
 

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=312986&r1=312985&r2=312986&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Sep 11 17:21:17 2017
@@ -11,7 +11,7 @@
 // which is used in GCC 3.2 and newer (and many compilers that are
 // ABI-compatible with GCC):
 //
-//   http://mentorembedded.github.io/cxx-abi/abi.html#mangling
+//   http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling
 //
 
//===--===//
 #include "clang/AST/Mangle.h"

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=312986&r1=312985&r2=312986&view=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Sep 11 17:21:17 2017
@@ -2084,7 +2084,7 @@ static bool mustSkipTailPadding(TargetCX
 // rules, we should implement the restrictions about over-sized
 // bitfields:
 //
-// http://mentorembedded.github.com/cxx-abi/abi.html#POD :
+// http://itanium-cxx-abi.github.io/cxx-abi/abi.html#POD :
 //   In general, a type is considered a POD for the purposes of
 //   layout if it is a POD type (in the sense of ISO C++
 //   [basic.types]). However, a POD-struct or POD-union (in the


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


Re: r362785 - [CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods.

2019-06-07 Thread Vlad Tsyrklevich via cfe-commits
This change caused LSan failures and has been reverted in r362830:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/32809

On Fri, Jun 7, 2019 at 2:42 AM Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Fri Jun  7 02:45:17 2019
> New Revision: 362785
>
> URL: http://llvm.org/viewvc/llvm-project?rev=362785&view=rev
> Log:
> [CodeComplete] Improve overload handling for C++ qualified and
> ref-qualified methods.
>
> Summary:
> - when a method is not available because of the target value kind (e.g. an
> &&
>   method on a Foo& variable), then don't offer it.
> - when a method is effectively shadowed by another method from the same
> class
>   with a) an identical argument list and b) superior qualifiers, then don't
>   offer it.
>
> Reviewers: ilya-biryukov
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D62582
>
> Modified:
> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
> cfe/trunk/test/CodeCompletion/member-access.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=362785&r1=362784&r2=362785&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Jun  7 02:45:17 2019
> @@ -16,7 +16,9 @@
>  #include "clang/AST/ExprCXX.h"
>  #include "clang/AST/ExprObjC.h"
>  #include "clang/AST/QualTypeNames.h"
> +#include "clang/AST/Type.h"
>  #include "clang/Basic/CharInfo.h"
> +#include "clang/Basic/Specifiers.h"
>  #include "clang/Lex/HeaderSearch.h"
>  #include "clang/Lex/MacroInfo.h"
>  #include "clang/Lex/Preprocessor.h"
> @@ -152,9 +154,16 @@ private:
>/// different levels of, e.g., the inheritance hierarchy.
>std::list ShadowMaps;
>
> +  /// Overloaded C++ member functions found by SemaLookup.
> +  /// Used to determine when one overload is dominated by another.
> +  llvm::DenseMap,
> ShadowMapEntry>
> +  OverloadMap;
> +
>/// If we're potentially referring to a C++ member function, the set
>/// of qualifiers applied to the object type.
>Qualifiers ObjectTypeQualifiers;
> +  /// The kind of the object expression, for rvalue/lvalue overloads.
> +  ExprValueKind ObjectKind;
>
>/// Whether the \p ObjectTypeQualifiers field is active.
>bool HasObjectTypeQualifiers;
> @@ -230,8 +239,9 @@ public:
>/// out member functions that aren't available (because there will be a
>/// cv-qualifier mismatch) or prefer functions with an exact qualifier
>/// match.
> -  void setObjectTypeQualifiers(Qualifiers Quals) {
> +  void setObjectTypeQualifiers(Qualifiers Quals, ExprValueKind Kind) {
>  ObjectTypeQualifiers = Quals;
> +ObjectKind = Kind;
>  HasObjectTypeQualifiers = true;
>}
>
> @@ -1157,6 +1167,53 @@ static void setInBaseClass(ResultBuilder
>R.InBaseClass = true;
>  }
>
> +enum class OverloadCompare { BothViable, Dominates, Dominated };
> +// Will Candidate ever be called on the object, when overloaded with
> Incumbent?
> +// Returns Dominates if Candidate is always called, Dominated if
> Incumbent is
> +// always called, BothViable if either may be called dependending on
> arguments.
> +// Precondition: must actually be overloads!
> +static OverloadCompare compareOverloads(const CXXMethodDecl &Candidate,
> +const CXXMethodDecl &Incumbent,
> +const Qualifiers &ObjectQuals,
> +ExprValueKind ObjectKind) {
> +  if (Candidate.isVariadic() != Incumbent.isVariadic() ||
> +  Candidate.getNumParams() != Incumbent.getNumParams() ||
> +  Candidate.getMinRequiredArguments() !=
> +  Incumbent.getMinRequiredArguments())
> +return OverloadCompare::BothViable;
> +  for (unsigned I = 0, E = Candidate.getNumParams(); I != E; ++I)
> +if (Candidate.parameters()[I]->getType().getCanonicalType() !=
> +Incumbent.parameters()[I]->getType().getCanonicalType())
> +  return OverloadCompare::BothViable;
> +  if (!llvm::empty(Candidate.specific_attrs()) ||
> +  !llvm::empty(Incumbent.specific_attrs()))
> +return OverloadCompare::BothViable;
> +  // At this point, we know calls can't pick one or the other based on
> +  // arguments, so one of the two must win. (Or both fail, handled
> elsewhere).
> +  RefQualifierKind CandidateRef = Candidate.getRefQualifier();
> +  RefQualifierKind IncumbentRef = Incumbent.getRefQualifier();
> +  if (CandidateRef != IncumbentRef) {
> +// If the object kind is LValue/RValue, there's one acceptable
> ref-qualifier
> +// and it can't be mixed with ref-unqualified overloads (in valid
> code).
> +
> +// For xvalue objects, we prefer the rvalue overload even if we have
> to
> +// add qualifiers (which is rare, because const&& is rare).
> +  

r362830 - Revert "[CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods."

2019-06-07 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Jun  7 12:18:30 2019
New Revision: 362830

URL: http://llvm.org/viewvc/llvm-project?rev=362830&view=rev
Log:
Revert "[CodeComplete] Improve overload handling for C++ qualified and 
ref-qualified methods."

This reverts commit f1f6e0fc2468e9c120b22b939507c527d08b8ee8, it was
causing LSan failures on the sanitizer bots:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/32809

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/member-access.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=362830&r1=362829&r2=362830&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Jun  7 12:18:30 2019
@@ -16,9 +16,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/QualTypeNames.h"
-#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
-#include "clang/Basic/Specifiers.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -154,16 +152,9 @@ private:
   /// different levels of, e.g., the inheritance hierarchy.
   std::list ShadowMaps;
 
-  /// Overloaded C++ member functions found by SemaLookup.
-  /// Used to determine when one overload is dominated by another.
-  llvm::DenseMap, ShadowMapEntry>
-  OverloadMap;
-
   /// If we're potentially referring to a C++ member function, the set
   /// of qualifiers applied to the object type.
   Qualifiers ObjectTypeQualifiers;
-  /// The kind of the object expression, for rvalue/lvalue overloads.
-  ExprValueKind ObjectKind;
 
   /// Whether the \p ObjectTypeQualifiers field is active.
   bool HasObjectTypeQualifiers;
@@ -239,9 +230,8 @@ public:
   /// out member functions that aren't available (because there will be a
   /// cv-qualifier mismatch) or prefer functions with an exact qualifier
   /// match.
-  void setObjectTypeQualifiers(Qualifiers Quals, ExprValueKind Kind) {
+  void setObjectTypeQualifiers(Qualifiers Quals) {
 ObjectTypeQualifiers = Quals;
-ObjectKind = Kind;
 HasObjectTypeQualifiers = true;
   }
 
@@ -1167,53 +1157,6 @@ static void setInBaseClass(ResultBuilder
   R.InBaseClass = true;
 }
 
-enum class OverloadCompare { BothViable, Dominates, Dominated };
-// Will Candidate ever be called on the object, when overloaded with Incumbent?
-// Returns Dominates if Candidate is always called, Dominated if Incumbent is
-// always called, BothViable if either may be called dependending on arguments.
-// Precondition: must actually be overloads!
-static OverloadCompare compareOverloads(const CXXMethodDecl &Candidate,
-const CXXMethodDecl &Incumbent,
-const Qualifiers &ObjectQuals,
-ExprValueKind ObjectKind) {
-  if (Candidate.isVariadic() != Incumbent.isVariadic() ||
-  Candidate.getNumParams() != Incumbent.getNumParams() ||
-  Candidate.getMinRequiredArguments() !=
-  Incumbent.getMinRequiredArguments())
-return OverloadCompare::BothViable;
-  for (unsigned I = 0, E = Candidate.getNumParams(); I != E; ++I)
-if (Candidate.parameters()[I]->getType().getCanonicalType() !=
-Incumbent.parameters()[I]->getType().getCanonicalType())
-  return OverloadCompare::BothViable;
-  if (!llvm::empty(Candidate.specific_attrs()) ||
-  !llvm::empty(Incumbent.specific_attrs()))
-return OverloadCompare::BothViable;
-  // At this point, we know calls can't pick one or the other based on
-  // arguments, so one of the two must win. (Or both fail, handled elsewhere).
-  RefQualifierKind CandidateRef = Candidate.getRefQualifier();
-  RefQualifierKind IncumbentRef = Incumbent.getRefQualifier();
-  if (CandidateRef != IncumbentRef) {
-// If the object kind is LValue/RValue, there's one acceptable 
ref-qualifier
-// and it can't be mixed with ref-unqualified overloads (in valid code).
-
-// For xvalue objects, we prefer the rvalue overload even if we have to
-// add qualifiers (which is rare, because const&& is rare).
-if (ObjectKind == clang::VK_XValue)
-  return CandidateRef == RQ_RValue ? OverloadCompare::Dominates
-   : OverloadCompare::Dominated;
-  }
-  // Now the ref qualifiers are the same (or we're in some invalid state).
-  // So make some decision based on the qualifiers.
-  Qualifiers CandidateQual = Candidate.getMethodQualifiers();
-  Qualifiers IncumbentQual = Incumbent.getMethodQualifiers();
-  bool CandidateSuperset = CandidateQual.compatiblyIncludes(IncumbentQual);
-  bool IncumbentSuperset = IncumbentQual.compatiblyIncludes(CandidateQual);
-  if (CandidateSuperset == IncumbentSuperset)
-return OverloadCompare::BothViable;

r329942 - Fix doc typo

2018-04-12 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Thu Apr 12 12:35:39 2018
New Revision: 329942

URL: http://llvm.org/viewvc/llvm-project?rev=329942&view=rev
Log:
Fix doc typo

Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=329942&r1=329941&r2=329942&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Thu Apr 12 12:35:39 2018
@@ -224,8 +224,8 @@ flag relax pointer type checking for cal
 applied across all functions compiled with ``-fsanitize=cfi-icall``.
 
 Specifically, pointers in return and argument types are treated as equivalent 
as
-long as the qualifiers for the type they point to match. For example, ``char*``
-``char**`, and ``int*`` are considered equivalent types. However, ``char*`` and
+long as the qualifiers for the type they point to match. For example, 
``char*``,
+``char**``, and ``int*`` are considered equivalent types. However, ``char*`` 
and
 ``const char*`` are considered separate types.
 
 ``-fsanitize-cfi-icall-generalize-pointers`` is not compatible with


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


Re: r336590 - [libclang] evalute compound statement cursors before trying to evaluate

2018-07-09 Thread Vlad Tsyrklevich via cfe-commits
The ASan bot is failing with a LeakSanitizer failure that appears related
to one of your libclang changes:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/6282/steps/check-clang%20asan/logs/stdio

Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x52c638 in operator new(unsigned long)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:106
#1 0x7fd236783b89 in make_unique
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/ADT/STLExtras.h:1057:29
#2 0x7fd236783b89 in evaluateExpr
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3755
#3 0x7fd236783b89 in clang_Cursor_Evaluate
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3917
#4 0x54e743 in operator()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:487:39
#5 0x54e743 in
LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::operator()(CXCursor,
CXCursor, void*) const::'lambda'(CXCursor, CXCursor,
void*)::__invoke(CXCursor, CXCursor, void*)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:482
#6 0x7fd23677de00 in
clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector&) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3019:17
#7 0x7fd23675c3a8 in
clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3164:17
#8 0x7fd236755d2f in
clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp
#9 0x7fd236754e5d in
clang::cxcursor::CursorVisitor::Visit(CXCursor, bool)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:225:16
#10 0x7fd23676487c in
clang::cxcursor::CursorVisitor::VisitFunctionDecl(clang::FunctionDecl*)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:889:9
#11 0x7fd236759e24 in
clang::declvisitor::Base::Visit(clang::Decl*)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/include/clang/AST/DeclVisitor.h
#12 0x7fd236755c17 in
clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:506:34
#13 0x7fd23678a558 in clang_visitChildren
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20
#14 0x54e024 in operator()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:480:11
#15 0x54e024 in
LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::__invoke(CXCursor,
CXCursor, void*)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:476
#16 0x7fd236754d49 in
clang::cxcursor::CursorVisitor::Visit(CXCursor, bool)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:217:11
#17 0x7fd23675cb87 in
clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl
const*) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:674:7
#18 0x7fd23675cefe in
clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:635:30
#19 0x7fd236756399 in
clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:540:20
#20 0x7fd23678a558 in clang_visitChildren
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20
#21 0x537fa1 in
LibclangParseTest_EvaluateChildExpression_Test::TestBody()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:474:3
#22 0x5cae31 in testing::Test::Run()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#23 0x5cd068 in testing::TestInfo::Run()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
#24 0x5ce430 in testing::TestCase::Run()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
#25 0x5ec1d4 in testing::internal::UnitTestImpl::RunAllTests()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
   #26 0x5eb380 in testing::UnitTest::Run()
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#27 0x5b3983 in RUN_ALL_TESTS
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
#28 0x5b3983 in main
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51
#29 0x7fd232efd2e0 in __libc_sta

r337037 - SafeStack: Add builtins to read unsafe stack top/bottom

2018-07-13 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Jul 13 12:48:35 2018
New Revision: 337037

URL: http://llvm.org/viewvc/llvm-project?rev=337037&view=rev
Log:
SafeStack: Add builtins to read unsafe stack top/bottom

Summary:
Introduce built-ins to read the unsafe stack top and bottom. The unsafe
stack top is required to implement garbage collection scanning for
Oilpan. Currently there is already a built-in 'get_unsafe_stack_start'
to read the bottom of the unsafe stack, but I chose to duplicate this
API because 'start' is ambiguous (e.g. Oilpan uses WTF::GetStackStart to
read the safe stack top.)

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits, kcc

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

Modified:
cfe/trunk/docs/SafeStack.rst
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/docs/SafeStack.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SafeStack.rst?rev=337037&r1=337036&r2=337037&view=diff
==
--- cfe/trunk/docs/SafeStack.rst (original)
+++ cfe/trunk/docs/SafeStack.rst Fri Jul 13 12:48:35 2018
@@ -165,11 +165,23 @@ never be stored on the heap, as it would
 This builtin function returns current unsafe stack pointer of the current
 thread.
 
+``__builtin___get_unsafe_stack_bottom()``
+~
+
+This builtin function returns a pointer to the bottom of the unsafe stack of 
the
+current thread.
+
+``__builtin___get_unsafe_stack_top()``
+~~
+
+This builtin function returns a pointer to the top of the unsafe stack of the
+current thread.
+
 ``__builtin___get_unsafe_stack_start()``
 
 
-This builtin function returns a pointer to the start of the unsafe stack of the
-current thread.
+Deprecated: This builtin function is an alias for
+``__builtin___get_unsafe_stack_bottom()``.
 
 Design
 ==

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=337037&r1=337036&r2=337037&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jul 13 12:48:35 2018
@@ -1412,6 +1412,8 @@ BUILTIN(__builtin_dump_struct, "ivC*v*",
 
 // Safestack builtins
 BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
+BUILTIN(__builtin___get_unsafe_stack_bottom, "v*", "Fn")
+BUILTIN(__builtin___get_unsafe_stack_top, "v*", "Fn")
 BUILTIN(__builtin___get_unsafe_stack_ptr, "v*", "Fn")
 
 // Nontemporal loads/stores builtins


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


[clang] 38839d0 - Revert "[Concepts] Constraint Enforcement & Diagnostics"

2019-10-28 Thread Vlad Tsyrklevich via cfe-commits

Author: Vlad Tsyrklevich
Date: 2019-10-28T15:00:40-07:00
New Revision: 38839d08b8e165dfaab0fa6acc77e620d6df294c

URL: 
https://github.com/llvm/llvm-project/commit/38839d08b8e165dfaab0fa6acc77e620d6df294c
DIFF: 
https://github.com/llvm/llvm-project/commit/38839d08b8e165dfaab0fa6acc77e620d6df294c.diff

LOG: Revert "[Concepts] Constraint Enforcement & Diagnostics"

This reverts commit ffa214ef22892d75340dc6720271863901dc2c90, it was
causing ASAN test failures on sanitizer-x86_64-linux-bootstrap.

Added: 


Modified: 
clang/include/clang/AST/ExprCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/TemplateDeduction.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/CMakeLists.txt
clang/lib/AST/Decl.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp

Removed: 
clang/include/clang/AST/ASTConcept.h
clang/lib/AST/ASTConcept.cpp
clang/test/CXX/temp/temp.constr/temp.constr.constr/function-templates.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp



diff  --git a/clang/include/clang/AST/ASTConcept.h 
b/clang/include/clang/AST/ASTConcept.h
deleted file mode 100644
index f5e99a8bfa1e..
--- a/clang/include/clang/AST/ASTConcept.h
+++ /dev/null
@@ -1,80 +0,0 @@
-//===--- ASTConcept.h - Concepts Related AST Data Structures *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-/// \file
-/// \brief This file provides AST data structures related to concepts.
-///
-//===--===//
-
-#ifndef LLVM_CLANG_AST_ASTCONCEPT_H
-#define LLVM_CLANG_AST_ASTCONCEPT_H
-#include "clang/AST/Expr.h"
-#include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/SmallVector.h"
-#include 
-#include 
-namespace clang {
-
-/// \brief The result of a constraint satisfaction check, containing the
-/// necessary information to diagnose an unsatisfied constraint.
-struct ConstraintSatisfaction {
-  using SubstitutionDiagnostic = std::pair;
-  using Detail = llvm::PointerUnion;
-
-  bool IsSatisfied = false;
-
-  /// \brief Pairs of unsatisfied atomic constraint expressions along with the
-  /// substituted constraint expr, if the template arguments could be
-  /// substituted into them, or a diagnostic if substitution resulted in an
-  /// invalid expression.
-  llvm::SmallVector, 4> Details;
-
-  // This can leak if used in an AST node, use ASTConstraintSatisfaction
-  // instead.
-  void *operator new(size_t bytes, ASTContext &C) = delete;
-};
-
-/// Pairs of unsatisfied atomic constraint expressions along with the
-/// substituted constraint expr, if the template arguments could be
-/// substituted into them, or a diagnostic if substitution resulted in
-/// an invalid expression.
-using UnsatisfiedConstraintRecord =
-std::pair *>>;
-
-/// \brief The result of a constraint satisfaction check, containing the
-/// necessary information to diagnose an unsatisfied constraint.
-///
-/// This is safe to store in an AST node, as opposed to ConstraintSatisfaction.
-struct ASTConstraintSatisfaction final :
-llvm::TrailingObjects {
-  std::size_t NumRecords;
-  bool IsSatisfied : 1;
-
-  const UnsatisfiedConstraintRecord *begin() const {
-return getTrailingObjects();
-  }
-
-  const UnsatisfiedConstraintRecord *end() const {
-return getTrailingObjects() + NumRecords;
-  }
-
-  ASTConstraintSatisfaction(const ASTContext &C,
-const ConstraintSatisfaction &Satisfaction);
-
-  static ASTConstraintSatisfaction *
-  Create(const ASTContext &C, const ConstraintSatisfaction &Satisfaction);
-};
-
-} // clang
-
-#endif // LLVM_CLANG_AST_ASTCONCEPT_H
\ No newline at end of file

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 3719f8229a36..2152e108c7cb 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_EXPRCXX_H
 #define LLVM_CLANG_AST_EXPRCXX_H
 
-#include "clang/AST/ASTConcept.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/A

[clang] ad531ff - Revert "[clang] Add no_builtin attribute"

2019-10-28 Thread Vlad Tsyrklevich via cfe-commits

Author: Vlad Tsyrklevich
Date: 2019-10-28T15:21:59-07:00
New Revision: ad531fff81a2a266ffed1d7da778cb59c983

URL: 
https://github.com/llvm/llvm-project/commit/ad531fff81a2a266ffed1d7da778cb59c983
DIFF: 
https://github.com/llvm/llvm-project/commit/ad531fff81a2a266ffed1d7da778cb59c983.diff

LOG: Revert "[clang] Add no_builtin attribute"

This reverts commit bd87916109483d33455cbf20da2309197b983cdd. It was
causing ASan/MSan failures on the sanitizer buildbots.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 
clang/test/CodeGen/no-builtin.cpp
clang/test/Sema/no-builtin.cpp



diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 16094c0988fa..b3e7a570fd6d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2031,10 +2031,6 @@ class FunctionDecl : public DeclaratorDecl,
   ///
   /// This does not determine whether the function has been defined (e.g., in a
   /// previous definition); for that information, use isDefined.
-  ///
-  /// Note: the function declaration does not become a definition until the
-  /// parser reaches the definition, if called before, this function will 
return
-  /// `false`.
   bool isThisDeclarationADefinition() const {
 return isDeletedAsWritten() || isDefaulted() || Body || hasSkippedBody() ||
isLateTemplateParsed() || willHaveBody() || hasDefiningAttr();

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index d5018f444e1c..4557a614d361 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3427,10 +3427,3 @@ def ObjCExternallyRetained : InheritableAttr {
   let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
   let Documentation = [ObjCExternallyRetainedDocs];
 }
-
-def NoBuiltin : Attr {
-  let Spellings = [Clang<"no_builtin">];
-  let Args = [VariadicStringArgument<"BuiltinNames">];
-  let Subjects = SubjectList<[Function]>;
-  let Documentation = [NoBuiltinDocs];
-}

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 9d0d27407573..6e79d0bb3631 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4413,40 +4413,3 @@ and is not a general mechanism for declaring arbitrary 
aliases for
 clang builtin functions.
   }];
 }
-
-def NoBuiltinDocs : Documentation {
-  let Category = DocCatFunction;
-  let Content = [{
-.. Note:: This attribute is not yet fully implemented, it is validated but has
-no effect on the generated code.
-
-The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin`` flag
-except it is specific to the body of a function. The attribute may also be
-applied to a virtual function but has no effect on the behavior of overriding
-functions in a derived class.
-
-It accepts one or more strings corresponding to the specific names of the
-builtins to disable (e.g. "memcpy", "memset").
-If the attribute is used without parameters it will disable all buitins at
-once.
-
-.. code-block:: c++
-
-  // The compiler is not allowed to add any builtin to foo's body.
-  void foo(char* data, size_t count) __attribute__((no_builtin)) {
-// The compiler is not allowed to convert the loop into
-// `__builtin_memset(data, 0xFE, count);`.
-for (size_t i = 0; i < count; ++i)
-  data[i] = 0xFE;
-  }
-
-  // The compiler is not allowed to add the `memcpy` builtin to bar's body.
-  void bar(char* data, size_t count) __attribute__((no_builtin("memcpy"))) {
-// The compiler is allowed to convert the loop into
-// `__builtin_memset(data, 0xFE, count);` but cannot generate any
-// `__builtin_memcpy`
-for (size_t i = 0; i < count; ++i)
-  data[i] = 0xFE;
-  }
-  }];
-}

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2313c60f006f..c93edb2f91c2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3604,15 +3604,6 @@ def err_attribute_overloadable_no_prototype : Error<
 def err_attribute_overloadable_multiple_unmarked_overloads : Error<
   "at most one overload for a given name may lack the 'overloadable' "
   "attribute">;
-def warn_attribute_no_builtin_invalid_builtin_name : Warning<
-  "'%0' is not a valid builtin name for %1">,
-  InGroup>;
-def err_attribute_no_builtin_wildcard_or_builtin_name : Error<
-  "empty %0 cannot be composed with named ones">;
-def err_attribute_no_builtin_on_non_definition : Error<
-  "%0 attribute is permitt

Re: [clang] bd87916 - [clang] Add no_builtin attribute

2019-10-28 Thread Vlad Tsyrklevich via cfe-commits
I've reverted this change as it was causing ASan/MSan failures in
check-clang, e.g. take a look at the bottom 2 failures here:
http://lab.llvm.org:8014/builders/sanitizer-x86_64-linux-bootstrap/builds/124/steps/check-clang%20asan/logs/stdio
or
here
http://lab.llvm.org:8014/builders/sanitizer-x86_64-linux-fast/builds/126/steps/check-clang%20msan/logs/stdio

On Mon, Oct 28, 2019 at 9:30 AM Guillaume Chatelet via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Guillaume Chatelet
> Date: 2019-10-28T17:30:11+01:00
> New Revision: bd87916109483d33455cbf20da2309197b983cdd
>
> URL:
> https://github.com/llvm/llvm-project/commit/bd87916109483d33455cbf20da2309197b983cdd
> DIFF:
> https://github.com/llvm/llvm-project/commit/bd87916109483d33455cbf20da2309197b983cdd.diff
>
> LOG: [clang] Add no_builtin attribute
>
> Summary:
> This is a follow up on https://reviews.llvm.org/D61634
> This patch is simpler and only adds the no_builtin attribute.
>
> Reviewers: tejohnson, courbet, theraven, t.p.northover, jdoerfert
>
> Subscribers: mgrang, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D68028
>
> Added:
> clang/test/CodeGen/no-builtin.cpp
> clang/test/Sema/no-builtin.cpp
>
> Modified:
> clang/include/clang/AST/Decl.h
> clang/include/clang/Basic/Attr.td
> clang/include/clang/Basic/AttrDocs.td
> clang/include/clang/Basic/DiagnosticSemaKinds.td
> clang/lib/CodeGen/CGCall.cpp
> clang/lib/Sema/SemaDecl.cpp
> clang/lib/Sema/SemaDeclAttr.cpp
> clang/test/Misc/pragma-attribute-supported-attributes-list.test
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/AST/Decl.h
> b/clang/include/clang/AST/Decl.h
> index b3e7a570fd6d..16094c0988fa 100644
> --- a/clang/include/clang/AST/Decl.h
> +++ b/clang/include/clang/AST/Decl.h
> @@ -2031,6 +2031,10 @@ class FunctionDecl : public DeclaratorDecl,
>///
>/// This does not determine whether the function has been defined
> (e.g., in a
>/// previous definition); for that information, use isDefined.
> +  ///
> +  /// Note: the function declaration does not become a definition until
> the
> +  /// parser reaches the definition, if called before, this function will
> return
> +  /// `false`.
>bool isThisDeclarationADefinition() const {
>  return isDeletedAsWritten() || isDefaulted() || Body ||
> hasSkippedBody() ||
> isLateTemplateParsed() || willHaveBody() || hasDefiningAttr();
>
> diff  --git a/clang/include/clang/Basic/Attr.td
> b/clang/include/clang/Basic/Attr.td
> index 4557a614d361..d5018f444e1c 100644
> --- a/clang/include/clang/Basic/Attr.td
> +++ b/clang/include/clang/Basic/Attr.td
> @@ -3427,3 +3427,10 @@ def ObjCExternallyRetained : InheritableAttr {
>let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
>let Documentation = [ObjCExternallyRetainedDocs];
>  }
> +
> +def NoBuiltin : Attr {
> +  let Spellings = [Clang<"no_builtin">];
> +  let Args = [VariadicStringArgument<"BuiltinNames">];
> +  let Subjects = SubjectList<[Function]>;
> +  let Documentation = [NoBuiltinDocs];
> +}
>
> diff  --git a/clang/include/clang/Basic/AttrDocs.td
> b/clang/include/clang/Basic/AttrDocs.td
> index 6e79d0bb3631..9d0d27407573 100644
> --- a/clang/include/clang/Basic/AttrDocs.td
> +++ b/clang/include/clang/Basic/AttrDocs.td
> @@ -4413,3 +4413,40 @@ and is not a general mechanism for declaring
> arbitrary aliases for
>  clang builtin functions.
>}];
>  }
> +
> +def NoBuiltinDocs : Documentation {
> +  let Category = DocCatFunction;
> +  let Content = [{
> +.. Note:: This attribute is not yet fully implemented, it is validated
> but has
> +no effect on the generated code.
> +
> +The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin``
> flag
> +except it is specific to the body of a function. The attribute may also be
> +applied to a virtual function but has no effect on the behavior of
> overriding
> +functions in a derived class.
> +
> +It accepts one or more strings corresponding to the specific names of the
> +builtins to disable (e.g. "memcpy", "memset").
> +If the attribute is used without parameters it will disable all buitins at
> +once.
> +
> +.. code-block:: c++
> +
> +  // The compiler is not allowed to add any builtin to foo's body.
> +  void foo(char* data, size_t count) __attribute__((no_builtin)) {
> +// The compiler is not allowed to convert the loop into
> +// `__builtin_memset(data, 0xFE, count);`.
> +for (size_t i = 0; i < count; ++i)
> +  data[i] = 0xFE;
> +  }
> +
> +  // The compiler is not allowed to add the `memcpy` builtin to bar's
> body.
> +  void bar(char* data, size_t count)
> __attribute__((no_builtin("memcpy"))) {
> +// The compiler is allowed to convert the loop into
> +// `__builtin_memset(data, 0xFE, count);` but cannot generate any
> +// `__builtin_memcpy`
> +for (size_t i = 0; i < count; ++i)

[clang] efed314 - Revert "[clang-format] Remove the dependency on frontend"

2019-10-29 Thread Vlad Tsyrklevich via cfe-commits

Author: Vlad Tsyrklevich
Date: 2019-10-29T10:48:03-07:00
New Revision: efed314118c7c287a71b8a8d67953a98d8a718d5

URL: 
https://github.com/llvm/llvm-project/commit/efed314118c7c287a71b8a8d67953a98d8a718d5
DIFF: 
https://github.com/llvm/llvm-project/commit/efed314118c7c287a71b8a8d67953a98d8a718d5.diff

LOG: Revert "[clang-format] Remove the dependency on frontend"

This reverts commit ec66603ac7ea655be5c2c5f508c5bf0d5eaeb65b. It was
causing ubsan failures like the following on the ubsan bot:
llvm/lib/Support/SourceMgr.cpp:440:48: runtime error: pointer index expression 
with base 0x overflowed to 0xfffa

Added: 


Modified: 
clang/tools/clang-format/CMakeLists.txt
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/tools/clang-format/CMakeLists.txt 
b/clang/tools/clang-format/CMakeLists.txt
index 35ecdb11253c..28ac4fb5913e 100644
--- a/clang/tools/clang-format/CMakeLists.txt
+++ b/clang/tools/clang-format/CMakeLists.txt
@@ -7,6 +7,7 @@ add_clang_tool(clang-format
 set(CLANG_FORMAT_LIB_DEPS
   clangBasic
   clangFormat
+  clangFrontend
   clangRewrite
   clangToolingCore
   )

diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index cbbb52bd0aa8..db00d41d0351 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -299,9 +300,12 @@ emitReplacementWarnings(const Replacements &Replaces, 
StringRef AssumedFileName,
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   DiagOpts->ShowColors = (ShowColors && !NoShowColors);
 
+  TextDiagnosticPrinter *DiagsBuffer =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts, false);
+
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
   IntrusiveRefCntPtr Diags(
-  new DiagnosticsEngine(DiagID, &*DiagOpts));
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagsBuffer));
 
   IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
@@ -310,40 +314,24 @@ emitReplacementWarnings(const Replacements &Replaces, 
StringRef AssumedFileName,
   FileID FileID = createInMemoryFile(AssumedFileName, Code.get(), Sources,
  Files, InMemoryFileSystem.get());
 
-  FileManager &FileMgr = Sources.getFileManager();
-  llvm::ErrorOr FileEntryPtr =
-  FileMgr.getFile(AssumedFileName);
+  const unsigned ID = Diags->getCustomDiagID(
+  WarningsAsErrors ? clang::DiagnosticsEngine::Error
+   : clang::DiagnosticsEngine::Warning,
+  "code should be clang-formatted [-Wclang-format-violations]");
 
   unsigned Errors = 0;
+  DiagsBuffer->BeginSourceFile(LangOptions(), nullptr);
   if (WarnFormat && !NoWarnFormat) {
 for (const auto &R : Replaces) {
-  PresumedLoc PLoc = Sources.getPresumedLoc(
-  
Sources.getLocForStartOfFile(FileID).getLocWithOffset(R.getOffset()));
-
-  SourceLocation LineBegin =
-  Sources.translateFileLineCol(FileEntryPtr.get(), PLoc.getLine(), 1);
-  SourceLocation NextLineBegin = Sources.translateFileLineCol(
-  FileEntryPtr.get(), PLoc.getLine() + 1, 1);
-
-  const char *StartBuf = Sources.getCharacterData(LineBegin);
-  const char *EndBuf = Sources.getCharacterData(NextLineBegin);
-
-  StringRef Line(StartBuf, (EndBuf - StartBuf) - 1);
-
-  SMDiagnostic Diags(
-  llvm::SourceMgr(), SMLoc(), AssumedFileName, PLoc.getLine(),
-  PLoc.getColumn(),
-  WarningsAsErrors ? SourceMgr::DiagKind::DK_Error
-   : SourceMgr::DiagKind::DK_Warning,
-  "code should be clang-formatted [-Wclang-format-violations]", Line,
-  ArrayRef>());
-
-  Diags.print(nullptr, llvm::errs(), (ShowColors && !NoShowColors));
+  Diags->Report(
+  Sources.getLocForStartOfFile(FileID).getLocWithOffset(R.getOffset()),
+  ID);
   Errors++;
   if (ErrorLimit && Errors >= ErrorLimit)
 break;
 }
   }
+  DiagsBuffer->EndSourceFile();
   return WarningsAsErrors;
 }
 



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


Re: [clang] ec66603 - [clang-format] Remove the dependency on frontend

2019-10-29 Thread Vlad Tsyrklevich via cfe-commits
I've reverted this commit as it was causing UBSan failures on the ubsan
bot. These failures looked like:
llvm/lib/Support/SourceMgr.cpp:440:48: runtime error: pointer index
expression with base 0x overflowed to 0xfffa

Looking at a backtrace, this line was reached from the
`Diags.print(nullptr, llvm::errs(), (ShowColors && !NoShowColors));` call
introduced in this change.

I apologize for the delay in this revert, normally reverts happen in under
a day but in this case this change was committed right as we switched to
GitHub and it took a while to get the sanitizers buildbots working properly
and track down failures.

On Thu, Oct 24, 2019 at 11:17 AM via cfe-commits 
wrote:

>
> Author: paulhoad
> Date: 2019-10-24T19:03:57+01:00
> New Revision: ec66603ac7ea655be5c2c5f508c5bf0d5eaeb65b
>
> URL:
> https://github.com/llvm/llvm-project/commit/ec66603ac7ea655be5c2c5f508c5bf0d5eaeb65b
> DIFF:
> https://github.com/llvm/llvm-project/commit/ec66603ac7ea655be5c2c5f508c5bf0d5eaeb65b.diff
>
> LOG: [clang-format] Remove the dependency on frontend
>
> Summary:
> Address review comments from {D68554} by trying to drop the dependency
> again on Frontend whilst keeping the same format diagnostic messages
>
> Not completely happy with having to do a split in order to get the
> StringRef for the Line the error occurred on, but could see a way to use
> SourceManager and SourceLocation to give me a single line?
>
> But this removes the dependency on frontend which should keep the binary
> size down.
>
> Reviewers: thakis, klimek, mitchell-stellar
>
> Reviewed By: klimek
>
> Subscribers: mgorny, cfe-commits
>
> Tags: #clang, #clang-format
>
> Differential Revision: https://reviews.llvm.org/D68969
>
> Added:
>
>
> Modified:
> clang/tools/clang-format/CMakeLists.txt
> clang/tools/clang-format/ClangFormat.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/tools/clang-format/CMakeLists.txt
> b/clang/tools/clang-format/CMakeLists.txt
> index 28ac4fb5913e..35ecdb11253c 100644
> --- a/clang/tools/clang-format/CMakeLists.txt
> +++ b/clang/tools/clang-format/CMakeLists.txt
> @@ -7,7 +7,6 @@ add_clang_tool(clang-format
>  set(CLANG_FORMAT_LIB_DEPS
>clangBasic
>clangFormat
> -  clangFrontend
>clangRewrite
>clangToolingCore
>)
>
> diff  --git a/clang/tools/clang-format/ClangFormat.cpp
> b/clang/tools/clang-format/ClangFormat.cpp
> index f39c18bae3ff..a10541d88f07 100644
> --- a/clang/tools/clang-format/ClangFormat.cpp
> +++ b/clang/tools/clang-format/ClangFormat.cpp
> @@ -18,7 +18,6 @@
>  #include "clang/Basic/SourceManager.h"
>  #include "clang/Basic/Version.h"
>  #include "clang/Format/Format.h"
> -#include "clang/Frontend/TextDiagnosticPrinter.h"
>  #include "clang/Rewrite/Core/Rewriter.h"
>  #include "llvm/Support/CommandLine.h"
>  #include "llvm/Support/FileSystem.h"
> @@ -325,12 +324,9 @@ emitReplacementWarnings(const Replacements &Replaces,
> StringRef AssumedFileName,
>IntrusiveRefCntPtr DiagOpts = new
> DiagnosticOptions();
>DiagOpts->ShowColors = (ShowColors && !NoShowColors);
>
> -  TextDiagnosticPrinter *DiagsBuffer =
> -  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts, false);
> -
>IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
>IntrusiveRefCntPtr Diags(
> -  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagsBuffer));
> +  new DiagnosticsEngine(DiagID, &*DiagOpts));
>
>IntrusiveRefCntPtr InMemoryFileSystem(
>new llvm::vfs::InMemoryFileSystem);
> @@ -339,24 +335,40 @@ emitReplacementWarnings(const Replacements
> &Replaces, StringRef AssumedFileName,
>FileID FileID = createInMemoryFile(AssumedFileName, Code.get(), Sources,
>   Files, InMemoryFileSystem.get());
>
> -  const unsigned ID = Diags->getCustomDiagID(
> -  WarningsAsErrors ? clang::DiagnosticsEngine::Error
> -   : clang::DiagnosticsEngine::Warning,
> -  "code should be clang-formatted [-Wclang-format-violations]");
> +  FileManager &FileMgr = Sources.getFileManager();
> +  llvm::ErrorOr FileEntryPtr =
> +  FileMgr.getFile(AssumedFileName);
>
>unsigned Errors = 0;
> -  DiagsBuffer->BeginSourceFile(LangOptions(), nullptr);
>if (WarnFormat && !NoWarnFormat) {
>  for (const auto &R : Replaces) {
> -  Diags->Report(
> -
> Sources.getLocForStartOfFile(FileID).getLocWithOffset(R.getOffset()),
> -  ID);
> +  PresumedLoc PLoc = Sources.getPresumedLoc(
> +
> Sources.getLocForStartOfFile(FileID).getLocWithOffset(R.getOffset()));
> +
> +  SourceLocation LineBegin =
> +  Sources.translateFileLineCol(FileEntryPtr.get(),
> PLoc.getLine(), 1);
> +  SourceLocation NextLineBegin = Sources.translateFileLineCol(
> +  FileEntryPtr.get(), PLoc.getLine() + 1, 1);
> +
> +  const char *StartBuf = Sources.getCharacterData(LineBegin);
> +  const char *EndBuf = Sources.getCharacterData(NextLineBegi

r370142 - Revert "Change the X86 datalayout to add three address spaces for 32 bit signed, "

2019-08-27 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Aug 27 18:08:54 2019
New Revision: 370142

URL: http://llvm.org/viewvc/llvm-project?rev=370142&view=rev
Log:
Revert "Change the X86 datalayout to add three address spaces for 32 bit 
signed,"

This reverts commit r370083 because it caused check-lld failures on
sanitizer-x86_64-linux-fast.

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/test/CodeGen/Inputs/thinlto-multi-module.ll
cfe/trunk/test/CodeGen/Inputs/thinlto_backend.ll
cfe/trunk/test/CodeGen/Inputs/thinlto_backend_local_name_conflict1.ll
cfe/trunk/test/CodeGen/Inputs/thinlto_backend_local_name_conflict2.ll
cfe/trunk/test/CodeGen/iamcu-abi.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll
cfe/trunk/test/CodeGen/thinlto-distributed-backend-skip.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
cfe/trunk/test/CodeGen/thinlto-distributed.ll
cfe/trunk/test/CodeGen/thinlto-multi-module.ll
cfe/trunk/test/CodeGen/thinlto_backend.ll
cfe/trunk/test/CodeGen/thinlto_backend_local_name_conflict.ll

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=370142&r1=370141&r2=370142&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Aug 27 18:08:54 2019
@@ -775,11 +775,9 @@ public:
 if (Triple.getArch() == llvm::Triple::arm) {
   // Handled in ARM's setABI().
 } else if (Triple.getArch() == llvm::Triple::x86) {
-  this->resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
-"i64:64-n8:16:32-S128");
+  this->resetDataLayout("e-m:e-p:32:32-i64:64-n8:16:32-S128");
 } else if (Triple.getArch() == llvm::Triple::x86_64) {
-  this->resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
-"i64:64-n8:16:32:64-S128");
+  this->resetDataLayout("e-m:e-p:32:32-i64:64-n8:16:32:64-S128");
 } else if (Triple.getArch() == llvm::Triple::mipsel) {
   // Handled on mips' setDataLayout.
 } else {

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=370142&r1=370141&r2=370142&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Tue Aug 27 18:08:54 2019
@@ -340,8 +340,7 @@ public:
 LongDoubleWidth = 96;
 LongDoubleAlign = 32;
 SuitableAlign = 128;
-resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
-"f80:32-n8:16:32-S128");
+resetDataLayout("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128");
 SizeType = UnsignedInt;
 PtrDiffType = SignedInt;
 IntPtrType = SignedInt;
@@ -441,8 +440,7 @@ public:
   UseSignedCharForObjCBool = false;
 SizeType = UnsignedLong;
 IntPtrType = SignedLong;
-resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
-"f80:128-n8:16:32-S128");
+resetDataLayout("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128");
 HasAlignMac68kSupport = true;
   }
 
@@ -467,10 +465,9 @@ public:
 DoubleAlign = LongLongAlign = 64;
 bool IsWinCOFF =
 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
-resetDataLayout(IsWinCOFF ? "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:"
-"64-i64:64-f80:32-n8:16:32-a:0:32-S32"
-  : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:"
-"64-i64:64-f80:32-n8:16:32-a:0:32-S32");
+resetDataLayout(IsWinCOFF
+? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+: "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
   }
 };
 
@@ -518,8 +515,7 @@ public:
   : X86_32TargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedShort;
 DoubleAlign = LongLongAlign = 64;
-
resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
-"32-n8:16:32-a:0:32-S32");
+resetDataLayout("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -556,8 +552,7 @@ public:
   : X86_32TargetInfo(Triple, Opts) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
-
resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-f64:"
-"32-f128:32-n8:16:32-a:0:32-S32");
+resetDataLayout("e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32");
 WIntType = UnsignedInt;
   }
 
@@ -616,12 +611,10 @@ public:
 

r310097 - CFI: blacklist STL allocate() from unrelated-casts

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 12:10:11 2017
New Revision: 310097

URL: http://llvm.org/viewvc/llvm-project?rev=310097&view=rev
Log:
CFI: blacklist STL allocate() from unrelated-casts

Summary:
Previously, STL allocators were blacklisted in compiler_rt's
cfi_blacklist.txt because they mandated a cast from void* to T* before
object initialization completed. This change moves that logic into the
front end because C++ name mangling supports a substitution compression
mechanism for symbols that makes it difficult to blacklist the mangled
symbol for allocate() using a regular expression.

Motivated by crbug.com/751385.

Reviewers: pcc, kcc

Reviewed By: pcc

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310097&r1=310096&r2=310097&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 12:10:11 2017
@@ -723,6 +723,25 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getName().equals("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +801,14 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Added: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310097&view=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (added)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp Fri Aug  4 12:10:11 2017
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -fvisibility hidden -fsanitize=cfi-unrelated-cast 
-emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


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


r310099 - Revert "CFI: blacklist STL allocate() from unrelated-casts"

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 12:17:16 2017
New Revision: 310099

URL: http://llvm.org/viewvc/llvm-project?rev=310099&view=rev
Log:
Revert "CFI: blacklist STL allocate() from unrelated-casts"

This reverts commit r310097.

Removed:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310099&r1=310098&r2=310099&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 12:17:16 2017
@@ -723,25 +723,6 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
-static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) {
-  auto *MD = dyn_cast_or_null(D);
-  if (!MD || !MD->getName().equals("allocate") ||
-  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
-return false;
-
-  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
-return false;
-
-  if (MD->getNumParams() == 2) {
-auto *PT = MD->parameters()[1]->getType()->getAs();
-if (!PT || !PT->isVoidPointerType() ||
-!PT->getPointeeType().isConstQualified())
-  return false;
-  }
-
-  return true;
-}
-
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -801,14 +782,6 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
-  // Ignore unrelated casts in STL allocate() since the allocator must cast
-  // from void* to T* before object initialization completes. Don't match on 
the
-  // namespace because not all allocators are in std::
-  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
-if (matchesStlAllocatorFn(D, getContext()))
-  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
-  }
-
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Removed: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310098&view=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (original)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (removed)
@@ -1,37 +0,0 @@
-// STL allocators should not have unrelated-cast tests applied
-// RUN: %clang_cc1 -flto -fvisibility hidden -fsanitize=cfi-unrelated-cast 
-emit-llvm -o - %s | FileCheck %s
-
-#include 
-
-template
-class myalloc {
- public:
-  // CHECK: define{{.*}}allocateE{{.}}
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}allocateE{{.}}PKv
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}differentName
-  // CHECK: llvm.type.test
-  T *differentName(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-};
-
-class C1 {
-  virtual void f() {}
-};
-
-C1 *f1() {
-  myalloc allocator;
-  (void)allocator.allocate(16);
-  (void)allocator.allocate(16, 0);
-  (void)allocator.differentName(16, 0);
-}


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


r310105 - Reland "CFI: blacklist STL allocate() from unrelated-casts"

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 12:50:39 2017
New Revision: 310105

URL: http://llvm.org/viewvc/llvm-project?rev=310105&view=rev
Log:
Reland "CFI: blacklist STL allocate() from unrelated-casts"

Reland r310097 with a unit test fix for MS ABI build bots.

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

Added:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310105&r1=310104&r2=310105&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 12:50:39 2017
@@ -723,6 +723,25 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getName().equals("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +801,14 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Added: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310105&view=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (added)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp Fri Aug  4 12:50:39 2017
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden 
-fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


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


r310121 - Revert "Reland "CFI: blacklist STL allocate() from unrelated-casts""

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 13:37:49 2017
New Revision: 310121

URL: http://llvm.org/viewvc/llvm-project?rev=310121&view=rev
Log:
Revert "Reland "CFI: blacklist STL allocate() from unrelated-casts""

This reverts commit r310105.

Removed:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310121&r1=310120&r2=310121&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 13:37:49 2017
@@ -723,25 +723,6 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
-static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) {
-  auto *MD = dyn_cast_or_null(D);
-  if (!MD || !MD->getName().equals("allocate") ||
-  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
-return false;
-
-  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
-return false;
-
-  if (MD->getNumParams() == 2) {
-auto *PT = MD->parameters()[1]->getType()->getAs();
-if (!PT || !PT->isVoidPointerType() ||
-!PT->getPointeeType().isConstQualified())
-  return false;
-  }
-
-  return true;
-}
-
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -801,14 +782,6 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
-  // Ignore unrelated casts in STL allocate() since the allocator must cast
-  // from void* to T* before object initialization completes. Don't match on 
the
-  // namespace because not all allocators are in std::
-  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
-if (matchesStlAllocatorFn(D, getContext()))
-  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
-  }
-
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Removed: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310120&view=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (original)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (removed)
@@ -1,37 +0,0 @@
-// STL allocators should not have unrelated-cast tests applied
-// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden 
-fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s
-
-#include 
-
-template
-class myalloc {
- public:
-  // CHECK: define{{.*}}allocateE{{.}}
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}allocateE{{.}}PKv
-  // CHECK-NOT: llvm.type.test
-  T *allocate(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-
-  // CHECK: define{{.*}}differentName
-  // CHECK: llvm.type.test
-  T *differentName(size_t sz, const void *ptr) {
-return (T*)::operator new(sz);
-  }
-};
-
-class C1 {
-  virtual void f() {}
-};
-
-C1 *f1() {
-  myalloc allocator;
-  (void)allocator.allocate(16);
-  (void)allocator.allocate(16, 0);
-  (void)allocator.differentName(16, 0);
-}


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


r310132 - Reland "CFI: blacklist STL allocate() from unrelated-casts"

2017-08-04 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug  4 14:21:00 2017
New Revision: 310132

URL: http://llvm.org/viewvc/llvm-project?rev=310132&view=rev
Log:
Reland "CFI: blacklist STL allocate() from unrelated-casts"

Reland r310097 with a fix for a debug assertion in NamedDecl.getName()

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

Added:
cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=310132&r1=310131&r2=310132&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug  4 14:21:00 2017
@@ -723,6 +723,26 @@ static void markAsIgnoreThreadCheckingAt
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
 }
 
+static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) {
+  auto *MD = dyn_cast_or_null(D);
+  if (!MD || !MD->getDeclName().getAsIdentifierInfo() ||
+  !MD->getDeclName().getAsIdentifierInfo()->isStr("allocate") ||
+  (MD->getNumParams() != 1 && MD->getNumParams() != 2))
+return false;
+
+  if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType())
+return false;
+
+  if (MD->getNumParams() == 2) {
+auto *PT = MD->parameters()[1]->getType()->getAs();
+if (!PT || !PT->isVoidPointerType() ||
+!PT->getPointeeType().isConstQualified())
+  return false;
+  }
+
+  return true;
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -782,6 +802,14 @@ void CodeGenFunction::StartFunction(Glob
 }
   }
 
+  // Ignore unrelated casts in STL allocate() since the allocator must cast
+  // from void* to T* before object initialization completes. Don't match on 
the
+  // namespace because not all allocators are in std::
+  if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (matchesStlAllocatorFn(D, getContext()))
+  SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast;
+  }
+
   // Apply xray attributes to the function (as a string, for now)
   if (D && ShouldXRayInstrumentFunction()) {
 if (const auto *XRayAttr = D->getAttr()) {

Added: cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp?rev=310132&view=auto
==
--- cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp (added)
+++ cfe/trunk/test/CodeGen/cfi-unrelated-cast.cpp Fri Aug  4 14:21:00 2017
@@ -0,0 +1,37 @@
+// STL allocators should not have unrelated-cast tests applied
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden 
-fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+template
+class myalloc {
+ public:
+  // CHECK: define{{.*}}allocateE{{.}}
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}allocateE{{.}}PKv
+  // CHECK-NOT: llvm.type.test
+  T *allocate(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+
+  // CHECK: define{{.*}}differentName
+  // CHECK: llvm.type.test
+  T *differentName(size_t sz, const void *ptr) {
+return (T*)::operator new(sz);
+  }
+};
+
+class C1 {
+  virtual void f() {}
+};
+
+C1 *f1() {
+  myalloc allocator;
+  (void)allocator.allocate(16);
+  (void)allocator.allocate(16, 0);
+  (void)allocator.differentName(16, 0);
+}


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


r311210 - Revert "[clang-diff] Move printing of matches and changes to clang-diff"

2017-08-18 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug 18 16:21:10 2017
New Revision: 311210

URL: http://llvm.org/viewvc/llvm-project?rev=311210&view=rev
Log:
Revert "[clang-diff] Move printing of matches and changes to clang-diff"

This reverts commit r311200, it was causing widespread build failures.

Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/Tooling/clang-diff-basic.cpp
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311210&r1=311209&r2=311210&view=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 16:21:10 2017
@@ -25,22 +25,37 @@
 namespace clang {
 namespace diff {
 
+/// This represents a match between two nodes in the source and destination
+/// trees, meaning that they are likely to be related.
+struct Match {
+  NodeId Src, Dst;
+};
+
 enum ChangeKind {
-  None,
-  Delete,// (Src): delete node Src.
-  Update,// (Src, Dst): update the value of node Src to match Dst.
-  Insert,// (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
-  Move,  // (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
-  UpdateMove // Same as Move plus Update.
+  Delete, // (Src): delete node Src.
+  Update, // (Src, Dst): update the value of node Src to match Dst.
+  Insert, // (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
+  Move// (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
+};
+
+struct Change {
+  ChangeKind Kind;
+  NodeId Src, Dst;
+  size_t Position;
+
+  Change(ChangeKind Kind, NodeId Src, NodeId Dst, size_t Position)
+  : Kind(Kind), Src(Src), Dst(Dst), Position(Position) {}
+  Change(ChangeKind Kind, NodeId Src) : Kind(Kind), Src(Src) {}
+  Change(ChangeKind Kind, NodeId Src, NodeId Dst)
+  : Kind(Kind), Src(Src), Dst(Dst) {}
 };
 
 /// Represents a Clang AST node, alongside some additional information.
 struct Node {
   NodeId Parent, LeftMostDescendant, RightMostDescendant;
-  int Depth, Height, Shift = 0;
+  int Depth, Height;
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
-  ChangeKind ChangeKind = None;
 
   ast_type_traits::ASTNodeKind getType() const;
   StringRef getTypeLabel() const;
@@ -52,8 +67,15 @@ public:
   ASTDiff(SyntaxTree &Src, SyntaxTree &Dst, const ComparisonOptions &Options);
   ~ASTDiff();
 
-  // Returns the ID of the node that is mapped to the given node in SourceTree.
-  NodeId getMapped(const SyntaxTree &SourceTree, NodeId Id) const;
+  // Returns a list of matches.
+  std::vector getMatches();
+  /// Returns an edit script.
+  std::vector getChanges();
+
+  // Prints an edit action.
+  void printChange(raw_ostream &OS, const Change &Chg) const;
+  // Prints a match between two nodes.
+  void printMatch(raw_ostream &OS, const Match &M) const;
 
   class Impl;
 
@@ -77,14 +99,8 @@ public:
   const ASTContext &getASTContext() const;
   StringRef getFilename() const;
 
-  int getSize() const;
-  NodeId getRootId() const;
-  using PreorderIterator = NodeId;
-  PreorderIterator begin() const;
-  PreorderIterator end() const;
-
   const Node &getNode(NodeId Id) const;
-  int findPositionInParent(NodeId Id) const;
+  NodeId getRootId() const;
 
   // Returns the starting and ending offset of the node in its source file.
   std::pair getSourceRangeOffsets(const Node &N) const;
@@ -92,8 +108,7 @@ public:
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
-  std::string getNodeValue(NodeId Id) const;
-  std::string getNodeValue(const Node &Node) const;
+  std::string getNodeValue(const DynTypedNode &DTN) const;
 
   class Impl;
   std::unique_ptr TreeImpl;
@@ -116,8 +131,8 @@ struct ComparisonOptions {
   bool EnableMatchingWithUnmatchableParents = false;
 
   /// Returns false if the nodes should never be matched.
-  bool isMatchingAllowed(const Node &N1, const Node &N2) const {
-return N1.getType().isSame(N2.getType());
+  bool isMatchingAllowed(const DynTypedNode &N1, const DynTypedNode &N2) const 
{
+return N1.getNodeKind().isSame(N2.getNodeKind());
   }
 };
 

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h?rev=311210&r1=311209&r2=311210&view=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTD

r311211 - Revert "[clang-diff] Move the JSON export function to clang-diff"

2017-08-18 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug 18 16:21:11 2017
New Revision: 311211

URL: http://llvm.org/viewvc/llvm-project?rev=311211&view=rev
Log:
Revert "[clang-diff] Move the JSON export function to clang-diff"

This reverts commit r311199, it was causing widespread build failures.

Removed:
cfe/trunk/test/Tooling/clang-diff-json.cpp
Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311211&r1=311210&r2=311211&view=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 16:21:11 2017
@@ -57,8 +57,8 @@ struct Node {
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
 
-  ast_type_traits::ASTNodeKind getType() const;
-  StringRef getTypeLabel() const;
+  ast_type_traits::ASTNodeKind getType() const { return ASTNode.getNodeKind(); 
}
+  const StringRef getTypeLabel() const { return getType().asStringRef(); }
   bool isLeaf() const { return Children.empty(); }
 };
 
@@ -96,20 +96,15 @@ public:
   SyntaxTree(SyntaxTree &&Other) = default;
   ~SyntaxTree();
 
-  const ASTContext &getASTContext() const;
-  StringRef getFilename() const;
-
   const Node &getNode(NodeId Id) const;
-  NodeId getRootId() const;
-
-  // Returns the starting and ending offset of the node in its source file.
-  std::pair getSourceRangeOffsets(const Node &N) const;
 
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
   std::string getNodeValue(const DynTypedNode &DTN) const;
 
+  void printAsJson(raw_ostream &OS);
+
   class Impl;
   std::unique_ptr TreeImpl;
 };

Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311211&r1=311210&r2=311211&view=diff
==
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original)
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Fri Aug 18 16:21:11 2017
@@ -176,6 +176,9 @@ public:
   void printTree(NodeId Root) const;
   void printTree(raw_ostream &OS, NodeId Root) const;
 
+  void printAsJsonImpl(raw_ostream &OS) const;
+  void printNodeAsJson(raw_ostream &OS, NodeId Id) const;
+
 private:
   /// Nodes in preorder.
   std::vector Nodes;
@@ -435,6 +438,28 @@ void SyntaxTree::Impl::printNode(raw_ost
   OS << "(" << PostorderIds[Id] << ")";
 }
 
+void SyntaxTree::Impl::printNodeAsJson(raw_ostream &OS, NodeId Id) const {
+  auto N = getNode(Id);
+  OS << R"({"type":")" << N.getTypeLabel() << R"(")";
+  if (getNodeValue(Id) != "")
+OS << R"(,"value":")" << getNodeValue(Id) << R"(")";
+  OS << R"(,"children":[)";
+  if (N.Children.size() > 0) {
+printNodeAsJson(OS, N.Children[0]);
+for (size_t I = 1, E = N.Children.size(); I < E; ++I) {
+  OS << ",";
+  printNodeAsJson(OS, N.Children[I]);
+}
+  }
+  OS << "]}";
+}
+
+void SyntaxTree::Impl::printAsJsonImpl(raw_ostream &OS) const {
+  OS << R"({"root":)";
+  printNodeAsJson(OS, getRootId());
+  OS << "}\n";
+}
+
 /// Identifies a node in a subtree by its postorder offset, starting at 1.
 struct SNodeId {
   int Id = 0;
@@ -649,12 +674,6 @@ private:
   }
 };
 
-ast_type_traits::ASTNodeKind Node::getType() const {
-  return ASTNode.getNodeKind();
-}
-
-StringRef Node::getTypeLabel() const { return getType().asStringRef(); }
-
 namespace {
 // Compares nodes by their depth.
 struct HeightLess {
@@ -980,28 +999,7 @@ void ASTDiff::printMatch(raw_ostream &OS
 
 SyntaxTree::~SyntaxTree() = default;
 
-const ASTContext &SyntaxTree::getASTContext() const { return TreeImpl->AST; }
-
-const Node &SyntaxTree::getNode(NodeId Id) const {
-  return TreeImpl->getNode(Id);
-}
-
-NodeId SyntaxTree::getRootId() const { return TreeImpl->getRootId(); }
-
-std::pair SyntaxTree::getSourceRangeOffsets(const Node &N) 
const {
-  const SourceManager &SrcMgr = TreeImpl->AST.getSourceManager();
-  SourceRange Range = N.ASTNode.getSourceRange();
-  SourceLocation BeginLoc = Range.getBegin();
-  SourceLocation EndLoc = Lexer::getLocForEndOfToken(
-  Range.getEnd(), /*Offset=*/0, SrcMgr, TreeImpl->AST.getLangOpts());
-  if (auto *ThisExpr = N.ASTNode.get()) {
-if (ThisExpr->isImplicit())
-  EndLoc = BeginLoc;
-  }
-  unsigned Begin = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(BeginLoc));
-  unsigned End = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(EndLoc));
-  return {Begin, End};
-}
+void SyntaxTree::printAsJson(raw_ostream 

Re: [clang] bd87916 - [clang] Add no_builtin attribute

2019-10-29 Thread Vlad Tsyrklevich via cfe-commits
Yup, I didn't follow up to this email but we talked on gchat and sorted it
out.

On Tue, Oct 29, 2019 at 2:20 PM Vitaly Buka  wrote:

> Ignoring "slave lost exception" bots are green for a while
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast?numbuilds=100
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap?numbuilds=100
>
> Vlads report was done when bots were on staging master :8014 for github
> migration. Now they are on primary master :8011, so old links are stale.
>
>
>
> On Tue, Oct 29, 2019 at 5:33 AM Guillaume Chatelet via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> hi Vlad,
>>
>> I've spend a big part of my day digging into this and I'm less and less
>> convinced that my patch broke the builds.
>> IIUC the built bots are still failing although my patch has been
>> reverted for quite some time now.
>>
>> Am I missing something?
>>
>> On Mon, Oct 28, 2019 at 11:24 PM Vlad Tsyrklevich 
>> wrote:
>>
>>> I've reverted this change as it was causing ASan/MSan failures in
>>> check-clang, e.g. take a look at the bottom 2 failures here:
>>> http://lab.llvm.org:8014/builders/sanitizer-x86_64-linux-bootstrap/builds/124/steps/check-clang%20asan/logs/stdio
>>>  or
>>> here
>>> http://lab.llvm.org:8014/builders/sanitizer-x86_64-linux-fast/builds/126/steps/check-clang%20msan/logs/stdio
>>>
>>> On Mon, Oct 28, 2019 at 9:30 AM Guillaume Chatelet via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>

 Author: Guillaume Chatelet
 Date: 2019-10-28T17:30:11+01:00
 New Revision: bd87916109483d33455cbf20da2309197b983cdd

 URL:
 https://github.com/llvm/llvm-project/commit/bd87916109483d33455cbf20da2309197b983cdd
 DIFF:
 https://github.com/llvm/llvm-project/commit/bd87916109483d33455cbf20da2309197b983cdd.diff

 LOG: [clang] Add no_builtin attribute

 Summary:
 This is a follow up on https://reviews.llvm.org/D61634
 This patch is simpler and only adds the no_builtin attribute.

 Reviewers: tejohnson, courbet, theraven, t.p.northover, jdoerfert

 Subscribers: mgrang, cfe-commits

 Tags: #clang

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

 Added:
 clang/test/CodeGen/no-builtin.cpp
 clang/test/Sema/no-builtin.cpp

 Modified:
 clang/include/clang/AST/Decl.h
 clang/include/clang/Basic/Attr.td
 clang/include/clang/Basic/AttrDocs.td
 clang/include/clang/Basic/DiagnosticSemaKinds.td
 clang/lib/CodeGen/CGCall.cpp
 clang/lib/Sema/SemaDecl.cpp
 clang/lib/Sema/SemaDeclAttr.cpp
 clang/test/Misc/pragma-attribute-supported-attributes-list.test

 Removed:




 
 diff  --git a/clang/include/clang/AST/Decl.h
 b/clang/include/clang/AST/Decl.h
 index b3e7a570fd6d..16094c0988fa 100644
 --- a/clang/include/clang/AST/Decl.h
 +++ b/clang/include/clang/AST/Decl.h
 @@ -2031,6 +2031,10 @@ class FunctionDecl : public DeclaratorDecl,
///
/// This does not determine whether the function has been defined
 (e.g., in a
/// previous definition); for that information, use isDefined.
 +  ///
 +  /// Note: the function declaration does not become a definition
 until the
 +  /// parser reaches the definition, if called before, this function
 will return
 +  /// `false`.
bool isThisDeclarationADefinition() const {
  return isDeletedAsWritten() || isDefaulted() || Body ||
 hasSkippedBody() ||
 isLateTemplateParsed() || willHaveBody() ||
 hasDefiningAttr();

 diff  --git a/clang/include/clang/Basic/Attr.td
 b/clang/include/clang/Basic/Attr.td
 index 4557a614d361..d5018f444e1c 100644
 --- a/clang/include/clang/Basic/Attr.td
 +++ b/clang/include/clang/Basic/Attr.td
 @@ -3427,3 +3427,10 @@ def ObjCExternallyRetained : InheritableAttr {
let Subjects = SubjectList<[NonParmVar, Function, Block,
 ObjCMethod]>;
let Documentation = [ObjCExternallyRetainedDocs];
  }
 +
 +def NoBuiltin : Attr {
 +  let Spellings = [Clang<"no_builtin">];
 +  let Args = [VariadicStringArgument<"BuiltinNames">];
 +  let Subjects = SubjectList<[Function]>;
 +  let Documentation = [NoBuiltinDocs];
 +}

 diff  --git a/clang/include/clang/Basic/AttrDocs.td
 b/clang/include/clang/Basic/AttrDocs.td
 index 6e79d0bb3631..9d0d27407573 100644
 --- a/clang/include/clang/Basic/AttrDocs.td
 +++ b/clang/include/clang/Basic/AttrDocs.td
 @@ -4413,3 +4413,40 @@ and is not a general mechanism for declaring
 arbitrary aliases for
  clang builtin functions.
}];
  }
 +
 +def NoBuiltinDocs : Documentation {
 +  let Category = DocCatFunction;
 +  let Content = [{
 +.. Note:: This attribute is not yet 

r329122 - Add the -fsanitize=shadow-call-stack flag

2018-04-03 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Apr  3 15:33:53 2018
New Revision: 329122

URL: http://llvm.org/viewvc/llvm-project?rev=329122&view=rev
Log:
Add the -fsanitize=shadow-call-stack flag

Summary:
Add support for the -fsanitize=shadow-call-stack flag which causes clang
to add ShadowCallStack attribute to functions compiled with that flag
enabled.

Reviewers: pcc, kcc

Reviewed By: pcc, kcc

Subscribers: cryptoad, cfe-commits, kcc

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

Added:
cfe/trunk/docs/ShadowCallStack.rst
cfe/trunk/test/CodeGen/shadowcallstack-attr.c
Modified:
cfe/trunk/docs/index.rst
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Added: cfe/trunk/docs/ShadowCallStack.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ShadowCallStack.rst?rev=329122&view=auto
==
--- cfe/trunk/docs/ShadowCallStack.rst (added)
+++ cfe/trunk/docs/ShadowCallStack.rst Tue Apr  3 15:33:53 2018
@@ -0,0 +1,150 @@
+===
+ShadowCallStack
+===
+
+.. contents::
+   :local:
+
+Introduction
+
+
+ShadowCallStack is an **experimental** instrumentation pass, currently only
+implemented for x86_64, that protects programs against return address
+overwrites (e.g. stack buffer overflows.) It works by saving a function's 
return
+address to a separately allocated 'shadow call stack' in the function prolog 
and
+checking the return address on the stack against the shadow call stack in the
+function epilog.
+
+Comparison
+--
+
+To optimize for memory consumption and cache locality, the shadow call stack
+stores an index followed by an array of return addresses. This is in contrast
+to other schemes, like :doc:`SafeStack`, that mirror the entire stack and
+trade-off consuming more memory for shorter function prologs and epilogs with
+fewer memory accesses. Similarly, `Return Flow Guard`_ consumes more memory 
with
+shorter function prologs and epilogs than ShadowCallStack but suffers from the
+same race conditions (see `Security`_). Intel `Control-flow Enforcement 
Technology`_
+(CET) is a proposed hardware extension that would add native support to
+use a shadow stack to store/check return addresses at call/return time. It
+would not suffer from race conditions at calls and returns and not incur the
+overhead of function instrumentation, but it does require operating system
+support.
+
+.. _`Return Flow Guard`: 
https://xlab.tencent.com/en/2016/11/02/return-flow-guard/
+.. _`Control-flow Enforcement Technology`: 
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf
+
+Compatibility
+-
+
+ShadowCallStack currently only supports x86_64. A runtime is not currently
+provided in compiler-rt so one must be provided by the compiled application.
+
+Security
+
+
+ShadowCallStack is intended to be a stronger alternative to
+``-fstack-protector``. It protects from non-linear overflows and arbitrary
+memory writes to the return address slot; however, similarly to
+``-fstack-protector`` this protection suffers from race conditions because of
+the call-return semantics on x86_64. There is a short race between the call
+instruction and the first instruction in the function that reads the return
+address where an attacker could overwrite the return address and bypass
+ShadowCallStack. Similarly, there is a time-of-check-to-time-of-use race in the
+function epilog where an attacker could overwrite the return address after it
+has been checked and before it has been returned to. Modifying the call-return
+semantics to fix this on x86_64 would incur an unacceptable performance 
overhead
+due to return branch prediction.
+
+The instrumentation makes use of the ``gs`` segment register to reference the
+shadow call stack meaning that references to the shadow call stack do not have
+to be stored in memory. This makes it possible to implement a runtime that
+avoids exposing the address of the shadow call stack to attackers that can read
+arbitrary memory. However, attackers could still try to exploit side channels
+exposed by the operating system `[1]`_ `[2]`_ or processor `[3]`_ to discover
+the address of the shadow call stack.
+
+.. _`[1]`: 
https://eyalitkin.wordpress.com/2017/09/01/cartography-lighting-up-the-shadows/
+.. _`[2]`: 
https://www.blackhat.com/docs/eu-16/materials/eu-16-Goktas-Bypassing-Clangs-SafeStack.pdf
+.. _`[3]`: https://www.vusec.net/projects/anc/
+
+Leaf functions are optimized to store the return address in a free register
+and avoid writing to the shadow call stack if a register is available. Very
+short leaf functions are uninstrumented if their execution is j

[libcxxabi] r329629 - [CFI] Disable CFI checks for __cxa_decrement_exception_refcount

2018-04-09 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Apr  9 15:11:28 2018
New Revision: 329629

URL: http://llvm.org/viewvc/llvm-project?rev=329629&view=rev
Log:
[CFI] Disable CFI checks for __cxa_decrement_exception_refcount

Summary:
exception_header->exceptionDestructor is a void(*)(void*) function
pointer; however, it can point to destructors like std::
exception::~exception that don't match that type signature.

Reviewers: pcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: kcc, christof, cfe-commits

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

Modified:
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=329629&r1=329628&r2=329629&view=diff
==
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Mon Apr  9 15:11:28 2018
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=329629&r1=329628&r2=329629&view=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Mon Apr  9 15:11:28 2018
@@ -630,8 +630,8 @@ __cxa_increment_exception_refcount(void
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);


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


r317044 - [CFI] Add CFI-icall pointer type generalization

2017-10-31 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Oct 31 15:39:44 2017
New Revision: 317044

URL: http://llvm.org/viewvc/llvm-project?rev=317044&view=rev
Log:
[CFI] Add CFI-icall pointer type generalization

Summary:
This change allows generalizing pointers in type signatures used for
cfi-icall by enabling the -fsanitize-cfi-icall-generalize-pointers flag.
This works by 1) emitting an additional generalized type signature
metadata node for functions and 2) llvm.type.test()ing for the
generalized type for translation units with the flag specified.

This flag is incompatible with -fsanitize-cfi-cross-dso because it would
require emitting twice as many type hashes which would increase artifact
size.

Reviewers: pcc, eugenis

Reviewed By: pcc

Subscribers: kcc

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

Added:
cfe/trunk/test/CodeGen/cfi-icall-generalize.c
Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/docs/ControlFlowIntegrity.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/cfi-icall-cross-dso.c
cfe/trunk/test/CodeGen/cfi-icall.c
cfe/trunk/test/CodeGenCXX/cfi-icall.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=317044&r1=317043&r2=317044&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Oct 31 15:39:44 2017
@@ -740,6 +740,10 @@ Path to blacklist file for sanitizers
 
 Enable control flow integrity (CFI) checks for cross-DSO calls.
 
+.. option:: -fsanitize-cfi-icall-generalize-pointers
+
+Generalize pointers in function type signatures used for Control Flow 
Integrity (CFI) indirect call checking
+
 .. option:: -fsanitize-coverage=,..., 
-fno-sanitize-coverage=,...
 
 Specify the type of coverage instrumentation for Sanitizers

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=317044&r1=317043&r2=317044&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Tue Oct 31 15:39:44 2017
@@ -215,6 +215,23 @@ shared library boundaries are handled as
 
 This scheme is currently only supported on the x86 and x86_64 architectures.
 
+``-fsanitize-cfi-icall-generalize-pointers``
+
+
+Mismatched pointer types are a common cause of cfi-icall check failures.
+Translation units compiled with the 
``-fsanitize-cfi-icall-generalize-pointers``
+flag relax pointer type checking for call sites in that translation unit,
+applied across all functions compiled with ``-fsanitize=cfi-icall``.
+
+Specifically, pointers in return and argument types are treated as equivalent 
as
+long as the qualifiers for the type they point to match. For example, ``char*``
+``char**`, and ``int*`` are considered equivalent types. However, ``char*`` and
+``const char*`` are considered separate types.
+
+``-fsanitize-cfi-icall-generalize-pointers`` is not compatible with
+``-fsanitize-cfi-cross-dso``.
+
+
 ``-fsanitize=cfi-icall`` and ``-fsanitize=function``
 
 

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=317044&r1=317043&r2=317044&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Oct 31 15:39:44 2017
@@ -1147,6 +1147,11 @@ are listed below.
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -fsanitize-cfi-icall-generalize-pointers
+
+   Generalize pointers in return and argument types in function type signatures
+   checked by Control Flow Integrity indirect call checking. See
+   :doc:`ControlFlowIntegrity` for more details.
 
 .. option:: -fstrict-vtable-pointers
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=317044&r1=317043&r2=317044&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Oct 31 15:39:44 2017
@@ -914,6 +914,9 @@ def 

Re: r323528 - [AST] Use bit packing to reduce sizeof(TypedefNameDecl) from 88 to 80.

2018-01-26 Thread Vlad Tsyrklevich via cfe-commits
This change has broken a number of buildbots, e.g.
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/23163

On Fri, Jan 26, 2018 at 6:15 AM Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Fri Jan 26 06:14:11 2018
> New Revision: 323528
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323528&view=rev
> Log:
> [AST] Use bit packing to reduce sizeof(TypedefNameDecl) from 88 to 80.
>
> We can stash the cached transparent tag bit in existing pointer padding.
> Everything coming out of ASTContext is always aligned to a multiple of
> 8, so we have 8 spare bits.
>
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/lib/AST/Decl.cpp
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=323528&r1=323527&r2=323528&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Fri Jan 26 06:14:11 2018
> @@ -2814,12 +2814,12 @@ public:
>  /// Base class for declarations which introduce a typedef-name.
>  class TypedefNameDecl : public TypeDecl, public
> Redeclarable {
>using ModedTInfo = std::pair;
> -  llvm::PointerUnion MaybeModedTInfo;
>
> -  // FIXME: This can be packed into the bitfields in Decl.
> -  /// If 0, we have not computed IsTransparentTag.
> -  /// Otherwise, IsTransparentTag is (CacheIsTransparentTag >> 1).
> -  mutable unsigned CacheIsTransparentTag : 2;
> +  /// If int part is 0, we have not computed IsTransparentTag.
> +  /// Otherwise, IsTransparentTag is (getInt() >> 1).
> +  mutable llvm::PointerIntPair<
> +  llvm::PointerUnion, 2>
> +  MaybeModedTInfo;
>
>void anchor() override;
>
> @@ -2828,7 +2828,7 @@ protected:
>SourceLocation StartLoc, SourceLocation IdLoc,
>IdentifierInfo *Id, TypeSourceInfo *TInfo)
>: TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C),
> -MaybeModedTInfo(TInfo), CacheIsTransparentTag(0) {}
> +MaybeModedTInfo(TInfo, 0) {}
>
>using redeclarable_base = Redeclarable;
>
> @@ -2855,26 +2855,29 @@ public:
>using redeclarable_base::getMostRecentDecl;
>using redeclarable_base::isFirstDecl;
>
> -  bool isModed() const { return MaybeModedTInfo.is(); }
> +  bool isModed() const {
> +return MaybeModedTInfo.getPointer().is();
> +  }
>
>TypeSourceInfo *getTypeSourceInfo() const {
> -return isModed()
> -  ? MaybeModedTInfo.get()->first
> -  : MaybeModedTInfo.get();
> +return isModed() ? MaybeModedTInfo.getPointer().get *>()->first
> + : MaybeModedTInfo.getPointer().get *>();
>}
>
>QualType getUnderlyingType() const {
> -return isModed()
> -  ? MaybeModedTInfo.get()->second
> -  : MaybeModedTInfo.get()->getType();
> +return isModed() ? MaybeModedTInfo.getPointer().get *>()->second
> + : MaybeModedTInfo.getPointer()
> +   .get()
> +   ->getType();
>}
>
>void setTypeSourceInfo(TypeSourceInfo *newType) {
> -MaybeModedTInfo = newType;
> +MaybeModedTInfo.setPointer(newType);
>}
>
>void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType
> modedTy) {
> -MaybeModedTInfo = new (getASTContext()) ModedTInfo(unmodedTSI,
> modedTy);
> +MaybeModedTInfo.setPointer(new (getASTContext(), 8)
> +   ModedTInfo(unmodedTSI, modedTy));
>}
>
>/// Retrieves the canonical declaration of this typedef-name.
> @@ -2891,8 +2894,8 @@ public:
>/// Determines if this typedef shares a name and spelling location with
> its
>/// underlying tag type, as is the case with the NS_ENUM macro.
>bool isTransparentTag() const {
> -if (CacheIsTransparentTag)
> -  return CacheIsTransparentTag & 0x2;
> +if (MaybeModedTInfo.getInt())
> +  return MaybeModedTInfo.getInt() & 0x2;
>  return isTransparentTagSlow();
>}
>
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=323528&r1=323527&r2=323528&view=diff
>
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Fri Jan 26 06:14:11 2018
> @@ -4372,9 +4372,7 @@ bool TypedefNameDecl::isTransparentTagSl
>};
>
>bool isTransparent = determineIsTransparent();
> -  CacheIsTransparentTag = 1;
> -  if (isTransparent)
> -CacheIsTransparentTag |= 0x2;
> +  MaybeModedTInfo.setInt((isTransparent << 1) | 1);
>return isTransparent;
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http