[libunwind] r362057 - [runtimes] Use -Wunknown-pragmas for the pragma check

2019-05-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May 29 22:38:06 2019
New Revision: 362057

URL: http://llvm.org/viewvc/llvm-project?rev=362057=rev
Log:
[runtimes] Use -Wunknown-pragmas for the pragma check

This is a follow up to r362055, we need -Wunknown-pragmas otherwise
the check is going to succeed it the pragma isn't supported.

Modified:
libunwind/trunk/cmake/config-ix.cmake

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=362057=362056=362057=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Wed May 29 22:38:06 2019
@@ -1,3 +1,4 @@
+include(CMakePushCheckState)
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(CheckLibraryExists)
@@ -57,10 +58,13 @@ endif ()
 
 # Check compiler pragmas
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  cmake_push_check_state()
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")
   check_c_source_compiles("
 #pragma comment(lib, \"c\")
 int main() { return 0; }
 " LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+  cmake_pop_check_state()
 endif()
 
 # Check compiler flags


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


[PATCH] D62645: [Sema] Resolve placeholder types before type deduction to silence spurious `-Warc-repeated-use-of-weak` warnings

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11101
+  if (auto *placeholderType = Init->getType()->getAsPlaceholderType())
+if (placeholderType->getKind() == BuiltinType::PseudoObject) {
+  Res = CheckPlaceholderExpr(Init).get();

`if (Init->hasPlaceholderType(BuiltinType::PseudoObject))`

Although maybe this should just be `isNonOverloadPlaceholderType()`, since it's 
the syntactic-only placeholders that we're trying to cover.  (Feel free to add 
`Expr::hasNonOverloadPlaceholderType()` for convenience.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62645



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


[PATCH] D62645: [Sema] Resolve placeholder types before type deduction to silence spurious `-Warc-repeated-use-of-weak` warnings

2019-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, rjmccall.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

The spurious `-Warc-repeated-use-of-weak` warnings are issued when an 
initializer expression uses a weak ObjC pointer.

My first attempt to silence the warnings (r350917) caused clang to reject code 
that is legal in C++17. The patch is based on the feedback I received from 
Richard when the patch was reverted.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268945.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268943.html


Repository:
  rC Clang

https://reviews.llvm.org/D62645

Files:
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaObjC/arc-repeated-weak.mm


Index: test/SemaObjC/arc-repeated-weak.mm
===
--- test/SemaObjC/arc-repeated-weak.mm
+++ test/SemaObjC/arc-repeated-weak.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks 
-Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks 
-Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks 
-Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks 
-Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
 
 @interface Test {
 @public
@@ -467,6 +467,18 @@
   __typeof__(NSBundle2.foo2.weakProp) t5;
 }
 
+void testAuto() {
+  auto __weak wp = NSBundle2.foo2.weakProp;
+}
+
+void testLambdaCaptureInit() {
+  [capture(NSBundle2.foo2.weakProp)] {} ();
+}
+
+void testAutoNew() {
+  auto p = new auto(NSBundle2.foo2.weakProp);
+}
+
 // This used to crash in the constructor of WeakObjectProfileTy when a
 // DeclRefExpr was passed that didn't reference a VarDecl.
 
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1826,6 +1826,15 @@
 NumInits = List->getNumExprs();
   }
 
+  for (unsigned I = 0, E = NumInits; I != E; ++I)
+if (auto *PlaceholderType = Inits[I]->getType()->getAsPlaceholderType())
+  if (PlaceholderType->getKind() == BuiltinType::PseudoObject) {
+ExprResult Result = CheckPlaceholderExpr(Inits[I]);
+if (!Result.isUsable())
+  return ExprError();
+Inits[I] = Result.get();
+  }
+
   // C++11 [expr.new]p15:
   //   A new-expression that creates an object of type T initializes that
   //   object as follows:
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6623,6 +6623,15 @@
 ExprResult Sema::ActOnParenListExpr(SourceLocation L,
 SourceLocation R,
 MultiExprArg Val) {
+  for (size_t I = 0, E = Val.size(); I != E; ++I)
+if (auto *PlaceholderType = Val[I]->getType()->getAsPlaceholderType())
+  if (PlaceholderType->getKind() == BuiltinType::PseudoObject) {
+ExprResult Result = CheckPlaceholderExpr(Val[I]);
+if (!Result.isUsable())
+  return ExprError();
+Val[I] = Result.get();
+  }
+
   return ParenListExpr::Create(Context, L, Val, R);
 }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11096,6 +11096,15 @@
 }
 Init = Res.get();
 
+if (!Init->getType().isNull())
+  if (auto *placeholderType = Init->getType()->getAsPlaceholderType())
+if (placeholderType->getKind() == BuiltinType::PseudoObject) {
+  Res = CheckPlaceholderExpr(Init).get();
+  if (!Res.isUsable())
+return;
+  Init = Res.get();
+}
+
 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
   return;
   }


Index: test/SemaObjC/arc-repeated-weak.mm
===
--- test/SemaObjC/arc-repeated-weak.mm
+++ test/SemaObjC/arc-repeated-weak.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
 
 @interface Test {
 

Re: r350917 - [Sema] If CheckPlaceholderExpr rewrites the initializer of an auto

2019-05-29 Thread Akira Hatanaka via cfe-commits
Hi Richard,

Thank you for the feedback. Please review my new patch: 
https://reviews.llvm.org/D62645 .

> On Apr 23, 2019, at 7:21 PM, Richard Smith  wrote:
> 
> Hi Akira,
> 
> I've reverted this in r359066. This subtly breaks the semantics of C++
> initializers by strripping off an outer level of parentheses / braces
> in some cases. Testcase:
> 
>  struct A {
>A();
>A(const A&) = delete;
>  };
>  auto x = [a{A()}] {};
> 
> (This should be accepted in C++17 mode onwards, but this patch rejects
> it by losing the braces around the A() expression.)
> 
> Moreover, I think this is fundamentally the wrong approach:
> DeduceAutoType should not ever be changing the initializer expression
> (and it certainly shouldn't expect those changes to stick around).
> Instead, we should check for a placeholder type before attempting
> deduction, just like we correct typos in the initializer before
> attempting deduction.
> 
> On Thu, 10 Jan 2019 at 21:01, Akira Hatanaka via cfe-commits
>  wrote:
>> 
>> Author: ahatanak
>> Date: Thu Jan 10 20:57:34 2019
>> New Revision: 350917
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=350917=rev
>> Log:
>> [Sema] If CheckPlaceholderExpr rewrites the initializer of an auto
>> variable during auto type deduction, use the rewritten initializer when
>> performing initialization of the variable.
>> 
>> This silences spurious -Warc-repeated-use-of-weak warnings that are
>> issued when the initializer uses a weak ObjC pointer.
>> 
>> Differential Revision: https://reviews.llvm.org/D55662
>> 
>> Modified:
>>cfe/trunk/include/clang/Sema/Sema.h
>>cfe/trunk/lib/Sema/SemaDecl.cpp
>>cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>cfe/trunk/lib/Sema/SemaLambda.cpp
>>cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350917=350916=350917=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 10 20:57:34 2019
>> @@ -1960,7 +1960,7 @@ public:
>>   bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult );
>>   void CheckVariableDeclarationType(VarDecl *NewVD);
>>   bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
>> - Expr *Init);
>> + Expr *);
>>   void CheckCompleteVariableDeclaration(VarDecl *VD);
>>   void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD);
>>   void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D);
>> @@ -7095,7 +7095,7 @@ public:
>>   QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
>> QualType Type, TypeSourceInfo *TSI,
>> SourceRange Range, bool DirectInit,
>> -Expr *Init);
>> +Expr *);
>> 
>>   TypeLoc getReturnTypeLoc(FunctionDecl *FD) const;
>> 
>> 
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=350917=350916=350917=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 10 20:57:34 2019
>> @@ -10812,7 +10812,7 @@ QualType Sema::deduceVarTypeFromInitiali
>> DeclarationName Name, QualType 
>> Type,
>> TypeSourceInfo *TSI,
>> SourceRange Range, bool 
>> DirectInit,
>> -Expr *Init) {
>> +Expr *) {
>>   bool IsInitCapture = !VDecl;
>>   assert((!VDecl || !VDecl->isInitCapture()) &&
>>  "init captures are expected to be deduced prior to initialization");
>> @@ -10928,7 +10928,8 @@ QualType Sema::deduceVarTypeFromInitiali
>>   << (DeduceInit->getType().isNull() ? TSI->getType()
>>  : DeduceInit->getType())
>>   << DeduceInit->getSourceRange();
>> -  }
>> +  } else
>> +Init = DeduceInit;
>> 
>>   // Warn if we deduced 'id'. 'auto' usually implies type-safety, but using
>>   // 'id' instead of a specific object type prevents most of our usual
>> @@ -10945,7 +10946,7 @@ QualType Sema::deduceVarTypeFromInitiali
>> }
>> 
>> bool Sema::DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
>> - Expr *Init) {
>> + Expr *) {
>>   QualType DeducedType = deduceVarTypeFromInitializer(
>>   VDecl, VDecl->getDeclName(), VDecl->getType(), 
>> VDecl->getTypeSourceInfo(),
>>   

[PATCH] D62643: [CodeGen][ObjC] Convert '[self alloc]' in a class method to 'objc_alloc(self)'

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGObjC.cpp:376
+  bool isClassMessage,
+  bool isSelfReceiverInClassMethod) {
   auto  = CGF.CGM;

I think it's fine to just call this a class message, unless I'm missing a 
reason to distinguish them in this function.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62643



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


[PATCH] D58321: Support for relative vtables

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:329
+"Whether to use clang's relative C++ ABI "
+"for classes with vtables")
+

leonardchan wrote:
> rjmccall wrote:
> > Yeah, see, this plays into the question above.  I would not want to provide 
> > this as a language option for general use.  The attribute seems good enough 
> > for testing, and if you want a -cc1 option to apply the attribute by 
> > default for experimentation during Fuchsia bring-up that's fair, but I 
> > don't want something that suggests to users that it's okay to pass this 
> > attribute and change the system default.
> Ok. So is this the reason for the white list approach mentioned in D17893? As 
> an alternative, would you also be ok with creating a `FuchsiaCXXABI` that 
> subclasses `ItaniumCXXABI`, similar to the ARM and WebAssembly ones? This way 
> it doesn't change the system default.
That design for relative v-tables was intended (at least as it was described to 
me) as an optimization for certain classes in a project that still needed to 
interoperate with system and other non-project C++ code.  It was initially 
attempting to apply the optimization eagerly to all classes that didn't match a 
blacklist of classes (and namespaces of classes) that needed to follow the 
system ABI, which I objected to, which is why I asked for it to be redesigned 
around applying the optimization only to whitelisted classes/namespaces.  None 
of that applies if you're changing the system ABI rule unless you decide you 
want to allow classes to opt into standard Itanium v-tables.

If introducing a `FuchsiaCXXABI` class makes the code easier, go for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D62643: [CodeGen][ObjC] Convert '[self alloc]' in a class method to 'objc_alloc(self)'

2019-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, pete, erik.pilkington.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

In a class method, 'self' points to the class object, so it should be safe to 
pass it to `objc_alloc`. Also, convert '[[self alloc] init]' in a class method 
to 'objc_alloc_init(self)'.

rdar://problem/50855121


Repository:
  rC Clang

https://reviews.llvm.org/D62643

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/CodeGenObjC/objc-alloc-init.m

Index: test/CodeGenObjC/objc-alloc-init.m
===
--- test/CodeGenObjC/objc-alloc-init.m
+++ test/CodeGenObjC/objc-alloc-init.m
@@ -23,14 +23,20 @@
 
 @interface Y : X
 +(void)meth;
+-(void)instanceMeth;
 @end
 
 @implementation Y
 +(void)meth {
   [[self alloc] init];
+  // OPTIMIZED: call i8* @objc_alloc_init(
+  // NOT_OPTIMIZED: call i8* @objc_alloc(
+}
+-(void)instanceMeth {
   // EITHER-NOT: call i8* @objc_alloc
   // EITHER: call {{.*}} @objc_msgSend
   // EITHER: call {{.*}} @objc_msgSend
+  [[self alloc] init];
 }
 @end
 
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -150,6 +150,34 @@
   return [c retain];
 }
 
+@interface TestSelf
++ (instancetype)alloc;
++ (instancetype)allocWithZone:(void*)zone;
++ (id)classMeth;
+- (id)instanceMeth;
+@end
+
+@implementation TestSelf
+// CHECK-LABEL: define internal i8* @"\01+[TestSelf classMeth]"(
++ (id)classMeth {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_allocWithZone\(}}
+  // CALLS: {{call.*@objc_alloc\(}}
+  [self allocWithZone:nil];
+  return [self alloc];
+}
+// CHECK-LABEL: define internal i8* @"\01-[TestSelf instanceMeth]"(
+- (id)instanceMeth {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  [self allocWithZone:nil];
+  return [self alloc];
+}
+@end
+
 @interface NSString : NSObject
 + (void)retain_self;
 - (void)retain_super;
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -372,7 +372,8 @@
   llvm::Value *Receiver,
   const CallArgList& Args, Selector Sel,
   const ObjCMethodDecl *method,
-  bool isClassMessage) {
+  bool isClassMessage,
+  bool isSelfReceiverInClassMethod) {
   auto  = CGF.CGM;
   if (!CGM.getCodeGenOpts().ObjCConvertMessagesToRuntimeCalls)
 return None;
@@ -380,13 +381,15 @@
   auto  = CGM.getLangOpts().ObjCRuntime;
   switch (Sel.getMethodFamily()) {
   case OMF_alloc:
-if (isClassMessage &&
+if ((isClassMessage || isSelfReceiverInClassMethod) &&
 Runtime.shouldUseRuntimeFunctionsForAlloc() &&
 ResultType->isObjCObjectPointerType()) {
-// [Foo alloc] -> objc_alloc(Foo)
+// [Foo alloc] -> objc_alloc(Foo) or
+// [self alloc] -> objc_alloc(self)
 if (Sel.isUnarySelector() && Sel.getNameForSlot(0) == "alloc")
   return CGF.EmitObjCAlloc(Receiver, CGF.ConvertType(ResultType));
-// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo)
+// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo) or
+// [self allocWithZone:nil] -> objc_allocWithZone(self)
 if (Sel.isKeywordSelector() && Sel.getNumArgs() == 1 &&
 Args.size() == 1 && Args.front().getType()->isPointerType() &&
 Sel.getNameForSlot(0) == "allocWithZone") {
@@ -444,22 +447,38 @@
   Sel.getNameForSlot(0) != "init")
 return None;
 
-  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'.
+  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]' or
+  // we are in an ObjC class method and 'receiver' is '[self alloc]'.
   auto *SubOME =
-  dyn_cast(OME->getInstanceReceiver()->IgnoreParens());
+  dyn_cast(OME->getInstanceReceiver()->IgnoreParenCasts());
   if (!SubOME)
 return None;
   Selector SubSel = SubOME->getSelector();
-  if (SubOME->getReceiverKind() != ObjCMessageExpr::Class ||
-  !SubOME->getType()->isObjCObjectPointerType() ||
+
+  // Check if we are in an ObjC class method and the receiver expression is
+  // 'self'.
+  const Expr *SelfInClassMethod = nullptr;
+  if (const auto *CurMD = dyn_cast(CGF.CurFuncDecl))
+if (CurMD->isClassMethod())
+  if ((SelfInClassMethod = SubOME->getInstanceReceiver()))
+if (!SelfInClassMethod->isObjCSelfExpr())
+  SelfInClassMethod = nullptr;
+
+  if ((SubOME->getReceiverKind() != 

[libunwind] r362055 - [runtimes] Check if pragma comment(lib, ...) is supported first

2019-05-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May 29 21:40:21 2019
New Revision: 362055

URL: http://llvm.org/viewvc/llvm-project?rev=362055=rev
Log:
[runtimes] Check if pragma comment(lib, ...) is supported first

This fixes the issue introduced by r362048 where we always use
pragma comment(lib, ...) for dependent libraries when the compiler
is Clang, but older Clang versions don't support this pragma so
we need to check first if it's supported before using it.

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/cmake/config-ix.cmake
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/RWMutex.hpp

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=362055=362054=362055=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed May 29 21:40:21 2019
@@ -362,6 +362,10 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AN
   add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
 endif()
 
+if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+  add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
 
#===
 # Setup Source Code
 
#===

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=362055=362054=362055=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Wed May 29 21:40:21 2019
@@ -1,7 +1,7 @@
-
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(CheckLibraryExists)
+include(CheckCSourceCompiles)
 
 check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
 
@@ -55,6 +55,14 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
   endif ()
 endif ()
 
+# Check compiler pragmas
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  check_c_source_compiles("
+#pragma comment(lib, \"c\")
+int main() { return 0; }
+" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
 # Check compiler flags
 check_c_compiler_flag(-funwind-tables LIBUNWIND_HAS_FUNWIND_TABLES)
 check_cxx_compiler_flag(-fno-exceptions   LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG)
@@ -96,4 +104,3 @@ endif()
 
 check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)
 check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)
-

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=362055=362054=362055=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed May 29 21:40:21 2019
@@ -27,7 +27,7 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include 
-#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) &&  defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
 #pragma comment(lib, "dl")
 #endif
 #endif

Modified: libunwind/trunk/src/RWMutex.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/RWMutex.hpp?rev=362055=362054=362055=diff
==
--- libunwind/trunk/src/RWMutex.hpp (original)
+++ libunwind/trunk/src/RWMutex.hpp Wed May 29 21:40:21 2019
@@ -17,7 +17,7 @@
 #include 
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include 
-#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) &&  defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
 #pragma comment(lib, "pthread")
 #endif
 #endif


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


[PATCH] D62299: [PR41567][Sema] Fixed cast kind in addr space conversions

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

Seems reasonable.


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

https://reviews.llvm.org/D62299



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


[PATCH] D62584: [OpenCL][PR42033] Deducing addr space of pointer/reference with template parameter types

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think the right approach here is probably to make sure you're applying 
deduction during instantiation as well.


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

https://reviews.llvm.org/D62584



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


r362054 - Add the `objc_class_stub` attribute.

2019-05-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed May 29 21:09:01 2019
New Revision: 362054

URL: http://llvm.org/viewvc/llvm-project?rev=362054=rev
Log:
Add the `objc_class_stub` attribute.

Swift requires certain classes to be not just initialized lazily on first
use, but actually allocated lazily using information that is only available
at runtime.  This is incompatible with ObjC class initialization, or at least
not efficiently compatible, because there is no meaningful class symbol
that can be put in a class-ref variable at load time.  This leaves ObjC
code unable to access such classes, which is undesirable.

objc_class_stub says that class references should be resolved by calling
a new ObjC runtime function with a pointer to a new "class stub" structure.
Non-ObjC compilers (like Swift) can simply emit this structure when ObjC
interop is required for a class that cannot be statically allocated,
then apply this attribute to the `@interface` in the generated ObjC header
for the class.

This attribute can be thought of as a generalization of the existing
`objc_runtime_visible` attribute which permits more efficient class
resolution as well as supporting the additon of categories to the class.
Subclassing these classes from ObjC is currently not allowed.

Patch by Slava Pestov!

Added:
cfe/trunk/test/CodeGenObjC/class-stubs.m
cfe/trunk/test/SemaObjC/class-stub-attr-unsupported.m
cfe/trunk/test/SemaObjC/class-stub-attr.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=362054=362053=362054=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 29 21:09:01 2019
@@ -284,20 +284,25 @@ class SubjectList subj
   string CustomDiag = customDiag;
 }
 
-class LangOpt {
+class LangOpt {
   string Name = name;
-  bit Negated = negated;
+
+  // A custom predicate, written as an expression evaluated in a context with
+  // "LangOpts" bound.
+  code CustomCode = customCode;
 }
 def MicrosoftExt : LangOpt<"MicrosoftExt">;
 def Borland : LangOpt<"Borland">;
 def CUDA : LangOpt<"CUDA">;
-def COnly : LangOpt<"CPlusPlus", 1>;
+def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
 def CPlusPlus : LangOpt<"CPlusPlus">;
 def OpenCL : LangOpt<"OpenCL">;
 def RenderScript : LangOpt<"RenderScript">;
 def ObjC : LangOpt<"ObjC">;
 def BlocksSupported : LangOpt<"Blocks">;
 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
+def ObjCNonFragileRuntime : LangOpt<"ObjCNonFragileRuntime",
+"LangOpts.ObjCRuntime.allowsClassStubs()">;
 
 // Language option for CMSE extensions
 def Cmse : LangOpt<"Cmse">;
@@ -1806,6 +1811,13 @@ def ObjCRuntimeVisible : Attr {
   let Documentation = [ObjCRuntimeVisibleDocs];
 }
 
+def ObjCClassStub : Attr {
+  let Spellings = [Clang<"objc_class_stub">];
+  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let Documentation = [ObjCClassStubDocs];
+  let LangOpts = [ObjCNonFragileRuntime];
+}
+
 def ObjCBoxable : Attr {
   let Spellings = [Clang<"objc_boxable">];
   let Subjects = SubjectList<[Record], ErrorDiag>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=362054=362053=362054=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed May 29 21:09:01 2019
@@ -1085,6 +1085,25 @@ them.
 }];
 }
 
+def ObjCClassStubDocs : Documentation {
+let Category = DocCatType;
+let Content = [{
+This attribute specifies that the Objective-C class to which it applies is
+instantiated at runtime.
+
+Unlike ``__attribute__((objc_runtime_visible))``, a class having this attribute
+still has a "class stub" that is visible to the linker. This allows categories
+to be defined. Static message sends with the class as a receiver use a special
+access pattern to ensure the class is lazily instantiated from the class stub.
+
+Classes annotated with this attribute cannot be subclassed and cannot have
+implementations defined for them. This attribute is intended for use in
+Swift-generated headers for classes defined in Swift.
+
+Adding or removing this attribute to a class is an ABI-breaking change.
+}];
+}
+
 def ObjCBoxableDocs : Documentation {
 let Category = DocCatDecl;
 let Content = [{

Modified: 

[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-29 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore marked an inline comment as done.
stephanemoore added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:46
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'Y2Bad' 
must have a name which starts with 'g[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-FIXES: extern NSString* gY2Bad;
+

This is interesting as it respects the Google Objective-C Style Guide as it is 
currently written. I think the truth might actually be that there are no 
guidelines for non-const extern variables as they are incredibly rare and 
presumably ubiquitously discouraged. In that respect, I am not sure that the 
fix here represents what would actually be recommended for Google Objective-C. 
With that said, the fix might be reasonable to emit based on the expectation 
that it would be exceedingly rare and it's unclear what better guidance we 
would provide. I think it's fine to continue allowing this existing behavior 
and continue monitoring.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D62509: [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC362052: [Driver] Render target options (e.g. 
-fuse-init-array) for -fembed-bitcode (authored by MaskRay, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62509?vs=202103=202105#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62509

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/fembed-bitcode.c


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 
\
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c 
%s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362052 - [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 19:30:04 2019
New Revision: 362052

URL: http://llvm.org/viewvc/llvm-project?rev=362052=rev
Log:
[Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

Modern ELF platforms use -fuse-init-array to emit .init_array instead of
.ctors .  ld.bfd and gold --ctors-in-init-array merge .init_array and
.ctors into .init_array but lld doesn't do that.

If crtbegin*.o crtend*.o don't provide .ctors/.dtors, such .ctors in
user object files can lead to crash (see PR42002. The first and the last
elements in .ctors/.dtors are ignored - they are traditionally provided
by crtbegin*.o crtend*.o).

Call addClangTargetOptions() to ensure -fuse-init-array is rendered on
modern ELF platforms. On Hexagon, this renders -target-feature
+reserved-r19 for -ffixed-r19.

Reviewed By: compnerd

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/fembed-bitcode.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=362052=362051=362052=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May 29 19:30:04 2019
@@ -3666,6 +3666,9 @@ void Clang::ConstructJob(Compilation ,
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {

Modified: cfe/trunk/test/Driver/fembed-bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fembed-bitcode.c?rev=362052=362051=362052=diff
==
--- cfe/trunk/test/Driver/fembed-bitcode.c (original)
+++ cfe/trunk/test/Driver/fembed-bitcode.c Wed May 29 19:30:04 2019
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 
\
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c 
%s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"


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


[PATCH] D62509: [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 202103.
MaskRay retitled this revision from "[Driver] Render -fuse-init-array for 
-fembed-bitcode" to "[Driver] Render target options (e.g. -fuse-init-array) for 
-fembed-bitcode".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Add hexagon test


Repository:
  rC Clang

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

https://reviews.llvm.org/D62509

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/fembed-bitcode.c


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -o 
/dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c 
%s -o /dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59185: [PowerPC] Set the default PLT mode on musl to Secure PLT

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362051: [PowerPC] Set the default PLT mode on musl to Secure 
PLT (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59185?vs=190003=202100#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59185

Files:
  cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,7 @@
   const ArgList ) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD())
+  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;


Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,7 @@
   const ArgList ) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD())
+  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-05-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Also, I read some of the article you showed as well as the one I found on the 
dominance frontier file documentation[1], and I feel a lot more enlightened 
about the subject, thanks! I'll spend more time on them before wrapping this up.

[1]
Sreedhar and Gao. A linear time algorithm for placing phi-nodes.
In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of 
Programming Languages
POPL '95. ACM, New York, NY, 62-73.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


r362051 - [PowerPC] Set the default PLT mode on musl to Secure PLT

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 19:13:15 2019
New Revision: 362051

URL: http://llvm.org/viewvc/llvm-project?rev=362051=rev
Log:
[PowerPC] Set the default PLT mode on musl to Secure PLT

The musl libc only supports Secure PLT.

Patch by A. Wilcox!

Reviewed By: jhibbits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp?rev=362051=362050=362051=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp Wed May 29 19:13:15 2019
@@ -115,7 +115,7 @@ ppc::ReadGOTPtrMode ppc::getPPCReadGOTPt
   const ArgList ) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD())
+  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;


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


[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-05-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I seem to have made good progress on this, although it did require a lot of 
code changes on LLVM side (basically turning `BasicBlock *` to template 
arguments). Here's a sample:

  //   <--
  //  /  <-   \
  // /  /  \   \
  // [B12 (ENTRY)] -> [B11] -> [B10]-> [B9] -> [B8] ---> [B7] -> [B6]  |
  // |  \\ /
  // |   \-> [B2] /
  // |\  /
  // |  -> [B5] -> [B4] -> [B3]
  // |   \  /
  // |<
  //  \
  //   -> [B1] -> [B0 (EXIT)]
  
  Control dependencies  (Node, Dependency):
  (2,10)
  (3,5)
  (3,9)
  (3,10)
  (4,5)
  (4,9)
  (4,10)
  (5,9)
  (5,5)
  (5,10)
  (6,8)
  (6,9)
  (6,10)
  (7,8)
  (7,9)
  (7,10)
  (8,9)
  (8,8)
  (8,10)
  (9,10)
  (10,10)

My solution is inspired by

In D62619#1521824 , @kuhar wrote:

> - 
> https://github.com/seahorn/seahorn/blob/deep-dev-5.0/include/seahorn/Analysis/ControlDependenceAnalysis.hh
> - 
> https://github.com/seahorn/seahorn/blob/deep-dev-5.0/lib/Analysis/ControlDependenceAnalysis.cc


, and I really like where this is going. I am yet to figure out how to deal 
with Clang's CFG containing null pointers in a not-too-invasive way (will 
probably end up doing something similar to `ChildrenGetter`), as it currently 
crashes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> I wrote some tests but i'm not really sure they're worth it.

Mmm, on second thought, they probably won't work out of the box, because they 
might require installing python modules in order to work. I'm actually not sure 
if all machines have python3. I'll try but it'll most likely fail. I guess i 
could try excluding them from `make check-all`.


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

https://reviews.llvm.org/D62638



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


r362050 - [Driver] -static-pie: add -z text

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 18:55:43 2019
New Revision: 362050

URL: http://llvm.org/viewvc/llvm-project?rev=362050=rev
Log:
[Driver] -static-pie: add -z text

This matches gcc -static-pie. The intention is to prevent dynamic
relocations in read-only segments.

In ld.bfd and gold, -z notext is the default. If text relocations are needed:

* -z notext: allow and emit DF_TEXTREL.
  DF_TEXTREL is not emitted if there is no text relocation.
* -z text: error

In lld, -z text is the default (this change is a no-op).

* -z text: error on text relocations
* -z notext: allow text relocations, and emit DF_TEXTREL no matter whether
  text relocations exist.

Reviewed By: sivachandra

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=362050=362049=362050=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed May 29 18:55:43 2019
@@ -382,6 +382,8 @@ void tools::gnutools::Linker::ConstructJ
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=362050=362049=362050=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Wed May 29 18:55:43 2019
@@ -190,6 +190,8 @@
 // CHECK-CLANG-LD-STATIC-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"


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


[PATCH] D62606: [Driver] -static-pie: add -z text

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362050: [Driver] -static-pie: add -z text (authored by 
MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62606

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/linux-ld.c


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -190,6 +190,8 @@
 // CHECK-CLANG-LD-STATIC-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -382,6 +382,8 @@
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -190,6 +190,8 @@
 // CHECK-CLANG-LD-STATIC-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -382,6 +382,8 @@
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 202094.
NoQ added a comment.

Use `os.path.join` for discovering the utility in tests.


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

https://reviews.llvm.org/D62638

Files:
  clang/test/Analysis/exploded-graph-rewriter/edge.dot
  clang/test/Analysis/exploded-graph-rewriter/empty.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- /dev/null
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,386 @@
+#!/usr/bin/env python3
+
+import argparse
+import collections
+import json as json_module  # 'json' is a great name for a variable.
+import logging
+import re
+
+
+# A deserialized source location.
+class SourceLocation(object):
+def __init__(self, json):
+super(SourceLocation, self).__init__()
+self.line = json['line']
+self.col = json['column']
+self.filename = json['filename'] \
+if 'filename' in json else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json):
+super(ProgramPoint, self).__init__()
+self.kind = json['kind']
+self.tag = json['tag']
+if self.kind == 'Edge':
+self.src_id = json['src_id']
+self.dst_id = json['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json['stmt_kind']
+self.pointer = json['pointer']
+self.pretty = json['pretty']
+self.sloc = SourceLocation(json['location']) \
+if json['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json):
+super(EnvironmentBinding, self).__init__()
+self.lctx_id = json['lctx_id']
+self.stmt_id = json['stmt_id']
+self.pretty = json['pretty']
+self.value = json['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, caption, decl, line):
+super(LocationContext, self).__init__()
+self.caption = caption
+self.decl = decl
+self.line = line
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json['location_context'],
+json['calling'],
+json['call_line'])
+self.bindings = [EnvironmentBinding(b) for b in json['items']]
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json):
+super(StoreBinding, self).__init__()
+self.kind = json['kind']
+self.offset = json['offset']
+self.value = json['value']
+
+
+# A single cluster of the deserialized RegionStore.
+class StoreCluster(object):
+def __init__(self, json):
+super(StoreCluster, self).__init__()
+self.base_region = json['cluster']
+self.bindings = [StoreBinding(b) for b in json['items']]
+
+
+# A deserialized RegionStore.
+class Store(object):
+def __init__(self, json):
+super(Store, self).__init__()
+self.clusters = [StoreCluster(c) for c in json]
+
+
+# A deserialized program state.
+class ProgramState(object):
+def __init__(self, state_id, json):
+super(ProgramState, self).__init__()
+logging.debug('Adding ProgramState ' + str(state_id))
+
+self.state_id = state_id
+self.store = Store(json['store']) \
+if json['store'] is not None else None
+self.environment = Environment(json['environment']) \
+if json['environment'] is not None else None
+# TODO: Objects under construction.
+# TODO: Constraint ranges.
+# TODO: Dynamic types of objects.
+# TODO: Checker messages.
+
+
+# A deserialized exploded graph node. Has a default constructor because it
+# may be referenced as part of an edge before its contents are deserialized,
+# and in this moment we already need a room for parents and children.
+class ExplodedNode(object):
+def __init__(self):
+

[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 202092.
NoQ added a comment.

Remove outdated comment.


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

https://reviews.llvm.org/D62638

Files:
  clang/test/Analysis/exploded-graph-rewriter/edge.dot
  clang/test/Analysis/exploded-graph-rewriter/empty.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- /dev/null
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,386 @@
+#!/usr/bin/env python3
+
+import argparse
+import collections
+import json as json_module  # 'json' is a great name for a variable
+import logging
+import re
+
+
+# A deserialized source location.
+class SourceLocation(object):
+def __init__(self, json):
+super(SourceLocation, self).__init__()
+self.line = json['line']
+self.col = json['column']
+self.filename = json['filename'] \
+if 'filename' in json else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json):
+super(ProgramPoint, self).__init__()
+self.kind = json['kind']
+self.tag = json['tag']
+if self.kind == 'Edge':
+self.src_id = json['src_id']
+self.dst_id = json['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json['stmt_kind']
+self.pointer = json['pointer']
+self.pretty = json['pretty']
+self.sloc = SourceLocation(json['location']) \
+if json['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json):
+super(EnvironmentBinding, self).__init__()
+self.lctx_id = json['lctx_id']
+self.stmt_id = json['stmt_id']
+self.pretty = json['pretty']
+self.value = json['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, caption, decl, line):
+super(LocationContext, self).__init__()
+self.caption = caption
+self.decl = decl
+self.line = line
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json['location_context'],
+json['calling'],
+json['call_line'])
+self.bindings = [EnvironmentBinding(b) for b in json['items']]
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json):
+super(StoreBinding, self).__init__()
+self.kind = json['kind']
+self.offset = json['offset']
+self.value = json['value']
+
+
+# A single cluster of the deserialized RegionStore.
+class StoreCluster(object):
+def __init__(self, json):
+super(StoreCluster, self).__init__()
+self.base_region = json['cluster']
+self.bindings = [StoreBinding(b) for b in json['items']]
+
+
+# A deserialized RegionStore.
+class Store(object):
+def __init__(self, json):
+super(Store, self).__init__()
+self.clusters = [StoreCluster(c) for c in json]
+
+
+# A deserialized program state.
+class ProgramState(object):
+def __init__(self, state_id, json):
+super(ProgramState, self).__init__()
+logging.debug('Adding ProgramState ' + str(state_id))
+
+self.state_id = state_id
+self.store = Store(json['store']) \
+if json['store'] is not None else None
+self.environment = Environment(json['environment']) \
+if json['environment'] is not None else None
+# TODO: Objects under construction.
+# TODO: Constraint ranges.
+# TODO: Dynamic types of objects.
+# TODO: Checker messages.
+
+
+# A deserialized exploded graph node. Has a default constructor because it
+# may be referenced as part of an edge before its contents are deserialized,
+# and in this moment we already need a room for parents and children.
+class ExplodedNode(object):
+def __init__(self):
+super(ExplodedNode, self).__init__()
+

[PATCH] D62638: [analyzer][WIP] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 202091.
NoQ added a comment.

Abstract away raw prints.


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

https://reviews.llvm.org/D62638

Files:
  clang/test/Analysis/exploded-graph-rewriter/edge.dot
  clang/test/Analysis/exploded-graph-rewriter/empty.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- /dev/null
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,386 @@
+#!/usr/bin/env python3
+
+import argparse
+import collections
+import json as json_module  # 'json' is a great name for a variable
+import logging
+import re
+
+
+# A deserialized source location. Lack of filename represents the main file.
+class SourceLocation(object):
+def __init__(self, json):
+super(SourceLocation, self).__init__()
+self.line = json['line']
+self.col = json['column']
+self.filename = json['filename'] \
+if 'filename' in json else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json):
+super(ProgramPoint, self).__init__()
+self.kind = json['kind']
+self.tag = json['tag']
+if self.kind == 'Edge':
+self.src_id = json['src_id']
+self.dst_id = json['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json['stmt_kind']
+self.pointer = json['pointer']
+self.pretty = json['pretty']
+self.sloc = SourceLocation(json['location']) \
+if json['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json):
+super(EnvironmentBinding, self).__init__()
+self.lctx_id = json['lctx_id']
+self.stmt_id = json['stmt_id']
+self.pretty = json['pretty']
+self.value = json['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, caption, decl, line):
+super(LocationContext, self).__init__()
+self.caption = caption
+self.decl = decl
+self.line = line
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json['location_context'],
+json['calling'],
+json['call_line'])
+self.bindings = [EnvironmentBinding(b) for b in json['items']]
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json):
+super(StoreBinding, self).__init__()
+self.kind = json['kind']
+self.offset = json['offset']
+self.value = json['value']
+
+
+# A single cluster of the deserialized RegionStore.
+class StoreCluster(object):
+def __init__(self, json):
+super(StoreCluster, self).__init__()
+self.base_region = json['cluster']
+self.bindings = [StoreBinding(b) for b in json['items']]
+
+
+# A deserialized RegionStore.
+class Store(object):
+def __init__(self, json):
+super(Store, self).__init__()
+self.clusters = [StoreCluster(c) for c in json]
+
+
+# A deserialized program state.
+class ProgramState(object):
+def __init__(self, state_id, json):
+super(ProgramState, self).__init__()
+logging.debug('Adding ProgramState ' + str(state_id))
+
+self.state_id = state_id
+self.store = Store(json['store']) \
+if json['store'] is not None else None
+self.environment = Environment(json['environment']) \
+if json['environment'] is not None else None
+# TODO: Objects under construction.
+# TODO: Constraint ranges.
+# TODO: Dynamic types of objects.
+# TODO: Checker messages.
+
+
+# A deserialized exploded graph node. Has a default constructor because it
+# may be referenced as part of an edge before its contents are deserialized,
+# and in this moment we already need a room for parents and children.
+class ExplodedNode(object):
+def __init__(self):
+

[PATCH] D62622: [CMake] Provide an option to use relative paths in debug info

2019-05-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D62622#1522247 , @aprantl wrote:

> -DLLVM_USE_RELATIVE_PATHS is very generic sounding and might give a false 
> impression. Is there a name that emphasizes that this affects the debug info 
> of the built compiler?


How about `LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO` or 
`LLVM_ENABLE_RELOCATABLE_DEBUG_INFO`?


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

https://reviews.llvm.org/D62622



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


[PATCH] D62623: Reduce memory consumption of coverage dumps

2019-05-29 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk added a comment.

In D62623#1521999 , @kwk wrote:

> @serge-sans-paille testing it now.


Unfortunately, the error for me is similar (or the same) to before;

  [692/2860] Building CXX object 
lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o
  FAILED: 
lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o 
  /usr/bin/clang++  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/AMDGPU/Utils 
-I/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU/Utils 
-I/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU -Ilib/Target/AMDGPU 
-I/usr/include/libxml2 -Iinclude -I/home/kkleine/dev/llvm-project/llvm/include 
-fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections 
-fprofile-instr-generate='/home/kkleine/llvm-builds/coverage-ninja-clang-lld/profiles/%4m.profraw'
 -fcoverage-mapping -O2 -DNDEBUG-fno-exceptions -fno-rtti -MD -MT 
lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o -MF 
lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o.d 
-o lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o 
-c 
/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
  LLVM ERROR: out of memory
  Stack dump:
  0.Program arguments: /usr/bin/clang-7 -cc1 -triple 
x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier 
-discard-value-names -main-file-name AMDGPUBaseInfo.cpp -mrelocation-model pic 
-pic-level 2 -mthread-model posix -fmath-errno -masm-verbose 
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 
-dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer 
-ffunction-sections -fdata-sections 
-fprofile-instrument-path=/home/kkleine/llvm-builds/coverage-ninja-clang-lld/profiles/%4m.profraw
 -fprofile-instrument=clang -fcoverage-mapping -coverage-notes-file 
/home/kkleine/llvm-builds/coverage-ninja-clang-lld/lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.gcno
 -resource-dir /usr/lib64/clang/7.0.1 -dependency-file 
lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o.d 
-sys-header-deps -MT 
lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o -D 
GTEST_HAS_RTTI=0 -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D 
__STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I lib/Target/AMDGPU/Utils -I 
/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU/Utils -I 
/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU -I lib/Target/AMDGPU -I 
/usr/include/libxml2 -I include -I /home/kkleine/dev/llvm-project/llvm/include 
-D NDEBUG -internal-isystem 
/usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 
-internal-isystem 
/usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux
 -internal-isystem 
/usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward 
-internal-isystem /usr/local/include -internal-isystem 
/usr/lib64/clang/7.0.1/include -internal-externc-isystem /include 
-internal-externc-isystem /usr/include -O2 -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long 
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -pedantic 
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir 
/home/kkleine/llvm-builds/coverage-ninja-clang-lld -ferror-limit 19 
-fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc 
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp 
-o lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o 
-x c++ 
/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp 
-faddrsig 
  1. parser at end of file
  2.Per-file LLVM IR generation
  #0 0x7f814657b09e llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/lib64/libLLVM-7.so+0x9b409e)
  #1 0x7f8146579554 llvm::sys::RunSignalHandlers() 
(/lib64/libLLVM-7.so+0x9b2554)
  #2 0x7f81465796d5 (/lib64/libLLVM-7.so+0x9b26d5)
  #3 0x7f8145bb8070 __restore_rt (/lib64/libpthread.so.0+0x13070)
  #4 0x7f8144b6457f __GI_raise (/lib64/libc.so.6+0x3857f)
  #5 0x7f8144b4e895 __GI_abort (/lib64/libc.so.6+0x22895)
  #6 0x7f81464fde34 llvm::report_bad_alloc_error(char const*, bool) 
(/lib64/libLLVM-7.so+0x936e34)
  #7 0x7f8144f28b34 operator new(unsigned long) 
(/lib64/libstdc++.so.6+0x97b34)
  

[libunwind] r362048 - [runtimes] Support ELF dependent libraries feature

2019-05-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May 29 18:34:41 2019
New Revision: 362048

URL: http://llvm.org/viewvc/llvm-project?rev=362048=rev
Log:
[runtimes] Support ELF dependent libraries feature

As of r360984, LLD supports dependent libraries feature for ELF.
libunwind, libc++abi and libc++ have library dependencies: libdl librt
and libpthread, which means that when libunwind and libc++ are being
statically linked (using -static-libstdc++ flag), user has to manually
specify -ldl -lpthread which is onerous.

This change includes the lib pragma to specify the library dependencies
directly in the source that uses those libraries. This doesn't make any
difference when using linkers that don't support dependent libraries.
However, when using LLD that has dependent libraries feature, users no
longer have to manually specifying library dependencies when using
static linking, linker will pick the library automatically.

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

Modified:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/RWMutex.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=362048=362047=362048=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed May 29 18:34:41 2019
@@ -27,6 +27,9 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include 
+#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#pragma comment(lib, "dl")
+#endif
 #endif
 
 #ifdef __APPLE__

Modified: libunwind/trunk/src/RWMutex.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/RWMutex.hpp?rev=362048=362047=362048=diff
==
--- libunwind/trunk/src/RWMutex.hpp (original)
+++ libunwind/trunk/src/RWMutex.hpp Wed May 29 18:34:41 2019
@@ -17,6 +17,9 @@
 #include 
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include 
+#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#pragma comment(lib, "pthread")
+#endif
 #endif
 
 namespace libunwind {


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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-29 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/lib/gwp_asan/tests/driver.cpp:14
+  return RUN_ALL_TESTS();
+}

hctim wrote:
> morehouse wrote:
> > Can we just link with gtest_main instead of having this?
> Unfortunately not easily. `generate_compiler_rt_tests` builds each test cpp 
> file individually, and provides no way to add `gtest_main` only during link 
> time. 
Then how does this driver.cpp get included in each unit test?

Maybe we should put the `main` in each test as is usually done.



Comment at: compiler-rt/lib/gwp_asan/tests/mutex_test.cpp:37
+  Mutex Mu;
+  { ScopedLock L(Mu); }
+  // Locking will fail here if the scoped lock failed to unlock.

morehouse wrote:
> We should trylock inside the scope, and maybe also do an unlock+lock.
No, I didn't mean that way.

Something like this:
```
{
  ScopedLock L(Mu);
  EXPECT_FALSE(Mu.tryLock());  // Test that the ctor did in fact lock
  Mu.unlock()
  EXPECT_TRUE(Mu.tryLock());  // Test that manual unlock overrides ScopedLock
}
EXPECT_TRUE(Mu.tryLock());  // Test that dtor did in fact unlock
```



Comment at: compiler-rt/lib/gwp_asan/tests/mutex_test.cpp:46
+  while (!StartingGun->load())
+;
+  for (unsigned i = 0; i < kNumLocksInARow; ++i) {

hctim wrote:
> morehouse wrote:
> > Format seems weird.  Does clang-format let us do `while (...) {}` on one 
> > line?
> CF changes it to 
> ```
> while (!StartingGun) {
> }
> ```
Not a big deal, but might be more readable if we do:

```
while (!StartingGun) {
  // Wait for starting gun.
}
```



Comment at: compiler-rt/lib/gwp_asan/tests/mutex_test.cpp:59
+
+  StartingGun.store(true);
+  T1.join();

morehouse wrote:
> Can we use simpler `StartingGun = true`?
Can we use simpler `StartingGun = true`?



Comment at: compiler-rt/lib/gwp_asan/tests/mutex_test.cpp:102
+TEST(GwpAsanMutexTest, ThrashTests) {
+  runThrashTest(2, 1);
+  runThrashTest(4, 1);

morehouse wrote:
> This test case seems to test a superset of ThreadedConstructionTest, so do we 
> really need that one?
This test case seems to test a superset of ThreadedConstructionTest, so do we 
really need that one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


[PATCH] D62638: [analyzer][WIP] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, Szelethus, 
baloghadamsoftware, Charusso, george.karpenkov.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, szepet.
Herald added a project: clang.

That's my attempt on D62553  that i (just) 
promised.

Here's roughly how it looks:

F8965939: Screen Shot 2019-05-29 at 6.12.07 PM.png 


Full dump of some random test file:

F8965929: graph.svg 

The rough idea behind this script is that it deserializes JSON dumps into 
familiar python objects. Serializing them back into a pretty graph dump is only 
one of the possible use-cases; we can manipulate the deserialized graph by, 
say, hiding nodes that we aren't interested in.

This initial commit only supports Environment and Store and silently drops 
unsupported information; i'll hopefully follow up with more this week, most 
importantly ranges. As of today it's only a dot-to-dot converter, so 
@Charusso's SVG cleanup is not supported yet. Diffs are not supported yet; 
tomorrow i'll think a bit more how exactly do i want to implement them.

I wrote some tests but i'm not really sure they're worth it. I guess some 
corner-cases would be nice to document this way.

@Charusso, could you see if you can:

- Bring back stable IDs for nodes into JSON (not only pointers). They're very 
useful for debugging.
- See if your trick for reducing SVG size with text joining is even applicable 
to the dumps that i produce.
- Understand my code here :)


Repository:
  rC Clang

https://reviews.llvm.org/D62638

Files:
  clang/test/Analysis/exploded-graph-rewriter/edge.dot
  clang/test/Analysis/exploded-graph-rewriter/empty.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- /dev/null
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,386 @@
+#!/usr/bin/env python3
+
+import argparse
+import collections
+import json as json_module  # 'json' is a great name for a variable
+import logging
+import re
+
+
+# A deserialized source location. Lack of filename represents the main file.
+class SourceLocation(object):
+def __init__(self, json):
+super(SourceLocation, self).__init__()
+self.line = json['line']
+self.col = json['column']
+self.filename = json['filename'] \
+if 'filename' in json else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json):
+super(ProgramPoint, self).__init__()
+self.kind = json['kind']
+self.tag = json['tag']
+if self.kind == 'Edge':
+self.src_id = json['src_id']
+self.dst_id = json['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json['stmt_kind']
+self.pointer = json['pointer']
+self.pretty = json['pretty']
+self.sloc = SourceLocation(json['location']) \
+if json['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json):
+super(EnvironmentBinding, self).__init__()
+self.lctx_id = json['lctx_id']
+self.stmt_id = json['stmt_id']
+self.pretty = json['pretty']
+self.value = json['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, caption, decl, line):
+super(LocationContext, self).__init__()
+self.caption = caption
+self.decl = decl
+self.line = line
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json['location_context'],
+json['calling'],
+json['call_line'])
+self.bindings = [EnvironmentBinding(b) for b in json['items']]
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json):
+super(StoreBinding, 

r362045 - clang support gnu asm goto.

2019-05-29 Thread Jennifer Yu via cfe-commits
Author: jyu2
Date: Wed May 29 18:05:46 2019
New Revision: 362045

URL: http://llvm.org/viewvc/llvm-project?rev=362045=rev
Log:
clang support gnu asm goto.
Syntax:
  asm [volatile] goto ( AssemblerTemplate
  :
  : InputOperands
  : Clobbers
  : GotoLabels)

https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html

New llvm IR is "callbr" for inline asm goto instead "call" for inline asm
For:
asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop);
IR:
callbr void asm sideeffect "testl $0, $0; jne ${1:l};", 
"r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, 
%label_true), i8* blockaddress(@foo, %loop)) #1
  to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3

asm.fallthrough:

Compiler need to generate:
1> a dummy constarint 'X' for each label.
2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number".


Diagnostic 
1>  duplicate asm operand name are used in output, input and label.
2>  goto out of scope.


Added:
cfe/trunk/test/Analysis/asm-goto.cpp
cfe/trunk/test/CodeGen/asm-goto.c
cfe/trunk/test/Sema/asm-goto.cpp
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Sema/JumpDiagnostics.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/CodeGen/asm.c
cfe/trunk/test/CodeGen/inline-asm-mixed-style.c
cfe/trunk/test/Coverage/c-language-features.inc
cfe/trunk/test/PCH/asm.h
cfe/trunk/test/Parser/asm.c
cfe/trunk/test/Parser/asm.cpp
cfe/trunk/test/Sema/asm.c
cfe/trunk/test/Sema/inline-asm-validate-tmpl.cpp
cfe/trunk/test/Sema/scope-check.c

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=362045=362044=362045=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed May 29 18:05:46 2019
@@ -46,6 +46,7 @@ class Attr;
 class CapturedDecl;
 class Decl;
 class Expr;
+class AddrLabelExpr;
 class LabelDecl;
 class ODRHash;
 class PrinterHelper;
@@ -2816,13 +2817,15 @@ class GCCAsmStmt : public AsmStmt {
   StringLiteral **Constraints = nullptr;
   StringLiteral **Clobbers = nullptr;
   IdentifierInfo **Names = nullptr;
+  unsigned NumLabels = 0;
 
 public:
   GCCAsmStmt(const ASTContext , SourceLocation asmloc, bool issimple,
  bool isvolatile, unsigned numoutputs, unsigned numinputs,
  IdentifierInfo **names, StringLiteral **constraints, Expr **exprs,
  StringLiteral *asmstr, unsigned numclobbers,
- StringLiteral **clobbers, SourceLocation rparenloc);
+ StringLiteral **clobbers, unsigned numlabels,
+ SourceLocation rparenloc);
 
   /// Build an empty inline-assembly statement.
   explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty) {}
@@ -2947,6 +2950,51 @@ public:
 return const_cast(this)->getInputExpr(i);
   }
 
+  //===--- Labels ---===//
+
+  bool isAsmGoto() const {
+return NumLabels > 0;
+  }
+
+  unsigned getNumLabels() const {
+return NumLabels;
+  }
+
+  IdentifierInfo *getLabelIdentifier(unsigned i) const {
+return Names[i + NumInputs];
+  }
+
+  AddrLabelExpr *getLabelExpr(unsigned i) const;
+  StringRef getLabelName(unsigned i) const;
+  using labels_iterator = CastIterator;
+  using const_labels_iterator = ConstCastIterator;
+  using labels_range = llvm::iterator_range;
+  using labels_const_range = llvm::iterator_range;
+
+  labels_iterator begin_labels() {
+return [0] + NumInputs;
+  }
+
+  labels_iterator end_labels() {
+return [0] + NumInputs + NumLabels;
+  }
+
+  labels_range labels() {
+return labels_range(begin_labels(), end_labels());
+  }
+
+  const_labels_iterator begin_labels() const {
+return [0] + NumInputs;
+  }
+
+  const_labels_iterator end_labels() const {
+return [0] + NumInputs + NumLabels;
+  }
+
+  labels_const_range labels() const {
+return labels_const_range(begin_labels(), end_labels());
+  }
+
 private:
   void setOutputsAndInputsAndClobbers(const ASTContext ,
   IdentifierInfo **Names,
@@ -2954,6 +3002,7 @@ private:
   Stmt **Exprs,
   unsigned 

[PATCH] D59628: Add support for __attribute__((objc_class_stub))

2019-05-29 Thread Slava Pestov via Phabricator via cfe-commits
slavapestov updated this revision to Diff 202084.

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

https://reviews.llvm.org/D59628

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/ObjCRuntime.h
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/class-stubs.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/class-stub-attr-unsupported.m
  clang/test/SemaObjC/class-stub-attr.m
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1922,6 +1922,30 @@
   return true;
 }
 
+static std::string GenerateTestExpression(ArrayRef LangOpts) {
+  std::string Test;
+
+  for (auto *E : LangOpts) {
+if (!Test.empty())
+  Test += " || ";
+
+const StringRef Code = E->getValueAsString("CustomCode");
+if (!Code.empty()) {
+  Test += "(";
+  Test += Code;
+  Test += ")";
+} else {
+  Test += "LangOpts.";
+  Test += E->getValueAsString("Name");
+}
+  }
+
+  if (Test.empty())
+return "true";
+
+  return Test;
+}
+
 std::string
 PragmaClangAttributeSupport::generateStrictConformsTo(const Record ,
   raw_ostream ) {
@@ -1948,19 +1972,8 @@
   // rules if the specific language options are specified.
   std::vector LangOpts = Rule.getLangOpts();
   OS << "  MatchRules.push_back(std::make_pair(" << Rule.getEnumValue()
- << ", /*IsSupported=*/";
-  if (!LangOpts.empty()) {
-for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I) {
-  const StringRef Part = (*I)->getValueAsString("Name");
-  if ((*I)->getValueAsBit("Negated"))
-OS << "!";
-  OS << "LangOpts." << Part;
-  if (I + 1 != E)
-OS << " || ";
-}
-  } else
-OS << "true";
-  OS << "));\n";
+ << ", /*IsSupported=*/" << GenerateTestExpression(LangOpts)
+ << "));\n";
 }
   }
   OS << "}\n\n";
@@ -3431,23 +3444,12 @@
   if (LangOpts.empty())
 return "defaultDiagnoseLangOpts";
 
-  // Generate the test condition, as well as a unique function name for the
-  // diagnostic test. The list of options should usually be short (one or two
-  // options), and the uniqueness isn't strictly necessary (it is just for
-  // codegen efficiency).
-  std::string FnName = "check", Test;
-  for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I) {
-const StringRef Part = (*I)->getValueAsString("Name");
-if ((*I)->getValueAsBit("Negated")) {
-  FnName += "Not";
-  Test += "!";
-}
-Test += "S.LangOpts.";
-Test +=  Part;
-if (I + 1 != E)
-  Test += " || ";
-FnName += Part;
-  }
+  // Generate a unique function name for the diagnostic test. The list of
+  // options should usually be short (one or two options), and the
+  // uniqueness isn't strictly necessary (it is just for codegen efficiency).
+  std::string FnName = "check";
+  for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I)
+FnName += (*I)->getValueAsString("Name");
   FnName += "LangOpts";
 
   // If this code has already been generated, simply return the previous
@@ -3458,7 +3460,8 @@
 return *I;
 
   OS << "static bool " << FnName << "(Sema , const ParsedAttr ) {\n";
-  OS << "  if (" << Test << ")\n";
+  OS << "  auto  = S.LangOpts;\n";
+  OS << "  if (" << GenerateTestExpression(LangOpts) << ")\n";
   OS << "return true;\n\n";
   OS << "  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) ";
   OS << "<< Attr.getName();\n";
Index: clang/test/SemaObjC/class-stub-attr.m
===
--- /dev/null
+++ clang/test/SemaObjC/class-stub-attr.m
@@ -0,0 +1,27 @@
+// RUN: %clang -target x86_64-apple-darwin -fsyntax-only -Xclang -verify %s
+// RUN: %clang -target x86_64-apple-darwin -x objective-c++ -fsyntax-only -Xclang -verify %s
+
+@interface NSObject
+@end
+
+__attribute__((objc_class_stub))
+@interface MissingSubclassingRestrictedAttribute : NSObject // expected-error {{'objc_class_stub' attribute cannot be specified on a class that does not have the 'objc_subclassing_restricted' attribute}}
+@end
+
+__attribute__((objc_class_stub))
+__attribute__((objc_subclassing_restricted))
+@interface ValidClassStubAttribute : NSObject
+@end
+
+@implementation ValidClassStubAttribute // expected-error {{cannot declare implementation of a class declared with the 'objc_class_stub' attribute}}
+@end
+
+@implementation ValidClassStubAttribute (MyCategory)
+@end
+
+__attribute__((objc_class_stub(123))) // expected-error {{'objc_class_stub' attribute takes 

[PATCH] D59628: Add support for __attribute__((objc_class_stub))

2019-05-29 Thread Slava Pestov via Phabricator via cfe-commits
slavapestov marked 2 inline comments as done.
slavapestov added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:297
 def CUDA : LangOpt<"CUDA">;
-def COnly : LangOpt<"CPlusPlus", 1>;
+def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
 def CPlusPlus : LangOpt<"CPlusPlus">;

aaron.ballman wrote:
> This compiles? I would have assumed that it would have to be `def COnly : 
> LangOpt<"COnly", [{!LangOpts.CPlusPlus}]>;`
> 
> (If it compiles as-is, that's fine, I just wasn't aware that you could use 
> string syntax for code blocks.)
It appears that both work! Going with your suggested version.


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

https://reviews.llvm.org/D59628



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


[PATCH] D62636: Driver, IRGen: Set partitions on GlobalValues according to -fsymbol-partition flag.

2019-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added a reviewer: rsmith.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62636

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/symbol-partition.cpp
  clang/test/Driver/symbol-partition.c

Index: clang/test/Driver/symbol-partition.c
===
--- /dev/null
+++ clang/test/Driver/symbol-partition.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -target x86_64-unknown-linux -c -fsymbol-partition=foo %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-pc-win32 -c -fsymbol-partition=foo %s 2>&1 | FileCheck --check-prefix=ERROR %s
+
+// CHECK: "-fsymbol-partition=foo"
+// ERROR: clang: error: unsupported option '-fsymbol-partition=foo' for target 'x86_64-pc-windows-msvc'
Index: clang/test/CodeGenCXX/symbol-partition.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/symbol-partition.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsymbol-partition=foo -emit-llvm -o - | FileCheck %s
+
+// CHECK: @gv = {{.*}}, partition "foo"
+// CHECK: @_ZTV1S = {{.*}}, partition "foo"
+// CHECK: @_ZTS1S = {{.*}}, partition "foo"
+// CHECK: @_ZTI1S = {{.*}}, partition "foo"
+
+// CHECK: @_Z5ifuncv = {{.*}}, partition "foo"
+
+// CHECK: define {{.*}} @_ZN1S1fEv({{.*}} partition "foo"
+// CHECK: define {{.*}} @f({{.*}} partition "foo"
+
+struct S {
+  virtual void f();
+};
+
+void S::f() {}
+
+int gv;
+extern "C" void *f() { return 0; }
+void ifunc() __attribute__((ifunc("f")));
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1343,6 +1343,8 @@
 
   Opts.PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ);
 
+  Opts.SymbolPartition = Args.getLastArgValue(OPT_fsymbol_partition_EQ);
+
   return Success;
 }
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5407,6 +5407,14 @@
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
+  if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {
+std::string Str = A->getAsString(Args);
+if (!TC.getTriple().isOSBinFormatELF())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << Str << TC.getTripleString();
+CmdArgs.push_back(Args.MakeArgString(Str));
+  }
+
   // Add the "-o out -x type src.c" flags last. This is done primarily to make
   // the -cc1 command easier to edit when reproducing compiler crashes.
   if (Output.getType() == types::TY_Dependencies) {
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3420,6 +3420,9 @@
   TypeName->setDLLStorageClass(DLLStorageClass);
   GV->setDLLStorageClass(DLLStorageClass);
 
+  TypeName->setPartition(CGM.getCodeGenOpts().SymbolPartition);
+  GV->setPartition(CGM.getCodeGenOpts().SymbolPartition);
+
   return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
 }
 
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -759,9 +759,6 @@
   /// Set the visibility for the given LLVM GlobalValue.
   void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
 
-  void setGlobalVisibilityAndLocal(llvm::GlobalValue *GV,
-   const NamedDecl *D) const;
-
   void setDSOLocal(llvm::GlobalValue *GV) const;
 
   void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const;
@@ -771,6 +768,8 @@
   void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const;
   void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
 
+  void setGVPropertiesAux(llvm::GlobalValue *GV, const NamedDecl *D) const;
+
   /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
   /// variable declaration D.
   void setTLSMode(llvm::GlobalValue *GV, const VarDecl ) const;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -870,19 +870,20 @@
 void CodeGenModule::setGVProperties(llvm::GlobalValue *GV,
 GlobalDecl GD) const {
   setDLLImportDLLExport(GV, GD);
-  setGlobalVisibilityAndLocal(GV, dyn_cast(GD.getDecl()));
+  

[PATCH] D62616: [CodeComplete] Add a bit more whitespace to completed patterns

2019-05-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

I totally agree about the space before the opening curly, but the space before 
the opening paren is a matter of style.  Certainly it does match LLVM style 
better, but it does not match some other styles.

I guess there's no way to satisfy everyone without an automatic reformatter, 
and if we were to pick a "default" style it might as well be LLVM, so I approve.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62616



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


[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-29 Thread Jian Cai via Phabricator via cfe-commits
jcai19 added a comment.

In D62049#1522203 , @srhines wrote:

> Everything looks great. Thanks for adding these improvements. While it's 
> probably safe to commit this, perhaps you should give it 24 hours in case 
> some of the other clang-tidy folks have different style or testing concerns.


Sounds good! Thanks for all the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049



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


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-05-29 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I think the AST dump for `EnumDecl` and `ClassTemplateSpecializationDecl` 
should be dumping the missing `SourceLocations` but I am having trouble 
tracking down where that should be done.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60499



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


[PATCH] D62635: Add enums as global variables in the IR metadata.

2019-05-29 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: rnk.
Herald added subscribers: llvm-commits, cfe-commits, aprantl.
Herald added projects: clang, LLVM.

Keeps track of the enums that were used by saving them as DIGlobalVariables,
since CodeView emits debug info for global constants.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62635

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-enum.cpp
  llvm/test/DebugInfo/COFF/global-constants.ll

Index: llvm/test/DebugInfo/COFF/global-constants.ll
===
--- llvm/test/DebugInfo/COFF/global-constants.ll
+++ llvm/test/DebugInfo/COFF/global-constants.ll
@@ -2,26 +2,41 @@
 ; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ
 
 ; C++ source to regenerate:
-; const int Test1 = 1;
-; struct Foo { static const int Test2 = 2; };
-; int main() {
-;   return Test1 + Foo::Test2;
+; const float TestConst1 = 3.14;
+; struct S {
+;   static const int TestConst2 = -10;
+; }
+; enum TestEnum : int {
+;ENUM_A = 214700,
+;ENUM_B = -214700,
+; };
+; void useConst(int);
+; void foo() {
+;   useConst(TestConst1);
+;   useConst(S::TestConst2);
+;   useConst(ENUM_B);
 ; }
 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
 
-; ASM-LABEL:  .long 241 # Symbol subsection for globals
-
-; ASM:.short {{.*-.*}}  # Record length
-; ASM:.short 4359   # Record kind: S_CONSTANT
-; ASM-NEXT:   .long 4099# Type
-; ASM-NEXT:   .byte 0x01, 0x00  # Value
-; ASM-NEXT:   .asciz "Test1"# Name
-
-; ASM:.short {{.*-.*}}  # Record length
-; ASM:.short 4359   # Record kind: S_CONSTANT
-; ASM:.long 4099# Type
-; ASM:.byte 0x02, 0x00  # Value
-; ASM:.asciz "Foo::Test2"   # Name
+; ASM-LABEL:  .long 241 # Symbol subsection for globals
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4099# Type
+; ASM-NEXT:   .byte 0x04, 0x80, 0xc3, 0xf5  # Value
+; ASM-NEXT:   .byte 0x48, 0x40
+; ASM-NEXT:   .asciz "TestConst1"   # Name
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4100# Type
+; ASM-NEXT:   .byte 0x61, 0x00  # Value
+; ASM-NEXT:   .asciz "S::TestConst2"# Name
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4102# Type
+; ASM-NEXT:   .byte 0x0a, 0x80, 0x40, 0x61  # Value
+; ASM-NEXT:   .byte 0x07, 0x80, 0xff, 0xff
+; ASM-NEXT:   .byte 0xff, 0xff
+; ASM-NEXT:   .asciz "ENUM_B"   # Name
 
 ; OBJ:CodeViewDebugInfo [
 ; OBJ:  Section: .debug$S
@@ -30,56 +45,77 @@
 ; OBJ:SubSectionType: Symbols (0xF1)
 ; OBJ:ConstantSym {
 ; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
-; OBJ-NEXT: Type: const int (0x1003)
-; OBJ-NEXT: Value: 1
-; OBJ-NEXT: Name: Test1
+; OBJ-NEXT: Type: const float (0x1003)
+; OBJ-NEXT: Value: 1078523331
+; OBJ-NEXT: Name: TestConst1
 ; OBJ-NEXT:   }
-; OBJ:ConstantSym {
+; OBJ-NEXT:   ConstantSym {
 ; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
-; OBJ-NEXT: Type: const int (0x1003)
-; OBJ-NEXT: Value: 2
-; OBJ-NEXT: Name: Foo::Test2
+; OBJ-NEXT: Type: const char (0x1004)
+; OBJ-NEXT: Value: 97
+; OBJ-NEXT: Name: S::TestConst2
 ; OBJ-NEXT:   }
+; OBJ-NEXT:   ConstantSym {
+; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
+; OBJ-NEXT: Type: TestEnum (0x1006)
+; OBJ-NEXT: Value: 18446744071562551616
+; OBJ-NEXT: Name: ENUM_B
+; OBJ-NEXT:   }
+
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc"
+target triple = "x86_64-w64-windows-gnu"
 
-; Function Attrs: noinline norecurse nounwind optnone
-define dso_local i32 @main() #0 !dbg !19 {
+; Function Attrs: noinline nounwind optnone
+define dso_local void @_Z3foov() #0 !dbg !28 {
 entry:
-  %retval = alloca i32, align 4
-  store i32 0, i32* %retval, align 4
-  ret i32 3, !dbg !22
+  call void @_Z8useConsti(i32 3), !dbg !32
+  call void @_Z8useConsti(i32 97), !dbg !33
+  call void @_Z8useConsti(i32 -214700), !dbg !34
+  ret void, !dbg !35
 }
 
-attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 

[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-29 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added inline comments.



Comment at: compiler-rt/lib/gwp_asan/tests/driver.cpp:14
+  return RUN_ALL_TESTS();
+}

morehouse wrote:
> Can we just link with gtest_main instead of having this?
Unfortunately not easily. `generate_compiler_rt_tests` builds each test cpp 
file individually, and provides no way to add `gtest_main` only during link 
time. 



Comment at: compiler-rt/lib/gwp_asan/tests/mutex_test.cpp:46
+  while (!StartingGun->load())
+;
+  for (unsigned i = 0; i < kNumLocksInARow; ++i) {

morehouse wrote:
> Format seems weird.  Does clang-format let us do `while (...) {}` on one line?
CF changes it to 
```
while (!StartingGun) {
}
```



Comment at: compiler-rt/test/gwp_asan/CMakeLists.txt:1
+set(GWP_ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(GWP_ASAN_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

morehouse wrote:
> Can the lit test stuff go in another patch when we actually have tests?
Not AFAIK. The unit tests are actually invoked through the lit configurations 
in this directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-29 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 202078.
hctim marked 21 inline comments as done.
hctim added a comment.

- Apologies about the delay on this. Updated with Matt's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/gwp_asan/mutex.h
  compiler-rt/lib/gwp_asan/platform_specific/mutex_posix.cpp
  compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
  compiler-rt/lib/gwp_asan/tests/driver.cpp
  compiler-rt/lib/gwp_asan/tests/mutex_test.cpp
  compiler-rt/test/gwp_asan/CMakeLists.txt
  compiler-rt/test/gwp_asan/dummy_test.cc
  compiler-rt/test/gwp_asan/lit.cfg
  compiler-rt/test/gwp_asan/lit.site.cfg.in
  compiler-rt/test/gwp_asan/unit/lit.site.cfg.in

Index: compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
@@ -0,0 +1,9 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.name = "GwpAsan-Unittest"
+# Load common config for all compiler-rt unit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
+
+config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
+ "lib", "gwp_asan", "tests")
+config.test_source_root = config.test_exec_root
Index: compiler-rt/test/gwp_asan/lit.site.cfg.in
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/lit.site.cfg.in
@@ -0,0 +1,11 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.name_suffix = "@GWP_ASAN_TEST_CONFIG_SUFFIX@"
+config.target_arch = "@GWP_ASAN_TEST_TARGET_ARCH@"
+config.target_cflags = "@GWP_ASAN_TEST_TARGET_CFLAGS@"
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@GWP_ASAN_LIT_SOURCE_DIR@/lit.cfg")
Index: compiler-rt/test/gwp_asan/lit.cfg
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/lit.cfg
@@ -0,0 +1,31 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = 'GWP-ASan' + config.name_suffix
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp', '.test']
+
+# C & CXX flags.
+c_flags = ([config.target_cflags])
+
+# Android doesn't want -lrt.
+if not config.android:
+  c_flags += ["-lrt"]
+
+cxx_flags = (c_flags + config.cxx_mode_flags + ["-std=c++11"])
+
+def build_invocation(compile_flags):
+  return " " + " ".join([config.clang] + compile_flags) + " "
+
+# Add substitutions.
+config.substitutions.append(("%clang ", build_invocation(c_flags)))
+
+# GWP-ASan tests are currently supported on Linux only.
+if config.host_os not in ['Linux']:
+   config.unsupported = True
Index: compiler-rt/test/gwp_asan/dummy_test.cc
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/dummy_test.cc
@@ -0,0 +1,4 @@
+// Exists to simply stop warnings about lit not discovering any tests here.
+// RUN: %clang %s
+
+int main() { return 0; }
Index: compiler-rt/test/gwp_asan/CMakeLists.txt
===
--- compiler-rt/test/gwp_asan/CMakeLists.txt
+++ compiler-rt/test/gwp_asan/CMakeLists.txt
@@ -0,0 +1,45 @@
+set(GWP_ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(GWP_ASAN_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
+set(GWP_ASAN_TESTSUITES)
+
+set(GWP_ASAN_UNITTEST_DEPS)
+set(GWP_ASAN_TEST_DEPS
+  ${SANITIZER_COMMON_LIT_TEST_DEPS}
+  gwp_asan)
+
+if (COMPILER_RT_INCLUDE_TESTS)
+  list(APPEND GWP_ASAN_TEST_DEPS GwpAsanUnitTests)
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg)
+  add_lit_testsuite(check-gwp_asan-unit "Running GWP-ASan unit tests"
+${CMAKE_CURRENT_BINARY_DIR}/unit
+DEPENDS ${GWP_ASAN_TEST_DEPS})
+  set_target_properties(check-gwp_asan-unit PROPERTIES FOLDER
+"Compiler-RT Tests")
+list(APPEND GWP_ASAN_TEST_DEPS check-gwp_asan-unit)
+endif()
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+
+foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
+  set(GWP_ASAN_TEST_TARGET_ARCH ${arch})
+  string(TOLOWER "-${arch}" GWP_ASAN_TEST_CONFIG_SUFFIX)
+  get_test_cc_for_arch(${arch} GWP_ASAN_TEST_TARGET_CC GWP_ASAN_TEST_TARGET_CFLAGS)
+  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+  set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
+  list(APPEND GWP_ASAN_TESTSUITES 

[PATCH] D62622: [CMake] Provide an option to use relative paths in debug info

2019-05-29 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

-DLLVM_USE_RELATIVE_PATHS is very generic sounding and might give a false 
impression. Is there a name that emphasizes that this affects the debug info of 
the built compiler?


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

https://reviews.llvm.org/D62622



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


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-05-29 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

So an alternative to testing could be matching the AST output from a 
`clang-import-test` like we did here:

https://reviews.llvm.org/D61140

although it unfortunately looks like only only the AST dump of `NamespaceDecl` 
output the `SourceLocation` you are fixing, see it on godbolt 
 when I try a `clang-import-test` it looks like 
it is missing that `SourceLocation`:

  |-NamespaceDecl 0x7f8c1f884750 > col:11 

and with your patch applied I see the `SourceLocation`:

  |-NamespaceDecl 0x7fe3e6882f50  line:1:11 A


Repository:
  rC Clang

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

https://reviews.llvm.org/D60499



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


[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-29 Thread Stephen Hines via Phabricator via cfe-commits
srhines accepted this revision.
srhines added a comment.
This revision is now accepted and ready to land.

Everything looks great. Thanks for adding these improvements. While it's 
probably safe to commit this, perhaps you should give it 24 hours in case some 
of the other clang-tidy folks have different style or testing concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049



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


[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-29 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 202072.
jcai19 marked an inline comment as done.
jcai19 added a comment.

Remove redundant CHECK-MESSAGES-NOT checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/CloexecPipe2Check.cpp
  clang-tools-extra/clang-tidy/android/CloexecPipe2Check.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp
@@ -0,0 +1,72 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe2 %t
+
+#define O_NONBLOCK 1
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int pipe2(int pipefd[2], int flags);
+
+void a() {
+  int pipefd[2];
+  pipe2(pipefd, O_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'pipe2' should use O_CLOEXEC where possible [android-cloexec-pipe2]
+  // CHECK-FIXES: pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: 'pipe2'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+}
+
+void f() {
+  int pipefd[2];
+  pipe2(pipefd, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'pipe2'
+  // CHECK-FIXES: pipe2(pipefd, 3 | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'pipe2'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(pipe2(pipefd, 3 | O_CLOEXEC));
+
+  int flag = O_NONBLOCK;
+  pipe2(pipefd, flag);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, flag));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int pipe2(int pipefd[2], int flags);
+
+void d() {
+  int pipefd[2];
+  pipe2(pipefd, O_NONBLOCK);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  int pipefd[2];
+  pipe2(pipefd, O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_CLOEXEC));
+  pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int pipe2(int pipefd[2], int flags);
+  void d() {
+int pipefd[2];
+pipe2(pipefd, O_NONBLOCK);
+TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe2
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - android-cloexec-pipe2
+
+android-cloexec-pipe2
+=
+
+Checks if the required file flag ``O_CLOEXEC`` is present in the argument of
+``pipe2()``. ``pipe2()`` should include ``O_CLOEXEC`` in its type argument to
+avoid the file descriptor leakage. Without this flag, an opened sensitive file
+would remain open across a ``fork``+``exec`` to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe2(pipefd, O_NONBLOCK);
+
+  // becomes
+
+  pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,12 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  Checks if the required file flag ``O_CLOEXEC`` is present in the argument of
+  ``pipe2()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipe2Check.h
===
--- /dev/null
+++ 

[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-29 Thread Stephen Hines via Phabricator via cfe-commits
srhines added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp:48
+  pipe2(pipefd, O_NONBLOCK);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));

Much like line 39 (which covers both lines 37 and 38), you can delete this 
CHECK-MESSAGES-NOT. The one on line 50 will cover both of these.



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp:64
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+  // CHECK-MESSAGES-NOT: warning:
+}

Only keep this CHECK-MESSAGES-NOT line.



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp:75
+TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+// CHECK-MESSAGES-NOT: warning:
+  }

Only keep this CHECK-MESSAGES-NOT line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049



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


[PATCH] D62622: [CMake] Provide an option to use relative paths in debug info

2019-05-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 202064.

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

https://reviews.llvm.org/D62622

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -371,7 +371,9 @@
 
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
 -DLLVM_BINARY_DIR=${LLVM_BINARY_DIR}
 -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
+
-DLLVM_MAIN_SRC_DIR=${LLVM_MAIN_SRC_DIR}
 
-DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
+
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
 
-DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
 
-DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
@@ -462,7 +464,9 @@
 
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
 -DLLVM_BINARY_DIR=${LLVM_BINARY_DIR}
 -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
+
-DLLVM_MAIN_SRC_DIR=${LLVM_MAIN_SRC_DIR}
 -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
+
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
 -DCMAKE_C_COMPILER_TARGET=${target}
 -DCMAKE_CXX_COMPILER_TARGET=${target}
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -231,6 +231,8 @@
-DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
-DLLVM_HOST_TRIPLE=${LLVM_HOST_TRIPLE}
-DLLVM_HAVE_LINK_VERSION_SCRIPT=${LLVM_HAVE_LINK_VERSION_SCRIPT}
+   -DLLVM_USE_RELATIVE_PATHS=${LLVM_USE_RELATIVE_PATHS}
+   -DLLVM_SOURCE_PREFIX=${LLVM_SOURCE_PREFIX}
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -977,3 +977,19 @@
 endif()
   endif()
 endif()
+
+option(LLVM_USE_RELATIVE_PATHS "Make builds independent of absolute file 
paths." OFF)
+set(LLVM_SOURCE_PREFIX "" CACHE STRING "LLVM source directory prefix")
+
+if(LLVM_USE_RELATIVE_PATHS)
+  check_c_compiler_flag("-fdebug-prefix-map=foo=bar" 
SUPPORTS_FDEBUG_PREFIX_MAP)
+  if(LLVM_ENABLE_PROJECTS_USED)
+get_filename_component(source_root "${LLVM_MAIN_SRC_DIR}/.." ABSOLUTE)
+  else()
+set(source_root "${LLVM_MAIN_SRC_DIR}")
+  endif()
+  file(RELATIVE_PATH relative_root "${source_root}" "${CMAKE_BINARY_DIR}")
+  append_if(SUPPORTS_FDEBUG_PREFIX_MAP 
"-fdebug-prefix-map=${CMAKE_BINARY_DIR}=${relative_root}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
+  append_if(SUPPORTS_FDEBUG_PREFIX_MAP 
"-fdebug-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
+  add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
+endif()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -15,6 +15,7 @@
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_USE_RELATIVE_PATHS ON CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)


Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -371,7 +371,9 @@
 -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
 -DLLVM_BINARY_DIR=${LLVM_BINARY_DIR}
 -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
+-DLLVM_MAIN_SRC_DIR=${LLVM_MAIN_SRC_DIR}
 

[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-29 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362038: CodeView - add static data members to global 
variable debug info. (authored by akhuang, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62167?vs=202027=202063#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62167

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
  llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/trunk/test/DebugInfo/COFF/global-constants.ll

Index: llvm/trunk/test/DebugInfo/COFF/global-constants.ll
===
--- llvm/trunk/test/DebugInfo/COFF/global-constants.ll
+++ llvm/trunk/test/DebugInfo/COFF/global-constants.ll
@@ -3,18 +3,25 @@
 
 ; C++ source to regenerate:
 ; const int Test1 = 1;
+; struct Foo { static const int Test2 = 2; };
 ; int main() {
-;   return Test1;
+;   return Test1 + Foo::Test2;
 ; }
 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
 
-; ASM-LABEL:  .long 241  # Symbol subsection for globals
+; ASM-LABEL:  .long 241 # Symbol subsection for globals
 
-; ASM:.short {{.*-.*}}   # Record length
-; ASM:.short 4359# Record kind: S_CONSTANT
-; ASM-NEXT:   .long 4099 # Type
-; ASM-NEXT:   .byte 0x01, 0x00   # Value
-; ASM-NEXT:   .asciz "Test1" # Name
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4099# Type
+; ASM-NEXT:   .byte 0x01, 0x00  # Value
+; ASM-NEXT:   .asciz "Test1"# Name
+
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM:.long 4099# Type
+; ASM:.byte 0x02, 0x00  # Value
+; ASM:.asciz "Foo::Test2"   # Name
 
 ; OBJ:CodeViewDebugInfo [
 ; OBJ:  Section: .debug$S
@@ -27,6 +34,12 @@
 ; OBJ-NEXT: Value: 1
 ; OBJ-NEXT: Name: Test1
 ; OBJ-NEXT:   }
+; OBJ:ConstantSym {
+; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
+; OBJ-NEXT: Type: const int (0x1003)
+; OBJ-NEXT: Value: 2
+; OBJ-NEXT: Name: Foo::Test2
+; OBJ-NEXT:   }
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
@@ -34,31 +47,39 @@
 target triple = "x86_64-pc-windows-msvc"
 
 ; Function Attrs: noinline norecurse nounwind optnone
-define dso_local i32 @main() #0 !dbg !13 {
+define dso_local i32 @main() #0 !dbg !19 {
 entry:
   %retval = alloca i32, align 4
   store i32 0, i32* %retval, align 4
-  ret i32 1, !dbg !16
+  ret i32 3, !dbg !22
 }
 
+attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!9, !10, !11}
-!llvm.ident = !{!12}
+!llvm.module.flags = !{!15, !16, !17}
+!llvm.ident = !{!18}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, nameTableKind: None)
-!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2b66a49044196d8b90d95d7d3b5246ccbe3abc05)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !10, nameTableKind: None)
+!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "77cff5e1c7b260440ed03b23c18809c3")
 !2 = !{}
 !3 = !{!4}
-!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
-!5 = distinct !DIGlobalVariable(name: "Test1", scope: !0, file: !6, line: 1, type: !7, isLocal: true, isDefinition: true)
-!6 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
-!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
-!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!9 = !{i32 2, !"CodeView", i32 1}
-!10 = !{i32 2, !"Debug Info Version", i32 3}
-!11 = !{i32 1, !"wchar_size", i32 2}
-!12 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 

r362038 - CodeView - add static data members to global variable debug info.

2019-05-29 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Wed May 29 14:45:34 2019
New Revision: 362038

URL: http://llvm.org/viewvc/llvm-project?rev=362038=rev
Log:
CodeView - add static data members to global variable debug info.

Summary:
Add static data members to IR debug info's list of global variables
so that they are emitted as S_CONSTANT records.

Related to https://bugs.llvm.org/show_bug.cgi?id=41615.

Reviewers: rnk

Subscribers: aprantl, cfe-commits, llvm-commits, thakis

Tags: #clang, #llvm

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=362038=362037=362038=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed May 29 14:45:34 2019
@@ -4361,9 +4361,13 @@ void CGDebugInfo::EmitGlobalVariable(con
 return;
   }
 
-  // Do not emit separate definitions for function local const/statics.
+  llvm::DIScope *DContext = nullptr;
+
+  // Do not emit separate definitions for function local consts.
   if (isa(VD->getDeclContext()))
 return;
+
+  // Emit definition for static members in CodeView.
   VD = cast(VD->getCanonicalDecl());
   auto *VarD = cast(VD);
   if (VarD->isStaticDataMember()) {
@@ -4375,10 +4379,16 @@ void CGDebugInfo::EmitGlobalVariable(con
 // through its scope.
 RetainedTypes.push_back(
 CGM.getContext().getRecordType(RD).getAsOpaquePtr());
-return;
-  }
 
-  llvm::DIScope *DContext = getDeclContextDescriptor(VD);
+if (!CGM.getCodeGenOpts().EmitCodeView)
+  return;
+
+// Use the global scope for static members.
+DContext = getContextDescriptor(
+cast(CGM.getContext().getTranslationUnitDecl()), TheCU);
+  } else {
+DContext = getDeclContextDescriptor(VD);
+  }
 
   auto  = DeclCache[VD];
   if (GV)

Modified: cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp?rev=362038=362037=362038=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp Wed May 29 14:45:34 
2019
@@ -1,6 +1,7 @@
 // RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | 
FileCheck %s
 // RUN: %clangxx -target x86_64-unknown-unknown -g -std=c++98 %s -emit-llvm -S 
-o - | FileCheck %s
 // RUN: %clangxx -target x86_64-unknown-unknown -g -std=c++11 %s -emit-llvm -S 
-o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited %s -emit-llvm -o - | FileCheck --check-prefix MSVC %s
 // PR14471
 
 // CHECK: @_ZN1C1aE = dso_local global i32 4, align 4, !dbg [[A:![0-9]+]]
@@ -35,6 +36,7 @@ public:
 // CHECK: [[A]] = !DIGlobalVariableExpression(var: [[AV:.*]], expr: 
!DIExpression())
 // CHECK: [[AV]] = distinct !DIGlobalVariable(name: "a",
 // CHECK-SAME:declaration: ![[DECL_A:[0-9]+]])
+// MSVC: distinct !DIGlobalVariable(name: "a"
 //
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "X"{{.*}}, 
identifier: "_ZTS1X")
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: 
"anon_static_decl_struct"
@@ -48,6 +50,7 @@ int C::a = 4;
 // CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BV:.*]], expr: 
!DIExpression())
 // CHECK: [[BV]] = distinct !DIGlobalVariable(name: "b",
 // CHECK-SAME:declaration: ![[DECL_B:[0-9]+]])
+// MSVC: distinct !DIGlobalVariable(name: "b"
 // CHECK: ![[DECL_B]] = !DIDerivedType(tag: DW_TAG_member, name: "b"
 // CHECK-NOT: size:
 // CHECK-NOT: align:
@@ -95,6 +98,7 @@ int C::a = 4;
 int C::b = 2;
 // CHECK: [[C]] = !DIGlobalVariableExpression(var: [[CV:.*]], expr: 
!DIExpression())
 // CHECK: [[CV]] = distinct !DIGlobalVariable(name: "c", {{.*}} declaration: 
![[DECL_C]])
+// MSVC: distinct !DIGlobalVariable(name: "c"
 int C::c = 1;
 
 int main()
@@ -114,11 +118,18 @@ struct anon_static_decl_struct {
 };
 }
 
-
 int ref() {
   return anon_static_decl_struct::anon_static_decl_var;
 }
 
+// In MSVC, static data members should be emitted as global variables when 
used.
+// MSVC: !DIGlobalVariableExpression(var: [[ANON_STATIC_DECL:![0-9]+]],
+// MSVC-SAME: !DIExpression(DW_OP_constu, 117, DW_OP_stack_value)
+// MSVC: [[ANON_STATIC_DECL]] = distinct !DIGlobalVariable(name: 
"anon_static_decl_var"
+// MSVC: !DIGlobalVariableExpression(var: [[STATIC_DECL_TEMPL:![0-9]+]]
+// MSVC-SAME: !DIExpression(DW_OP_constu, 7, DW_OP_stack_value)
+// MSVC: [[STATIC_DECL_TEMPL]] = distinct !DIGlobalVariable(name: 
"static_decl_templ_var"
+
 template
 struct 

[PATCH] D62167: CodeView - add static data members to global variable debug info.

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

lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167



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


[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D61974#1521334 , @theraven wrote:

> LGTM.  I wonder if we have any other ugly GCC bug compatibility parts in 
> clang's Objective-C implementation...


I see a couple of FIXME comments in ASTContext.cpp that seem to suggest clang 
is copying gcc's behavior that is possibly incorrect.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974



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


[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC362034: [ObjC] Fix encoding of ObjC pointer types that are 
pointers to typedefs (authored by ahatanak, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61974

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  test/CodeGenObjC/encode-test-6.m
  test/CodeGenObjC/encode-test.m
  test/CodeGenObjCXX/encode.mm

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -6927,13 +6927,10 @@
   getObjCEncodingForTypeImpl(Field->getType(), S,
  ObjCEncOptions().setExpandStructures(),
  Field);
-else {
-  ObjCEncOptions NewOptions = ObjCEncOptions().setExpandStructures();
-  if (Options.EncodePointerToObjCTypedef())
-NewOptions.setEncodePointerToObjCTypedef();
-  getObjCEncodingForTypeImpl(Field->getType(), S, NewOptions, FD,
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S,
+ ObjCEncOptions().setExpandStructures(), FD,
  NotEncodedT);
-}
   }
 }
 S += '}';
@@ -6976,36 +6973,6 @@
   return;
 }
 
-QualType PointeeTy = OPT->getPointeeType();
-if (!Options.EncodingProperty() &&
-isa(PointeeTy.getTypePtr()) &&
-!Options.EncodePointerToObjCTypedef()) {
-  // Another historical/compatibility reason.
-  // We encode the underlying type which comes out as
-  // {...};
-  S += '^';
-  if (FD && OPT->getInterfaceDecl()) {
-// Prevent recursive encoding of fields in some rare cases.
-ObjCInterfaceDecl *OI = OPT->getInterfaceDecl();
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  if (Ivars[i] == FD) {
-S += '{';
-S += OI->getObjCRuntimeNameAsString();
-S += '}';
-return;
-  }
-}
-  }
-  ObjCEncOptions NewOptions =
-  ObjCEncOptions().setEncodePointerToObjCTypedef();
-  if (Options.ExpandPointedToStructures())
-NewOptions.setExpandStructures();
-  getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions, /*Field=*/nullptr);
-  return;
-}
-
 S += '@';
 if (OPT->getInterfaceDecl() &&
 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -2897,7 +2897,6 @@
   V(IsStructField, 4)  \
   V(EncodeBlockParameters, 5)  \
   V(EncodeClassNames, 6)   \
-  V(EncodePointerToObjCTypedef, 7)
 
 #define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
 OPT_LIST(V)
@@ -2916,8 +2915,7 @@
 LLVM_NODISCARD ObjCEncOptions forComponentType() const {
   ObjCEncOptions Mask = ObjCEncOptions()
 .setIsOutermostType()
-.setIsStructField()
-.setEncodePointerToObjCTypedef();
+.setIsStructField();
   return Bits & ~Mask.Bits;
 }
   };
Index: test/CodeGenObjC/encode-test-6.m
===
--- test/CodeGenObjC/encode-test-6.m
+++ test/CodeGenObjC/encode-test-6.m
@@ -34,7 +34,7 @@
 @synthesize property = _property;
 @end
 
-// CHECK: private unnamed_addr constant [24 x i8] c"^{BABugExample=@}16
+// CHECK: private unnamed_addr constant [8 x i8] c"@16
 
 // rdar://14408244
 @class SCNCamera;
@@ -52,7 +52,7 @@
 C3DCameraStorage _storage;
 }
 @end
-// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22^{SCNCamera}}\00"
+// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22@\22SCNCamera\22}\00"
 
 // rdar://16655340
 int i;
Index: test/CodeGenObjC/encode-test.m
===
--- test/CodeGenObjC/encode-test.m
+++ test/CodeGenObjC/encode-test.m
@@ -107,7 +107,7 @@
 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
 const char g4[] = @encode(const struct S);
 
-// CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
+// CHECK: @g5 = constant [2 x i8] c"@\00"
 const char g5[] = @encode(MyObj * const);
 
 
Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -242,6 +242,6 @@
 @end
 
 const 

r362034 - [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-29 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May 29 14:23:30 2019
New Revision: 362034

URL: http://llvm.org/viewvc/llvm-project?rev=362034=rev
Log:
[ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

clang was encoding pointers to typedefs as if they were pointers to
structs because that is apparently what gcc is doing.

For example:

```
@class Class1;

typedef NSArray MyArray;

void foo1(void) {
  const char *s0 = @encode(MyArray *); // "^{NSArray=#}"
  const char *s1 = @encode(NSArray *); // "@"
}
```

This commit removes the code that was there to make clang compatible
with gcc and make clang emit the correct encoding for ObjC pointers,
which is "@".

rdar://problem/50563529

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenObjC/encode-test-6.m
cfe/trunk/test/CodeGenObjC/encode-test.m
cfe/trunk/test/CodeGenObjCXX/encode.mm

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=362034=362033=362034=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 29 14:23:30 2019
@@ -2897,7 +2897,6 @@ private:
   V(IsStructField, 4)  
\
   V(EncodeBlockParameters, 5)  
\
   V(EncodeClassNames, 6)   
\
-  V(EncodePointerToObjCTypedef, 7)
 
 #define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
 OPT_LIST(V)
@@ -2916,8 +2915,7 @@ OPT_LIST(V)
 LLVM_NODISCARD ObjCEncOptions forComponentType() const {
   ObjCEncOptions Mask = ObjCEncOptions()
 .setIsOutermostType()
-.setIsStructField()
-.setEncodePointerToObjCTypedef();
+.setIsStructField();
   return Bits & ~Mask.Bits;
 }
   };

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=362034=362033=362034=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed May 29 14:23:30 2019
@@ -6927,13 +6927,10 @@ void ASTContext::getObjCEncodingForTypeI
   getObjCEncodingForTypeImpl(Field->getType(), S,
  ObjCEncOptions().setExpandStructures(),
  Field);
-else {
-  ObjCEncOptions NewOptions = ObjCEncOptions().setExpandStructures();
-  if (Options.EncodePointerToObjCTypedef())
-NewOptions.setEncodePointerToObjCTypedef();
-  getObjCEncodingForTypeImpl(Field->getType(), S, NewOptions, FD,
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S,
+ ObjCEncOptions().setExpandStructures(), 
FD,
  NotEncodedT);
-}
   }
 }
 S += '}';
@@ -6976,36 +6973,6 @@ void ASTContext::getObjCEncodingForTypeI
   return;
 }
 
-QualType PointeeTy = OPT->getPointeeType();
-if (!Options.EncodingProperty() &&
-isa(PointeeTy.getTypePtr()) &&
-!Options.EncodePointerToObjCTypedef()) {
-  // Another historical/compatibility reason.
-  // We encode the underlying type which comes out as
-  // {...};
-  S += '^';
-  if (FD && OPT->getInterfaceDecl()) {
-// Prevent recursive encoding of fields in some rare cases.
-ObjCInterfaceDecl *OI = OPT->getInterfaceDecl();
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  if (Ivars[i] == FD) {
-S += '{';
-S += OI->getObjCRuntimeNameAsString();
-S += '}';
-return;
-  }
-}
-  }
-  ObjCEncOptions NewOptions =
-  ObjCEncOptions().setEncodePointerToObjCTypedef();
-  if (Options.ExpandPointedToStructures())
-NewOptions.setExpandStructures();
-  getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions, /*Field=*/nullptr);
-  return;
-}
-
 S += '@';
 if (OPT->getInterfaceDecl() &&
 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {

Modified: cfe/trunk/test/CodeGenObjC/encode-test-6.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test-6.m?rev=362034=362033=362034=diff
==
--- cfe/trunk/test/CodeGenObjC/encode-test-6.m (original)
+++ cfe/trunk/test/CodeGenObjC/encode-test-6.m Wed May 29 14:23:30 2019
@@ -34,7 

[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-05-29 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 202052.
jcai19 added a comment.

Add CHECK-MESSAGES-NOT checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61967

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe %t
+
+extern "C" int pipe(int pipefd[2]);
+
+void f() {
+  int pipefd[2];
+  pipe(pipefd);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() to pipe() because pipe2() allows O_CLOEXEC [android-cloexec-pipe]
+  // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
+}
+
+namespace i {
+int pipe(int pipefd[2]);
+void g() {
+  int pipefd[2];
+  pipe(pipefd);
+  // CHECK-MESSAGES-NOT: warning:
+}
+} // namespace i
+
+class C {
+public:
+  int pipe(int pipefd[2]);
+  void h() {
+int pipefd[2];
+pipe(pipefd);
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-pipe
+
+android-cloexec-pipe
+
+
+Detects usage of ``pipe()``. The usage of ``pipe()`` is not recommended, it's better to use ``pipe2()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a ``fork``+``exec`` to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe(pipefd);
+
+  // becomes
+
+  pipe2(pipefd, O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,11 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  Detects usage of ``pipe()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.h - clang-tidy-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// pipe() is better to be replaced by pipe2().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-pipe.html
+class CloexecPipeCheck : public CloexecCheck {
+public:
+  CloexecPipeCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
@@ -0,0 +1,37 @@
+//===--- CloexecPipeCheck.cpp - clang-tidy-===//
+//
+// Part of the LLVM Project, under the Apache 

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D62603#1521979 , @yaxunl wrote:

> > I think `static __device__` globals would fall into the same category -- 
> > nominally they should not be visible outside of device-side object file, 
> > but in practice we do need to make them visible from the host side of the 
> > same TU.
>
> Are you sure nvcc support accessing static `__device__` variables in host 
> code? That would be expensive to implement.


Address (of the shadow, translatable to device address) and size -- yes. Values 
-- no.

E.g. you can pass  as a parameter to the kernel. Host-side code will use 
shadow's address, but device-side kernel will get the real device-side address, 
translated from the shadow address by the runtime.

> Instead of looking up dynamic symbol tables only, now we need to look up 
> symbol tables for local symbols. Also we have to differentiate local symbols 
> that have the same name. This also means user can not strip symbol tables.

I'm not sure I understand what you're saying. CUDA runtime and device-side 
object file management is a black box to me, so I don't know how exactly NVIDIA 
has implemented this on device side, but the fact remains. host must have some 
way to refer to (some) device-side entities. Specifically, kernels and the 
global variables, whether they are nominally static or not.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


[PATCH] D53720: [analyzer] Remove EndPath function as it is dead code

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362030: [analyzer] Remove EndPath function as it is dead 
code (authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53720?vs=171151=202049#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D53720

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2316,7 +2316,6 @@
Pred->getStackFrame()->getParent()));
 
   PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
-  StateMgr.EndPath(Pred->getState());
 
   ExplodedNodeSet Dst;
   if (Pred->getLocationContext()->inTopFrame()) {
Index: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -166,8 +166,6 @@
  const char *NL, unsigned int Space,
  bool IsDot) const = 0;
 
-  virtual void EndPath(ProgramStateRef state) {}
-
   /// Convenience method to query the state to see if a symbol is null or
   /// not null, or if neither assumption can be made.
   ConditionTruthVal isNull(ProgramStateRef State, SymbolRef Sym) {
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -634,10 +634,6 @@
 
 return ProgramStateTrait::MakeContext(p);
   }
-
-  void EndPath(ProgramStateRef St) {
-ConstraintMgr->EndPath(St);
-  }
 };
 
 


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2316,7 +2316,6 @@
Pred->getStackFrame()->getParent()));
 
   PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
-  StateMgr.EndPath(Pred->getState());
 
   ExplodedNodeSet Dst;
   if (Pred->getLocationContext()->inTopFrame()) {
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -166,8 +166,6 @@
  const char *NL, unsigned int Space,
  bool IsDot) const = 0;
 
-  virtual void EndPath(ProgramStateRef state) {}
-
   /// Convenience method to query the state to see if a symbol is null or
   /// not null, or if neither assumption can be made.
   ConditionTruthVal isNull(ProgramStateRef State, SymbolRef Sym) {
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -634,10 +634,6 @@
 
 return ProgramStateTrait::MakeContext(p);
   }
-
-  void EndPath(ProgramStateRef St) {
-ConstraintMgr->EndPath(St);
-  }
 };
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62623: Reduce memory consumption of coverage dumps

2019-05-29 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk added a comment.

@serge-sans-paille testing it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62623



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


r362030 - [analyzer] Remove EndPath function as it is dead code

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 13:47:27 2019
New Revision: 362030

URL: http://llvm.org/viewvc/llvm-project?rev=362030=rev
Log:
[analyzer] Remove EndPath function as it is dead code

Summary: -

Reviewers: george.karpenkov

Reviewed By: george.karpenkov

Subscribers: baloghadamsoftware, cfe-commits, xazax.hun, szepet, a.sidorin,
 mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=362030=362029=362030=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
Wed May 29 13:47:27 2019
@@ -166,8 +166,6 @@ public:
  const char *NL, unsigned int Space,
  bool IsDot) const = 0;
 
-  virtual void EndPath(ProgramStateRef state) {}
-
   /// Convenience method to query the state to see if a symbol is null or
   /// not null, or if neither assumption can be made.
   ConditionTruthVal isNull(ProgramStateRef State, SymbolRef Sym) {

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=362030=362029=362030=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Wed May 29 13:47:27 2019
@@ -634,10 +634,6 @@ public:
 
 return ProgramStateTrait::MakeContext(p);
   }
-
-  void EndPath(ProgramStateRef St) {
-ConstraintMgr->EndPath(St);
-  }
 };
 
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=362030=362029=362030=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed May 29 13:47:27 2019
@@ -2316,7 +2316,6 @@ void ExprEngine::processEndOfFunction(No
Pred->getStackFrame()->getParent()));
 
   PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
-  StateMgr.EndPath(Pred->getState());
 
   ExplodedNodeSet Dst;
   if (Pred->getLocationContext()->inTopFrame()) {


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


r362028 - Revert "LLVM IR: update Clang tests for byval being a typed attribute."

2019-05-29 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed May 29 13:45:32 2019
New Revision: 362028

URL: http://llvm.org/viewvc/llvm-project?rev=362028=rev
Log:
Revert "LLVM IR: update Clang tests for byval being a typed attribute."

The underlying LLVM change couldn't cope with llvm-link and broke LTO builds.

Modified:
cfe/trunk/test/CodeGen/aapcs-align.cpp
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
cfe/trunk/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl

Modified: cfe/trunk/test/CodeGen/aapcs-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aapcs-align.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGen/aapcs-align.cpp (original)
+++ cfe/trunk/test/CodeGen/aapcs-align.cpp Wed May 29 13:45:32 2019
@@ -95,8 +95,8 @@ void g4() {
   f4m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define void @g4
-// CHECK: call void @f4(i32 1, %struct.SF16* nonnull byval align 8
-// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
nonnull byval align 8
+// CHECK: call void @f4(i32 1, %struct.SF16* byval nonnull align 8
+// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
byval nonnull align 8
 // CHECK: declare void @f4(i32, %struct.SF16* byval align 8)
 // CHECK: declare void @f4m(i32, i32, i32, i32, i32, %struct.SF16* byval align 
8)
 

Modified: cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp Wed May 29 13:45:32 
2019
@@ -104,7 +104,7 @@ struct TestInit {
 //
 // CHECK-CTOR-GLOBAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP_ONE:[^,]*]],
 // CHECK-CTOR-GLOBAL-SAME: i32 3400, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{.*}}%[[TMP_ONE]])
+// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{[^%]*}}%[[TMP_ONE]])
 #line 3400 "GlobalInitVal.cpp"
 TestInit GlobalInitVal;
 
@@ -119,7 +119,7 @@ extern "C" void test_init_function() {
 //
 // CHECK-CTOR-LOCAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP:[^,]*]],
 // CHECK-CTOR-LOCAL-SAME: i32 3500, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{.*}}%[[TMP]])
+// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{[^%]*}}%[[TMP]])
 #line 3500 "LocalInitVal.cpp"
   TestInit init_local;
   sink(init_local);

Modified: cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp Wed May 29 13:45:32 2019
@@ -30,12 +30,12 @@ struct two_fields {
   double d, e;
 };
 test(two_fields);
-// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* nocapture readonly byval align 8 
%{{.*}})
+// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 
%{{.*}})
 //
 // CHECK: define void @_Z15test_two_fieldsv()
 // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8
 // CHECK: call void @_Z14def_two_fieldsv(%struct.two_fields* nonnull sret 
%[[tmp]])
-// CHECK: call void @_Z3use10two_fields(%struct.two_fields* nonnull byval 
align 8 %[[tmp]])
+// CHECK: call void @_Z3use10two_fields(%struct.two_fields* byval nonnull 
align 8 %[[tmp]])
 // CHECK: ret void
 //
 // CHECK: declare void @_Z3use10two_fields(%struct.two_fields* byval align 8)

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp Wed May 29 13:45:32 
2019
@@ -20,7 +20,7 

[PATCH] D58207: [analyzer] ConditionBRVisitor: Boolean support

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362027: [analyzer] ConditionBRVisitor: Boolean support 
(authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58207?vs=195074=202047#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58207

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
  cfe/trunk/test/Analysis/inner-pointer.cpp
  cfe/trunk/test/Analysis/use-after-move.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2323,10 +2323,17 @@
   if (!IsAssuming)
 IntValue = getConcreteIntegerValue(CondVarExpr, N);
 
-  if (IsAssuming || !IntValue.hasValue())
-Out << (TookTrue ? "not equal to 0" : "0");
-  else
-Out << *IntValue.getValue();
+  if (IsAssuming || !IntValue.hasValue()) {
+if (Ty->isBooleanType())
+  Out << (TookTrue ? "true" : "false");
+else
+  Out << (TookTrue ? "not equal to 0" : "0");
+  } else {
+if (Ty->isBooleanType())
+  Out << (IntValue.getValue()->getBoolValue() ? "true" : "false");
+else
+  Out << *IntValue.getValue();
+  }
 
   return true;
 }
Index: cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
===
--- cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
+++ cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
@@ -829,9 +829,9 @@

  
  extended_message
- fail is 1
+ fail is true
  message
- fail is 1
+ fail is true
 
 
  kindcontrol
Index: cfe/trunk/test/Analysis/inner-pointer.cpp
===
--- cfe/trunk/test/Analysis/inner-pointer.cpp
+++ cfe/trunk/test/Analysis/inner-pointer.cpp
@@ -38,9 +38,9 @@
   std::string s;
   const char *c2 = s.c_str();
   if (cond) {
-// expected-note@-1 {{Assuming 'cond' is not equal to 0}}
+// expected-note@-1 {{Assuming 'cond' is true}}
 // expected-note@-2 {{Taking true branch}}
-// expected-note@-3 {{Assuming 'cond' is 0}}
+// expected-note@-3 {{Assuming 'cond' is false}}
 // expected-note@-4 {{Taking false branch}}
 consume(c); // expected-warning {{Inner pointer of container used after re/deallocation}}
 // expected-note@-1 {{Inner pointer of container used after re/deallocation}}
@@ -73,9 +73,9 @@
   std::wstring s;
   const wchar_t *c2 = s.c_str();
   if (cond) {
-// expected-note@-1 {{Assuming 'cond' is not equal to 0}}
+// expected-note@-1 {{Assuming 'cond' is true}}
 // expected-note@-2 {{Taking true branch}}
-// expected-note@-3 {{Assuming 'cond' is 0}}
+// expected-note@-3 {{Assuming 'cond' is false}}
 // expected-note@-4 {{Taking false branch}}
 consume(c); // expected-warning {{Inner pointer of container used after re/deallocation}}
 // expected-note@-1 {{Inner pointer of container used after re/deallocation}}
@@ -122,9 +122,9 @@
   std::string s2;
   const char *c2 = s2.c_str();
   if (cond) {
-// expected-note@-1 {{Assuming 'cond' is not equal to 0}}
+// expected-note@-1 {{Assuming 'cond' is true}}
 // expected-note@-2 {{Taking true branch}}
-// expected-note@-3 {{Assuming 'cond' is 0}}
+// expected-note@-3 {{Assuming 'cond' is false}}
 // expected-note@-4 {{Taking false branch}}
 consume(c1); // expected-warning {{Inner pointer of container used after re/deallocation}}
 // expected-note@-1 {{Inner pointer of container used after re/deallocation}}
Index: cfe/trunk/test/Analysis/use-after-move.cpp
===
--- cfe/trunk/test/Analysis/use-after-move.cpp
+++ cfe/trunk/test/Analysis/use-after-move.cpp
@@ -395,7 +395,7 @@
   A b;
   b = std::move(a); // peaceful-note {{Object 'a' is moved}}
 
-  if (cond) { // peaceful-note {{Assuming 'cond' is not equal to 0}}
+  if (cond) { // peaceful-note {{Assuming 'cond' is true}}
   // peaceful-note@-1 {{Taking true branch}}
 a.foo(); // peaceful-warning {{Method called on moved-from object 'a'}}
  // peaceful-note@-1 {{Method called on moved-from object 'a'}}
Index: cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
===
--- cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
+++ cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
@@ -102,7 +102,7 @@
 
   C(int pX, 

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D62603#1521832 , @tra wrote:

> In D62603#1521792 , @hliao wrote:
>
> > that should assume that variable is not declared with `static`. that's also 
> > the motivation of this patch.
>
>
> cppreference defines internal linkage as 'The name can be referred to from 
> all scopes in the current translation unit.'
>  The current translation unit in CUDA context gets a bit murky. On one hand 
> host and device are compiled separately, and may conceivably be considered 
> separate TUs. On the other hand, the fact that we mix host and device code in 
> the same source file implies tight coupling and the users do expect them to 
> be treated as if all host and device code in the source file is in the same 
> TU. E.g. you may have a kernel in an anonymous namespace yet you do want to 
> be able to launch it from the host side.
>
> I think `static __device__` globals would fall into the same category -- 
> nominally they should not be visible outside of device-side object file, but 
> in practice we do need to make them visible from the host side of the same TU.


Are you sure nvcc support accessing static `__device__` variables in host code? 
That would be expensive to implement. Instead of looking up dynamic symble 
tables only, now we need to look up symbol tables for local symbols. Also we 
have to differentiate local symbols that have the same name. This also means 
user can not strip symbol tables.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


r362027 - [analyzer] ConditionBRVisitor: Boolean support

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 13:34:29 2019
New Revision: 362027

URL: http://llvm.org/viewvc/llvm-project?rev=362027=rev
Log:
[analyzer] ConditionBRVisitor: Boolean support

Summary: -

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ, george.karpenkov

Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin,
 mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
cfe/trunk/test/Analysis/inner-pointer.cpp
cfe/trunk/test/Analysis/use-after-move.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=362027=362026=362027=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed May 29 
13:34:29 2019
@@ -2323,10 +2323,17 @@ bool ConditionBRVisitor::printValue(cons
   if (!IsAssuming)
 IntValue = getConcreteIntegerValue(CondVarExpr, N);
 
-  if (IsAssuming || !IntValue.hasValue())
-Out << (TookTrue ? "not equal to 0" : "0");
-  else
-Out << *IntValue.getValue();
+  if (IsAssuming || !IntValue.hasValue()) {
+if (Ty->isBooleanType())
+  Out << (TookTrue ? "true" : "false");
+else
+  Out << (TookTrue ? "not equal to 0" : "0");
+  } else {
+if (Ty->isBooleanType())
+  Out << (IntValue.getValue()->getBoolValue() ? "true" : "false");
+else
+  Out << *IntValue.getValue();
+  }
 
   return true;
 }

Modified: cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist?rev=362027=362026=362027=diff
==
--- cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist 
(original)
+++ cfe/trunk/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist Wed 
May 29 13:34:29 2019
@@ -829,9 +829,9 @@

  
  extended_message
- fail is 1
+ fail is true
  message
- fail is 1
+ fail is true
 
 
  kindcontrol

Modified: cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp?rev=362027=362026=362027=diff
==
--- cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp (original)
+++ cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp Wed May 29 
13:34:29 2019
@@ -102,7 +102,7 @@ struct C {
 
   C(int pX, int pY, bool Flag) {
 x = pX;
-if (Flag) // expected-note{{Assuming 'Flag' is not equal to 0}}
+if (Flag) // expected-note{{Assuming 'Flag' is true}}
   // expected-note@-1{{Taking true branch}}
   return; // expected-note{{Returning without writing to 'this->y'}}
 y = pY;

Modified: cfe/trunk/test/Analysis/inner-pointer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inner-pointer.cpp?rev=362027=362026=362027=diff
==
--- cfe/trunk/test/Analysis/inner-pointer.cpp (original)
+++ cfe/trunk/test/Analysis/inner-pointer.cpp Wed May 29 13:34:29 2019
@@ -38,9 +38,9 @@ void deref_after_scope_char(bool cond) {
   std::string s;
   const char *c2 = s.c_str();
   if (cond) {
-// expected-note@-1 {{Assuming 'cond' is not equal to 0}}
+// expected-note@-1 {{Assuming 'cond' is true}}
 // expected-note@-2 {{Taking true branch}}
-// expected-note@-3 {{Assuming 'cond' is 0}}
+// expected-note@-3 {{Assuming 'cond' is false}}
 // expected-note@-4 {{Taking false branch}}
 consume(c); // expected-warning {{Inner pointer of container used after 
re/deallocation}}
 // expected-note@-1 {{Inner pointer of container used after 
re/deallocation}}
@@ -73,9 +73,9 @@ void deref_after_scope_wchar_t(bool cond
   std::wstring s;
   const wchar_t *c2 = s.c_str();
   if (cond) {
-// expected-note@-1 {{Assuming 'cond' is not equal to 0}}
+// expected-note@-1 {{Assuming 'cond' is true}}
 // expected-note@-2 {{Taking true branch}}
-// expected-note@-3 {{Assuming 'cond' is 0}}
+// expected-note@-3 {{Assuming 'cond' is false}}
 // expected-note@-4 {{Taking false branch}}
 consume(c); // expected-warning {{Inner pointer of container used after 
re/deallocation}}
 // expected-note@-1 {{Inner pointer of container used after 
re/deallocation}}
@@ -122,9 +122,9 @@ void 

[PATCH] D58206: [analyzer] ConditionBRVisitor: MemberExpr support

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC362026: [analyzer] ConditionBRVisitor: MemberExpr support 
(authored by Charusso, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58206?vs=195073=202044#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58206

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  
test/Analysis/diagnostics/Inputs/expected-plists/deref-track-symbolic-region.c.plist
  test/Analysis/diagnostics/deref-track-symbolic-region.c
  test/Analysis/diagnostics/dtors.cpp
  test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
  test/Analysis/inlining/path-notes.cpp
  test/Analysis/null-deref-path-notes.cpp
  test/Analysis/osobject-retain-release.cpp
  test/Analysis/uninit-vals.m

Index: include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -203,6 +203,11 @@
 bool TookTrue, bool IsAssuming);
 
   std::shared_ptr
+  VisitTrueTest(const Expr *Cond, const MemberExpr *ME, BugReporterContext ,
+BugReport , const ExplodedNode *N, bool TookTrue,
+bool IsAssuming);
+
+  std::shared_ptr
   VisitConditionVariable(StringRef LhsString, const Expr *CondVarExpr,
  BugReporterContext , BugReport ,
  const ExplodedNode *N, bool TookTrue);
@@ -225,7 +230,8 @@
 BugReporterContext ,
 BugReport ,
 const ExplodedNode *N,
-Optional );
+Optional ,
+bool IsSameFieldName);
 
   static bool isPieceMessageGeneric(const PathDiagnosticPiece *Piece);
 };
Index: test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
===
--- test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
+++ test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
@@ -4271,9 +4271,9 @@
  
  depth0
  extended_message
- Assuming pointer value is null
+ Assuming field arr is null
  message
- Assuming pointer value is null
+ Assuming field arr is null
 
 
  kindcontrol
Index: test/Analysis/inlining/path-notes.cpp
===
--- test/Analysis/inlining/path-notes.cpp
+++ test/Analysis/inlining/path-notes.cpp
@@ -231,7 +231,7 @@
 };
 
 void Owner::testGetDerefExprOnMemberExprWithADot() {
-	if (arr)  // expected-note {{Assuming pointer value is null}}
+	if (arr)  // expected-note {{Assuming field 'arr' is null}}
 // expected-note@-1 {{Taking false branch}}
 	  ;
 	arr[1].x = 1; //expected-warning {{Dereference of null pointer}}
Index: test/Analysis/diagnostics/Inputs/expected-plists/deref-track-symbolic-region.c.plist
===
--- test/Analysis/diagnostics/Inputs/expected-plists/deref-track-symbolic-region.c.plist
+++ test/Analysis/diagnostics/Inputs/expected-plists/deref-track-symbolic-region.c.plist
@@ -165,9 +165,9 @@
  
  depth0
  extended_message
- Assuming pointer value is null
+ Assuming field x is null
  message
- Assuming pointer value is null
+ Assuming field x is null
 
 
  kindcontrol
@@ -454,9 +454,9 @@
  
  depth0
  extended_message
- Assuming pointer value is null
+ Assuming field x is null
  message
- Assuming pointer value is null
+ Assuming field x is null
 
 
  kindcontrol
Index: test/Analysis/diagnostics/dtors.cpp
===
--- test/Analysis/diagnostics/dtors.cpp
+++ test/Analysis/diagnostics/dtors.cpp
@@ -16,10 +16,11 @@
   S *s;
   smart_ptr(S *);
   S *get() {
-return (x || 0) ? nullptr : s; // expected-note{{Left side of '||' is false}}
-   // expected-note@-1{{'?' condition is false}}
-   // expected-warning@-2{{Use of memory after it is freed}}
-   // expected-note@-3{{Use of memory after it is freed}}
+return (x || 0) ? nullptr : s; // expected-note{{Field 'x' is 0}}
+   // expected-note@-1{{Left side of '||' is false}}
+   // expected-note@-2{{'?' condition is false}}
+   // expected-warning@-3{{Use of memory after it is freed}}
+   // expected-note@-4{{Use of memory after it 

r362026 - [analyzer] ConditionBRVisitor: MemberExpr support

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 13:29:02 2019
New Revision: 362026

URL: http://llvm.org/viewvc/llvm-project?rev=362026=rev
Log:
[analyzer] ConditionBRVisitor: MemberExpr support

Summary: -

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ

Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin,
 mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/Inputs/expected-plists/edges-new.mm.plist

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-plists/deref-track-symbolic-region.c.plist
cfe/trunk/test/Analysis/diagnostics/deref-track-symbolic-region.c
cfe/trunk/test/Analysis/diagnostics/dtors.cpp
cfe/trunk/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
cfe/trunk/test/Analysis/inlining/path-notes.cpp
cfe/trunk/test/Analysis/null-deref-path-notes.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
cfe/trunk/test/Analysis/uninit-vals.m

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=362026=362025=362026=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Wed May 29 13:29:02 2019
@@ -203,6 +203,11 @@ public:
 bool TookTrue, bool IsAssuming);
 
   std::shared_ptr
+  VisitTrueTest(const Expr *Cond, const MemberExpr *ME, BugReporterContext 
,
+BugReport , const ExplodedNode *N, bool TookTrue,
+bool IsAssuming);
+
+  std::shared_ptr
   VisitConditionVariable(StringRef LhsString, const Expr *CondVarExpr,
  BugReporterContext , BugReport ,
  const ExplodedNode *N, bool TookTrue);
@@ -225,7 +230,8 @@ public:
 BugReporterContext ,
 BugReport ,
 const ExplodedNode *N,
-Optional );
+Optional ,
+bool IsSameFieldName);
 
   static bool isPieceMessageGeneric(const PathDiagnosticPiece *Piece);
 };

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=362026=362025=362026=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed May 29 
13:29:02 2019
@@ -1991,6 +1991,11 @@ ConditionBRVisitor::VisitTrueTest(const
BRC, R, N, TookTrueTmp, IsAssuming))
   return P;
 break;
+  case Stmt::MemberExprClass:
+if (auto P = VisitTrueTest(Cond, cast(CondTmp),
+   BRC, R, N, TookTrueTmp, IsAssuming))
+  return P;
+break;
   case Stmt::UnaryOperatorClass: {
 const auto *UO = cast(CondTmp);
 if (UO->getOpcode() == UO_LNot) {
@@ -2025,7 +2030,8 @@ bool ConditionBRVisitor::patternMatch(co
   BugReporterContext ,
   BugReport ,
   const ExplodedNode *N,
-  Optional ) {
+  Optional ,
+  bool IsSameFieldName) {
   const Expr *OriginalExpr = Ex;
   Ex = Ex->IgnoreParenCasts();
 
@@ -2091,6 +2097,17 @@ bool ConditionBRVisitor::patternMatch(co
 return false;
   }
 
+  if (const auto *ME = dyn_cast(Ex)) {
+if (!IsSameFieldName)
+  Out << "field '" << ME->getMemberDecl()->getName() << '\'';
+else
+  Out << '\''
+  << Lexer::getSourceText(
+ CharSourceRange::getTokenRange(Ex->getSourceRange()),
+ BRC.getSourceManager(), BRC.getASTContext().getLangOpts(), 0)
+  << '\'';
+  }
+
   return false;
 }
 
@@ -2100,13 +2117,23 @@ std::shared_ptr Con
   bool shouldInvert = false;
   Optional shouldPrune;
 
+  // Check if the field name of the MemberExprs is ambiguous. Example:
+  // " 'a.d' is equal to 'h.d' " in 'test/Analysis/null-deref-path-notes.cpp'.
+  bool IsSameFieldName = false;
+  if (const auto *LhsME =
+  dyn_cast(BExpr->getLHS()->IgnoreParenCasts()))
+if (const auto *RhsME =
+dyn_cast(BExpr->getRHS()->IgnoreParenCasts()))
+  IsSameFieldName = LhsME->getMemberDecl()->getName() ==
+

[PATCH] D58199: [analyzer] ConditionBRVisitor: Remove duplicated code

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362025: [analyzer] ConditionBRVisitor: Remove duplicated 
code (authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58199?vs=195072=202041#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58199

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -207,6 +207,18 @@
  BugReporterContext , BugReport ,
  const ExplodedNode *N, bool TookTrue);
 
+  /// Tries to print the value of the given expression.
+  ///
+  /// \param CondVarExpr The expression to print its value.
+  /// \param Out The stream to print.
+  /// \param N The node where we encountered the condition.
+  /// \param TookTrue Whether we took the \c true branch of the condition.
+  ///
+  /// \return Whether the print was successful. (The printing is successful if
+  /// we model the value and we could obtain it.)
+  bool printValue(const Expr *CondVarExpr, raw_ostream ,
+  const ExplodedNode *N, bool TookTrue, bool IsAssuming);
+
   bool patternMatch(const Expr *Ex,
 const Expr *ParentEx,
 raw_ostream ,
Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2190,17 +2190,7 @@
   llvm::raw_svector_ostream Out(buf);
   Out << "Assuming " << LhsString << " is ";
 
-  QualType Ty = CondVarExpr->getType();
-
-  if (Ty->isPointerType())
-Out << (TookTrue ? "not null" : "null");
-  else if (Ty->isObjCObjectPointerType())
-Out << (TookTrue ? "not nil" : "nil");
-  else if (Ty->isBooleanType())
-Out << (TookTrue ? "true" : "false");
-  else if (Ty->isIntegralOrEnumerationType())
-Out << (TookTrue ? "non-zero" : "zero");
-  else
+  if (!printValue(CondVarExpr, Out, N, TookTrue, /*IsAssuming=*/true))
 return nullptr;
 
   const LocationContext *LCtx = N->getLocationContext();
@@ -2232,22 +,7 @@
 
   Out << (IsAssuming ? "Assuming '" : "'") << VD->getDeclName() << "' is ";
 
-  QualType Ty = VD->getType();
-
-  if (Ty->isPointerType())
-Out << (TookTrue ? "non-null" : "null");
-  else if (Ty->isObjCObjectPointerType())
-Out << (TookTrue ? "non-nil" : "nil");
-  else if (Ty->isScalarType()) {
-Optional IntValue;
-if (!IsAssuming)
-  IntValue = getConcreteIntegerValue(DRE, N);
-
-if (IsAssuming || !IntValue.hasValue())
-  Out << (TookTrue ? "not equal to 0" : "0");
-else
-  Out << *IntValue.getValue();
-  } else
+  if (!printValue(DRE, Out, N, TookTrue, IsAssuming))
 return nullptr;
 
   const LocationContext *LCtx = N->getLocationContext();
@@ -2271,6 +2246,36 @@
   return std::move(event);
 }
 
+bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream ,
+const ExplodedNode *N, bool TookTrue,
+bool IsAssuming) {
+  QualType Ty = CondVarExpr->getType();
+
+  if (Ty->isPointerType()) {
+Out << (TookTrue ? "non-null" : "null");
+return true;
+  }
+
+  if (Ty->isObjCObjectPointerType()) {
+Out << (TookTrue ? "non-nil" : "nil");
+return true;
+  }
+
+  if (!Ty->isIntegralOrEnumerationType())
+return false;
+
+  Optional IntValue;
+  if (!IsAssuming)
+IntValue = getConcreteIntegerValue(CondVarExpr, N);
+
+  if (IsAssuming || !IntValue.hasValue())
+Out << (TookTrue ? "not equal to 0" : "0");
+  else
+Out << *IntValue.getValue();
+
+  return true;
+}
+
 const char *const ConditionBRVisitor::GenericTrueMessage =
 "Assuming the condition is true";
 const char *const ConditionBRVisitor::GenericFalseMessage =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62623: Reduce memory consumption of coverage dumps

2019-05-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: vsk, arphaman.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
serge-sans-paille edited the summary of this revision.

Avoiding an intermediate join operation, which in turns removes the need for an
intermediate buffer that may be quite large, as showcased by

  https://bugs.llvm.org/show_bug.cgi?id=41965


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62623

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp


Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1388,10 +1388,12 @@
   std::string FilenamesAndCoverageMappings;
   llvm::raw_string_ostream OS(FilenamesAndCoverageMappings);
   CoverageFilenamesSectionWriter(FilenameRefs).write(OS);
-  std::string RawCoverageMappings =
-  llvm::join(CoverageMappings.begin(), CoverageMappings.end(), "");
-  OS << RawCoverageMappings;
-  size_t CoverageMappingSize = RawCoverageMappings.size();
+
+  size_t CoverageMappingSize = 0;
+  for (auto  : CoverageMappings) {
+CoverageMappingSize += S.size();
+OS << std::move(S);
+  }
   size_t FilenamesSize = OS.str().size() - CoverageMappingSize;
   // Append extra zeroes if necessary to ensure that the size of the filenames
   // and coverage mappings is a multiple of 8.


Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1388,10 +1388,12 @@
   std::string FilenamesAndCoverageMappings;
   llvm::raw_string_ostream OS(FilenamesAndCoverageMappings);
   CoverageFilenamesSectionWriter(FilenameRefs).write(OS);
-  std::string RawCoverageMappings =
-  llvm::join(CoverageMappings.begin(), CoverageMappings.end(), "");
-  OS << RawCoverageMappings;
-  size_t CoverageMappingSize = RawCoverageMappings.size();
+
+  size_t CoverageMappingSize = 0;
+  for (auto  : CoverageMappings) {
+CoverageMappingSize += S.size();
+OS << std::move(S);
+  }
   size_t FilenamesSize = OS.str().size() - CoverageMappingSize;
   // Append extra zeroes if necessary to ensure that the size of the filenames
   // and coverage mappings is a multiple of 8.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362025 - [analyzer] ConditionBRVisitor: Remove duplicated code

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 13:18:07 2019
New Revision: 362025

URL: http://llvm.org/viewvc/llvm-project?rev=362025=rev
Log:
[analyzer] ConditionBRVisitor: Remove duplicated code

Summary: -

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ

Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin,
 mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=362025=362024=362025=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Wed May 29 13:18:07 2019
@@ -207,6 +207,18 @@ public:
  BugReporterContext , BugReport ,
  const ExplodedNode *N, bool TookTrue);
 
+  /// Tries to print the value of the given expression.
+  ///
+  /// \param CondVarExpr The expression to print its value.
+  /// \param Out The stream to print.
+  /// \param N The node where we encountered the condition.
+  /// \param TookTrue Whether we took the \c true branch of the condition.
+  ///
+  /// \return Whether the print was successful. (The printing is successful if
+  /// we model the value and we could obtain it.)
+  bool printValue(const Expr *CondVarExpr, raw_ostream ,
+  const ExplodedNode *N, bool TookTrue, bool IsAssuming);
+
   bool patternMatch(const Expr *Ex,
 const Expr *ParentEx,
 raw_ostream ,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=362025=362024=362025=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed May 29 
13:18:07 2019
@@ -2190,17 +2190,7 @@ std::shared_ptr Con
   llvm::raw_svector_ostream Out(buf);
   Out << "Assuming " << LhsString << " is ";
 
-  QualType Ty = CondVarExpr->getType();
-
-  if (Ty->isPointerType())
-Out << (TookTrue ? "not null" : "null");
-  else if (Ty->isObjCObjectPointerType())
-Out << (TookTrue ? "not nil" : "nil");
-  else if (Ty->isBooleanType())
-Out << (TookTrue ? "true" : "false");
-  else if (Ty->isIntegralOrEnumerationType())
-Out << (TookTrue ? "non-zero" : "zero");
-  else
+  if (!printValue(CondVarExpr, Out, N, TookTrue, /*IsAssuming=*/true))
 return nullptr;
 
   const LocationContext *LCtx = N->getLocationContext();
@@ -2232,22 +,7 @@ std::shared_ptr Con
 
   Out << (IsAssuming ? "Assuming '" : "'") << VD->getDeclName() << "' is ";
 
-  QualType Ty = VD->getType();
-
-  if (Ty->isPointerType())
-Out << (TookTrue ? "non-null" : "null");
-  else if (Ty->isObjCObjectPointerType())
-Out << (TookTrue ? "non-nil" : "nil");
-  else if (Ty->isScalarType()) {
-Optional IntValue;
-if (!IsAssuming)
-  IntValue = getConcreteIntegerValue(DRE, N);
-
-if (IsAssuming || !IntValue.hasValue())
-  Out << (TookTrue ? "not equal to 0" : "0");
-else
-  Out << *IntValue.getValue();
-  } else
+  if (!printValue(DRE, Out, N, TookTrue, IsAssuming))
 return nullptr;
 
   const LocationContext *LCtx = N->getLocationContext();
@@ -2271,6 +2246,36 @@ std::shared_ptr Con
   return std::move(event);
 }
 
+bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream ,
+const ExplodedNode *N, bool TookTrue,
+bool IsAssuming) {
+  QualType Ty = CondVarExpr->getType();
+
+  if (Ty->isPointerType()) {
+Out << (TookTrue ? "non-null" : "null");
+return true;
+  }
+
+  if (Ty->isObjCObjectPointerType()) {
+Out << (TookTrue ? "non-nil" : "nil");
+return true;
+  }
+
+  if (!Ty->isIntegralOrEnumerationType())
+return false;
+
+  Optional IntValue;
+  if (!IsAssuming)
+IntValue = getConcreteIntegerValue(CondVarExpr, N);
+
+  if (IsAssuming || !IntValue.hasValue())
+Out << (TookTrue ? "not equal to 0" : "0");
+  else
+Out << *IntValue.getValue();
+
+  return true;
+}
+
 const char *const ConditionBRVisitor::GenericTrueMessage =
 "Assuming the condition is true";
 const char *const ConditionBRVisitor::GenericFalseMessage =


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D61060: [analyzer] ConditionBRVisitor: Test 'add-pop-up-notes=false'

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362023: [analyzer] ConditionBRVisitor: Test 
add-pop-up-notes=false (authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61060?vs=196425=202037#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61060

Files:
  cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  cfe/trunk/test/Analysis/NewDelete-path-notes.cpp

Index: cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
===
--- cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
+++ cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
@@ -13,30 +13,30 @@
  kindevent
  location
  
-  line7
-  col12
+  line24
+  col3
   file0
  
  ranges
  

 
- line7
- col12
+ line24
+ col3
  file0
 
 
- line7
- col18
+ line24
+ col10
  file0
 

  
  depth0
  extended_message
- Memory is allocated
+ Attempt to free released memory
  message
- Memory is allocated
+ Attempt to free released memory
 
 
  kindcontrol
@@ -46,26 +46,26 @@
 start
  
   
-   line7
-   col3
+   line17
+   col1
file0
   
   
-   line7
-   col5
+   line17
+   col4
file0
   
  
 end
  
   
-   line9
+   line18
col3
file0
   
   
-   line9
-   col4
+   line18
+   col5
file0
   
  
@@ -73,6 +73,35 @@
   
 
 
+ kindevent
+ location
+ 
+  line18
+  col12
+  file0
+ 
+ ranges
+ 
+   
+
+ line18
+ col12
+ file0
+
+
+ line18
+ col18
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ Memory is allocated
+ message
+ Memory is allocated
+
+
  kindcontrol
  edges
   
@@ -80,26 +109,26 @@
 start
  
   
-   line9
+   line18
col3
file0
   
   
-   line9
-   col4
+   line18
+   col5
file0
   
  
 end
  
   
-   line9
-   col7
+   line20
+   col3
file0
   
   
-   line9
-   col7
+   line20
+   col4
file0
   
  
@@ -107,34 +136,6 @@
   
 
 
- kindpop-up
- location
- 
-  line9
-  col7
-  file0
- 
- ranges
- 
-   
-
- line9
- col7
- file0
-
-
- line9
- col7
- file0
-
-   
- 
- extended_message
- p is non-null
- message
- p is non-null
-
-
  kindcontrol
  edges
   
@@ -142,25 +143,25 @@
 start
  
   
-   line9
-   col7
+   line20
+   col3
file0
   
   
-   line9
-   col7
+   line20
+   col4
file0
   
  
 end
  
   
-   line11
+   line21
col5
file0
   
   
-   line11
+   line21
col10
file0
   
@@ -172,7 +173,7 @@
  kindevent
  location
  
-  line11
+  line21
   col5
   file0
  
@@ -180,12 +181,12 @@
  

 
- line11
+ line21
  col5
  file0
 
 
- line11
+ line21
  col12
  file0
 
@@ -205,12 +206,12 @@
 start
  
   
-   line11
+   line21
col5
file0
   
   
-   line11
+   line21
col10
file0
   
@@ -218,12 +219,12 @@
 end
  
   
-   line14
+   line24
col3
file0
   
   
-   line14
+   line24
col8
file0
   
@@ -231,35 +232,6 @@

   
 
-
- kindevent
- location
- 
-  line14
-  col3
-  file0
- 
- ranges
- 
-   
-
- line14
- col3
- file0
-   

r362023 - [analyzer] ConditionBRVisitor: Test 'add-pop-up-notes=false'

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 13:13:29 2019
New Revision: 362023

URL: http://llvm.org/viewvc/llvm-project?rev=362023=rev
Log:
[analyzer] ConditionBRVisitor: Test 'add-pop-up-notes=false'

Summary: -

Reviewers: NoQ, alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin,
 mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:

cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
cfe/trunk/test/Analysis/NewDelete-path-notes.cpp

Modified: 
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist?rev=362023=362022=362023=diff
==
--- 
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist 
(original)
+++ 
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist 
Wed May 29 13:13:29 2019
@@ -13,30 +13,30 @@
  kindevent
  location
  
-  line7
-  col12
+  line24
+  col3
   file0
  
  ranges
  

 
- line7
- col12
+ line24
+ col3
  file0
 
 
- line7
- col18
+ line24
+ col10
  file0
 

  
  depth0
  extended_message
- Memory is allocated
+ Attempt to free released memory
  message
- Memory is allocated
+ Attempt to free released memory
 
 
  kindcontrol
@@ -46,26 +46,26 @@
 start
  
   
-   line7
-   col3
+   line17
+   col1
file0
   
   
-   line7
-   col5
+   line17
+   col4
file0
   
  
 end
  
   
-   line9
+   line18
col3
file0
   
   
-   line9
-   col4
+   line18
+   col5
file0
   
  
@@ -73,6 +73,35 @@
   
 
 
+ kindevent
+ location
+ 
+  line18
+  col12
+  file0
+ 
+ ranges
+ 
+   
+
+ line18
+ col12
+ file0
+
+
+ line18
+ col18
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ Memory is allocated
+ message
+ Memory is allocated
+
+
  kindcontrol
  edges
   
@@ -80,26 +109,26 @@
 start
  
   
-   line9
+   line18
col3
file0
   
   
-   line9
-   col4
+   line18
+   col5
file0
   
  
 end
  
   
-   line9
-   col7
+   line20
+   col3
file0
   
   
-   line9
-   col7
+   line20
+   col4
file0
   
  
@@ -107,34 +136,6 @@
   
 
 
- kindpop-up
- location
- 
-  line9
-  col7
-  file0
- 
- ranges
- 
-   
-
- line9
- col7
- file0
-
-
- line9
- col7
- file0
-
-   
- 
- extended_message
- p is non-null
- message
- p is non-null
-
-
  kindcontrol
  edges
   
@@ -142,25 +143,25 @@
 start
  
   
-   line9
-   col7
+   line20
+   col3
file0
   
   
-   line9
-   col7
+   line20
+   col4
file0
   
  
 end
  
   
-   line11
+   line21
col5
file0
   
   
-   line11
+   line21
col10
file0
   
@@ -172,7 +173,7 @@
  kindevent
  location
  
-  line11
+  line21
   col5
   file0
  
@@ -180,12 +181,12 @@
  

 
- line11
+ line21
  col5
  file0
 
 
- line11
+ line21
  col12
  file0
 
@@ -205,12 +206,12 @@
 start
  
   
-   line11
+   line21
col5
file0
   
   
-   line11
+   line21
col10
file0
   
@@ -218,12 +219,12 @@
 end
  
   
-   line14
+   line24
col3
file0
   
   
-   line14
+   line24
col8
file0
   
@@ -231,35 +232,6 @@


[PATCH] D62622: [CMake] Provide an option to use relative paths in debug info

2019-05-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: beanz, smeenai.
Herald added subscribers: llvm-commits, cfe-commits, aprantl, mgorny.
Herald added projects: clang, LLVM.

CMake always uses absolute file paths in the generated compiler
invocation which results in absolute file paths being embedded in debug
info. This is undesirable when building a toolchain e.g. on bots as the
debug info may embed the bot source checkout path which is meaningless
anywhere else.

This change introduces the LLVM_USE_RELATIVE_PATHS which uses
-fdebug-prefix-map (where supported) options to rewrite paths embedded
into debug info with relative ones. Additionally, LLVM_SOURCE_PREFIX can
be used to override the path to source directory with a different one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62622

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake


Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -231,6 +231,8 @@
-DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
-DLLVM_HOST_TRIPLE=${LLVM_HOST_TRIPLE}
-DLLVM_HAVE_LINK_VERSION_SCRIPT=${LLVM_HAVE_LINK_VERSION_SCRIPT}
+   -DLLVM_USE_RELATIVE_PATHS=${LLVM_USE_RELATIVE_PATHS}
+   -DLLVM_SOURCE_PREFIX=${LLVM_SOURCE_PREFIX}
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -977,3 +977,19 @@
 endif()
   endif()
 endif()
+
+option(LLVM_USE_RELATIVE_PATHS "Make builds independent of absolute file 
paths." OFF)
+set(LLVM_SOURCE_PREFIX "" CACHE STRING "LLVM source directory prefix")
+
+if(LLVM_USE_RELATIVE_PATHS)
+  check_c_compiler_flag("-fdebug-prefix-map=foo=bar" 
SUPPORTS_FDEBUG_PREFIX_MAP)
+  set(source_root "${CMAKE_CURRENT_SOURCE_DIR}/../..")
+  if(LLVM_ENABLE_PROJECTS_USED)
+string(APPEND source_root "/..")
+  endif()
+  get_filename_component(source_root "${source_root}" ABSOLUTE)
+  file(RELATIVE_PATH relative_root "${source_root}" "${CMAKE_BINARY_DIR}")
+  append_if(SUPPORTS_FDEBUG_PREFIX_MAP 
"-fdebug-prefix-map=${CMAKE_BINARY_DIR}=${relative_root}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
+  append_if(SUPPORTS_FDEBUG_PREFIX_MAP 
"-fdebug-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
+  add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
+endif()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -15,6 +15,7 @@
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_USE_RELATIVE_PATHS ON CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)


Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -231,6 +231,8 @@
-DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
-DLLVM_HOST_TRIPLE=${LLVM_HOST_TRIPLE}
-DLLVM_HAVE_LINK_VERSION_SCRIPT=${LLVM_HAVE_LINK_VERSION_SCRIPT}
+   -DLLVM_USE_RELATIVE_PATHS=${LLVM_USE_RELATIVE_PATHS}
+   -DLLVM_SOURCE_PREFIX=${LLVM_SOURCE_PREFIX}
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -977,3 +977,19 @@
 endif()
   endif()
 endif()
+
+option(LLVM_USE_RELATIVE_PATHS "Make builds independent of absolute file paths." OFF)
+set(LLVM_SOURCE_PREFIX "" CACHE STRING "LLVM source directory prefix")
+
+if(LLVM_USE_RELATIVE_PATHS)
+  check_c_compiler_flag("-fdebug-prefix-map=foo=bar" SUPPORTS_FDEBUG_PREFIX_MAP)
+  set(source_root "${CMAKE_CURRENT_SOURCE_DIR}/../..")
+  if(LLVM_ENABLE_PROJECTS_USED)
+string(APPEND source_root "/..")
+  endif()
+  get_filename_component(source_root "${source_root}" ABSOLUTE)
+  file(RELATIVE_PATH relative_root "${source_root}" "${CMAKE_BINARY_DIR}")
+  append_if(SUPPORTS_FDEBUG_PREFIX_MAP 

[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-29 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 202030.
jcai19 added a comment.

Add CHECK-MESSAGES-NOT checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/CloexecPipe2Check.cpp
  clang-tools-extra/clang-tidy/android/CloexecPipe2Check.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp
@@ -0,0 +1,77 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe2 %t
+
+#define O_NONBLOCK 1
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int pipe2(int pipefd[2], int flags);
+
+void a() {
+  int pipefd[2];
+  pipe2(pipefd, O_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'pipe2' should use O_CLOEXEC where possible [android-cloexec-pipe2]
+  // CHECK-FIXES: pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: 'pipe2'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+}
+
+void f() {
+  int pipefd[2];
+  pipe2(pipefd, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'pipe2'
+  // CHECK-FIXES: pipe2(pipefd, 3 | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'pipe2'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(pipe2(pipefd, 3 | O_CLOEXEC));
+
+  int flag = O_NONBLOCK;
+  pipe2(pipefd, flag);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, flag));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int pipe2(int pipefd[2], int flags);
+
+void d() {
+  int pipefd[2];
+  pipe2(pipefd, O_NONBLOCK);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  int pipefd[2];
+  pipe2(pipefd, O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_CLOEXEC));
+  // CHECK-MESSAGES-NOT: warning:
+  pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int pipe2(int pipefd[2], int flags);
+  void d() {
+int pipefd[2];
+pipe2(pipefd, O_NONBLOCK);
+// CHECK-MESSAGES-NOT: warning:
+TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe2
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - android-cloexec-pipe2
+
+android-cloexec-pipe2
+=
+
+Checks if the required file flag ``O_CLOEXEC`` is present in the argument of
+``pipe2()``. ``pipe2()`` should include ``O_CLOEXEC`` in its type argument to
+avoid the file descriptor leakage. Without this flag, an opened sensitive file
+would remain open across a ``fork``+``exec`` to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe2(pipefd, O_NONBLOCK);
+
+  // becomes
+
+  pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,12 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  Checks if the required file flag ``O_CLOEXEC`` is present in the argument of
+  ``pipe2()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipe2Check.h

[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-29 Thread Jian Cai via Phabricator via cfe-commits
jcai19 marked 2 inline comments as done.
jcai19 added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp:52
+
+void e() {
+  int pipefd[2];

srhines wrote:
> jcai19 wrote:
> > srhines wrote:
> > > I'm not all that familiar with writing clang-tidy-specific tests, but 
> > > should these tests here denote that a diagnostic should NOT be issued? 
> > > That is usually the convention in regular Clang tests, so I assume the 
> > > test runner here should be equally supportive of ensuring that the 
> > > contents passed through without any other diagnostics related to pipe2 
> > > and/or O_CLOEXEC.
> > That makes sense, and I have seem tests for similar checks with (e.g. 
> > android-cloexec-open)  and without (e.g. android-cloexec-accep4 and 
> > android-cloexec-socket) additional CHECK-MESSAGES-NOT check. But based on 
> > the Testing Checks section of 
> > https://clang.llvm.org/extra/clang-tidy/Contributing.html, it seems 
> > typically CHECK-MASSAGES and CHECK-FIXES are sufficient for clang-tidy 
> > checks. Please let me know what you think.
> If you look in test/clang-tidy/android-cloexec-creat.cpp, you will see that 
> there are "CHECK-MESSAGES-NOT" checks that ensure the diagnostic is not 
> issued in correct cases. You can put the checks on lines 39, 58, and 67, 
> which will ensure that there are no additional diagnostics being generated.
Sounds good! Thanks for the reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049



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


[PATCH] D62580: [OpenCL] Use long instead of long long in x86 builtins

2019-05-29 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka added a comment.

What about a testcase? It shouldn't be hard to add a small testcase that 
demonstrate that the changed builtins now work when compiling OpenCL C code for 
x86. I don't think you have to add all changed builtins to the testcase (but a 
few to demonstrate the change).


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

https://reviews.llvm.org/D62580



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


[PATCH] D59168: [runtimes] Move libunwind, libc++abi and libc++ to lib/$target/c++ and include/c++

2019-05-29 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

This commit stopped clang++ from finding libc++:

main.cc:

  #include 
  
  int main() {
std::vector x;
return x.size();
  }



  $ clang++ main.cc -stdlib=libc++ -v
  clang version 9.0.0 (/w/src/llvm.org/tools/clang 
754813c4737a444eeb4ea5b4070073dd251504cc) (/w/src/llvm.org 
e145e44a7c34acf851da0d6a2c66b274b6ebc82d)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /w/c/org/bin
  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
  Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
  Candidate multilib: .;@m64
  Candidate multilib: 32;@m32
  Candidate multilib: x32;@mx32
  Selected multilib: .;@m64
   "/w/c/org/bin/clang-9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj 
-mrelax-all -disable-free -main-file-name main.cc -mrelocation-model static 
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose 
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 
-dwarf-column-info -debugger-tuning=gdb -v -resource-dir 
/w/c/org/lib/clang/9.0.0 -internal-isystem /usr/local/include -internal-isystem 
/w/c/org/lib/clang/9.0.0/include -internal-externc-isystem 
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include 
-internal-externc-isystem /usr/include -fdeprecated-macro 
-fdebug-compilation-dir /w/test -ferror-limit 19 -fmessage-length 0 
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option 
-fcolor-diagnostics -faddrsig -o /tmp/main-32e7f3.o -x c++ main.cc
  clang -cc1 version 9.0.0 based upon LLVM 9.0.0svn default target 
x86_64-unknown-linux-gnu
  ignoring nonexistent directory "/include"
  #include "..." search starts here:
  #include <...> search starts here:
   /usr/local/include
   /w/c/org/lib/clang/9.0.0/include
   /usr/include/x86_64-linux-gnu
   /usr/include
  End of search list.
  main.cc:1:10: fatal error: 'vector' file not found
  #include 
   ^~~~
  1 error generated.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59168



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


[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-29 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 202027.
akhuang added a comment.
Herald added a subscriber: hiraditya.

Append class name to static data member debug info name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-static-member.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/test/DebugInfo/COFF/global-constants.ll

Index: llvm/test/DebugInfo/COFF/global-constants.ll
===
--- llvm/test/DebugInfo/COFF/global-constants.ll
+++ llvm/test/DebugInfo/COFF/global-constants.ll
@@ -3,18 +3,25 @@
 
 ; C++ source to regenerate:
 ; const int Test1 = 1;
+; struct Foo { static const int Test2 = 2; };
 ; int main() {
-;   return Test1;
+;   return Test1 + Foo::Test2;
 ; }
 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
 
-; ASM-LABEL:  .long 241  # Symbol subsection for globals
+; ASM-LABEL:  .long 241 # Symbol subsection for globals
 
-; ASM:.short {{.*-.*}}   # Record length
-; ASM:.short 4359# Record kind: S_CONSTANT
-; ASM-NEXT:   .long 4099 # Type
-; ASM-NEXT:   .byte 0x01, 0x00   # Value
-; ASM-NEXT:   .asciz "Test1" # Name
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4099# Type
+; ASM-NEXT:   .byte 0x01, 0x00  # Value
+; ASM-NEXT:   .asciz "Test1"# Name
+
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM:.long 4099# Type
+; ASM:.byte 0x02, 0x00  # Value
+; ASM:.asciz "Foo::Test2"   # Name
 
 ; OBJ:CodeViewDebugInfo [
 ; OBJ:  Section: .debug$S
@@ -27,6 +34,12 @@
 ; OBJ-NEXT: Value: 1
 ; OBJ-NEXT: Name: Test1
 ; OBJ-NEXT:   }
+; OBJ:ConstantSym {
+; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
+; OBJ-NEXT: Type: const int (0x1003)
+; OBJ-NEXT: Value: 2
+; OBJ-NEXT: Name: Foo::Test2
+; OBJ-NEXT:   }
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
@@ -34,31 +47,39 @@
 target triple = "x86_64-pc-windows-msvc"
 
 ; Function Attrs: noinline norecurse nounwind optnone
-define dso_local i32 @main() #0 !dbg !13 {
+define dso_local i32 @main() #0 !dbg !19 {
 entry:
   %retval = alloca i32, align 4
   store i32 0, i32* %retval, align 4
-  ret i32 1, !dbg !16
+  ret i32 3, !dbg !22
 }
 
+attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!9, !10, !11}
-!llvm.ident = !{!12}
+!llvm.module.flags = !{!15, !16, !17}
+!llvm.ident = !{!18}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, nameTableKind: None)
-!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2b66a49044196d8b90d95d7d3b5246ccbe3abc05)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !10, nameTableKind: None)
+!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "77cff5e1c7b260440ed03b23c18809c3")
 !2 = !{}
 !3 = !{!4}
-!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
-!5 = distinct !DIGlobalVariable(name: "Test1", scope: !0, file: !6, line: 1, type: !7, isLocal: true, isDefinition: true)
-!6 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
-!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
-!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!9 = !{i32 2, !"CodeView", i32 1}
-!10 = !{i32 2, !"Debug Info Version", i32 3}
-!11 = !{i32 1, !"wchar_size", i32 2}
-!12 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)"}
-!13 = distinct !DISubprogram(name: "main", scope: !6, file: !6, line: 3, type: !14, scopeLine: 3, flags: 

[PATCH] D62621: [LibTooling] Add insert/remove convenience functions for creating `ASTEdit`s.

2019-05-29 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 202026.
ymandel added a comment.

added comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62621

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/unittests/Tooling/TransformerTest.cpp


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -349,6 +349,64 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, InsertBeforeEdit) {
+  std::string Input = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Ret = "return";
+  testRule(makeRule(returnStmt().bind(Ret),
+insertBefore(statement(Ret), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, InsertAfterEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int x = 5;
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl),
+insertAfter(statement(Decl), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, RemoveEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
+   Expected);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -193,6 +193,24 @@
   return change(node(RewriteRule::RootID), std::move(Replacement));
 }
 
+/// Inserts \p Replacement before \p S, leaving the source selected by \S
+/// unchanged.
+inline ASTEdit insertBefore(RangeSelector S, TextGenerator Replacement) {
+  return change(before(std::move(S)), std::move(Replacement));
+}
+
+/// Inserts \p Replacement after \p S, automatically calculating the end
+/// location of \p S.
+inline ASTEdit insertAfter(RangeSelector S, TextGenerator Replacement) {
+  return change(after(std::move(S)), std::move(Replacement));
+}
+
+/// Removes the source selected by \p S, automatically calculating the end
+/// location of \p S.
+inline ASTEdit remove(RangeSelector S) {
+  return change(std::move(S), text(""));
+}
+
 /// The following three functions are a low-level part of the RewriteRule
 /// API. We expose them for use in implementing the fixtures that interpret
 /// RewriteRule, like Transformer and TransfomerTidy, or for more advanced


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -349,6 +349,64 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, InsertBeforeEdit) {
+  std::string Input = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Ret = "return";
+  testRule(makeRule(returnStmt().bind(Ret),
+insertBefore(statement(Ret), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, InsertAfterEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int x = 5;
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl),
+insertAfter(statement(Decl), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, RemoveEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
+   Expected);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -193,6 +193,24 @@
   return change(node(RewriteRule::RootID), std::move(Replacement));
 

[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-05-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D62619#1521824 , @kuhar wrote:

> You can easily get CD by calculating the PostDominanceFrontier. LLVM 
> implements a templated IDF (Iterated Dominance Frontier) construction.
>  A native implementation for llvm ir for reference, if you need:
>
> - 
> https://github.com/seahorn/seahorn/blob/deep-dev-5.0/include/seahorn/Analysis/ControlDependenceAnalysis.hh
> - 
> https://github.com/seahorn/seahorn/blob/deep-dev-5.0/lib/Analysis/ControlDependenceAnalysis.cc
>
>   Paper: R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. 
> Efficiently computing static single assignment form and the control 
> dependence graph. ACM Trans. Program. Lang. Syst., 13(4):451–490, Oct. 1991.


Wow, thank you so much! This looks like a far superior but not a much more 
complicated solution then my own :) And I came to realize it may not even be 
correct.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D62603#1521832 , @tra wrote:

> In D62603#1521792 , @hliao wrote:
>
> > that should assume that variable is not declared with `static`. that's also 
> > the motivation of this patch.
>
>
> cppreference defines internal linkage as 'The name can be referred to from 
> all scopes in the current translation unit.'
>  The current translation unit in CUDA context gets a bit murky. On one hand 
> host and device are compiled separately, and may conceivably be considered 
> separate TUs. On the other hand, the fact that we mix host and device code in 
> the same source file implies tight coupling and the users do expect them to 
> be treated as if all host and device code in the source file is in the same 
> TU. E.g. you may have a kernel in an anonymous namespace yet you do want to 
> be able to launch it from the host side.
>
> I think `static __device__` globals would fall into the same category -- 
> nominally they should not be visible outside of device-side object file, but 
> in practice we do need to make them visible from the host side of the same TU.


That's true if there's a reference on the host side. E.g, if I modify `foo` 
function as both __host__ and __device, that host-side shadow could be 
generated (with 'undef` initializer as expected.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


[PATCH] D62621: [LibTooling] Add insert/remove convenience functions for creating `ASTEdit`s.

2019-05-29 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.

`change()` is an all purpose function; the revision adds simple shortcuts for 
the specific operations of inserting (before/after) or removing source.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62621

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/unittests/Tooling/TransformerTest.cpp


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -349,6 +349,64 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, InsertBeforeEdit) {
+  std::string Input = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Ret = "return";
+  testRule(makeRule(returnStmt().bind(Ret),
+insertBefore(statement(Ret), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, InsertAfterEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int x = 5;
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl),
+insertAfter(statement(Decl), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, RemoveEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
+   Expected);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -193,6 +193,18 @@
   return change(node(RewriteRule::RootID), std::move(Replacement));
 }
 
+inline ASTEdit insertBefore(RangeSelector S, TextGenerator Replacement) {
+  return change(before(std::move(S)), std::move(Replacement));
+}
+
+inline ASTEdit insertAfter(RangeSelector S, TextGenerator Replacement) {
+  return change(after(std::move(S)), std::move(Replacement));
+}
+
+inline ASTEdit remove(RangeSelector S) {
+  return change(std::move(S), text(""));
+}
+
 /// The following three functions are a low-level part of the RewriteRule
 /// API. We expose them for use in implementing the fixtures that interpret
 /// RewriteRule, like Transformer and TransfomerTidy, or for more advanced


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -349,6 +349,64 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, InsertBeforeEdit) {
+  std::string Input = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Ret = "return";
+  testRule(makeRule(returnStmt().bind(Ret),
+insertBefore(statement(Ret), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, InsertAfterEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int x = 5;
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl),
+insertAfter(statement(Decl), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, RemoveEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
+   Expected);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -193,6 +193,18 @@
   return change(node(RewriteRule::RootID), std::move(Replacement));
 }
 
+inline ASTEdit insertBefore(RangeSelector S, TextGenerator Replacement) {
+  return change(before(std::move(S)), std::move(Replacement));
+}
+
+inline ASTEdit 

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D62603#1521792 , @hliao wrote:

> that should assume that variable is not declared with `static`. that's also 
> the motivation of this patch.


cppreference defines internal linkage as 'The name can be referred to from all 
scopes in the current translation unit.'
The current translation unit in CUDA context gets a bit murky. On one hand host 
and device are compiled separately, and may conceivably be considered separate 
TUs. On the other hand, the fact that we mix host and device code in the same 
source file implies tight coupling and the users do expect them to be treated 
as if all host and device code in the source file is in the same TU. E.g. you 
may have a kernel in an anonymous namespace yet you do want to be able to 
launch it from the host side.

I think `static __device__` globals would fall into the same category -- 
nominally they should not be visible outside of device-side object file, but in 
practice we do need to make them visible from the host side of the same TU.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-05-29 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added a comment.

You can easily get CD by calculating the PostDominanceFrontier. LLVM implements 
a templated IDF (Iterated Dominance Frontier) construction.
A native implementation for llvm ir for reference, if you need:

- 
https://github.com/seahorn/seahorn/blob/deep-dev-5.0/include/seahorn/Analysis/ControlDependenceAnalysis.hh
- 
https://github.com/seahorn/seahorn/blob/deep-dev-5.0/lib/Analysis/ControlDependenceAnalysis.cc

Paper: R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. 
Efficiently
computing static single assignment form and the control dependence graph. ACM
Trans. Program. Lang. Syst., 13(4):451–490, Oct. 1991.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


[PATCH] D60670: [analyzer] [NFC] PathDiagnostic: Create PathDiagnosticPopUpPiece

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC362014: [analyzer] [NFC] PathDiagnostic: Create 
PathDiagnosticPopUpPiece (authored by Charusso, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60670?vs=200109=202021#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D60670

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  test/Analysis/analyzer-config.c

Index: include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -367,7 +367,7 @@
 
 class PathDiagnosticPiece: public llvm::FoldingSetNode {
 public:
-  enum Kind { ControlFlow, Event, Macro, Call, Note };
+  enum Kind { ControlFlow, Event, Macro, Call, Note, PopUp };
   enum DisplayHint { Above, Below };
 
 private:
@@ -482,7 +482,7 @@
 
   static bool classof(const PathDiagnosticPiece *P) {
 return P->getKind() == Event || P->getKind() == Macro ||
-   P->getKind() == Note;
+   P->getKind() == Note || P->getKind() == PopUp;
   }
 };
 
@@ -746,7 +746,7 @@
 class PathDiagnosticNotePiece: public PathDiagnosticSpotPiece {
 public:
   PathDiagnosticNotePiece(const PathDiagnosticLocation , StringRef S,
-   bool AddPosRange = true)
+  bool AddPosRange = true)
   : PathDiagnosticSpotPiece(Pos, S, Note, AddPosRange) {}
   ~PathDiagnosticNotePiece() override;
 
@@ -759,6 +759,22 @@
   void Profile(llvm::FoldingSetNodeID ) const override;
 };
 
+class PathDiagnosticPopUpPiece: public PathDiagnosticSpotPiece {
+public:
+  PathDiagnosticPopUpPiece(const PathDiagnosticLocation , StringRef S,
+   bool AddPosRange = true)
+  : PathDiagnosticSpotPiece(Pos, S, PopUp, AddPosRange) {}
+  ~PathDiagnosticPopUpPiece() override;
+
+  static bool classof(const PathDiagnosticPiece *P) {
+return P->getKind() == PopUp;
+  }
+
+  void dump() const override;
+
+  void Profile(llvm::FoldingSetNodeID ) const override;
+};
+
 /// File IDs mapped to sets of line numbers.
 using FilesToLineNumsMap = std::map>;
 
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -204,6 +204,10 @@
 "be pruned out of the final output.",
 true)
 
+ANALYZER_OPTION(bool, ShouldAddPopUpNotes, "add-pop-up-notes",
+"Whether pop-up notes should be added to the final output.",
+true)
+
 ANALYZER_OPTION(
 bool, ShouldConditionalizeStaticInitializers,
 "cfg-conditional-static-initializers",
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -2,6 +2,7 @@
 // RUN: FileCheck --input-file=%t %s --match-full-lines
 
 // CHECK: [config]
+// CHECK-NEXT: add-pop-up-notes = true
 // CHECK-NEXT: aggressive-binary-operation-simplification = false
 // CHECK-NEXT: alpha.clone.CloneChecker:IgnoredFilesPattern = ""
 // CHECK-NEXT: alpha.clone.CloneChecker:MinimumCloneComplexity = 50
@@ -87,4 +88,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 84
+// CHECK-NEXT: num-entries = 85
Index: lib/Rewrite/HTMLRewrite.cpp
===
--- lib/Rewrite/HTMLRewrite.cpp
+++ lib/Rewrite/HTMLRewrite.cpp
@@ -306,14 +306,16 @@
 .keyword { color: blue }
 .string_literal { color: red }
 .directive { color: darkmagenta }
-/* Macro expansions. */
-.expansion { display: none; }
-.macro:hover .expansion {
+
+/* Macros and variables could have pop-up notes hidden by default.
+  - Macro pop-up:expansion of the macro
+  - Variable pop-up: value (table) of the variable */
+.macro_popup, .variable_popup { display: none; }
+
+/* Pop-up appears on mouse-hover event. */
+.macro:hover .macro_popup, .variable:hover .variable_popup {
   display: block;
-  border: 2px solid #FF;
   padding: 2px;
-  background-color:#FFF0F0;
-  font-weight: normal;
   -webkit-border-radius:5px;
   -webkit-box-shadow:1px 1px 7px #000;
   border-radius:5px;
@@ -324,6 +326,27 @@
   z-index: 1
 }
 
+.macro_popup {
+  border: 2px solid red;
+  background-color:#FFF0F0;
+  

[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-05-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: kuhar, NoQ, dcoughlin, xazax.hun, rnkovacs, 
baloghadamsoftware, Charusso.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.
Szelethus added a parent revision: D62611: [analyzer][Dominators] Add unittests.

Block A is a control dependency of block B, is A dominates B but B doesn't post 
dominate A.

In detail:

- Create the `CFGControlDependencyTree`, which in fact stores both a dominator 
and a post dominator tree
- Add the new debug checker `debug.DumpControlDependencies`
- Add both lit and unit tests.

Now I'm not sure whether this is the optimal approach -- In fact I'm fairly 
certain that this isn't the most efficient way of calculating control 
dependencies, however, I'm not that concerned with performance just yet. This 
will be used to improve bug reports the static analyzer emits, and if this 
turns out to be useful, I might look enhancing this further.


Repository:
  rC Clang

https://reviews.llvm.org/D62619

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/test/Analysis/domtest.c
  clang/test/Analysis/domtest.cpp
  clang/unittests/Analysis/CFGDominatorTree.cpp

Index: clang/unittests/Analysis/CFGDominatorTree.cpp
===
--- clang/unittests/Analysis/CFGDominatorTree.cpp
+++ clang/unittests/Analysis/CFGDominatorTree.cpp
@@ -117,6 +117,105 @@
   EXPECT_TRUE(PostDom.dominates(nullptr, ExitBlock));
 }
 
+TEST(CFGDominatorTree, ControlDependency) {
+  const char *Code = R"(bool coin();
+
+void funcWithBranch() {
+  int x = 0;
+  if (coin()) {
+if (coin()) {
+  x = 5;
+}
+int j = 10 / x;
+(void)j;
+  }
+};)";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  //  1st if  2nd if
+  //  [B5 (ENTRY)]  -> [B4] -> [B3] -> [B2] -> [B1] -> [B0 (EXIT)]
+  //\\  / /
+  // \-> /
+  //  -->
+
+  CFG *cfg = Result.getCFG();
+
+  // Sanity checks.
+  EXPECT_EQ(cfg->size(), 6u);
+
+  CFGBlock *ExitBlock = *cfg->begin();
+  EXPECT_EQ(ExitBlock, >getExit());
+
+  CFGBlock *NullDerefBlock = *(cfg->begin() + 1);
+
+  CFGBlock *SecondThenBlock = *(cfg->begin() + 2);
+
+  CFGBlock *SecondIfBlock = *(cfg->begin() + 3);
+  EXPECT_TRUE(hasStmtType(SecondIfBlock));
+
+  CFGBlock *FirstIfBlock = *(cfg->begin() + 4);
+  EXPECT_TRUE(hasStmtType(FirstIfBlock));
+
+  CFGBlock *EntryBlock = *(cfg->begin() + 5);
+  EXPECT_EQ(EntryBlock, >getEntry());
+
+  CFGControlDependencyTree Control;
+  Control.buildDominatorTree(cfg);
+
+  EXPECT_TRUE(Control.isControlDependency(SecondIfBlock, SecondThenBlock));
+  EXPECT_TRUE(Control.isControlDependency(FirstIfBlock, SecondIfBlock));
+  EXPECT_FALSE(Control.isControlDependency(SecondIfBlock, NullDerefBlock));
+}
+
+TEST(CFGDominatorTree, ControlDependencyWithLoops) {
+  const char *Code = R"(int test3() {
+  int x,y,z;
+
+  x = y = z = 1;
+  if (x > 0) {
+while (x >= 0){
+  while (y >= x) {
+x = x-1;
+y = y/2;
+  }
+}
+  }
+  z = y;
+
+  return 0;
+})";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  //<-
+  //   /  \
+  //   |---> [B2]
+  //   |   /
+  // [B8 (ENTRY)] -> [B7] -> [B6] -> [B5] -> [B4] -> [B3]
+  //   \   |   \  /
+  //\  |<-
+  // \  \
+  //  > [B1] -> [B0 (EXIT)]
+
+  CFG *cfg = Result.getCFG();
+
+  CFGControlDependencyTree Control;
+  Control.buildDominatorTree(cfg);
+
+  auto GetBlock = [cfg] (unsigned Index) -> CFGBlock * {
+assert(Index < cfg->size());
+return *(cfg->begin() + Index);
+  };
+
+  // While not immediately obvious, the second block in fact post dominates the
+  // fifth, hence B5 is not a control dependency of 2.
+  EXPECT_FALSE(Control.isControlDependency(GetBlock(5), GetBlock(2)));

r362014 - [analyzer] [NFC] PathDiagnostic: Create PathDiagnosticPopUpPiece

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 12:21:59 2019
New Revision: 362014

URL: http://llvm.org/viewvc/llvm-project?rev=362014=rev
Log:
[analyzer] [NFC] PathDiagnostic: Create PathDiagnosticPopUpPiece

Summary:
This new piece is similar to our macro expansion printing in HTML reports:
On mouse-hover event it pops up on variables. Similar to note pieces it
supports `plist` diagnostics as well.

It is optional, on by default: `add-pop-up-notes=true`.

Extra: In HTML reports `background-color: LemonChiffon` was too light,
changed to `PaleGoldenRod`.

Reviewers: NoQ, alexfh

Reviewed By: NoQ

Subscribers: cfe-commits, gerazo, gsd, george.karpenkov, alexfh, xazax.hun,
 baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho,
 Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
cfe/trunk/test/Analysis/analyzer-config.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=362014=362013=362014=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Wed May 29 
12:21:59 2019
@@ -204,6 +204,10 @@ ANALYZER_OPTION(bool, ShouldPrunePaths,
 "be pruned out of the final output.",
 true)
 
+ANALYZER_OPTION(bool, ShouldAddPopUpNotes, "add-pop-up-notes",
+"Whether pop-up notes should be added to the final output.",
+true)
+
 ANALYZER_OPTION(
 bool, ShouldConditionalizeStaticInitializers,
 "cfg-conditional-static-initializers",

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=362014=362013=362014=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
Wed May 29 12:21:59 2019
@@ -367,7 +367,7 @@ public:
 
 class PathDiagnosticPiece: public llvm::FoldingSetNode {
 public:
-  enum Kind { ControlFlow, Event, Macro, Call, Note };
+  enum Kind { ControlFlow, Event, Macro, Call, Note, PopUp };
   enum DisplayHint { Above, Below };
 
 private:
@@ -482,7 +482,7 @@ public:
 
   static bool classof(const PathDiagnosticPiece *P) {
 return P->getKind() == Event || P->getKind() == Macro ||
-   P->getKind() == Note;
+   P->getKind() == Note || P->getKind() == PopUp;
   }
 };
 
@@ -746,7 +746,7 @@ public:
 class PathDiagnosticNotePiece: public PathDiagnosticSpotPiece {
 public:
   PathDiagnosticNotePiece(const PathDiagnosticLocation , StringRef S,
-   bool AddPosRange = true)
+  bool AddPosRange = true)
   : PathDiagnosticSpotPiece(Pos, S, Note, AddPosRange) {}
   ~PathDiagnosticNotePiece() override;
 
@@ -755,6 +755,22 @@ public:
   }
 
   void dump() const override;
+
+  void Profile(llvm::FoldingSetNodeID ) const override;
+};
+
+class PathDiagnosticPopUpPiece: public PathDiagnosticSpotPiece {
+public:
+  PathDiagnosticPopUpPiece(const PathDiagnosticLocation , StringRef S,
+   bool AddPosRange = true)
+  : PathDiagnosticSpotPiece(Pos, S, PopUp, AddPosRange) {}
+  ~PathDiagnosticPopUpPiece() override;
+
+  static bool classof(const PathDiagnosticPiece *P) {
+return P->getKind() == PopUp;
+  }
+
+  void dump() const override;
 
   void Profile(llvm::FoldingSetNodeID ) const override;
 };

Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=362014=362013=362014=diff
==
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Wed May 29 12:21:59 2019
@@ -306,14 +306,16 @@ h1 { font-size:14pt }
 .keyword { color: blue }
 .string_literal { color: red }
 .directive { color: darkmagenta }
-/* Macro expansions. */
-.expansion { display: none; }
-.macro:hover .expansion {
+
+/* Macros and variables could have pop-up notes hidden by default.
+  - Macro pop-up:expansion of the macro
+  - 

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D62603#1521788 , @tra wrote:

> >> NVCC also allows that: https://godbolt.org/z/t78RvM
> > 
> > BTW, that code posted looks quite weird to me, how the code could make 
> > sense by return a pointer of device variable? or a pointer of shadow host 
> > variable?
>
> Magic. :-)
>  More practical example would be something like this:
>
>   __device__ int array[10];
>  
>   __host__ func() {
> cudaMemset(array, 0, sizeof(array));
>   }
>
>
> cudaMemset is a host function and it needs to use something that exists on 
> the host side as the first argument.
>  In order to deal with this, compiler:
>
> - creates uninitialized `int array[10]` on the host side. This allows ising 
> sizeof(array) on the host size.
> - registers its address/size with CUDA runtime. This allows passing address 
> of host-side shadow array to various CUDA runtime routines. The runtime knows 
> what it has on device side and maps shadow's address to the real device 
> address. This way CUDA runtime functions can make static device-side data 
> accessible without having to explicitly figure out their device-side address.


that should assume that variable is not declared with `static`. that's also the 
motivation of this patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

>> NVCC also allows that: https://godbolt.org/z/t78RvM
> 
> BTW, that code posted looks quite weird to me, how the code could make sense 
> by return a pointer of device variable? or a pointer of shadow host variable?

Magic. :-)
More practical example would be something like this:

  __device__ int array[10];
  
  __host__ func() {
cudaMemset(array, 0, sizeof(array));
  }

cudaMemset is a host function and it needs to use something that exists on the 
host side as the first argument.
In order to deal with this, compiler:

- creates uninitialized `int array[10]` on the host side. This allows ising 
sizeof(array) on the host size.
- registers its address/size with CUDA runtime. This allows passing address of 
host-side shadow array to various CUDA runtime routines. The runtime knows what 
it has on device side and maps shadow's address to the real device address. 
This way CUDA runtime functions can make static device-side data accessible 
without having to explicitly figure out their device-side address.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


r362013 - LLVM IR: update Clang tests for byval being a typed attribute.

2019-05-29 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed May 29 12:13:29 2019
New Revision: 362013

URL: http://llvm.org/viewvc/llvm-project?rev=362013=rev
Log:
LLVM IR: update Clang tests for byval being a typed attribute.

Since byval is now a typed attribute it gets sorted slightly differently by
LLVM when the order of attributes is being canonicalized. This updates the few
Clang tests that depend on the old order.

Modified:
cfe/trunk/test/CodeGen/aapcs-align.cpp
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
cfe/trunk/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl

Modified: cfe/trunk/test/CodeGen/aapcs-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aapcs-align.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGen/aapcs-align.cpp (original)
+++ cfe/trunk/test/CodeGen/aapcs-align.cpp Wed May 29 12:13:29 2019
@@ -95,8 +95,8 @@ void g4() {
   f4m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define void @g4
-// CHECK: call void @f4(i32 1, %struct.SF16* byval nonnull align 8
-// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
byval nonnull align 8
+// CHECK: call void @f4(i32 1, %struct.SF16* nonnull byval align 8
+// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
nonnull byval align 8
 // CHECK: declare void @f4(i32, %struct.SF16* byval align 8)
 // CHECK: declare void @f4m(i32, i32, i32, i32, i32, %struct.SF16* byval align 
8)
 

Modified: cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp Wed May 29 12:13:29 
2019
@@ -104,7 +104,7 @@ struct TestInit {
 //
 // CHECK-CTOR-GLOBAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP_ONE:[^,]*]],
 // CHECK-CTOR-GLOBAL-SAME: i32 3400, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{[^%]*}}%[[TMP_ONE]])
+// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{.*}}%[[TMP_ONE]])
 #line 3400 "GlobalInitVal.cpp"
 TestInit GlobalInitVal;
 
@@ -119,7 +119,7 @@ extern "C" void test_init_function() {
 //
 // CHECK-CTOR-LOCAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP:[^,]*]],
 // CHECK-CTOR-LOCAL-SAME: i32 3500, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{[^%]*}}%[[TMP]])
+// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{.*}}%[[TMP]])
 #line 3500 "LocalInitVal.cpp"
   TestInit init_local;
   sink(init_local);

Modified: cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp Wed May 29 12:13:29 2019
@@ -30,12 +30,12 @@ struct two_fields {
   double d, e;
 };
 test(two_fields);
-// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 
%{{.*}})
+// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* nocapture readonly byval align 8 
%{{.*}})
 //
 // CHECK: define void @_Z15test_two_fieldsv()
 // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8
 // CHECK: call void @_Z14def_two_fieldsv(%struct.two_fields* nonnull sret 
%[[tmp]])
-// CHECK: call void @_Z3use10two_fields(%struct.two_fields* byval nonnull 
align 8 %[[tmp]])
+// CHECK: call void @_Z3use10two_fields(%struct.two_fields* nonnull byval 
align 8 %[[tmp]])
 // CHECK: ret void
 //
 // CHECK: declare void @_Z3use10two_fields(%struct.two_fields* byval align 8)

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp 

[PATCH] D62580: [OpenCL] Use long instead of long long in x86 builtins

2019-05-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Conditional approval, commit with the comment fixed.  Let me know if you need 
me to commit it for you.




Comment at: clang/include/clang/Basic/Builtins.def:56
 //  N   -> 'int' size if target is LP64, 'L' otherwise.
+//  O   -> long for OpenCL targets, long long otherwise
 //  S   -> signed

End the comment with a period.


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

https://reviews.llvm.org/D62580



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


[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D62603#1521503 , @tra wrote:

> In D62603#1521484 , @hliao wrote:
>
> > thanks, but that `static __device__` variable won't have shadow in host 
> > anymore.
>
>
> Why not? Your change only changes whether `externally_initialized` is applied 
> to the variable during device-side compilation. It does not change what 
> happens on the host side. 
>  AFAICT, it will still be generated on the host side and the host side should 
> still be able to take its address.
>  NVCC also allows that: https://godbolt.org/z/t78RvM


BTW, that code posted looks quite weird to me, how the code could make sense by 
return a pointer of device variable? or a pointer of shadow host variable?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


r362011 - [analyzer] print() JSONify chain: Generic stmt_id

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 11:58:41 2019
New Revision: 362011

URL: http://llvm.org/viewvc/llvm-project?rev=362011=rev
Log:
[analyzer] print() JSONify chain: Generic stmt_id

Summary: Some environment create less statements so make them generic.

Modified:
cfe/trunk/test/Analysis/dump_egraph.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: cfe/trunk/test/Analysis/dump_egraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.cpp?rev=362011=362010=362011=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.cpp (original)
+++ cfe/trunk/test/Analysis/dump_egraph.cpp Wed May 29 11:58:41 2019
@@ -16,9 +16,9 @@ void foo() {
   T t;
 }
 
-// CHECK: \"constructing_objects\": [\l\{ 
\"location_context\": \"#0 Call\", \"calling\": \"foo\", \"call_line\": null, 
\"items\": [\l\{ \"lctx_id\": 
1, \"stmt_id\": 1155, \"kind\": \"construct into local variable\", 
\"argument_index\": null, \"pretty\": \"T t;\", \"value\": \"\"
+// CHECK: \"constructing_objects\": [\l\{ 
\"location_context\": \"#0 Call\", \"calling\": \"foo\", \"call_line\": null, 
\"items\": [\l\{ \"lctx_id\": 
1, \"stmt_id\": {{[0-9]+}}, \"kind\": \"construct into local variable\", 
\"argument_index\": null, \"pretty\": \"T t;\", \"value\": \"\"
 
-// CHECK: \"constructing_objects\": [\l\{ 
\"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"call_line\": 
\"16\", \"items\": [\l\{ 
\"lctx_id\": 2, \"init_id\": 1092, \"kind\": \"construct into member 
variable\", \"argument_index\": null, \"pretty\": \"s\", \"value\": \"\>s\"
+// CHECK: \"constructing_objects\": [\l\{ 
\"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"call_line\": 
\"16\", \"items\": [\l\{ 
\"lctx_id\": 2, \"init_id\": {{[0-9]+}}, \"kind\": \"construct into member 
variable\", \"argument_index\": null, \"pretty\": \"s\", \"value\": \"\>s\"
 
 // CHECK: \"store\": [\l\{ \"cluster\": 
\"t\", \"items\": [\l\{ 
\"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$3\{int, LC3, no stmt, 
#1\}\"
 

Modified: cfe/trunk/test/Analysis/expr-inspection.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/expr-inspection.c?rev=362011=362010=362011=diff
==
--- cfe/trunk/test/Analysis/expr-inspection.c (original)
+++ cfe/trunk/test/Analysis/expr-inspection.c Wed May 29 11:58:41 2019
@@ -31,7 +31,7 @@ void foo(int x) {
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "environment": [
 // CHECK-NEXT: { "location_context": "#0 Call", "calling": "foo", 
"call_line": null, "items": [
-// CHECK-NEXT:   { "lctx_id": 1, "stmt_id": 847, "pretty": 
"clang_analyzer_printState", "value": "{clang_analyzer_printState}" }
+// CHECK-NEXT:   { "lctx_id": 1, "stmt_id": {{[0-9]+}}, "pretty": 
"clang_analyzer_printState", "value": "{clang_analyzer_printState}" }
 // CHECK-NEXT: ]}
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "constraints": [


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


[PATCH] D62616: [CodeComplete] Add a bit more whitespace to completed patterns

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: gribozavr.
Herald added subscribers: kadircet, arphaman, jkorous.
Herald added a project: clang.

E.g. we now turn `while(<#cond#>){` into `while (<#cond#>) {`

This slightly improves the final output. Should not affect clients that
format the result on their own.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62616

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -12,7 +12,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
   // CHECK-CC1: COMPLETION: Pattern : [#void#]delete <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : do{
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : do {
   // CHECK-CC1-NEXT: <#statements#>
   // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: double
@@ -22,11 +22,11 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]false
   // CHECK-CC1-NEXT: COMPLETION: float
   // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : for (<#init-statement#>; <#condition#>; <#inc-expression#>) {
   // CHECK-CC1-NEXT: <#statements#>{{$}}
   // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: Pattern : goto <#label#>;
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : if (<#condition#>) {
   // CHECK-CC1-NEXT: <#statements#>{{$}}
   // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: int
@@ -42,13 +42,13 @@
   // CHECK-CC1-NEXT: COMPLETION: static
   // CHECK-CC1-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
   // CHECK-CC1-NEXT: COMPLETION: struct
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : switch(<#condition#>){
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : switch (<#condition#>) {
   // CHECK-CC1: COMPLETION: t : t
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]true
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : try{
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : try {
   // CHECK-CC1-NEXT: <#statements#>
-  // CHECK-CC1-NEXT: }catch(<#declaration#>){
+  // CHECK-CC1-NEXT: } catch (<#declaration#>) {
   // CHECK-CC1-NEXT: <#statements#>
   // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
@@ -63,7 +63,7 @@
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
   // CHECK-CC1-NEXT: COMPLETION: wchar_t
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : while(<#condition#>){
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : while (<#condition#>) {
   // CHECK-CC1-NEXT: <#statements#>
   // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: X : X
@@ -83,7 +83,7 @@
   // CHECK-CC2-NEXT: COMPLETION: inline
   // CHECK-CC2-NEXT: COMPLETION: int
   // CHECK-CC2-NEXT: COMPLETION: long
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#> {
   // CHECK-CC2-NEXT: <#declarations#>
   // CHECK-CC2-NEXT: }
   // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>;
@@ -195,7 +195,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
   // CHECK-NO-RTTI: COMPLETION: Pattern : [#void#]delete <#expression#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do{
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do {
   // CHECK-NO-RTTI: COMPLETION: double
   // CHECK-NO-RTTI-NOT: dynamic_cast
   // CHECK-NO-RTTI: COMPLETION: enum
@@ -203,9 +203,9 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#bool#]false
   // CHECK-NO-RTTI-NEXT: COMPLETION: float
   // CHECK-NO-RTTI-NEXT: COMPLETION: foo : [#void#]foo()
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for (<#init-statement#>; <#condition#>; <#inc-expression#>) {
   // CHECK-NO-RTTI: COMPLETION: Pattern : goto <#label#>;
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if(<#condition#>){
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if (<#condition#>) {
   // CHECK-NO-RTTI: COMPLETION: int
   // CHECK-NO-RTTI-NEXT: COMPLETION: long
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
@@ -219,7 +219,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: static
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
   // 

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D62603#1521503 , @tra wrote:

> In D62603#1521484 , @hliao wrote:
>
> > thanks, but that `static __device__` variable won't have shadow in host 
> > anymore.
>
>
> Why not? Your change only changes whether `externally_initialized` is applied 
> to the variable during device-side compilation. It does not change what 
> happens on the host side. 
>  AFAICT, it will still be generated on the host side and the host side should 
> still be able to take its address.
>  NVCC also allows that: https://godbolt.org/z/t78RvM




In D62603#1521507 , @tra wrote:

> Note for the future -- it would be great if we could finish discussing the 
> patch before landing it. 
>  I would still like to see the host-side test.


Sorry, will follow that rule. Yes, that patch only changes the device-side. 
But, for host-side, even that variable is declared as `static` as well, but 
there's no reference to it. clang just skip emitting it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603



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


r362009 - [analyzer] SATestBuild.py: Use driver for analyzing single-file tests.

2019-05-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed May 29 11:49:31 2019
New Revision: 362009

URL: http://llvm.org/viewvc/llvm-project?rev=362009=rev
Log:
[analyzer] SATestBuild.py: Use driver for analyzing single-file tests.

Don't bother coming up with a -cc1 run-line ourselves.

This, in particular, gets rid of a macOS-specific code path.

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py
cfe/trunk/utils/analyzer/SATestUtils.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=362009=362008=362009=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Wed May 29 11:49:31 2019
@@ -343,18 +343,13 @@ def runAnalyzePreprocessed(Args, Dir, SB
 BuildScript))
 raise Exception()
 
-CmdPrefix = Clang + " -cc1 "
+CmdPrefix = Clang + " --analyze "
 
-# For now, we assume the preprocessed files should be analyzed
-# with the OS X SDK.
-SDKPath = SATestUtils.getSDKPath("macosx")
-if SDKPath is not None:
-CmdPrefix += "-isysroot " + SDKPath + " "
-
-CmdPrefix += "-analyze -analyzer-output=plist -w "
-CmdPrefix += "-analyzer-checker=" + Checkers
+CmdPrefix += "--analyzer-output plist "
+CmdPrefix += " -Xclang -analyzer-checker=" + Checkers
 CmdPrefix += " -fcxx-exceptions -fblocks "
-CmdPrefix += " -analyzer-config %s " % generateAnalyzerConfig(Args)
+CmdPrefix += " -Xclang -analyzer-config -Xclang %s "\
+% generateAnalyzerConfig(Args)
 
 if (Mode == 2):
 CmdPrefix += "-std=c++11 "

Modified: cfe/trunk/utils/analyzer/SATestUtils.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestUtils.py?rev=362009=362008=362009=diff
==
--- cfe/trunk/utils/analyzer/SATestUtils.py (original)
+++ cfe/trunk/utils/analyzer/SATestUtils.py Wed May 29 11:49:31 2019
@@ -1,5 +1,5 @@
 import os
-from subprocess import check_output, check_call
+from subprocess import check_call
 import sys
 
 
@@ -47,18 +47,6 @@ def isValidSingleInputFile(FileName):
 return Ext in (".i", ".ii", ".c", ".cpp", ".m", "")
 
 
-def getSDKPath(SDKName):
-"""
-Get the path to the SDK for the given SDK name. Returns None if
-the path cannot be determined.
-"""
-if which("xcrun") is None:
-return None
-
-Cmd = "xcrun --sdk " + SDKName + " --show-sdk-path"
-return check_output(Cmd, shell=True).rstrip()
-
-
 def runScript(ScriptPath, PBuildLogFile, Cwd, Stdout=sys.stdout,
   Stderr=sys.stderr):
 """


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


[PATCH] D62611: [analyzer][Dominators] Add unittests

2019-05-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 202004.
Szelethus added a comment.

Fixes according to reviewer comments, thanks! :)


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

https://reviews.llvm.org/D62611

Files:
  clang/unittests/Analysis/CFGBuilder.h
  clang/unittests/Analysis/CFGDominatorTree.cpp
  clang/unittests/Analysis/CFGTest.cpp
  clang/unittests/Analysis/CMakeLists.txt

Index: clang/unittests/Analysis/CMakeLists.txt
===
--- clang/unittests/Analysis/CMakeLists.txt
+++ clang/unittests/Analysis/CMakeLists.txt
@@ -3,6 +3,7 @@
   )
 
 add_clang_unittest(ClangAnalysisTests
+  CFGDominatorTree.cpp
   CFGTest.cpp
   CloneDetectionTest.cpp
   ExprMutationAnalyzerTest.cpp
Index: clang/unittests/Analysis/CFGTest.cpp
===
--- clang/unittests/Analysis/CFGTest.cpp
+++ clang/unittests/Analysis/CFGTest.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "CFGBuilder.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Tooling/Tooling.h"
@@ -17,57 +18,6 @@
 namespace analysis {
 namespace {
 
-class BuildResult {
-public:
-  enum Status {
-ToolFailed,
-ToolRan,
-SawFunctionBody,
-BuiltCFG,
-  };
-
-  BuildResult(Status S, std::unique_ptr Cfg = nullptr)
-  : S(S), Cfg(std::move(Cfg)) {}
-
-  Status getStatus() const { return S; }
-  CFG *getCFG() const { return Cfg.get(); }
-
-private:
-  Status S;
-  std::unique_ptr Cfg;
-};
-
-class CFGCallback : public ast_matchers::MatchFinder::MatchCallback {
-public:
-  BuildResult TheBuildResult = BuildResult::ToolRan;
-
-  void run(const ast_matchers::MatchFinder::MatchResult ) override {
-const auto *Func = Result.Nodes.getNodeAs("func");
-Stmt *Body = Func->getBody();
-if (!Body)
-  return;
-TheBuildResult = BuildResult::SawFunctionBody;
-CFG::BuildOptions Options;
-Options.AddImplicitDtors = true;
-if (std::unique_ptr Cfg =
-CFG::buildCFG(nullptr, Body, Result.Context, Options))
-  TheBuildResult = {BuildResult::BuiltCFG, std::move(Cfg)};
-  }
-};
-
-BuildResult BuildCFG(const char *Code) {
-  CFGCallback Callback;
-
-  ast_matchers::MatchFinder Finder;
-  Finder.addMatcher(ast_matchers::functionDecl().bind("func"), );
-  std::unique_ptr Factory(
-  tooling::newFrontendActionFactory());
-  std::vector Args = {"-std=c++11", "-fno-delayed-template-parsing"};
-  if (!tooling::runToolOnCodeWithArgs(Factory->create(), Code, Args))
-return BuildResult::ToolFailed;
-  return std::move(Callback.TheBuildResult);
-}
-
 // Constructing a CFG for a range-based for over a dependent type fails (but
 // should not crash).
 TEST(CFG, RangeBasedForOverDependentType) {
Index: clang/unittests/Analysis/CFGDominatorTree.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/CFGDominatorTree.cpp
@@ -0,0 +1,122 @@
+//===- unittests/Analysis/CFGTest.cpp - CFG tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CFGBuilder.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/Analyses/Dominators.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace analysis {
+namespace {
+
+template  struct FindStmt {
+  bool operator()(const CFGElement ) {
+if (auto S = E.getAs())
+  return isa(S->getStmt());
+return false;
+  }
+};
+
+template  bool hasStmtType(CFGBlock *Block) {
+  return llvm::find_if(*Block, FindStmt()) == Block->end();
+}
+
+TEST(CFGDominatorTree, DomTree) {
+  const char *Code = R"(enum Kind {
+  A
+};
+
+void f() {
+  switch(Kind{}) {
+  case A:
+break;
+  }
+})";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  //  [B3 (ENTRY)]  -> [B1] -> [B2] -> [B0 (EXIT)]
+  //  switch  case A
+
+  CFG *cfg = Result.getCFG();
+
+  // Sanity checks.
+  EXPECT_EQ(cfg->size(), 4u);
+
+  CFGBlock *ExitBlock = *cfg->begin();
+  EXPECT_EQ(ExitBlock, >getExit());
+
+  CFGBlock *SwitchBlock = *(cfg->begin() + 1);
+  EXPECT_TRUE(hasStmtType(SwitchBlock));
+
+  CFGBlock *CaseABlock = *(cfg->begin() + 2);
+  EXPECT_TRUE(hasStmtType(CaseABlock));
+
+  CFGBlock *EntryBlock = *(cfg->begin() + 3);
+  EXPECT_EQ(EntryBlock, >getEntry());
+
+  // Test 

[PATCH] D62611: [analyzer][Dominators] Add unittests

2019-05-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 5 inline comments as done.
Szelethus added inline comments.



Comment at: clang/unittests/Analysis/CFGDominatorTree.cpp:95
+  CFGPostDomTree PostDom;
+  PostDom.buildDominatorTree(cfg);
+

kuhar wrote:
> Why not have a constructor that takes the cfg and constructs a domtree 
> straight away? But this should probably go into a separate patch.
Yea, it's been bothering me for a while, but apparently not enough to fix it 
(just yet!).


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

https://reviews.llvm.org/D62611



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


[PATCH] D62497: [analyzer] print() JSONify: SVal implementation

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362008: [analyzer] print() JSONify: SVal implementation 
(authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62497?vs=201582=202008#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62497

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -190,6 +190,9 @@
 
   const MemRegion *getAsRegion() const;
 
+  /// printJson - Pretty-prints in JSON format.
+  void printJson(raw_ostream , bool AddQuotes) const;
+
   void dumpToStream(raw_ostream ) const;
   void dump() const;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
@@ -263,10 +263,12 @@
   Indent(Out, InnerSpace, IsDot)
   << "{ \"lctx_id\": " << LC->getID()
   << ", \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
-
   S->printJson(Out, nullptr, PP, /*AddQuotes=*/true);
 
-  Out << ", \"value\": \"" << I->second << "\" }";
+  Out << ", \"value\": ";
+  I->second.printJson(Out, /*AddQuotes=*/true);
+
+  Out << " }";
 
   if (I != LastI)
 Out << ',';
Index: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -283,6 +284,15 @@
 
 LLVM_DUMP_METHOD void SVal::dump() const { dumpToStream(llvm::errs()); }
 
+void SVal::printJson(raw_ostream , bool AddQuotes) const {
+  std::string Buf;
+  llvm::raw_string_ostream TempOut(Buf);
+
+  dumpToStream(TempOut);
+
+  Out << JsonFormat(TempOut.str(), AddQuotes);
+}
+
 void SVal::dumpToStream(raw_ostream ) const {
   switch (getBaseKind()) {
 case UnknownValKind:


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -190,6 +190,9 @@
 
   const MemRegion *getAsRegion() const;
 
+  /// printJson - Pretty-prints in JSON format.
+  void printJson(raw_ostream , bool AddQuotes) const;
+
   void dumpToStream(raw_ostream ) const;
   void dump() const;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
@@ -263,10 +263,12 @@
   Indent(Out, InnerSpace, IsDot)
   << "{ \"lctx_id\": " << LC->getID()
   << ", \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
-
   S->printJson(Out, nullptr, PP, /*AddQuotes=*/true);
 
-  Out << ", \"value\": \"" << I->second << "\" }";
+  Out << ", \"value\": ";
+  I->second.printJson(Out, /*AddQuotes=*/true);
+
+  Out << " }";
 
   if (I != LastI)
 Out << ',';
Index: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -283,6 +284,15 @@
 
 LLVM_DUMP_METHOD void SVal::dump() const { dumpToStream(llvm::errs()); }
 
+void SVal::printJson(raw_ostream , bool AddQuotes) const {
+  std::string Buf;
+  llvm::raw_string_ostream TempOut(Buf);
+
+  dumpToStream(TempOut);
+
+  Out << JsonFormat(TempOut.str(), AddQuotes);
+}
+
 void SVal::dumpToStream(raw_ostream ) const {
   switch (getBaseKind()) {
 case UnknownValKind:
___
cfe-commits mailing list

[PATCH] D62591: [OpenCL][PR42031] Prevent deducing addr space in type alias.

2019-05-29 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added inline comments.



Comment at: lib/Sema/SemaType.cpp:7355
+  // object.
+  (D.getContext() == DeclaratorContext::AliasDeclContext) ||
   // Do not deduce addr space for types used to define a typedef and the

I think this should also check for `!IsPointee` as it breaks the following 
example with `error: cannot initialize a variable of type 'c_ptr' (aka 'c1 *') 
with an rvalue of type 'c1 *'`.


```
struct c1 { int x; };
using c_ptr = c1*;

__kernel void test2() {
  c1 x = { 0 };
  c1* y =  // okay
  c_ptr z =  // fails
}
```



Comment at: test/SemaOpenCLCXX/address-space-deduction.cl:1
 //RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
 

I guess it's an oversight from previous reviews, but FileCheck is not called 
here.



Comment at: test/SemaOpenCLCXX/address-space-deduction.cl:5
 
 //CHECK: |-VarDecl  foo {{.*}} 'const __global int' constexpr cinit
 constexpr int foo = 0;

The pattern should probably be:

`//CHECK: |-VarDecl {{.*}} foo 'const __global int' constexpr cinit`

(i.e. move the {{.*}} before foo).



Comment at: test/SemaOpenCLCXX/address-space-deduction.cl:10
 public:
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
   static constexpr int foo2 = 0;

This check fails for me because `inline` is "missing" between `static` and 
`constexpr`. Not sure if it makes sense for `foo2` to be inline or not, but 
that's a different story.


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

https://reviews.llvm.org/D62591



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


r362008 - [analyzer] print() JSONify: SVal implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 11:38:52 2019
New Revision: 362008

URL: http://llvm.org/viewvc/llvm-project?rev=362008=rev
Log:
[analyzer] print() JSONify: SVal implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: cfe-commits, szepet, rnkovacs, a.sidorin, mikhail.ramalho,
 Szelethus, donat.nagy, dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h?rev=362008=362007=362008=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h Wed May 
29 11:38:52 2019
@@ -190,6 +190,9 @@ public:
 
   const MemRegion *getAsRegion() const;
 
+  /// printJson - Pretty-prints in JSON format.
+  void printJson(raw_ostream , bool AddQuotes) const;
+
   void dumpToStream(raw_ostream ) const;
   void dump() const;
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp?rev=362008=362007=362008=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp Wed May 29 11:38:52 2019
@@ -263,10 +263,12 @@ void Environment::printJson(raw_ostream
   Indent(Out, InnerSpace, IsDot)
   << "{ \"lctx_id\": " << LC->getID()
   << ", \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
-
   S->printJson(Out, nullptr, PP, /*AddQuotes=*/true);
 
-  Out << ", \"value\": \"" << I->second << "\" }";
+  Out << ", \"value\": ";
+  I->second.printJson(Out, /*AddQuotes=*/true);
+
+  Out << " }";
 
   if (I != LastI)
 Out << ',';

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp?rev=362008=362007=362008=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp Wed May 29 11:38:52 2019
@@ -16,6 +16,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -283,6 +284,15 @@ SVal loc::ConcreteInt::evalBinOp(BasicVa
 
 LLVM_DUMP_METHOD void SVal::dump() const { dumpToStream(llvm::errs()); }
 
+void SVal::printJson(raw_ostream , bool AddQuotes) const {
+  std::string Buf;
+  llvm::raw_string_ostream TempOut(Buf);
+
+  dumpToStream(TempOut);
+
+  Out << JsonFormat(TempOut.str(), AddQuotes);
+}
+
 void SVal::dumpToStream(raw_ostream ) const {
   switch (getBaseKind()) {
 case UnknownValKind:


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


r362005 - Fix an unused-variable error.

2019-05-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 29 11:36:54 2019
New Revision: 362005

URL: http://llvm.org/viewvc/llvm-project?rev=362005=rev
Log:
Fix an unused-variable error.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp?rev=362005=362004=362005=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp Wed May 29 11:36:54 2019
@@ -248,6 +248,7 @@ void Environment::printJson(raw_ostream
   }
 
   const Stmt *S = I->first.getStmt();
+  (void)S;
   assert(S != nullptr && "Expected non-null Stmt");
 
   LastI = I;


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


[PATCH] D62579: [Index] Compute correct symbol kind for variable templates

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Index/IndexSymbol.cpp:99
 
+  if (auto *VT = dyn_cast(D)) {
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > what about function and class templates? Are they handled in somewhere 
> > > else?
> > Yeah, they're handled in ifs and a large switch below. I tried unifying 
> > those cases (matching a `TemplateDecl` here instead of `VarTemplateDecl`), 
> > but they start producing different results for template classes and this 
> > function is **mostly** not called for templates from withing the index 
> > library (only for the underlying declarations) and it's only clangd that 
> > cares about the returned value in that case.
> > 
> > So I decided to make a minimal change that fixes clangd, but does not 
> > change behavior of the index library to avoid potential fallout of a more 
> > general fix.
> ok then it makes sense, could you also add a test case for one of the 
> fall-through cases(static member/parameter(?) etc.)?
Done. (Only static member, though, since we can't have templated parameters or 
non-static fields)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62579



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


[PATCH] D62615: [CodeComplete] Include more text into typed chunks of pattern completions

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a project: clang.

To allow filtering on any of the words in the editors.
In particular, the following completions were changed:

- 'using namespace <#name#>' Typed text before: 'using', after: 'using 
namespace'.
- 'else if (#)' Before: 'else', after: 'else if'.
- 'using typename <#qualifier#>::<#name#>' Before: 'using', after: 'using 
typename'.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62615

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1918,9 +1918,7 @@
   Results.AddResult(Result(Builder.TakeString()));
 
   // Using directives
-  Builder.AddTypedTextChunk("using");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("namespace");
+  Builder.AddTypedTextChunk("using namespace");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("identifier");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -1963,9 +1961,7 @@
 
   // using typename qualifier::name (only in a dependent context)
   if (SemaRef.CurContext->isDependentContext()) {
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("typename");
+Builder.AddTypedTextChunk("using typename");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("qualifier");
 Builder.AddTextChunk("::");
@@ -2219,9 +2215,7 @@
 Results.AddResult(Result(Builder.TakeString()));
 
 // Using directives
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("namespace");
+Builder.AddTypedTextChunk("using namespace");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("identifier");
 Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -5184,9 +5178,7 @@
   Results.AddResult(Builder.TakeString());
 
   // "else if" block
-  Builder.AddTypedTextChunk("else");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("if");
+  Builder.AddTypedTextChunk("else if");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
   if (getLangOpts().CPlusPlus)


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1918,9 +1918,7 @@
   Results.AddResult(Result(Builder.TakeString()));
 
   // Using directives
-  Builder.AddTypedTextChunk("using");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("namespace");
+  Builder.AddTypedTextChunk("using namespace");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("identifier");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -1963,9 +1961,7 @@
 
   // using typename qualifier::name (only in a dependent context)
   if (SemaRef.CurContext->isDependentContext()) {
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("typename");
+Builder.AddTypedTextChunk("using typename");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("qualifier");
 Builder.AddTextChunk("::");
@@ -2219,9 +2215,7 @@
 Results.AddResult(Result(Builder.TakeString()));
 
 // Using directives
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("namespace");
+Builder.AddTypedTextChunk("using namespace");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("identifier");
 Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -5184,9 +5178,7 @@
   Results.AddResult(Builder.TakeString());
 
   // "else if" block
-  Builder.AddTypedTextChunk("else");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("if");
+  Builder.AddTypedTextChunk("else if");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
   if (getLangOpts().CPlusPlus)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >